@colordx/core
Advanced tools
| import {a,b}from'./chunk-WGY6QKPW.mjs';import {a as a$2}from'./chunk-GLKEY6D3.mjs';import {a as a$1,h as h$1,i,f,g,l,k}from'./chunk-IOXRZECH.mjs';var U=.4122214708,z=.5363325363,q=.0514459929,D=.2119034982,H=.6806995451,J=.1073969566,P=.0883024619,Q=.2817188376,V=.6299787005,W=.2104542553,X=.793617785,Y=-0.0040720468,Z=1.9779984951,nn=-2.428592205,on=.4505937099,rn=.0259040371,tn=.7827717662,sn=-0.808675766,I=.3963377774,S=.2158037573,O=-0.1055613458,B=-0.0638541728,h=-0.0894841775,x=-1.291485548,A=4.0767416613,C=-3.3077115904,w=.2309699287,T=-1.2684380041,y=2.6097574007,G=-0.3413193963,d=-0.0041960865,N=-0.7034186145,$=1.7076147009;var cn=(o,n,r)=>{let t=Math.cbrt(U*o+z*n+q*r),s=Math.cbrt(D*o+H*n+J*r),c=Math.cbrt(P*o+Q*n+V*r);return [W*t+X*s+Y*c,Z*t+nn*s+on*c,rn*t+tn*s+sn*c]},Mn=({r:o,g:n,b:r,alpha:t})=>{let[s,c,e]=cn(a(o/255),a(n/255),a(r/255));return {l:s,a:c,b:e,alpha:t}},j=({l:o,a:n,b:r,alpha:t})=>{let[s,c,e]=en(o,n,r);return {r:b(s)*255,g:b(c)*255,b:b(e)*255,alpha:t}},un=({l:o,a:n,b:r,alpha:t})=>{if(n===0&&r===0){let K=o**3,k=b(a$1(K,0,1))*255;return a$2({r:k,g:k,b:k,alpha:t})}let s=o+.3963377774*n+.2158037573*r,c=o-.1055613458*n-.0638541728*r,e=o-.0894841775*n-1.291485548*r,_=s**3,l=c**3,b$1=e**3,p=4.0767416613*_-3.3077115904*l+.2309699287*b$1,E=-1.2684380041*_+2.6097574007*l-.3413193963*b$1,F=-0.0041960865*_-.7034186145*l+1.7076147009*b$1;return a$2({r:b(a$1(p,0,1))*255,g:b(a$1(E,0,1))*255,b:b(a$1(F,0,1))*255,alpha:t})},mn=(o,n,r,t)=>{if(r===0&&t===0){let p=n**3;o[0]=p,o[1]=p,o[2]=p;return}let s=n+I*r+S*t,c=n+O*r+B*t,e=n+h*r+x*t,_=s**3,l=c**3,b=e**3;o[0]=A*_+C*l+w*b,o[1]=T*_+y*l+G*b,o[2]=d*_+N*l+$*b;},en=(o,n,r)=>{if(n===0&&r===0){let b=o**3;return [b,b,b]}let t=o+I*n+S*r,s=o+O*n+B*r,c=o+h*n+x*r,e=t**3,_=s**3,l=c**3;return [A*e+C*_+w*l,T*e+y*_+G*l,d*e+N*_+$*l]},pn=o=>{if(!h$1(o)||o.colorSpace==="lab"||!i(o,["l","a","b"])||"r"in o||"x"in o||"c"in o||"h"in o)return null;let{l:n,a:r,b:t,alpha:s=1}=o;return !f(n)||!f(r)||!f(t)||!f(s)||g(n)>1?null:j({l:g(n),a:g(r),b:g(t),alpha:a$1(g(s),0,1)})},_n=new RegExp(`^oklab\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<a>${k})(?<ap>%?)\\s+(?<b>${k})(?<bp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),vn=o=>{if(typeof o!="string")return null;let n=_n.exec(o.trim())?.groups;if(!n)return null;let r=n.lp?l(n.l)/100:l(n.l),t=n.ap?l(n.a)*.004:l(n.a),s=n.bp?l(n.b)*.004:l(n.b),c=n.al===void 0?1:l(n.al)/(n.alp?100:1);return j({l:r,a:t,b:s,alpha:a$1(c,0,1)})};export{cn as a,Mn as b,j as c,un as d,mn as e,en as f,pn as g,vn as h};//# sourceMappingURL=chunk-2FEDFNW7.mjs.map | ||
| //# sourceMappingURL=chunk-2FEDFNW7.mjs.map |
| {"version":3,"sources":["../src/colorModels/oklab.ts"],"names":["M1_LR","M1_LG","M1_LB","M1_MR","M1_MG","M1_MB","M1_SR","M1_SG","M1_SB","M2_L_L","M2_M_L","M2_S_L","M2_L_A","M2_M_A","M2_S_A","M2_L_B","M2_M_B","M2_S_B","M2I_A_L","M2I_B_L","M2I_A_M","M2I_B_M","M2I_A_S","M2I_B_S","M1I_L_R","M1I_M_R","M1I_S_R","M1I_L_G","M1I_M_G","M1I_S_G","M1I_L_B","M1I_M_B","M1I_S_B","linearSrgbToOklab","lr","lg","lb","lv","mv","sv","rgbToOklab","r","g","b","alpha","l","a","bv","srgbToLinear","oklabToRgbUnclamped","oklabToLinear","srgbFromLinear","oklabToRgb","v","srgb","clamp","clampRgb","l_","m_","s_","oklabToLinearInto","out","parseOklabObject","input","isObject","hasKeys","isAnyNumber","sanitize","OKLAB_RE","NUM_OR_NONE","parseOklabString","L","parseNum"],"mappings":"kJAQA,IAAMA,EAAQ,WAAA,CACZC,CAAAA,CAAQ,WAAA,CACRC,CAAAA,CAAQ,YACJC,CAAAA,CAAQ,WAAA,CACZC,CAAAA,CAAQ,WAAA,CACRC,EAAQ,WAAA,CACJC,CAAAA,CAAQ,YACZC,CAAAA,CAAQ,WAAA,CACRC,EAAQ,WAAA,CAEJC,CAAAA,CAAS,WAAA,CACbC,CAAAA,CAAS,WACTC,CAAAA,CAAS,aAAA,CACLC,EAAS,YAAA,CACbC,EAAAA,CAAS,aACTC,EAAAA,CAAS,WAAA,CACLC,EAAAA,CAAS,WAAA,CACbC,GAAS,WAAA,CACTC,EAAAA,CAAS,aAELC,CAAAA,CAAU,WAAA,CACdC,EAAU,WAAA,CACNC,CAAAA,CAAU,aAAA,CACdC,CAAAA,CAAU,cACNC,CAAAA,CAAU,aAAA,CACdC,EAAU,YAAA,CAENC,CAAAA,CAAU,aACdC,CAAAA,CAAU,aAAA,CACVC,CAAAA,CAAU,WAAA,CACNC,EAAU,aAAA,CACdC,CAAAA,CAAU,aACVC,CAAAA,CAAU,aAAA,CACNC,EAAU,aAAA,CACdC,CAAAA,CAAU,aAAA,CACVC,CAAAA,CAAU,aAaL,IAAMC,EAAAA,CAAoB,CAACC,CAAAA,CAAYC,CAAAA,CAAYC,IAAyC,CACjG,IAAMC,CAAAA,CAAK,IAAA,CAAK,KAAKrC,CAAAA,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,CAAAA,CAAS9B,EAAE,CAAE,CAAA,CAAI,KAAQ8B,CAAAA,CAAS9B,CAAAA,CAAE,CAAE,CAAA,CACjDE,EAAQF,CAAAA,CAAE,EAAA,GAAO,OAAY,CAAA,CAAI8B,CAAAA,CAAS9B,EAAE,EAAE,CAAA,EAAKA,CAAAA,CAAE,GAAA,CAAM,IAAM,CAAA,CAAA,CACvE,OAAOO,EAAoB,CAAE,CAAA,CAAGsB,EAAG,CAAA,CAAAzB,CAAAA,CAAG,CAAA,CAAAH,CAAAA,CAAG,MAAOY,GAAAA,CAAMX,CAAAA,CAAO,EAAG,CAAC,CAAE,CAAC,CACtE","file":"chunk-2FEDFNW7.mjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { OklabColor, RgbColor } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\n// Björn Ottosson's OKLab matrix coefficients. Referenced by both the allocating\n// and zero-alloc (*Into) variants so the math lives in one place.\n// sRGB linear → LMS (cubed roots taken at M1 stage)\nconst M1_LR = 0.4122214708,\n M1_LG = 0.5363325363,\n M1_LB = 0.0514459929;\nconst M1_MR = 0.2119034982,\n M1_MG = 0.6806995451,\n M1_MB = 0.1073969566;\nconst M1_SR = 0.0883024619,\n M1_SG = 0.2817188376,\n M1_SB = 0.6299787005;\n// LMS' → OKLab\nconst M2_L_L = 0.2104542553,\n M2_M_L = 0.793617785,\n M2_S_L = -0.0040720468;\nconst M2_L_A = 1.9779984951,\n M2_M_A = -2.428592205,\n M2_S_A = 0.4505937099;\nconst M2_L_B = 0.0259040371,\n M2_M_B = 0.7827717662,\n M2_S_B = -0.808675766;\n// OKLab → LMS' (inverse of M2)\nconst M2I_A_L = 0.3963377774,\n M2I_B_L = 0.2158037573;\nconst M2I_A_M = -0.1055613458,\n M2I_B_M = -0.0638541728;\nconst M2I_A_S = -0.0894841775,\n M2I_B_S = -1.291485548;\n// LMS → linear sRGB (inverse of M1)\nconst M1I_L_R = 4.0767416613,\n M1I_M_R = -3.3077115904,\n M1I_S_R = 0.2309699287;\nconst M1I_L_G = -1.2684380041,\n M1I_M_G = 2.6097574007,\n M1I_S_G = -0.3413193963;\nconst M1I_L_B = -0.0041960865,\n M1I_M_B = -0.7034186145,\n M1I_S_B = 1.7076147009;\n\n/** Zero-allocation sibling of linearSrgbToOklab — writes [l, a, b] into `out`. */\nexport const linearSrgbToOklabInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n const lv = Math.cbrt(M1_LR * lr + M1_LG * lg + M1_LB * lb);\n const mv = Math.cbrt(M1_MR * lr + M1_MG * lg + M1_MB * lb);\n const sv = Math.cbrt(M1_SR * lr + M1_SG * lg + M1_SB * lb);\n out[0] = M2_L_L * lv + M2_M_L * mv + M2_S_L * sv;\n out[1] = M2_L_A * lv + M2_M_A * mv + M2_S_A * sv;\n out[2] = M2_L_B * lv + M2_M_B * mv + M2_S_B * sv;\n};\n\n/** Convert linear sRGB channels to OKLab (Björn Ottosson). No gamma, no clamping. */\nexport const linearSrgbToOklab = (lr: number, lg: number, lb: number): [number, number, number] => {\n const lv = Math.cbrt(M1_LR * lr + M1_LG * lg + M1_LB * lb);\n const mv = Math.cbrt(M1_MR * lr + M1_MG * lg + M1_MB * lb);\n const sv = Math.cbrt(M1_SR * lr + M1_SG * lg + M1_SB * lb);\n return [\n M2_L_L * lv + M2_M_L * mv + M2_S_L * sv,\n M2_L_A * lv + M2_M_A * mv + M2_S_A * sv,\n M2_L_B * lv + M2_M_B * mv + M2_S_B * sv,\n ];\n};\n\nexport const rgbToOklab = ({ r, g, b, alpha }: RgbColor): OklabColor => {\n const [l, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n return { l, a, b: bv, alpha };\n};\n\n/** Unclamped OKLab → gamma-encoded sRGB. Channels may exceed [0, 255] for out-of-sRGB-gamut colors. */\nexport const oklabToRgbUnclamped = ({ l, a, b, alpha }: OklabColor): RgbColor => {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\nexport const oklabToRgb = ({ l, a, b, alpha }: OklabColor): RgbColor => {\n if (a === 0 && b === 0) {\n const v = l ** 3;\n const srgb = srgbFromLinear(clamp(v, 0, 1)) * 255;\n return clampRgb({ r: srgb, g: srgb, b: srgb, alpha });\n }\n\n const l_ = l + 0.3963377774 * a + 0.2158037573 * b;\n const m_ = l - 0.1055613458 * a - 0.0638541728 * b;\n const s_ = l - 0.0894841775 * a - 1.291485548 * b;\n\n const lv = l_ ** 3;\n const mv = m_ ** 3;\n const sv = s_ ** 3;\n\n const r = 4.0767416613 * lv - 3.3077115904 * mv + 0.2309699287 * sv;\n const g = -1.2684380041 * lv + 2.6097574007 * mv - 0.3413193963 * sv;\n const bv = -0.0041960865 * lv - 0.7034186145 * mv + 1.7076147009 * sv;\n\n return clampRgb({\n r: srgbFromLinear(clamp(r, 0, 1)) * 255,\n g: srgbFromLinear(clamp(g, 0, 1)) * 255,\n b: srgbFromLinear(clamp(bv, 0, 1)) * 255,\n alpha,\n });\n};\n\n/** Zero-allocation sibling of oklabToLinear — writes [lr, lg, lb] into `out`. */\nexport const oklabToLinearInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n // Achromatic short-circuit: M1⁻¹ rows sum to 1 mathematically, but floating-point\n // rounding leaves lr/lg/lb ~1 ULP apart, which gets amplified into a phantom hue\n // downstream in rgbToHslRaw. Explicitly return lv for all channels.\n if (a === 0 && b === 0) {\n const v = l ** 3;\n out[0] = v;\n out[1] = v;\n out[2] = v;\n return;\n }\n const l_ = l + M2I_A_L * a + M2I_B_L * b;\n const m_ = l + M2I_A_M * a + M2I_B_M * b;\n const s_ = l + M2I_A_S * a + M2I_B_S * b;\n const lv = l_ ** 3,\n mv = m_ ** 3,\n sv = s_ ** 3;\n out[0] = M1I_L_R * lv + M1I_M_R * mv + M1I_S_R * sv;\n out[1] = M1I_L_G * lv + M1I_M_G * mv + M1I_S_G * sv;\n out[2] = M1I_L_B * lv + M1I_M_B * mv + M1I_S_B * sv;\n};\n\n/** Unclamped linear sRGB channels from OKLab values. Channels may exceed [0, 1] for out-of-gamut colors. */\nexport const oklabToLinear = (l: number, a: number, b: number): [number, number, number] => {\n if (a === 0 && b === 0) {\n const v = l ** 3;\n return [v, v, v];\n }\n const l_ = l + M2I_A_L * a + M2I_B_L * b;\n const m_ = l + M2I_A_M * a + M2I_B_M * b;\n const s_ = l + M2I_A_S * a + M2I_B_S * b;\n const lv = l_ ** 3,\n mv = m_ ** 3,\n sv = s_ ** 3;\n return [\n M1I_L_R * lv + M1I_M_R * mv + M1I_S_R * sv,\n M1I_L_G * lv + M1I_M_G * mv + M1I_S_G * sv,\n M1I_L_B * lv + M1I_M_B * mv + M1I_S_B * sv,\n ];\n};\n\nexport const parseOklabObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lab' are CIE Lab, not OKLab — let parseLabObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lab') return null;\n if (!hasKeys(input, ['l', 'a', 'b'])) return null;\n if ('r' in input || 'x' in input || 'c' in input || 'h' in input) return null;\n const { l, a, b, alpha = 1 } = input as { l: unknown; a: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(a) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLab L is always [0, 1]; reject CIE Lab values passed without colorSpace branding\n return oklabToRgbUnclamped({\n l: sanitize(l),\n a: sanitize(a),\n b: sanitize(b),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLAB_RE = new RegExp(\n `^oklab\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<a>${NUM_OR_NONE})(?<ap>%?)\\\\s+(?<b>${NUM_OR_NONE})(?<bp>%?)` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklabString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLAB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const a = g.ap ? parseNum(g.a!) * 0.004 : parseNum(g.a!); // 100% = 0.4\n const b = g.bp ? parseNum(g.b!) * 0.004 : parseNum(g.b!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklabToRgbUnclamped({ l: L, a, b, alpha: clamp(alpha, 0, 1) });\n};\n"]} |
| 'use strict';var chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var $=s=>({r:chunkYISEJCI6_cjs.a(s.r,0,255),g:chunkYISEJCI6_cjs.a(s.g,0,255),b:chunkYISEJCI6_cjs.a(s.b,0,255),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(s.alpha,3),0,1)}),x=s=>{if(!chunkYISEJCI6_cjs.h(s))return null;let n=s.colorSpace;if(n==="display-p3"||n==="rec2020"||n==="a98-rgb"||n==="prophoto-rgb"||!chunkYISEJCI6_cjs.i(s,["r","g","b"]))return null;let{r:e,g:t,b:c,alpha:l=1}=s;return !chunkYISEJCI6_cjs.f(e)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(c)||!chunkYISEJCI6_cjs.f(l)?null:$({r:chunkYISEJCI6_cjs.g(e),g:chunkYISEJCI6_cjs.g(t),b:chunkYISEJCI6_cjs.g(c),alpha:chunkYISEJCI6_cjs.g(l)})},y=new RegExp(`^rgba?\\(\\s*(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s*(?:,\\s*(?<g_c>${chunkYISEJCI6_cjs.k})(?<gp_c>%?)\\s*,\\s*(?<b_c>${chunkYISEJCI6_cjs.k})(?<bp_c>%?)(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.k})(?<alp_c>%?))?\\s*|\\s+(?<g_s>${chunkYISEJCI6_cjs.k})(?<gp_s>%?)\\s+(?<b_s>${chunkYISEJCI6_cjs.k})(?<bp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?))?\\s*)\\)$`,"i"),N=s=>{if(typeof s!="string")return null;let n=y.exec(s.trim())?.groups;if(!n)return null;let e=n.g_c!==void 0,t=n.g_c??n.g_s,c=n.b_c??n.b_s,l=!!n.rp,b=!!(n.gp_c??n.gp_s),_=!!(n.bp_c??n.bp_s),m=l?chunkYISEJCI6_cjs.l(n.r)/100*255:chunkYISEJCI6_cjs.l(n.r),w=b?chunkYISEJCI6_cjs.l(t)/100*255:chunkYISEJCI6_cjs.l(t),d=_?chunkYISEJCI6_cjs.l(c)/100*255:chunkYISEJCI6_cjs.l(c);if(e&&(l!==b||b!==_||/^none$/i.test(n.r)||/^none$/i.test(t)||/^none$/i.test(c)))return null;let u=n.al_c??n.al_s,h=!!(n.alp_c??n.alp_s);if(e&&u!==void 0&&/^none$/i.test(u))return null;let k=u===void 0?1:chunkYISEJCI6_cjs.l(u)/(h?100:1);return $({r:m,g:w,b:d,alpha:k})};exports.a=$;exports.b=x;exports.c=N;//# sourceMappingURL=chunk-2KB6V6KD.cjs.map | ||
| //# sourceMappingURL=chunk-2KB6V6KD.cjs.map |
| {"version":3,"sources":["../src/colorModels/rgb.ts"],"names":["clampRgb","rgb","clamp","round","parseRgbObject","input","isObject","cs","hasKeys","r","g","b","alpha","isAnyNumber","sanitize","RGB_RE","NUM_OR_NONE","parseRgbString","isComma","gRaw","bRaw","rPct","gPct","bPct","parseNum","gc","rawA","aPct"],"mappings":"mEAGO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,oBAAMD,CAAAA,CA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AAAA,EAAQA,IAASC,CAAAA,EAC1B,SAAA,CAAU,IAAA,CAAKb,CAAAA,CAAE,CAAE,CAAA,EAAK,SAAA,CAAU,IAAA,CAAKS,CAAI,CAAA,EAAK,SAAA,CAAU,IAAA,CAAKC,CAAI,GAAG,OAAO,IAAA,CAGnF,IAAMM,CAAAA,CAAOhB,EAAE,IAAA,EAAQA,CAAAA,CAAE,IAAA,CACnBiB,CAAAA,CAAO,CAAC,EAAEjB,CAAAA,CAAE,KAAA,EAASA,CAAAA,CAAE,KAAA,CAAA,CAC7B,GAAIQ,CAAAA,EAAWQ,CAAAA,GAAS,QAAa,SAAA,CAAU,IAAA,CAAKA,CAAI,CAAA,CAAG,OAAO,IAAA,CAClE,IAAMd,CAAAA,CAAQc,CAAAA,GAAS,OAAY,CAAA,CAAIF,mBAAAA,CAASE,CAAI,CAAA,EAAKC,CAAAA,CAAO,GAAA,CAAM,CAAA,CAAA,CAEtE,OAAO3B,EAAS,CAAE,CAAA,CAAAS,CAAAA,CAAG,CAAA,CAAGgB,EAAI,CAAA,CAAAd,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAC,CACxC","file":"chunk-2KB6V6KD.cjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport type { RgbColor } from '../types.js';\n\nexport const clampRgb = (rgb: RgbColor): RgbColor => ({\n r: clamp(rgb.r, 0, 255),\n g: clamp(rgb.g, 0, 255),\n b: clamp(rgb.b, 0, 255),\n alpha: clamp(round(rgb.alpha, 3), 0, 1),\n});\n\nexport const parseRgbObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n const cs = (input as { colorSpace?: unknown }).colorSpace;\n if (cs === 'display-p3' || cs === 'rec2020' || cs === 'a98-rgb' || cs === 'prophoto-rgb') return null;\n if (!hasKeys(input, ['r', 'g', 'b'])) return null;\n const { r, g, b, alpha = 1 } = input as { r: unknown; g: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(r) || !isAnyNumber(g) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n return clampRgb({ r: sanitize(r), g: sanitize(g), b: sanitize(b), alpha: sanitize(alpha) });\n};\n\n// Matches both legacy comma syntax: rgb(255, 0, 0) / rgba(255, 0, 0, 0.5)\n// and modern space syntax: rgb(255 0 0) / rgb(255 0 0 / 0.5).\n// Supports percentage-based channels and the CSS Color 4 `none` keyword.\n// Named groups are suffixed `_c` (comma/legacy branch) or `_s` (space/modern branch)\n// because ES2022 regex requires distinct names across alternation branches.\nconst RGB_RE = new RegExp(\n `^rgba?\\\\(\\\\s*(?<r>${NUM_OR_NONE})(?<rp>%?)\\\\s*(?:` +\n `,\\\\s*(?<g_c>${NUM_OR_NONE})(?<gp_c>%?)\\\\s*,\\\\s*(?<b_c>${NUM_OR_NONE})(?<bp_c>%?)` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM_OR_NONE})(?<alp_c>%?))?\\\\s*` +\n `|` +\n `\\\\s+(?<g_s>${NUM_OR_NONE})(?<gp_s>%?)\\\\s+(?<b_s>${NUM_OR_NONE})(?<bp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?))?\\\\s*` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseRgbString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = RGB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n\n const isComma = g.g_c !== undefined;\n const gRaw = g.g_c ?? g.g_s!;\n const bRaw = g.b_c ?? g.b_s!;\n const rPct = !!g.rp;\n const gPct = !!(g.gp_c ?? g.gp_s);\n const bPct = !!(g.bp_c ?? g.bp_s);\n\n const r = rPct ? (parseNum(g.r!) / 100) * 255 : parseNum(g.r!);\n const gc = gPct ? (parseNum(gRaw) / 100) * 255 : parseNum(gRaw);\n const b = bPct ? (parseNum(bRaw) / 100) * 255 : parseNum(bRaw);\n\n // Legacy: channels must match type, no `none`. Modern: mixing + `none` allowed.\n if (isComma) {\n if (rPct !== gPct || gPct !== bPct) return null;\n if (/^none$/i.test(g.r!) || /^none$/i.test(gRaw) || /^none$/i.test(bRaw)) return null;\n }\n\n const rawA = g.al_c ?? g.al_s;\n const aPct = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (aPct ? 100 : 1);\n\n return clampRgb({ r, g: gc, b, alpha });\n};\n"]} |
| 'use strict';var chunkVSMEJU4Z_cjs=require('./chunk-VSMEJU4Z.cjs'),chunk2KB6V6KD_cjs=require('./chunk-2KB6V6KD.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var L=96.4295675298354,O=100,w=82.51046025104603,lo=.4123907992659595,ao=.35758433938387796,co=.1804807884018343,eo=.21263900587151036,bo=.7151686787677559,po=.07219231536073371,uo=.01933081871559185,_o=.11919477979462599,yo=.9505321522496606,A=.032409699419045215,B=-0.015373831775700935,G=-0.004986107602930032,I=-0.009692436362808799,P=.018759675015077207,U=.0004155505740717561,F=.000556300796969936,H=-0.002039769588889766,K=.010569715142428786,Wo=1.0479297925449969,Eo=.022946870601609652,qo=-0.05019226628920524,jo=.02962780877005599,Ao=.9904344267538799,Bo=-0.017073799063418826,Go=-0.009243040646204504,Io=.015055191490298152,Po=.7518742814281371,xo=.955473421488075,go=-0.02309845494876471,mo=.06325924320057072,Do=-0.0283697093338637,zo=1.0099953980813041,io=.021041441191917323,Xo=.012314014864481998,ho=-0.020507649298898964,Co=1.330365926242124,sn=({r:n,g:o,b:t,alpha:s})=>{let r=chunkVSMEJU4Z_cjs.a(n/255),l=chunkVSMEJU4Z_cjs.a(o/255),a=chunkVSMEJU4Z_cjs.a(t/255);return {x:100*(lo*r+ao*l+co*a),y:100*(eo*r+bo*l+po*a),z:100*(uo*r+_o*l+yo*a),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(s,3),0,1),colorSpace:"xyz-d65"}},Uo=(n,o,t)=>[A*n+B*o+G*t,I*n+P*o+U*t,F*n+H*o+K*t],fo=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=Uo(n,o,t);return {r:chunkVSMEJU4Z_cjs.b(r)*255,g:chunkVSMEJU4Z_cjs.b(l)*255,b:chunkVSMEJU4Z_cjs.b(a)*255,alpha:s}},To=({r:n,g:o,b:t,alpha:s})=>{let r=chunkVSMEJU4Z_cjs.a(n/255),l=chunkVSMEJU4Z_cjs.a(o/255),a=chunkVSMEJU4Z_cjs.a(t/255),u=100*(lo*r+ao*l+co*a),e=100*(eo*r+bo*l+po*a),x=100*(uo*r+_o*l+yo*a);return {x:Wo*u+Eo*e+qo*x,y:jo*u+Ao*e+Bo*x,z:Go*u+Io*e+Po*x,alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(s,3),0,1)}},ln=(n,o,t,s)=>{let r=xo*o+go*t+mo*s,l=Do*o+zo*t+io*s,a=Xo*o+ho*t+Co*s;n[0]=A*r+B*l+G*a,n[1]=I*r+P*l+U*a,n[2]=F*r+H*l+K*a;},M=(n,o,t)=>{let s=xo*n+go*o+mo*t,r=Do*n+zo*o+io*t,l=Xo*n+ho*o+Co*t;return [A*s+B*r+G*l,I*s+P*r+U*l,F*s+H*r+K*l]},Ro=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=M(n,o,t);return chunk2KB6V6KD_cjs.a({r:chunkVSMEJU4Z_cjs.b(r)*255,g:chunkVSMEJU4Z_cjs.b(l)*255,b:chunkVSMEJU4Z_cjs.b(a)*255,alpha:s})},So=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=M(n,o,t);return {r:chunkVSMEJU4Z_cjs.b(r)*255,g:chunkVSMEJU4Z_cjs.b(l)*255,b:chunkVSMEJU4Z_cjs.b(a)*255,alpha:s}},an=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace==="xyz-d65"||!chunkYISEJCI6_cjs.i(n,["x","y","z"]))return null;let{x:o,y:t,z:s,alpha:r=1}=n;return !chunkYISEJCI6_cjs.e(o)||!chunkYISEJCI6_cjs.e(t)||!chunkYISEJCI6_cjs.e(s)||!chunkYISEJCI6_cjs.e(r)?null:So({x:o,y:t,z:s,alpha:chunkYISEJCI6_cjs.a(r,0,1)})},cn=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace!=="xyz-d65"||!chunkYISEJCI6_cjs.i(n,["x","y","z"]))return null;let{x:o,y:t,z:s,alpha:r=1}=n;return !chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(s)||!chunkYISEJCI6_cjs.f(r)?null:fo({x:chunkYISEJCI6_cjs.g(o),y:chunkYISEJCI6_cjs.g(t),z:chunkYISEJCI6_cjs.g(s),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(r),0,1)})},Fo=new RegExp(`^color\\(\\s*xyz-d65\\s+(?<x>${chunkYISEJCI6_cjs.k})(?<xp>%?)\\s+(?<y>${chunkYISEJCI6_cjs.k})(?<yp>%?)\\s+(?<z>${chunkYISEJCI6_cjs.k})(?<zp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Ho=new RegExp(`^color\\(\\s*xyz-d50\\s+(?<x>${chunkYISEJCI6_cjs.k})(?<xp>%?)\\s+(?<y>${chunkYISEJCI6_cjs.k})(?<yp>%?)\\s+(?<z>${chunkYISEJCI6_cjs.k})(?<zp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),en=n=>{if(typeof n!="string")return null;let o=Fo.exec(n.trim())?.groups;if(!o)return null;let t=chunkYISEJCI6_cjs.l(o.x),s=chunkYISEJCI6_cjs.l(o.y),r=chunkYISEJCI6_cjs.l(o.z),l=o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1);return fo({x:t,y:s,z:r,alpha:chunkYISEJCI6_cjs.a(l,0,1)})},bn=n=>{if(typeof n!="string")return null;let o=Ho.exec(n.trim())?.groups;if(!o)return null;let t=chunkYISEJCI6_cjs.l(o.x),s=chunkYISEJCI6_cjs.l(o.y),r=chunkYISEJCI6_cjs.l(o.z),l=o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1);return So({x:t,y:s,z:r,alpha:chunkYISEJCI6_cjs.a(l,0,1)})};var Ko=.3127/.329*100,vo=100,Vo=(1-.3127-.329)/.329*100,S=216/24389,z=24389/27,C=n=>n>S?Math.cbrt(n):(z*n+16)/116,Jo=({x:n,y:o,z:t,alpha:s})=>{let r=C(o/O);return {l:116*r-16,a:500*(C(n/L)-r)||0,b:200*(r-C(t/w))||0,alpha:chunkYISEJCI6_cjs.b(s,3),colorSpace:"lab"}},Lo=(n,o,t)=>{let s=(n+16)/116,r=o/500+s,l=s-t/200;return [(r**3>S?r**3:(116*r-16)/z)*L,(n>8?s**3:n/z)*O,(l**3>S?l**3:(116*l-16)/z)*w]},xn=(n,o,t,s)=>{let r=(o+16)/116,l=t/500+r,a=r-s/200;n[0]=(l**3>S?l**3:(116*l-16)/z)*L,n[1]=(o>8?r**3:o/z)*O,n[2]=(a**3>S?a**3:(116*a-16)/z)*w;},Qo=({l:n,a:o,b:t,alpha:s})=>{let[r,l,a]=Lo(n,o,t);return {x:r,y:l,z:a,alpha:s}},gn=n=>Jo(To(n)),mn=({r:n,g:o,b:t,alpha:s})=>{let r=chunkVSMEJU4Z_cjs.a(n/255),l=chunkVSMEJU4Z_cjs.a(o/255),a=chunkVSMEJU4Z_cjs.a(t/255),u=100*(.4123907992659595*r+.35758433938387796*l+.1804807884018343*a),e=100*(.21263900587151036*r+.7151686787677559*l+.07219231536073371*a),x=100*(.01933081871559185*r+.11919477979462599*l+.9505321522496606*a),f=C(e/vo);return {l:116*f-16,a:500*(C(u/Ko)-f)||0,b:200*(f-C(x/Vo))||0,alpha:chunkYISEJCI6_cjs.b(s,3),colorSpace:"lab"}},Dn=(n,o)=>{let{l:t,a:s,b:r}=n,{l,a,b:u}=o,e=Math.PI/180,x=180/Math.PI,f=Math.sqrt(s**2+r**2),wo=Math.sqrt(a**2+u**2),v=((f+wo)/2)**7,V=.5*(1-Math.sqrt(v/(v+25**7))),Y=s*(1+V),Z=a*(1+V),k=Math.sqrt(Y**2+r**2),$=Math.sqrt(Z**2+u**2),N=(k+$)/2,W=Y===0&&r===0?0:Math.atan2(r,Y)*x,E=Z===0&&u===0?0:Math.atan2(u,Z)*x,i=W<0?W+360:W,X=E<0?E+360:E,q=X-i,j=Math.abs(X-i);j>180&&X<=i?q+=360:j>180&&X>i&&(q-=360);let J=(t+l)/2,D=i+X;j<=180?D/=2:D=(i+X<360?D+360:D-360)/2;let Mo=1-.17*Math.cos(e*(D-30))+.24*Math.cos(2*e*D)+.32*Math.cos(e*(3*D+6))-.2*Math.cos(e*(4*D-63)),Yo=l-t,Q=$-k,oo=2*Math.sin(e*q/2)*Math.sqrt(k*$),Zo=1+.015*(J-50)**2/Math.sqrt(20+(J-50)**2),no=1+.045*N,ro=1+.015*N*Mo,to=N**7,ko=2*Math.sqrt(to/(to+25**7)),$o=30*Math.exp(-(((D-275)/25)**2)),No=-ko*Math.sin(2*e*$o);return Math.sqrt((Yo/Zo)**2+(Q/no)**2+(oo/ro)**2+No*(Q/no)*(oo/ro))},zn=n=>Ro(Qo(n)),Oo=({l:n,a:o,b:t,alpha:s})=>{let[r,l,a]=Lo(n,o,t),[u,e,x]=M(r,l,a);return {r:chunkVSMEJU4Z_cjs.b(u)*255,g:chunkVSMEJU4Z_cjs.b(e)*255,b:chunkVSMEJU4Z_cjs.b(x)*255,alpha:s}},on=new RegExp(`^lab\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<a>${chunkYISEJCI6_cjs.k})(?<ap>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Xn=n=>{if(typeof n!="string")return null;let o=on.exec(n.trim())?.groups;if(!o)return null;let t=chunkYISEJCI6_cjs.l(o.l),s=o.ap?chunkYISEJCI6_cjs.l(o.a)*1.25:chunkYISEJCI6_cjs.l(o.a),r=o.bp?chunkYISEJCI6_cjs.l(o.b)*1.25:chunkYISEJCI6_cjs.l(o.b),l=o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1);return Oo({l:chunkYISEJCI6_cjs.a(t,0,100),a:s,b:r,alpha:chunkYISEJCI6_cjs.a(l,0,1)})},hn=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace!=="lab"||!chunkYISEJCI6_cjs.i(n,["l","a","b"]))return null;let{l:o,a:t,b:s,alpha:r=1}=n;return !chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(s)||!chunkYISEJCI6_cjs.f(r)?null:Oo({l:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(o),0,100),a:chunkYISEJCI6_cjs.g(t),b:chunkYISEJCI6_cjs.g(s),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(r),0,1)})};exports.a=sn;exports.b=Uo;exports.c=To;exports.d=ln;exports.e=M;exports.f=an;exports.g=cn;exports.h=en;exports.i=bn;exports.j=Lo;exports.k=xn;exports.l=Qo;exports.m=gn;exports.n=mn;exports.o=Dn;exports.p=zn;exports.q=Oo;exports.r=Xn;exports.s=hn;//# sourceMappingURL=chunk-6FI7U3TH.cjs.map | ||
| //# sourceMappingURL=chunk-6FI7U3TH.cjs.map |
| {"version":3,"sources":["../src/colorModels/xyz.ts","../src/colorModels/lab.ts"],"names":["D50_WX","D50_WY","D50_WZ","S_XR","S_XG","S_XB","S_YR","S_YG","S_YB","S_ZR","S_ZG","S_ZB","X_RX","X_RY","X_RZ","X_GX","X_GY","X_GZ","X_BX","X_BY","X_BZ","D65_TO_D50_XX","D65_TO_D50_XY","D65_TO_D50_XZ","D65_TO_D50_YX","D65_TO_D50_YY","D65_TO_D50_YZ","D65_TO_D50_ZX","D65_TO_D50_ZY","D65_TO_D50_ZZ","D50_TO_D65_XX","D50_TO_D65_XY","D50_TO_D65_XZ","D50_TO_D65_YX","D50_TO_D65_YY","D50_TO_D65_YZ","D50_TO_D65_ZX","D50_TO_D65_ZY","D50_TO_D65_ZZ","rgbToXyzD65","r","g","b","alpha","lr","srgbToLinear","lg","lb","clamp","round","xyzD65ToLinearSrgb","x","y","z","xyzD65ToRgbUnclamped","srgbFromLinear","rgbToXyz","xd65","yd65","zd65","xyzD50ToLinearSrgbInto","out","xyzD50ToLinearSrgb","xyzToRgb","clampRgb","xyzToRgbUnclamped","parseXyzObject","input","isObject","hasKeys","isNumber","parseXyzD65Object","isAnyNumber","sanitize","XYZ_D65_RE","NUM_OR_NONE","XYZ_D50_RE","parseXyzD65String","parseNum","parseXyzD50String","D65_WX","D65_WY","D65_WZ","EPSILON","KAPPA","f","t","xyzToLab","fy","labToXyzValues","l","a","fx","fz","labToXyzValuesInto","labToXyz","rgbToLab","rgb","rgbToLabD65","deltaE2000","lab1","lab2","L1","a1","b1","L2","a2","b2","rad","deg","C1","C2","Cab","G","a1p","a2p","C1p","C2p","Cp","h1p","h2p","h1","h2","dhp","absDh","Lm","Hm","T","dLp","dCp","dHp","SL","SC","SH","RC7","RC","dTheta","RT","labToRgb","lab","labToRgbUnclamped","LAB_RE","parseLabString","parseLabObject"],"mappings":"uKAMO,IAAMA,CAAAA,CAAS,iBACTC,CAAAA,CAAS,GAAA,CACTC,EAAS,iBAAA,CAIhBC,EAAAA,CAAO,iBAAA,CACXC,EAAAA,CAAO,kBAAA,CACPC,EAAAA,CAAO,kBACHC,EAAAA,CAAO,kBAAA,CACXC,GAAO,iBAAA,CACPC,EAAAA,CAAO,mBACHC,EAAAA,CAAO,kBAAA,CACXC,EAAAA,CAAO,kBA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A,CAAS9B,CAAK,CAAA,CAAG,CAAA,CAAG,CAAC,CAEpC,CAAC,CACH","file":"chunk-6FI7U3TH.cjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { RgbColor, XyzColor, XyzD65Color } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\n// D50 white point (CSS Color 4: xy = 0.3457/0.3585)\nexport const D50_WX = 96.42956752983539;\nexport const D50_WY = 100;\nexport const D50_WZ = 82.51046025104603;\n\n// ── CSS Color 4 exact rational matrices ─────────────────────────────────────\n// sRGB linear → XYZ D65 (xyz in 0–1; callers scale to 0–100 by multiplying).\nconst S_XR = 0.41239079926595951,\n S_XG = 0.35758433938387796,\n S_XB = 0.18048078840183429;\nconst S_YR = 0.21263900587151036,\n S_YG = 0.71516867876775592,\n S_YB = 0.072192315360733714;\nconst S_ZR = 0.019330818715591849,\n S_ZG = 0.11919477979462599,\n S_ZB = 0.95053215224966059;\n\n// XYZ D65 (0–100 scale) → sRGB linear (0–1). Equals the CSS inverse matrix ÷100.\nconst X_RX = 0.032409699419045213,\n X_RY = -0.015373831775700935,\n X_RZ = -0.0049861076029300327;\nconst X_GX = -0.0096924363628087984,\n X_GY = 0.018759675015077206,\n X_GZ = 0.00041555057407175612;\nconst X_BX = 0.00055630079696993608,\n X_BY = -0.0020397695888897657,\n X_BZ = 0.010569715142428786;\n\n// Bradford D65 → D50 (CSS Color 4)\nconst D65_TO_D50_XX = 1.0479297925449969,\n D65_TO_D50_XY = 0.022946870601609652,\n D65_TO_D50_XZ = -0.05019226628920524;\nconst D65_TO_D50_YX = 0.02962780877005599,\n D65_TO_D50_YY = 0.9904344267538799,\n D65_TO_D50_YZ = -0.017073799063418826;\nconst D65_TO_D50_ZX = -0.009243040646204504,\n D65_TO_D50_ZY = 0.015055191490298152,\n D65_TO_D50_ZZ = 0.7518742814281371;\n\n// Bradford D50 → D65 (CSS Color 4, inverse of above)\nconst D50_TO_D65_XX = 0.955473421488075,\n D50_TO_D65_XY = -0.02309845494876471,\n D50_TO_D65_XZ = 0.06325924320057072;\nconst D50_TO_D65_YX = -0.0283697093338637,\n D50_TO_D65_YY = 1.0099953980813041,\n D50_TO_D65_YZ = 0.021041441191917323;\nconst D50_TO_D65_ZX = 0.012314014864481998,\n D50_TO_D65_ZY = -0.020507649298898964,\n D50_TO_D65_ZZ = 1.330365926242124;\n\n// ── RGB ↔ XYZ D65 ───────────────────────────────────────────────────────────\n\n/** sRGB (0–255) → XYZ D65 (0–100, screen-native, no Bradford adaptation). */\nexport const rgbToXyzD65 = ({ r, g, b, alpha }: RgbColor): XyzD65Color => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n return {\n x: 100 * (S_XR * lr + S_XG * lg + S_XB * lb),\n y: 100 * (S_YR * lr + S_YG * lg + S_YB * lb),\n z: 100 * (S_ZR * lr + S_ZG * lg + S_ZB * lb),\n alpha: clamp(round(alpha, 3), 0, 1),\n colorSpace: 'xyz-d65' as const,\n };\n};\n\n/** XYZ D65 (0–100) → linear sRGB (0–1, unclamped). */\nexport const xyzD65ToLinearSrgb = (x: number, y: number, z: number): [number, number, number] => [\n X_RX * x + X_RY * y + X_RZ * z,\n X_GX * x + X_GY * y + X_GZ * z,\n X_BX * x + X_BY * y + X_BZ * z,\n];\n\nconst xyzD65ToRgbUnclamped = ({ x, y, z, alpha }: XyzD65Color): RgbColor => {\n const [lr, lg, lb] = xyzD65ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// ── RGB ↔ XYZ D50 ───────────────────────────────────────────────────────────\n\nexport const rgbToXyz = ({ r, g, b, alpha }: RgbColor): XyzColor => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n const xd65 = 100 * (S_XR * lr + S_XG * lg + S_XB * lb);\n const yd65 = 100 * (S_YR * lr + S_YG * lg + S_YB * lb);\n const zd65 = 100 * (S_ZR * lr + S_ZG * lg + S_ZB * lb);\n return {\n x: D65_TO_D50_XX * xd65 + D65_TO_D50_XY * yd65 + D65_TO_D50_XZ * zd65,\n y: D65_TO_D50_YX * xd65 + D65_TO_D50_YY * yd65 + D65_TO_D50_YZ * zd65,\n z: D65_TO_D50_ZX * xd65 + D65_TO_D50_ZY * yd65 + D65_TO_D50_ZZ * zd65,\n alpha: clamp(round(alpha, 3), 0, 1),\n };\n};\n\n/** Zero-allocation sibling of xyzD50ToLinearSrgb — writes [lr, lg, lb] into `out`. */\nexport const xyzD50ToLinearSrgbInto = (out: Float64Array | number[], x: number, y: number, z: number): void => {\n const xd65 = D50_TO_D65_XX * x + D50_TO_D65_XY * y + D50_TO_D65_XZ * z;\n const yd65 = D50_TO_D65_YX * x + D50_TO_D65_YY * y + D50_TO_D65_YZ * z;\n const zd65 = D50_TO_D65_ZX * x + D50_TO_D65_ZY * y + D50_TO_D65_ZZ * z;\n out[0] = X_RX * xd65 + X_RY * yd65 + X_RZ * zd65;\n out[1] = X_GX * xd65 + X_GY * yd65 + X_GZ * zd65;\n out[2] = X_BX * xd65 + X_BY * yd65 + X_BZ * zd65;\n};\n\n/** XYZ D50 → linear sRGB (no gamma, no clamping). x/y/z are in 0–100 scale. */\nexport const xyzD50ToLinearSrgb = (x: number, y: number, z: number): [number, number, number] => {\n const xd65 = D50_TO_D65_XX * x + D50_TO_D65_XY * y + D50_TO_D65_XZ * z;\n const yd65 = D50_TO_D65_YX * x + D50_TO_D65_YY * y + D50_TO_D65_YZ * z;\n const zd65 = D50_TO_D65_ZX * x + D50_TO_D65_ZY * y + D50_TO_D65_ZZ * z;\n return [\n X_RX * xd65 + X_RY * yd65 + X_RZ * zd65,\n X_GX * xd65 + X_GY * yd65 + X_GZ * zd65,\n X_BX * xd65 + X_BY * yd65 + X_BZ * zd65,\n ];\n};\n\nexport const xyzToRgb = ({ x, y, z, alpha }: XyzColor): RgbColor => {\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return clampRgb({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n};\n\n/** Unclamped XYZ D50 → gamma-encoded sRGB. Channels may exceed [0, 255] for out-of-sRGB-gamut colors. */\nconst xyzToRgbUnclamped = ({ x, y, z, alpha }: XyzColor): RgbColor => {\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// ── Parsers ─────────────────────────────────────────────────────────────────\n\nexport const parseXyzObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Reject D65-discriminated objects — parseXyzD65Object owns those.\n if ((input as { colorSpace?: unknown }).colorSpace === 'xyz-d65') return null;\n if (!hasKeys(input, ['x', 'y', 'z'])) return null;\n const { x, y, z, alpha = 1 } = input as { x: unknown; y: unknown; z: unknown; alpha?: unknown };\n if (!isNumber(x) || !isNumber(y) || !isNumber(z) || !isNumber(alpha)) return null;\n return xyzToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n });\n};\n\nexport const parseXyzD65Object = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if ((input as { colorSpace?: unknown }).colorSpace !== 'xyz-d65') return null;\n if (!hasKeys(input, ['x', 'y', 'z'])) return null;\n const { x, y, z, alpha = 1 } = input as { x: unknown; y: unknown; z: unknown; alpha?: unknown };\n if (!isAnyNumber(x) || !isAnyNumber(y) || !isAnyNumber(z) || !isAnyNumber(alpha)) return null;\n return xyzD65ToRgbUnclamped({\n x: sanitize(x),\n y: sanitize(y),\n z: sanitize(z),\n alpha: clamp(sanitize(alpha), 0, 1),\n colorSpace: 'xyz-d65',\n });\n};\n\n// CSS Color 4: color(xyz-d65 x y z / alpha). Channels accept number|percentage|none.\n// The library uses a 0–100 XYZ scale (to match the existing XyzColor convention); percent is\n// treated as the same scale for symmetry with the emitted string (100% = 100).\nconst XYZ_D65_RE = new RegExp(\n `^color\\\\(\\\\s*xyz-d65\\\\s+(?<x>${NUM_OR_NONE})(?<xp>%?)\\\\s+(?<y>${NUM_OR_NONE})(?<yp>%?)` +\n `\\\\s+(?<z>${NUM_OR_NONE})(?<zp>%?)\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nconst XYZ_D50_RE = new RegExp(\n `^color\\\\(\\\\s*xyz-d50\\\\s+(?<x>${NUM_OR_NONE})(?<xp>%?)\\\\s+(?<y>${NUM_OR_NONE})(?<yp>%?)` +\n `\\\\s+(?<z>${NUM_OR_NONE})(?<zp>%?)\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseXyzD65String = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = XYZ_D65_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const x = parseNum(g.x!);\n const y = parseNum(g.y!);\n const z = parseNum(g.z!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return xyzD65ToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n colorSpace: 'xyz-d65',\n });\n};\n\nexport const parseXyzD50String = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = XYZ_D50_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const x = parseNum(g.x!);\n const y = parseNum(g.y!);\n const z = parseNum(g.z!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return xyzToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { LabColor, RgbColor, XyzColor } from '../types.js';\nimport { D50_WX as WX, D50_WY as WY, D50_WZ as WZ, rgbToXyz, xyzD50ToLinearSrgb, xyzToRgb } from './xyz.js';\n\n// D65 white point derived from CIE chromaticity (x=0.3127, y=0.329)\nconst D65_WX = (0.3127 / 0.329) * 100;\nconst D65_WY = 100;\nconst D65_WZ = ((1 - 0.3127 - 0.329) / 0.329) * 100;\n\nconst EPSILON = 216 / 24389;\nconst KAPPA = 24389 / 27;\n\nconst f = (t: number) => (t > EPSILON ? Math.cbrt(t) : (KAPPA * t + 16) / 116);\n\nexport const xyzToLab = ({ x, y, z, alpha }: XyzColor): LabColor => {\n const fy = f(y / WY);\n return {\n l: 116 * fy - 16,\n a: 500 * (f(x / WX) - fy) || 0, // || 0 suppresses −0; NaN is impossible since WX/WZ are non-zero constants\n b: 200 * (fy - f(z / WZ)) || 0,\n alpha: round(alpha, 3),\n colorSpace: 'lab' as const,\n };\n};\n\n/** Primitives-only Lab → XYZ D50. x/y/z in 0–100 scale. Shared with channels.ts hot paths. */\nexport const labToXyzValues = (l: number, a: number, b: number): [number, number, number] => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n return [\n (fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA) * WX,\n (l > 8 ? fy ** 3 : l / KAPPA) * WY,\n (fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA) * WZ,\n ];\n};\n\n/** Zero-allocation sibling of labToXyzValues — writes [x, y, z] into `out`. */\nexport const labToXyzValuesInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n out[0] = (fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA) * WX;\n out[1] = (l > 8 ? fy ** 3 : l / KAPPA) * WY;\n out[2] = (fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA) * WZ;\n};\n\nexport const labToXyz = ({ l, a, b, alpha }: LabColor): XyzColor => {\n const [x, y, z] = labToXyzValues(l, a, b);\n return { x, y, z, alpha };\n};\n\nexport const rgbToLab = (rgb: RgbColor): LabColor => xyzToLab(rgbToXyz(rgb));\n\n/** RGB → CIE Lab using D65 white point (screen-native; used for perceptual difference). */\nexport const rgbToLabD65 = ({ r, g, b, alpha }: RgbColor): LabColor => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n const x = 100 * (0.41239079926595951 * lr + 0.35758433938387796 * lg + 0.18048078840183429 * lb);\n const y = 100 * (0.21263900587151036 * lr + 0.71516867876775592 * lg + 0.072192315360733714 * lb);\n const z = 100 * (0.019330818715591849 * lr + 0.11919477979462599 * lg + 0.95053215224966059 * lb);\n const fy = f(y / D65_WY);\n return {\n l: 116 * fy - 16,\n a: 500 * (f(x / D65_WX) - fy) || 0,\n b: 200 * (fy - f(z / D65_WZ)) || 0,\n alpha: round(alpha, 3),\n colorSpace: 'lab' as const,\n };\n};\n\nexport const deltaE2000 = (lab1: LabColor, lab2: LabColor): number => {\n const { l: L1, a: a1, b: b1 } = lab1;\n const { l: L2, a: a2, b: b2 } = lab2;\n const rad = Math.PI / 180;\n const deg = 180 / Math.PI;\n\n const C1 = Math.sqrt(a1 ** 2 + b1 ** 2);\n const C2 = Math.sqrt(a2 ** 2 + b2 ** 2);\n const Cab = ((C1 + C2) / 2) ** 7;\n const G = 0.5 * (1 - Math.sqrt(Cab / (Cab + 25 ** 7)));\n const a1p = a1 * (1 + G);\n const a2p = a2 * (1 + G);\n const C1p = Math.sqrt(a1p ** 2 + b1 ** 2);\n const C2p = Math.sqrt(a2p ** 2 + b2 ** 2);\n const Cp = (C1p + C2p) / 2;\n\n const h1p = a1p === 0 && b1 === 0 ? 0 : Math.atan2(b1, a1p) * deg;\n const h2p = a2p === 0 && b2 === 0 ? 0 : Math.atan2(b2, a2p) * deg;\n const h1 = h1p < 0 ? h1p + 360 : h1p;\n const h2 = h2p < 0 ? h2p + 360 : h2p;\n\n let dhp = h2 - h1;\n const absDh = Math.abs(h2 - h1);\n if (absDh > 180 && h2 <= h1) dhp += 360;\n else if (absDh > 180 && h2 > h1) dhp -= 360;\n\n const Lm = (L1 + L2) / 2;\n let Hm = h1 + h2;\n if (absDh <= 180) Hm /= 2;\n else Hm = (h1 + h2 < 360 ? Hm + 360 : Hm - 360) / 2;\n\n const T =\n 1 -\n 0.17 * Math.cos(rad * (Hm - 30)) +\n 0.24 * Math.cos(2 * rad * Hm) +\n 0.32 * Math.cos(rad * (3 * Hm + 6)) -\n 0.2 * Math.cos(rad * (4 * Hm - 63));\n\n const dLp = L2 - L1;\n const dCp = C2p - C1p;\n const dHp = 2 * Math.sin((rad * dhp) / 2) * Math.sqrt(C1p * C2p);\n\n const SL = 1 + (0.015 * (Lm - 50) ** 2) / Math.sqrt(20 + (Lm - 50) ** 2);\n const SC = 1 + 0.045 * Cp;\n const SH = 1 + 0.015 * Cp * T;\n\n const RC7 = Cp ** 7;\n const RC = 2 * Math.sqrt(RC7 / (RC7 + 25 ** 7));\n const dTheta = 30 * Math.exp(-(((Hm - 275) / 25) ** 2));\n const RT = -RC * Math.sin(2 * rad * dTheta);\n\n return Math.sqrt((dLp / SL) ** 2 + (dCp / SC) ** 2 + (dHp / SH) ** 2 + RT * (dCp / SC) * (dHp / SH));\n};\n\nexport const labToRgb = (lab: LabColor): RgbColor => xyzToRgb(labToXyz(lab));\n\n/**\n * Unclamped Lab (D50) → gamma-encoded sRGB (0–255). Channels may exceed [0, 255] or go\n * negative for colors outside the sRGB gamut. Preserves out-of-gamut information so callers\n * (mapSrgb, inGamut*) can detect and map the color; sRGB output methods clamp at the edge.\n */\nexport const labToRgbUnclamped = ({ l, a, b, alpha }: LabColor): RgbColor => {\n const [x, y, z] = labToXyzValues(l, a, b);\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// CSS Color 4: lab(L a b / alpha). L: number|percentage|none (100% = 100).\n// a/b: number|percentage|none (100% = 125).\nconst LAB_RE = new RegExp(\n `^lab\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<a>${NUM_OR_NONE})(?<ap>%?)\\\\s+(?<b>${NUM_OR_NONE})(?<bp>%?)` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseLabString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = LAB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const l = parseNum(g.l!); // 100% = 100, so value is unchanged whether `%` present\n const a = g.ap ? parseNum(g.a!) * 1.25 : parseNum(g.a!);\n const b = g.bp ? parseNum(g.b!) * 1.25 : parseNum(g.b!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return labToRgbUnclamped({\n l: clamp(l, 0, 100),\n a,\n b,\n alpha: clamp(alpha, 0, 1),\n colorSpace: 'lab',\n });\n};\n\nexport const parseLabObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if ((input as { colorSpace?: unknown }).colorSpace !== 'lab') return null;\n if (!hasKeys(input, ['l', 'a', 'b'])) return null;\n const { l, a, b, alpha = 1 } = input as { l: unknown; a: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(a) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n return labToRgbUnclamped({\n l: clamp(sanitize(l), 0, 100),\n a: sanitize(a),\n b: sanitize(b),\n alpha: clamp(sanitize(alpha), 0, 1),\n colorSpace: 'lab',\n });\n};\n"]} |
| 'use strict';var chunkZNT33DPT_cjs=require('./chunk-ZNT33DPT.cjs'),chunk6FI7U3TH_cjs=require('./chunk-6FI7U3TH.cjs'),chunkVSMEJU4Z_cjs=require('./chunk-VSMEJU4Z.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var mr=.7151256068556248,lr=.2848743931443754,cr=.04116194845011846,pr=.9588380515498816,an=1.3983557439607788,un=-0.3983557439607783,sn=-0.042928989294473266,mn=1.0429289892944733,to=(o,r,n,e)=>{o[0]=mr*r+lr*n,o[1]=n,o[2]=cr*n+pr*e;},ir=(o,r,n)=>[mr*o+lr*r,r,cr*r+pr*n];var v=(o,r,n)=>[an*o+un*r,r,sn*r+mn*n],ao=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=ir(chunkVSMEJU4Z_cjs.a(o/255),chunkVSMEJU4Z_cjs.a(r/255),chunkVSMEJU4Z_cjs.a(n/255));return {r:chunkVSMEJU4Z_cjs.f(b),g:chunkVSMEJU4Z_cjs.f(t),b:chunkVSMEJU4Z_cjs.f(u),alpha:e,colorSpace:"a98-rgb"}};var gr=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=v(chunkVSMEJU4Z_cjs.e(o),chunkVSMEJU4Z_cjs.e(r),chunkVSMEJU4Z_cjs.e(n));return {r:chunkVSMEJU4Z_cjs.b(b)*255,g:chunkVSMEJU4Z_cjs.b(t)*255,b:chunkVSMEJU4Z_cjs.b(u)*255,alpha:e}},uo=o=>{if(!chunkYISEJCI6_cjs.h(o)||o.colorSpace!=="a98-rgb"||!chunkYISEJCI6_cjs.i(o,["r","g","b"]))return null;let{r,g:n,b:e,alpha:b=1}=o;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(e)||!chunkYISEJCI6_cjs.f(b)?null:gr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(e),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},ln=new RegExp(`^color\\(\\s*a98-rgb\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),so=o=>{if(typeof o!="string")return null;let r=ln.exec(o.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),e=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return gr({r:n,g:e,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},mo=(o,r,n)=>ir(...chunkZNT33DPT_cjs.f(o,r,n));var hr=.8224619687,dr=.1775380313,Rr=.0331941989,fr=.9668058011,Sr=.0170826307,yr=.0723974407,Tr=.9105199286,cn=1.2249401762805598,pn=-0.22494017628055996,gn=-0.04205695470968816,hn=1.042056954709688,dn=-0.019637554590334432,Rn=-0.07863604555063189,fn=1.0982736001409663,go=(o,r,n,e)=>{o[0]=hr*r+dr*n,o[1]=Rr*r+fr*n,o[2]=Sr*r+yr*n+Tr*e;},Pr=(o,r,n)=>[hr*o+dr*r,Rr*o+fr*r,Sr*o+yr*r+Tr*n];var z=(o,r,n)=>[cn*o+pn*r,gn*o+hn*r,dn*o+Rn*r+fn*n],ho=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=Pr(chunkVSMEJU4Z_cjs.a(o/255),chunkVSMEJU4Z_cjs.a(r/255),chunkVSMEJU4Z_cjs.a(n/255));return {r:chunkVSMEJU4Z_cjs.b(b),g:chunkVSMEJU4Z_cjs.b(t),b:chunkVSMEJU4Z_cjs.b(u),alpha:e,colorSpace:"display-p3"}};var xr=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=z(chunkVSMEJU4Z_cjs.a(o),chunkVSMEJU4Z_cjs.a(r),chunkVSMEJU4Z_cjs.a(n));return {r:chunkVSMEJU4Z_cjs.b(b)*255,g:chunkVSMEJU4Z_cjs.b(t)*255,b:chunkVSMEJU4Z_cjs.b(u)*255,alpha:e}},Ro=o=>{if(!chunkYISEJCI6_cjs.h(o)||o.colorSpace!=="display-p3"||!chunkYISEJCI6_cjs.i(o,["r","g","b"]))return null;let{r,g:n,b:e,alpha:b=1}=o;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(e)||!chunkYISEJCI6_cjs.f(b)?null:xr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(e),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},Sn=new RegExp(`^color\\(\\s*display-p3\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),fo=o=>{if(typeof o!="string")return null;let r=Sn.exec(o.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),e=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return xr({r:n,g:e,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},So=(o,r,n)=>Pr(...chunkZNT33DPT_cjs.f(o,r,n));var Cr=.5292769776226117,_r=.330154501978493,Lr=.14056852039889559,Nr=.09836585954044925,Ar=.8734707129069617,kr=.02816342755258901,Gr=.016875340921386848,wr=.11765941425612084,Mr=.8654652448224923,yn=2.034380849516996,Tn=-0.7276357899341348,Pn=-0.3067450595828616,xn=-0.2288257316330505,Cn=1.231742541190105,_n=-0.0029168095570545408,Ln=-0.008558828783917425,Nn=-0.15326670213803723,An=1.1618255309219545,Co=(o,r,n,e)=>{o[0]=Cr*r+_r*n+Lr*e,o[1]=Nr*r+Ar*n+kr*e,o[2]=Gr*r+wr*n+Mr*e;},Br=(o,r,n)=>[Cr*o+_r*r+Lr*n,Nr*o+Ar*r+kr*n,Gr*o+wr*r+Mr*n];var D=(o,r,n)=>[yn*o+Tn*r+Pn*n,xn*o+Cn*r+_n*n,Ln*o+Nn*r+An*n],_o=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=Br(chunkVSMEJU4Z_cjs.a(o/255),chunkVSMEJU4Z_cjs.a(r/255),chunkVSMEJU4Z_cjs.a(n/255));return {r:chunkVSMEJU4Z_cjs.h(b),g:chunkVSMEJU4Z_cjs.h(t),b:chunkVSMEJU4Z_cjs.h(u),alpha:e,colorSpace:"prophoto-rgb"}};var Ir=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=D(chunkVSMEJU4Z_cjs.g(o),chunkVSMEJU4Z_cjs.g(r),chunkVSMEJU4Z_cjs.g(n));return {r:chunkVSMEJU4Z_cjs.b(b)*255,g:chunkVSMEJU4Z_cjs.b(t)*255,b:chunkVSMEJU4Z_cjs.b(u)*255,alpha:e}},Lo=o=>{if(!chunkYISEJCI6_cjs.h(o)||o.colorSpace!=="prophoto-rgb"||!chunkYISEJCI6_cjs.i(o,["r","g","b"]))return null;let{r,g:n,b:e,alpha:b=1}=o;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(e)||!chunkYISEJCI6_cjs.f(b)?null:Ir({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(e),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},kn=new RegExp(`^color\\(\\s*prophoto-rgb\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),No=o=>{if(typeof o!="string")return null;let r=kn.exec(o.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),e=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return Ir({r:n,g:e,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},Ao=(o,r,n)=>Br(...chunkZNT33DPT_cjs.f(o,r,n));var Fr=.6274038959,Er=.3292830384,Or=.0433130657,$r=.0690972894,vr=.9195403951,zr=.0113623156,Dr=.0163914389,jr=.0880133079,Ur=.8955952532,Gn=1.6604910021084345,wn=-0.5876411387885495,Mn=-0.07284986331988488,Bn=-0.12455047452159074,In=1.1328998971259603,Fn=-0.008349422604369477,En=-0.018150763354905303,On=-0.10057889800800739,$n=1.1187296613629127,Bo=(o,r,n,e)=>{o[0]=Fr*r+Er*n+Or*e,o[1]=$r*r+vr*n+zr*e,o[2]=Dr*r+jr*n+Ur*e;},Xr=(o,r,n)=>[Fr*o+Er*r+Or*n,$r*o+vr*r+zr*n,Dr*o+jr*r+Ur*n];var j=(o,r,n)=>[Gn*o+wn*r+Mn*n,Bn*o+In*r+Fn*n,En*o+On*r+$n*n],Io=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=Xr(chunkVSMEJU4Z_cjs.a(o/255),chunkVSMEJU4Z_cjs.a(r/255),chunkVSMEJU4Z_cjs.a(n/255));return {r:chunkVSMEJU4Z_cjs.d(b),g:chunkVSMEJU4Z_cjs.d(t),b:chunkVSMEJU4Z_cjs.d(u),alpha:e,colorSpace:"rec2020"}};var Kr=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=j(chunkVSMEJU4Z_cjs.c(o),chunkVSMEJU4Z_cjs.c(r),chunkVSMEJU4Z_cjs.c(n));return {r:chunkVSMEJU4Z_cjs.b(b)*255,g:chunkVSMEJU4Z_cjs.b(t)*255,b:chunkVSMEJU4Z_cjs.b(u)*255,alpha:e}},Fo=o=>{if(!chunkYISEJCI6_cjs.h(o)||o.colorSpace!=="rec2020"||!chunkYISEJCI6_cjs.i(o,["r","g","b"]))return null;let{r,g:n,b:e,alpha:b=1}=o;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(e)||!chunkYISEJCI6_cjs.f(b)?null:Kr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(e),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},vn=new RegExp(`^color\\(\\s*rec2020\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Eo=o=>{if(typeof o!="string")return null;let r=vn.exec(o.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),e=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return Kr({r:n,g:e,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},Oo=(o,r,n)=>Xr(...chunkZNT33DPT_cjs.f(o,r,n));var zn=/^oklch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Dn=/^oklab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jn=/^lab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Un=/^lch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Xn=/^color\(\s*display-p3\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Kn=/^color\(\s*rec2020\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Hn=/^color\(\s*a98-rgb\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qn=/^color\(\s*prophoto-rgb\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Vn=/^color\(\s*xyz-d50\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Yn=/^color\(\s*xyz-d65\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,I=(o,r,n)=>{let{x:e,y:b,z:t}=chunk6FI7U3TH_cjs.l({l:o,a:r,b:n,alpha:1,colorSpace:"lab"}),[u,l,c]=chunk6FI7U3TH_cjs.e(e,b,t);return chunkZNT33DPT_cjs.a(u,l,c)},Hr=(o,r,n)=>{let[e,b,t]=z(chunkVSMEJU4Z_cjs.a(o),chunkVSMEJU4Z_cjs.a(r),chunkVSMEJU4Z_cjs.a(n));return chunkZNT33DPT_cjs.a(e,b,t)},qr=(o,r,n)=>{let[e,b,t]=j(chunkVSMEJU4Z_cjs.c(o),chunkVSMEJU4Z_cjs.c(r),chunkVSMEJU4Z_cjs.c(n));return chunkZNT33DPT_cjs.a(e,b,t)},Vr=(o,r,n)=>{let[e,b,t]=v(chunkVSMEJU4Z_cjs.e(o),chunkVSMEJU4Z_cjs.e(r),chunkVSMEJU4Z_cjs.e(n));return chunkZNT33DPT_cjs.a(e,b,t)},Yr=(o,r,n)=>{let[e,b,t]=D(chunkVSMEJU4Z_cjs.g(o),chunkVSMEJU4Z_cjs.g(r),chunkVSMEJU4Z_cjs.g(n));return chunkZNT33DPT_cjs.a(e,b,t)},Zr=(o,r,n)=>{let[e,b,t]=chunk6FI7U3TH_cjs.e(o,r,n);return chunkZNT33DPT_cjs.a(e,b,t)},Jr=(o,r,n)=>{let[e,b,t]=chunk6FI7U3TH_cjs.b(o,r,n);return chunkZNT33DPT_cjs.a(e,b,t)},F=o=>{if(typeof o=="object"&&o!==null){let r=o;if("l"in r&&"a"in r&&"b"in r&&r.colorSpace!=="lab"&&!("c"in r)&&!("r"in r)){let n=o;if(typeof n.l=="number"&&typeof n.a=="number"&&typeof n.b=="number"&&typeof n.alpha=="number")return {l:n.l,a:n.a,b:n.b,alpha:n.alpha}}if("l"in r&&"c"in r&&"h"in r&&r.colorSpace!=="lch"&&!("a"in r)&&!("r"in r)){let n=o;if(typeof n.l=="number"&&typeof n.c=="number"&&typeof n.h=="number"){let e=n.h*Math.PI/180;return {l:n.l,a:n.c*Math.cos(e),b:n.c*Math.sin(e),alpha:n.alpha}}}if(r.colorSpace==="lab"){let n=o;if(typeof n.l!="number"||typeof n.a!="number"||typeof n.b!="number")return null;let[e,b,t]=I(n.l,n.a,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="lch"){let n=o;if(typeof n.l!="number"||typeof n.c!="number"||typeof n.h!="number")return null;let e=n.h*Math.PI/180,[b,t,u]=I(n.l,n.c*Math.cos(e),n.c*Math.sin(e));return {l:b,a:t,b:u,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="display-p3"){let n=o;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[e,b,t]=Hr(n.r,n.g,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="rec2020"){let n=o;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[e,b,t]=qr(n.r,n.g,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="a98-rgb"){let n=o;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[e,b,t]=Vr(n.r,n.g,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="prophoto-rgb"){let n=o;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[e,b,t]=Yr(n.r,n.g,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="xyz-d65"){let n=o;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[e,b,t]=Jr(n.x,n.y,n.z);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if("x"in r&&"y"in r&&"z"in r){let n=o;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[e,b,t]=Zr(n.x,n.y,n.z);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}return null}if(typeof o=="string"){let r=zn.exec(o);if(r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(chunkYISEJCI6_cjs.d[b]??1)*Math.PI/180,l=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:e*Math.cos(u),b:e*Math.sin(u),alpha:l}}if(r=Dn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?Number(r[5])*.004:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:e,b,alpha:t}}if(r=jn.exec(o),r){let n=Number(r[1]),e=r[4]?Number(r[3])*1.25:Number(r[3]),b=r[6]?Number(r[5])*1.25:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=I(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Un.exec(o),r){let n=Number(r[1]),e=r[4]?Number(r[3])*1.5:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(chunkYISEJCI6_cjs.d[b]??1)*Math.PI/180,l=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[c,L,N]=I(n,e*Math.cos(u),e*Math.sin(u));return {l:c,a:L,b:N,alpha:l}}if(r=Xn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=Hr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Kn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=qr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Hn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=Vr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=qn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=Yr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Vn.exec(o),r){let n=Number(r[1]),e=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,l,c]=Zr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Yn.exec(o),r){let n=Number(r[1]),e=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,l,c]=Jr(n,e,b);return {l:u,a:l,b:c,alpha:t}}return null}return null},_=5e-4,nn=(o,r,n)=>o>=-_&&o<=1+_&&r>=-_&&r<=1+_&&n>=-_&&n<=1+_,Qr=(o,r,n)=>o>=0&&o<=1&&r>=0&&r<=1&&n>=0&&n<=1,Vo=o=>{let r=F(o);if(r===null)return true;let[n,e,b]=chunkZNT33DPT_cjs.f(r.l,r.a,r.b);return nn(n,e,b)},Wr=.02,Zn=1e-4,rn=(o,r)=>{let n=o[0]-r[0],e=o[1]-r[1],b=o[2]-r[2];return Math.sqrt(n*n+e*e+b*b)},on=(o,r,n,e,b)=>{if(o>=1)return [1,1,1];if(o<=0)return [0,0,0];let[t,u,l]=e(o,r,n);if(Qr(t,u,l))return [t,u,l];let c=chunkYISEJCI6_cjs.a(t,0,1),L=chunkYISEJCI6_cjs.a(u,0,1),N=chunkYISEJCI6_cjs.a(l,0,1);if(rn(b(c,L,N),[o,r,n])<=Wr)return [c,L,N];let K=Math.atan2(n,r),tn=Math.sqrt(r*r+n*n),G=0,E=tn,H=true,q=c,V=L,Y=N;for(;E-G>Zn;){let A=(G+E)/2,Z=A*Math.cos(K),J=A*Math.sin(K),[Q,W,rr]=e(o,Z,J);if(H&&Qr(Q,W,rr)){G=A;continue}let nr=chunkYISEJCI6_cjs.a(Q,0,1),or=chunkYISEJCI6_cjs.a(W,0,1),er=chunkYISEJCI6_cjs.a(rr,0,1);q=nr,V=or,Y=er,rn(b(nr,or,er),[o,Z,J])<=Wr?(G=A,H=false):E=A;}return [q,V,Y]},Yo=o=>{let r=F(o);return r===null?null:{linear:on(r.l,r.a,r.b,chunkZNT33DPT_cjs.f,chunkZNT33DPT_cjs.a),alpha:r.alpha}},Zo=(o,r)=>{let n=F(o);if(n===null)return true;let[e,b,t]=r(n.l,n.a,n.b);return nn(e,b,t)},Jo=(o,r,n)=>{let e=F(o);return e===null?null:{linear:on(e.l,e.a,e.b,r,n),alpha:e.alpha}};var x=Math.PI/180,en=(o,r,n)=>{let e=n*x;return chunkZNT33DPT_cjs.f(o,r*Math.cos(e),r*Math.sin(e))},bn=(o,r,n,e)=>{let b=e*x;chunkZNT33DPT_cjs.e(o,r,n*Math.cos(b),n*Math.sin(b));},ee=(o,r,n)=>{let[e,b,t]=en(o,r,n);return [chunkVSMEJU4Z_cjs.b(e),chunkVSMEJU4Z_cjs.b(b),chunkVSMEJU4Z_cjs.b(t)]},be=(o,r,n,e)=>{bn(o,r,n,e),o[0]=chunkVSMEJU4Z_cjs.b(o[0]),o[1]=chunkVSMEJU4Z_cjs.b(o[1]),o[2]=chunkVSMEJU4Z_cjs.b(o[2]);},te=(o,r,n)=>{let[e,b,t]=en(o,r,n);return [[e,b,t],[chunkVSMEJU4Z_cjs.b(e),chunkVSMEJU4Z_cjs.b(b),chunkVSMEJU4Z_cjs.b(t)]]},ae=(o,r,n,e,b)=>{bn(o,n,e,b),r[0]=chunkVSMEJU4Z_cjs.b(o[0]),r[1]=chunkVSMEJU4Z_cjs.b(o[1]),r[2]=chunkVSMEJU4Z_cjs.b(o[2]);},ue=(o,r,n)=>[chunkVSMEJU4Z_cjs.a(o),chunkVSMEJU4Z_cjs.a(r),chunkVSMEJU4Z_cjs.a(n)],se=(o,r,n,e)=>{o[0]=chunkVSMEJU4Z_cjs.a(r),o[1]=chunkVSMEJU4Z_cjs.a(n),o[2]=chunkVSMEJU4Z_cjs.a(e);},U=(o,r,n)=>{let[e,b,t]=chunk6FI7U3TH_cjs.j(o,r,n);return chunk6FI7U3TH_cjs.e(e,b,t)},X=(o,r,n,e)=>{chunk6FI7U3TH_cjs.k(o,r,n,e),chunk6FI7U3TH_cjs.d(o,o[0],o[1],o[2]);},me=(o,r,n)=>{let e=n*x;return U(o,r*Math.cos(e),r*Math.sin(e))},le=(o,r,n,e)=>{let b=e*x;X(o,r,n*Math.cos(b),n*Math.sin(b));},Jn=(o,r,n)=>{let[e,b,t]=U(o,r,n);return [chunkVSMEJU4Z_cjs.b(e),chunkVSMEJU4Z_cjs.b(b),chunkVSMEJU4Z_cjs.b(t)]},Qn=(o,r,n,e)=>{X(o,r,n,e),o[0]=chunkVSMEJU4Z_cjs.b(o[0]),o[1]=chunkVSMEJU4Z_cjs.b(o[1]),o[2]=chunkVSMEJU4Z_cjs.b(o[2]);},ce=(o,r,n)=>{let e=n*x;return Jn(o,r*Math.cos(e),r*Math.sin(e))},pe=(o,r,n,e)=>{let b=e*x;Qn(o,r,n*Math.cos(b),n*Math.sin(b));},Wn=(o,r,n)=>{let[e,b,t]=U(o,r,n);return [[e,b,t],[chunkVSMEJU4Z_cjs.b(e),chunkVSMEJU4Z_cjs.b(b),chunkVSMEJU4Z_cjs.b(t)]]},ro=(o,r,n,e,b)=>{X(o,n,e,b),r[0]=chunkVSMEJU4Z_cjs.b(o[0]),r[1]=chunkVSMEJU4Z_cjs.b(o[1]),r[2]=chunkVSMEJU4Z_cjs.b(o[2]);},ie=(o,r,n)=>{let e=n*x;return Wn(o,r*Math.cos(e),r*Math.sin(e))},ge=(o,r,n,e,b)=>{let t=b*x;ro(o,r,n,e*Math.cos(t),e*Math.sin(t));};exports.A=Eo;exports.B=Oo;exports.C=Vo;exports.D=Yo;exports.E=Zo;exports.F=Jo;exports.G=en;exports.H=bn;exports.I=ee;exports.J=be;exports.K=te;exports.L=ae;exports.M=ue;exports.N=se;exports.O=U;exports.P=X;exports.Q=me;exports.R=le;exports.S=Jn;exports.T=Qn;exports.U=ce;exports.V=pe;exports.W=Wn;exports.X=ro;exports.Y=ie;exports.Z=ge;exports.a=to;exports.b=ir;exports.c=v;exports.d=ao;exports.e=uo;exports.f=so;exports.g=mo;exports.h=go;exports.i=Pr;exports.j=z;exports.k=ho;exports.l=Ro;exports.m=fo;exports.n=So;exports.o=Co;exports.p=Br;exports.q=D;exports.r=_o;exports.s=Lo;exports.t=No;exports.u=Ao;exports.v=Bo;exports.w=Xr;exports.x=j;exports.y=Io;exports.z=Fo;//# sourceMappingURL=chunk-DCLFNJD3.cjs.map | ||
| //# sourceMappingURL=chunk-DCLFNJD3.cjs.map |
Sorry, the diff of this file is too big to display
| import {a,b,h,i,f,g,l,k}from'./chunk-IOXRZECH.mjs';var $=s=>({r:a(s.r,0,255),g:a(s.g,0,255),b:a(s.b,0,255),alpha:a(b(s.alpha,3),0,1)}),x=s=>{if(!h(s))return null;let n=s.colorSpace;if(n==="display-p3"||n==="rec2020"||n==="a98-rgb"||n==="prophoto-rgb"||!i(s,["r","g","b"]))return null;let{r:e,g:t,b:c,alpha:l=1}=s;return !f(e)||!f(t)||!f(c)||!f(l)?null:$({r:g(e),g:g(t),b:g(c),alpha:g(l)})},y=new RegExp(`^rgba?\\(\\s*(?<r>${k})(?<rp>%?)\\s*(?:,\\s*(?<g_c>${k})(?<gp_c>%?)\\s*,\\s*(?<b_c>${k})(?<bp_c>%?)(?:\\s*,\\s*(?<al_c>${k})(?<alp_c>%?))?\\s*|\\s+(?<g_s>${k})(?<gp_s>%?)\\s+(?<b_s>${k})(?<bp_s>%?)(?:\\s*/\\s*(?<al_s>${k})(?<alp_s>%?))?\\s*)\\)$`,"i"),N=s=>{if(typeof s!="string")return null;let n=y.exec(s.trim())?.groups;if(!n)return null;let e=n.g_c!==void 0,t=n.g_c??n.g_s,c=n.b_c??n.b_s,l$1=!!n.rp,b=!!(n.gp_c??n.gp_s),_=!!(n.bp_c??n.bp_s),m=l$1?l(n.r)/100*255:l(n.r),w=b?l(t)/100*255:l(t),d=_?l(c)/100*255:l(c);if(e&&(l$1!==b||b!==_||/^none$/i.test(n.r)||/^none$/i.test(t)||/^none$/i.test(c)))return null;let u=n.al_c??n.al_s,h=!!(n.alp_c??n.alp_s);if(e&&u!==void 0&&/^none$/i.test(u))return null;let k=u===void 0?1:l(u)/(h?100:1);return $({r:m,g:w,b:d,alpha:k})};export{$ as a,x as b,N as c};//# sourceMappingURL=chunk-GLKEY6D3.mjs.map | ||
| //# sourceMappingURL=chunk-GLKEY6D3.mjs.map |
| {"version":3,"sources":["../src/colorModels/rgb.ts"],"names":["clampRgb","rgb","clamp","round","parseRgbObject","input","isObject","cs","hasKeys","r","g","b","alpha","isAnyNumber","sanitize","RGB_RE","NUM_OR_NONE","parseRgbString","isComma","gRaw","bRaw","rPct","gPct","bPct","parseNum","gc","rawA","aPct"],"mappings":"mDAGO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,EAAMD,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,CAAA,CAAGC,CAAAA,CAAMD,CAAAA,CAAI,EAAG,CAAA,CAAG,GAAG,CAAA,CACtB,CAAA,CAAGC,CAAAA,CAAMD,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,KAAA,CAAOC,CAAAA,CAAMC,CAAAA,CAAMF,EAAI,KAAA,CAAO,CAAC,CAAA,CAAG,CAAA,CAAG,CAAC,CACxC,CAAA,CAAA,CAEaG,CAAAA,CAAkBC,CAAAA,EAAoC,CACjE,GAAI,CAACC,CAAAA,CAASD,CAAK,CAAA,CAAG,OAAO,IAAA,CAC7B,IAAME,EAAMF,CAAAA,CAAmC,UAAA,CAE/C,GADIE,CAAAA,GAAO,cAAgBA,CAAAA,GAAO,SAAA,EAAaA,CAAAA,GAAO,SAAA,EAAaA,CAAAA,GAAO,cAAA,EACtE,CAACC,CAAAA,CAAQH,EAAO,CAAC,GAAA,CAAK,GAAA,CAAK,GAAG,CAAC,CAAA,CAAG,OAAO,IAAA,CAC7C,GAAM,CAAE,CAAA,CAAAI,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAAA,CAAQ,CAAE,CAAA,CAAIP,CAAAA,CAC/B,OAAI,CAACQ,CAAAA,CAAYJ,CAAC,CAAA,EAAK,CAACI,EAAYH,CAAC,CAAA,EAAK,CAACG,CAAAA,CAAYF,CAAC,CAAA,EAAK,CAACE,CAAAA,CAAYD,CAAK,CAAA,CAAU,IAAA,CAClFZ,CAAAA,CAAS,CAAE,E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A,CAAMK,CAAAA,CAASL,CAAI,CAAA,CACxDR,EAAIY,CAAAA,CAAQC,CAAAA,CAASJ,CAAI,CAAA,CAAI,GAAA,CAAO,GAAA,CAAMI,CAAAA,CAASJ,CAAI,EAG7D,GAAIF,CAAAA,GACEG,GAAAA,GAASC,CAAAA,EAAQA,IAASC,CAAAA,EAC1B,SAAA,CAAU,IAAA,CAAKb,CAAAA,CAAE,CAAE,CAAA,EAAK,SAAA,CAAU,IAAA,CAAKS,CAAI,CAAA,EAAK,SAAA,CAAU,IAAA,CAAKC,CAAI,GAAG,OAAO,IAAA,CAGnF,IAAMM,CAAAA,CAAOhB,EAAE,IAAA,EAAQA,CAAAA,CAAE,IAAA,CACnBiB,CAAAA,CAAO,CAAC,EAAEjB,CAAAA,CAAE,KAAA,EAASA,CAAAA,CAAE,KAAA,CAAA,CAC7B,GAAIQ,CAAAA,EAAWQ,CAAAA,GAAS,QAAa,SAAA,CAAU,IAAA,CAAKA,CAAI,CAAA,CAAG,OAAO,IAAA,CAClE,IAAMd,CAAAA,CAAQc,CAAAA,GAAS,OAAY,CAAA,CAAIF,CAAAA,CAASE,CAAI,CAAA,EAAKC,CAAAA,CAAO,GAAA,CAAM,CAAA,CAAA,CAEtE,OAAO3B,EAAS,CAAE,CAAA,CAAAS,CAAAA,CAAG,CAAA,CAAGgB,EAAI,CAAA,CAAAd,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAC,CACxC","file":"chunk-GLKEY6D3.mjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport type { RgbColor } from '../types.js';\n\nexport const clampRgb = (rgb: RgbColor): RgbColor => ({\n r: clamp(rgb.r, 0, 255),\n g: clamp(rgb.g, 0, 255),\n b: clamp(rgb.b, 0, 255),\n alpha: clamp(round(rgb.alpha, 3), 0, 1),\n});\n\nexport const parseRgbObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n const cs = (input as { colorSpace?: unknown }).colorSpace;\n if (cs === 'display-p3' || cs === 'rec2020' || cs === 'a98-rgb' || cs === 'prophoto-rgb') return null;\n if (!hasKeys(input, ['r', 'g', 'b'])) return null;\n const { r, g, b, alpha = 1 } = input as { r: unknown; g: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(r) || !isAnyNumber(g) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n return clampRgb({ r: sanitize(r), g: sanitize(g), b: sanitize(b), alpha: sanitize(alpha) });\n};\n\n// Matches both legacy comma syntax: rgb(255, 0, 0) / rgba(255, 0, 0, 0.5)\n// and modern space syntax: rgb(255 0 0) / rgb(255 0 0 / 0.5).\n// Supports percentage-based channels and the CSS Color 4 `none` keyword.\n// Named groups are suffixed `_c` (comma/legacy branch) or `_s` (space/modern branch)\n// because ES2022 regex requires distinct names across alternation branches.\nconst RGB_RE = new RegExp(\n `^rgba?\\\\(\\\\s*(?<r>${NUM_OR_NONE})(?<rp>%?)\\\\s*(?:` +\n `,\\\\s*(?<g_c>${NUM_OR_NONE})(?<gp_c>%?)\\\\s*,\\\\s*(?<b_c>${NUM_OR_NONE})(?<bp_c>%?)` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM_OR_NONE})(?<alp_c>%?))?\\\\s*` +\n `|` +\n `\\\\s+(?<g_s>${NUM_OR_NONE})(?<gp_s>%?)\\\\s+(?<b_s>${NUM_OR_NONE})(?<bp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?))?\\\\s*` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseRgbString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = RGB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n\n const isComma = g.g_c !== undefined;\n const gRaw = g.g_c ?? g.g_s!;\n const bRaw = g.b_c ?? g.b_s!;\n const rPct = !!g.rp;\n const gPct = !!(g.gp_c ?? g.gp_s);\n const bPct = !!(g.bp_c ?? g.bp_s);\n\n const r = rPct ? (parseNum(g.r!) / 100) * 255 : parseNum(g.r!);\n const gc = gPct ? (parseNum(gRaw) / 100) * 255 : parseNum(gRaw);\n const b = bPct ? (parseNum(bRaw) / 100) * 255 : parseNum(bRaw);\n\n // Legacy: channels must match type, no `none`. Modern: mixing + `none` allowed.\n if (isComma) {\n if (rPct !== gPct || gPct !== bPct) return null;\n if (/^none$/i.test(g.r!) || /^none$/i.test(gRaw) || /^none$/i.test(bRaw)) return null;\n }\n\n const rawA = g.al_c ?? g.al_s;\n const aPct = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (aPct ? 100 : 1);\n\n return clampRgb({ r, g: gc, b, alpha });\n};\n"]} |
| import {f as f$2,e,a as a$2}from'./chunk-2FEDFNW7.mjs';import {j as j$1,e as e$1,k,d as d$1,l as l$1,b as b$1}from'./chunk-YQKSXMBN.mjs';import {a,f,b,h as h$1,d,e as e$2,g as g$1,c}from'./chunk-WGY6QKPW.mjs';import {h,i,f as f$1,a as a$1,g,l,k as k$1,d as d$2}from'./chunk-IOXRZECH.mjs';var mr=.7151256068556248,lr=.2848743931443754,cr=.04116194845011846,pr=.9588380515498816,an=1.3983557439607788,un=-0.3983557439607783,sn=-0.042928989294473266,mn=1.0429289892944733,to=(o,r,n,e)=>{o[0]=mr*r+lr*n,o[1]=n,o[2]=cr*n+pr*e;},ir=(o,r,n)=>[mr*o+lr*r,r,cr*r+pr*n];var v=(o,r,n)=>[an*o+un*r,r,sn*r+mn*n],ao=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=ir(a(o/255),a(r/255),a(n/255));return {r:f(b),g:f(t),b:f(u),alpha:e,colorSpace:"a98-rgb"}};var gr=({r:o,g:r,b:n,alpha:e})=>{let[b$1,t,u]=v(e$2(o),e$2(r),e$2(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:e}},uo=o=>{if(!h(o)||o.colorSpace!=="a98-rgb"||!i(o,["r","g","b"]))return null;let{r,g:n,b:e,alpha:b=1}=o;return !f$1(r)||!f$1(n)||!f$1(e)||!f$1(b)?null:gr({r:g(r),g:g(n),b:g(e),alpha:a$1(g(b),0,1)})},ln=new RegExp(`^color\\(\\s*a98-rgb\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),so=o=>{if(typeof o!="string")return null;let r=ln.exec(o.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),e=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return gr({r:n,g:e,b,alpha:a$1(t,0,1)})},mo=(o,r,n)=>ir(...f$2(o,r,n));var hr=.8224619687,dr=.1775380313,Rr=.0331941989,fr=.9668058011,Sr=.0170826307,yr=.0723974407,Tr=.9105199286,cn=1.2249401762805598,pn=-0.22494017628055996,gn=-0.04205695470968816,hn=1.042056954709688,dn=-0.019637554590334432,Rn=-0.07863604555063189,fn=1.0982736001409663,go=(o,r,n,e)=>{o[0]=hr*r+dr*n,o[1]=Rr*r+fr*n,o[2]=Sr*r+yr*n+Tr*e;},Pr=(o,r,n)=>[hr*o+dr*r,Rr*o+fr*r,Sr*o+yr*r+Tr*n];var z=(o,r,n)=>[cn*o+pn*r,gn*o+hn*r,dn*o+Rn*r+fn*n],ho=({r:o,g:r,b:n,alpha:e})=>{let[b$1,t,u]=Pr(a(o/255),a(r/255),a(n/255));return {r:b(b$1),g:b(t),b:b(u),alpha:e,colorSpace:"display-p3"}};var xr=({r:o,g:r,b:n,alpha:e})=>{let[b$1,t,u]=z(a(o),a(r),a(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:e}},Ro=o=>{if(!h(o)||o.colorSpace!=="display-p3"||!i(o,["r","g","b"]))return null;let{r,g:n,b:e,alpha:b=1}=o;return !f$1(r)||!f$1(n)||!f$1(e)||!f$1(b)?null:xr({r:g(r),g:g(n),b:g(e),alpha:a$1(g(b),0,1)})},Sn=new RegExp(`^color\\(\\s*display-p3\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),fo=o=>{if(typeof o!="string")return null;let r=Sn.exec(o.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),e=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return xr({r:n,g:e,b,alpha:a$1(t,0,1)})},So=(o,r,n)=>Pr(...f$2(o,r,n));var Cr=.5292769776226117,_r=.330154501978493,Lr=.14056852039889559,Nr=.09836585954044925,Ar=.8734707129069617,kr=.02816342755258901,Gr=.016875340921386848,wr=.11765941425612084,Mr=.8654652448224923,yn=2.034380849516996,Tn=-0.7276357899341348,Pn=-0.3067450595828616,xn=-0.2288257316330505,Cn=1.231742541190105,_n=-0.0029168095570545408,Ln=-0.008558828783917425,Nn=-0.15326670213803723,An=1.1618255309219545,Co=(o,r,n,e)=>{o[0]=Cr*r+_r*n+Lr*e,o[1]=Nr*r+Ar*n+kr*e,o[2]=Gr*r+wr*n+Mr*e;},Br=(o,r,n)=>[Cr*o+_r*r+Lr*n,Nr*o+Ar*r+kr*n,Gr*o+wr*r+Mr*n];var D=(o,r,n)=>[yn*o+Tn*r+Pn*n,xn*o+Cn*r+_n*n,Ln*o+Nn*r+An*n],_o=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=Br(a(o/255),a(r/255),a(n/255));return {r:h$1(b),g:h$1(t),b:h$1(u),alpha:e,colorSpace:"prophoto-rgb"}};var Ir=({r:o,g:r,b:n,alpha:e})=>{let[b$1,t,u]=D(g$1(o),g$1(r),g$1(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:e}},Lo=o=>{if(!h(o)||o.colorSpace!=="prophoto-rgb"||!i(o,["r","g","b"]))return null;let{r,g:n,b:e,alpha:b=1}=o;return !f$1(r)||!f$1(n)||!f$1(e)||!f$1(b)?null:Ir({r:g(r),g:g(n),b:g(e),alpha:a$1(g(b),0,1)})},kn=new RegExp(`^color\\(\\s*prophoto-rgb\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),No=o=>{if(typeof o!="string")return null;let r=kn.exec(o.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),e=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return Ir({r:n,g:e,b,alpha:a$1(t,0,1)})},Ao=(o,r,n)=>Br(...f$2(o,r,n));var Fr=.6274038959,Er=.3292830384,Or=.0433130657,$r=.0690972894,vr=.9195403951,zr=.0113623156,Dr=.0163914389,jr=.0880133079,Ur=.8955952532,Gn=1.6604910021084345,wn=-0.5876411387885495,Mn=-0.07284986331988488,Bn=-0.12455047452159074,In=1.1328998971259603,Fn=-0.008349422604369477,En=-0.018150763354905303,On=-0.10057889800800739,$n=1.1187296613629127,Bo=(o,r,n,e)=>{o[0]=Fr*r+Er*n+Or*e,o[1]=$r*r+vr*n+zr*e,o[2]=Dr*r+jr*n+Ur*e;},Xr=(o,r,n)=>[Fr*o+Er*r+Or*n,$r*o+vr*r+zr*n,Dr*o+jr*r+Ur*n];var j=(o,r,n)=>[Gn*o+wn*r+Mn*n,Bn*o+In*r+Fn*n,En*o+On*r+$n*n],Io=({r:o,g:r,b:n,alpha:e})=>{let[b,t,u]=Xr(a(o/255),a(r/255),a(n/255));return {r:d(b),g:d(t),b:d(u),alpha:e,colorSpace:"rec2020"}};var Kr=({r:o,g:r,b:n,alpha:e})=>{let[b$1,t,u]=j(c(o),c(r),c(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:e}},Fo=o=>{if(!h(o)||o.colorSpace!=="rec2020"||!i(o,["r","g","b"]))return null;let{r,g:n,b:e,alpha:b=1}=o;return !f$1(r)||!f$1(n)||!f$1(e)||!f$1(b)?null:Kr({r:g(r),g:g(n),b:g(e),alpha:a$1(g(b),0,1)})},vn=new RegExp(`^color\\(\\s*rec2020\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),Eo=o=>{if(typeof o!="string")return null;let r=vn.exec(o.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),e=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return Kr({r:n,g:e,b,alpha:a$1(t,0,1)})},Oo=(o,r,n)=>Xr(...f$2(o,r,n));var zn=/^oklch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Dn=/^oklab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jn=/^lab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Un=/^lch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Xn=/^color\(\s*display-p3\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Kn=/^color\(\s*rec2020\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Hn=/^color\(\s*a98-rgb\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qn=/^color\(\s*prophoto-rgb\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Vn=/^color\(\s*xyz-d50\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Yn=/^color\(\s*xyz-d65\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,I=(o,r,n)=>{let{x:e,y:b,z:t}=l$1({l:o,a:r,b:n,alpha:1,colorSpace:"lab"}),[u,l,c]=e$1(e,b,t);return a$2(u,l,c)},Hr=(o,r,n)=>{let[e,b,t]=z(a(o),a(r),a(n));return a$2(e,b,t)},qr=(o,r,n)=>{let[e,b,t]=j(c(o),c(r),c(n));return a$2(e,b,t)},Vr=(o,r,n)=>{let[e,b,t]=v(e$2(o),e$2(r),e$2(n));return a$2(e,b,t)},Yr=(o,r,n)=>{let[e,b,t]=D(g$1(o),g$1(r),g$1(n));return a$2(e,b,t)},Zr=(o,r,n)=>{let[e,b,t]=e$1(o,r,n);return a$2(e,b,t)},Jr=(o,r,n)=>{let[e,b,t]=b$1(o,r,n);return a$2(e,b,t)},F=o=>{if(typeof o=="object"&&o!==null){let r=o;if("l"in r&&"a"in r&&"b"in r&&r.colorSpace!=="lab"&&!("c"in r)&&!("r"in r)){let n=o;if(typeof n.l=="number"&&typeof n.a=="number"&&typeof n.b=="number"&&typeof n.alpha=="number")return {l:n.l,a:n.a,b:n.b,alpha:n.alpha}}if("l"in r&&"c"in r&&"h"in r&&r.colorSpace!=="lch"&&!("a"in r)&&!("r"in r)){let n=o;if(typeof n.l=="number"&&typeof n.c=="number"&&typeof n.h=="number"){let e=n.h*Math.PI/180;return {l:n.l,a:n.c*Math.cos(e),b:n.c*Math.sin(e),alpha:n.alpha}}}if(r.colorSpace==="lab"){let n=o;if(typeof n.l!="number"||typeof n.a!="number"||typeof n.b!="number")return null;let[e,b,t]=I(n.l,n.a,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="lch"){let n=o;if(typeof n.l!="number"||typeof n.c!="number"||typeof n.h!="number")return null;let e=n.h*Math.PI/180,[b,t,u]=I(n.l,n.c*Math.cos(e),n.c*Math.sin(e));return {l:b,a:t,b:u,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="display-p3"){let n=o;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[e,b,t]=Hr(n.r,n.g,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="rec2020"){let n=o;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[e,b,t]=qr(n.r,n.g,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="a98-rgb"){let n=o;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[e,b,t]=Vr(n.r,n.g,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="prophoto-rgb"){let n=o;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[e,b,t]=Yr(n.r,n.g,n.b);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="xyz-d65"){let n=o;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[e,b,t]=Jr(n.x,n.y,n.z);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if("x"in r&&"y"in r&&"z"in r){let n=o;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[e,b,t]=Zr(n.x,n.y,n.z);return {l:e,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}return null}if(typeof o=="string"){let r=zn.exec(o);if(r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(d$2[b]??1)*Math.PI/180,l=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:e*Math.cos(u),b:e*Math.sin(u),alpha:l}}if(r=Dn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?Number(r[5])*.004:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:e,b,alpha:t}}if(r=jn.exec(o),r){let n=Number(r[1]),e=r[4]?Number(r[3])*1.25:Number(r[3]),b=r[6]?Number(r[5])*1.25:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=I(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Un.exec(o),r){let n=Number(r[1]),e=r[4]?Number(r[3])*1.5:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(d$2[b]??1)*Math.PI/180,l=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[c,L,N]=I(n,e*Math.cos(u),e*Math.sin(u));return {l:c,a:L,b:N,alpha:l}}if(r=Xn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=Hr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Kn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=qr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Hn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=Vr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=qn.exec(o),r){let n=r[2]?Number(r[1])/100:Number(r[1]),e=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,l,c]=Yr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Vn.exec(o),r){let n=Number(r[1]),e=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,l,c]=Zr(n,e,b);return {l:u,a:l,b:c,alpha:t}}if(r=Yn.exec(o),r){let n=Number(r[1]),e=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,l,c]=Jr(n,e,b);return {l:u,a:l,b:c,alpha:t}}return null}return null},_=5e-4,nn=(o,r,n)=>o>=-_&&o<=1+_&&r>=-_&&r<=1+_&&n>=-_&&n<=1+_,Qr=(o,r,n)=>o>=0&&o<=1&&r>=0&&r<=1&&n>=0&&n<=1,Vo=o=>{let r=F(o);if(r===null)return true;let[n,e,b]=f$2(r.l,r.a,r.b);return nn(n,e,b)},Wr=.02,Zn=1e-4,rn=(o,r)=>{let n=o[0]-r[0],e=o[1]-r[1],b=o[2]-r[2];return Math.sqrt(n*n+e*e+b*b)},on=(o,r,n,e,b)=>{if(o>=1)return [1,1,1];if(o<=0)return [0,0,0];let[t,u,l]=e(o,r,n);if(Qr(t,u,l))return [t,u,l];let c=a$1(t,0,1),L=a$1(u,0,1),N=a$1(l,0,1);if(rn(b(c,L,N),[o,r,n])<=Wr)return [c,L,N];let K=Math.atan2(n,r),tn=Math.sqrt(r*r+n*n),G=0,E=tn,H=true,q=c,V=L,Y=N;for(;E-G>Zn;){let A=(G+E)/2,Z=A*Math.cos(K),J=A*Math.sin(K),[Q,W,rr]=e(o,Z,J);if(H&&Qr(Q,W,rr)){G=A;continue}let nr=a$1(Q,0,1),or=a$1(W,0,1),er=a$1(rr,0,1);q=nr,V=or,Y=er,rn(b(nr,or,er),[o,Z,J])<=Wr?(G=A,H=false):E=A;}return [q,V,Y]},Yo=o=>{let r=F(o);return r===null?null:{linear:on(r.l,r.a,r.b,f$2,a$2),alpha:r.alpha}},Zo=(o,r)=>{let n=F(o);if(n===null)return true;let[e,b,t]=r(n.l,n.a,n.b);return nn(e,b,t)},Jo=(o,r,n)=>{let e=F(o);return e===null?null:{linear:on(e.l,e.a,e.b,r,n),alpha:e.alpha}};var x=Math.PI/180,en=(o,r,n)=>{let e=n*x;return f$2(o,r*Math.cos(e),r*Math.sin(e))},bn=(o,r,n,e$1)=>{let b=e$1*x;e(o,r,n*Math.cos(b),n*Math.sin(b));},ee=(o,r,n)=>{let[e,b$1,t]=en(o,r,n);return [b(e),b(b$1),b(t)]},be=(o,r,n,e)=>{bn(o,r,n,e),o[0]=b(o[0]),o[1]=b(o[1]),o[2]=b(o[2]);},te=(o,r,n)=>{let[e,b$1,t]=en(o,r,n);return [[e,b$1,t],[b(e),b(b$1),b(t)]]},ae=(o,r,n,e,b$1)=>{bn(o,n,e,b$1),r[0]=b(o[0]),r[1]=b(o[1]),r[2]=b(o[2]);},ue=(o,r,n)=>[a(o),a(r),a(n)],se=(o,r,n,e)=>{o[0]=a(r),o[1]=a(n),o[2]=a(e);},U=(o,r,n)=>{let[e,b,t]=j$1(o,r,n);return e$1(e,b,t)},X=(o,r,n,e)=>{k(o,r,n,e),d$1(o,o[0],o[1],o[2]);},me=(o,r,n)=>{let e=n*x;return U(o,r*Math.cos(e),r*Math.sin(e))},le=(o,r,n,e)=>{let b=e*x;X(o,r,n*Math.cos(b),n*Math.sin(b));},Jn=(o,r,n)=>{let[e,b$1,t]=U(o,r,n);return [b(e),b(b$1),b(t)]},Qn=(o,r,n,e)=>{X(o,r,n,e),o[0]=b(o[0]),o[1]=b(o[1]),o[2]=b(o[2]);},ce=(o,r,n)=>{let e=n*x;return Jn(o,r*Math.cos(e),r*Math.sin(e))},pe=(o,r,n,e)=>{let b=e*x;Qn(o,r,n*Math.cos(b),n*Math.sin(b));},Wn=(o,r,n)=>{let[e,b$1,t]=U(o,r,n);return [[e,b$1,t],[b(e),b(b$1),b(t)]]},ro=(o,r,n,e,b$1)=>{X(o,n,e,b$1),r[0]=b(o[0]),r[1]=b(o[1]),r[2]=b(o[2]);},ie=(o,r,n)=>{let e=n*x;return Wn(o,r*Math.cos(e),r*Math.sin(e))},ge=(o,r,n,e,b)=>{let t=b*x;ro(o,r,n,e*Math.cos(t),e*Math.sin(t));};export{Eo as A,Oo as B,Vo as C,Yo as D,Zo as E,Jo as F,en as G,bn as H,ee as I,be as J,te as K,ae as L,ue as M,se as N,U as O,X as P,me as Q,le as R,Jn as S,Qn as T,ce as U,pe as V,Wn as W,ro as X,ie as Y,ge as Z,to as a,ir as b,v as c,ao as d,uo as e,so as f,mo as g,go as h,Pr as i,z as j,ho as k,Ro as l,fo as m,So as n,Co as o,Br as p,D as q,_o as r,Lo as s,No as t,Ao as u,Bo as v,Xr as w,j as x,Io as y,Fo as z};//# sourceMappingURL=chunk-JT2PPQ6V.mjs.map | ||
| //# sourceMappingURL=chunk-JT2PPQ6V.mjs.map |
Sorry, the diff of this file is too big to display
| import {a as a$1}from'./chunk-GLKEY6D3.mjs';import {a,b,l,d,h,i,f,g as g$1,k,j as j$1,c}from'./chunk-IOXRZECH.mjs';var N=r=>({h:c(r.h),s:a(r.s,0,100),v:a(r.v,0,100),alpha:a(b(r.alpha,3),0,1)}),g={h:0,s:0,v:0,alpha:0},T=({r,g:n,b:u,alpha:h})=>{let t=r/255,o=n/255,c=u/255,e=Math.max(t,o,c),a$1=Math.min(t,o,c),l=e-a$1,i=e===0?0:l/e,f=0;if(e!==a$1)switch(e){case t:f=((o-c)/l+(o<c?6:0))/6;break;case o:f=((c-t)/l+2)/6;break;case c:f=((t-o)/l+4)/6;break}let k=f*360;return g.h=k>=0&&k<360?k:(k%360+360)%360,g.s=a(i*100,0,100),g.v=a(e*100,0,100),g.alpha=a(b(h,3),0,1),g};var s=[0,0,0],M=({h:r,s:n,v:u,alpha:h})=>{let t=n/100,o=u/100,c=Math.floor(r/60%6),e=r/60-Math.floor(r/60),a=o*(1-t),l=o*(1-e*t),i=o*(1-(1-e)*t);switch(c){case 0:s[0]=o,s[1]=i,s[2]=a;break;case 1:s[0]=l,s[1]=o,s[2]=a;break;case 2:s[0]=a,s[1]=o,s[2]=i;break;case 3:s[0]=a,s[1]=l,s[2]=o;break;case 4:s[0]=i,s[1]=a,s[2]=o;break;default:s[0]=o,s[1]=a,s[2]=l;break}return a$1({r:s[0]*255,g:s[1]*255,b:s[2]*255,alpha:h})},y=new RegExp(`^hsva?\\(\\s*(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${j$1})%\\s*,\\s*(?<v_c>${j$1})%(?:\\s*,\\s*(?<al_c>${j$1})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${k})(?<sp_s>%?)\\s+(?<v_s>${k})(?<vp_s>%?)(?:\\s*/\\s*(?<al_s>${k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),j=r=>{if(typeof r!="string")return null;let n=y.exec(r.trim())?.groups;if(!n)return null;let u=n.s_c!==void 0;if(u&&/^none$/i.test(n.h))return null;let h=n.hu?.toLowerCase()??"deg",t=l(n.h)*(d[h]??1),o=l(n.s_c??n.s_s),c=l(n.v_c??n.v_s),e=n.al_c??n.al_s;if(u&&e!==void 0&&/^none$/i.test(e))return null;let a=!!(n.alp_c??n.alp_s),l$1=e===void 0?1:l(e)/(a?100:1);return M(N({h:t,s:o,v:c,alpha:l$1}))},A=r=>{if(!h(r)||!i(r,["h","s","v"]))return null;let{h:n,s:u,v:h$1,alpha:t=1}=r;return !f(n)||!f(u)||!f(h$1)||!f(t)?null:M(N({h:g$1(n),s:g$1(u),v:g$1(h$1),alpha:g$1(t)}))};export{T as a,M as b,j as c,A as d};//# sourceMappingURL=chunk-LAE55ZGF.mjs.map | ||
| //# sourceMappingURL=chunk-LAE55ZGF.mjs.map |
| {"version":3,"sources":["../src/colorModels/hsv.ts"],"names":["clampHsv","hsv","normalizeHue","clamp","round","_hsvBuf","rgbToHsvRaw","g","b","alpha","rn","gn","bn","max","min","d","s","h","hDeg","_RGB","hsvToRgb","v","sn","vn","i","f","p","q","t","clampRgb","HSV_RE","NUM_OR_NONE","NUM","parseHsvString","input","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","parseHsvObject","isObject","hasKeys","isAnyNumber","sanitize"],"mappings":"mHAgBA,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CAC7C,CAAA,CAAGC,CAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,CAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CA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\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HsvColor, RgbColor } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\nconst clampHsv = (hsv: HsvColor): HsvColor => ({\n h: normalizeHue(hsv.h),\n s: clamp(hsv.s, 0, 100),\n v: clamp(hsv.v, 0, 100),\n alpha: clamp(round(hsv.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHsvRaw — callers must destructure immediately, never store the reference.\nconst _hsvBuf: HsvColor = { h: 0, s: 0, v: 0, alpha: 0 };\n\nexport const rgbToHsvRaw = ({ r, g, b, alpha }: RgbColor): HsvColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const d = max - min;\n const s = max === 0 ? 0 : d / max;\n let h = 0;\n\n if (max !== min) {\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hsvBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hsvBuf.s = clamp(s * 100, 0, 100);\n _hsvBuf.v = clamp(max * 100, 0, 100);\n _hsvBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hsvBuf;\n};\n\nexport const rgbToHsv = (rgb: RgbColor): HsvColor => {\n const { h, s, v, alpha } = rgbToHsvRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), v: round(v, 2), alpha };\n};\n\nconst _RGB = [0, 0, 0] as [number, number, number];\n\nexport const hsvToRgb = ({ h, s, v, alpha }: HsvColor): RgbColor => {\n const sn = s / 100,\n vn = v / 100;\n const i = Math.floor((h / 60) % 6);\n const f = h / 60 - Math.floor(h / 60);\n const p = vn * (1 - sn);\n const q = vn * (1 - f * sn);\n const t = vn * (1 - (1 - f) * sn);\n\n switch (i) {\n case 0:\n _RGB[0] = vn;\n _RGB[1] = t;\n _RGB[2] = p;\n break;\n case 1:\n _RGB[0] = q;\n _RGB[1] = vn;\n _RGB[2] = p;\n break;\n case 2:\n _RGB[0] = p;\n _RGB[1] = vn;\n _RGB[2] = t;\n break;\n case 3:\n _RGB[0] = p;\n _RGB[1] = q;\n _RGB[2] = vn;\n break;\n case 4:\n _RGB[0] = t;\n _RGB[1] = p;\n _RGB[2] = vn;\n break;\n default: // case 5 — not an error handler; i is always 0–5 for h in [0, 360)\n _RGB[0] = vn;\n _RGB[1] = p;\n _RGB[2] = q;\n break;\n }\n\n return clampRgb({ r: _RGB[0] * 255, g: _RGB[1] * 255, b: _RGB[2] * 255, alpha });\n};\n\n// HSV/HSVA is a non-standard, library-defined syntax (not part of any CSS spec).\n// Format mirrors HSL for consistency. Legacy comma form kept for back-compat input;\n// modern space form supports optional `%` and the CSS Color 4 `none` keyword.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSV_RE = new RegExp(\n `^hsva?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<v_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<v_s>${NUM_OR_NONE})(?<vp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHsvString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSV_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null;\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const v = parseNum((g.v_c ?? g.v_s)!);\n const rawA = g.al_c ?? g.al_s;\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hsvToRgb(clampHsv({ h, s, v, alpha }));\n};\n\nexport const parseHsvObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'v'])) return null;\n const { h, s, v, alpha = 1 } = input as { h: unknown; s: unknown; v: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(v) || !isAnyNumber(alpha)) return null;\n return hsvToRgb(clampHsv({ h: sanitize(h), s: sanitize(s), v: sanitize(v), alpha: sanitize(alpha) }));\n};\n"]} |
| 'use strict';var chunk2KB6V6KD_cjs=require('./chunk-2KB6V6KD.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var N=r=>({h:chunkYISEJCI6_cjs.c(r.h),s:chunkYISEJCI6_cjs.a(r.s,0,100),v:chunkYISEJCI6_cjs.a(r.v,0,100),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r.alpha,3),0,1)}),g={h:0,s:0,v:0,alpha:0},T=({r,g:n,b:u,alpha:h})=>{let t=r/255,o=n/255,c=u/255,e=Math.max(t,o,c),a=Math.min(t,o,c),l=e-a,i=e===0?0:l/e,f=0;if(e!==a)switch(e){case t:f=((o-c)/l+(o<c?6:0))/6;break;case o:f=((c-t)/l+2)/6;break;case c:f=((t-o)/l+4)/6;break}let k=f*360;return g.h=k>=0&&k<360?k:(k%360+360)%360,g.s=chunkYISEJCI6_cjs.a(i*100,0,100),g.v=chunkYISEJCI6_cjs.a(e*100,0,100),g.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(h,3),0,1),g};var s=[0,0,0],M=({h:r,s:n,v:u,alpha:h})=>{let t=n/100,o=u/100,c=Math.floor(r/60%6),e=r/60-Math.floor(r/60),a=o*(1-t),l=o*(1-e*t),i=o*(1-(1-e)*t);switch(c){case 0:s[0]=o,s[1]=i,s[2]=a;break;case 1:s[0]=l,s[1]=o,s[2]=a;break;case 2:s[0]=a,s[1]=o,s[2]=i;break;case 3:s[0]=a,s[1]=l,s[2]=o;break;case 4:s[0]=i,s[1]=a,s[2]=o;break;default:s[0]=o,s[1]=a,s[2]=l;break}return chunk2KB6V6KD_cjs.a({r:s[0]*255,g:s[1]*255,b:s[2]*255,alpha:h})},y=new RegExp(`^hsva?\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${chunkYISEJCI6_cjs.j})%\\s*,\\s*(?<v_c>${chunkYISEJCI6_cjs.j})%(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${chunkYISEJCI6_cjs.k})(?<sp_s>%?)\\s+(?<v_s>${chunkYISEJCI6_cjs.k})(?<vp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),j=r=>{if(typeof r!="string")return null;let n=y.exec(r.trim())?.groups;if(!n)return null;let u=n.s_c!==void 0;if(u&&/^none$/i.test(n.h))return null;let h=n.hu?.toLowerCase()??"deg",t=chunkYISEJCI6_cjs.l(n.h)*(chunkYISEJCI6_cjs.d[h]??1),o=chunkYISEJCI6_cjs.l(n.s_c??n.s_s),c=chunkYISEJCI6_cjs.l(n.v_c??n.v_s),e=n.al_c??n.al_s;if(u&&e!==void 0&&/^none$/i.test(e))return null;let a=!!(n.alp_c??n.alp_s),l=e===void 0?1:chunkYISEJCI6_cjs.l(e)/(a?100:1);return M(N({h:t,s:o,v:c,alpha:l}))},A=r=>{if(!chunkYISEJCI6_cjs.h(r)||!chunkYISEJCI6_cjs.i(r,["h","s","v"]))return null;let{h:n,s:u,v:h,alpha:t=1}=r;return !chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(u)||!chunkYISEJCI6_cjs.f(h)||!chunkYISEJCI6_cjs.f(t)?null:M(N({h:chunkYISEJCI6_cjs.g(n),s:chunkYISEJCI6_cjs.g(u),v:chunkYISEJCI6_cjs.g(h),alpha:chunkYISEJCI6_cjs.g(t)}))};exports.a=T;exports.b=M;exports.c=j;exports.d=A;//# sourceMappingURL=chunk-SVWD7LPC.cjs.map | ||
| //# sourceMappingURL=chunk-SVWD7LPC.cjs.map |
| {"version":3,"sources":["../src/colorModels/hsv.ts"],"names":["clampHsv","hsv","normalizeHue","clamp","round","_hsvBuf","rgbToHsvRaw","g","b","alpha","rn","gn","bn","max","min","d","s","h","hDeg","_RGB","hsvToRgb","v","sn","vn","i","f","p","q","t","clampRgb","HSV_RE","NUM_OR_NONE","NUM","parseHsvString","input","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","parseHsvObject","isObject","hasKeys","isAnyNumber","sanitize"],"mappings":"qHAgBA,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CAC7C,CAAA,CAAGC,mBAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,KAAA,CAAOE,mBAAAA,CAAMC,mBAAAA,CAAMH,CAAAA,CAAI,KAAA,CAAO,CAAC,CAAA,CAAG,EAAG,CAAC,CACxC,CAAA,CAAA,CAGMI,CAAAA,CAAoB,CAAE,CAAA,CAAG,CAAA,CAAG,CAAA,CA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CAAS,CAAE,CAAA,CAAAiB,CAAAA,CAAG,CAAA,CAAAD,EAAG,CAAA,CAAAK,CAAAA,CAAG,KAAA,CAAAZ,CAAM,CAAC,CAAC,CAC9C,CAAA,CAEagC,EAAkBP,CAAAA,EAAoC,CAEjE,GADI,CAACQ,mBAAAA,CAASR,CAAK,CAAA,EACf,CAACS,mBAAAA,CAAQT,CAAAA,CAAO,CAAC,GAAA,CAAK,GAAA,CAAK,GAAG,CAAC,CAAA,CAAG,OAAO,IAAA,CAC7C,GAAM,CAAE,CAAA,CAAAjB,CAAAA,CAAG,CAAA,CAAAD,CAAAA,CAAG,CAAA,CAAAK,EAAG,KAAA,CAAAZ,CAAAA,CAAQ,CAAE,CAAA,CAAIyB,CAAAA,CAC/B,OAAI,CAACU,mBAAAA,CAAY3B,CAAC,CAAA,EAAK,CAAC2B,mBAAAA,CAAY5B,CAAC,CAAA,EAAK,CAAC4B,mBAAAA,CAAYvB,CAAC,CAAA,EAAK,CAACuB,mBAAAA,CAAYnC,CAAK,CAAA,CAAU,IAAA,CAClFW,CAAAA,CAASpB,CAAAA,CAAS,CAAE,CAAA,CAAG6C,mBAAAA,CAAS5B,CAAC,CAAA,CAAG,CAAA,CAAG4B,mBAAAA,CAAS7B,CAAC,CAAA,CAAG,EAAG6B,mBAAAA,CAASxB,CAAC,CAAA,CAAG,KAAA,CAAOwB,mBAAAA,CAASpC,CAAK,CAAE,CAAC,CAAC,CACtG","file":"chunk-SVWD7LPC.cjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HsvColor, RgbColor } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\nconst clampHsv = (hsv: HsvColor): HsvColor => ({\n h: normalizeHue(hsv.h),\n s: clamp(hsv.s, 0, 100),\n v: clamp(hsv.v, 0, 100),\n alpha: clamp(round(hsv.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHsvRaw — callers must destructure immediately, never store the reference.\nconst _hsvBuf: HsvColor = { h: 0, s: 0, v: 0, alpha: 0 };\n\nexport const rgbToHsvRaw = ({ r, g, b, alpha }: RgbColor): HsvColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const d = max - min;\n const s = max === 0 ? 0 : d / max;\n let h = 0;\n\n if (max !== min) {\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hsvBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hsvBuf.s = clamp(s * 100, 0, 100);\n _hsvBuf.v = clamp(max * 100, 0, 100);\n _hsvBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hsvBuf;\n};\n\nexport const rgbToHsv = (rgb: RgbColor): HsvColor => {\n const { h, s, v, alpha } = rgbToHsvRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), v: round(v, 2), alpha };\n};\n\nconst _RGB = [0, 0, 0] as [number, number, number];\n\nexport const hsvToRgb = ({ h, s, v, alpha }: HsvColor): RgbColor => {\n const sn = s / 100,\n vn = v / 100;\n const i = Math.floor((h / 60) % 6);\n const f = h / 60 - Math.floor(h / 60);\n const p = vn * (1 - sn);\n const q = vn * (1 - f * sn);\n const t = vn * (1 - (1 - f) * sn);\n\n switch (i) {\n case 0:\n _RGB[0] = vn;\n _RGB[1] = t;\n _RGB[2] = p;\n break;\n case 1:\n _RGB[0] = q;\n _RGB[1] = vn;\n _RGB[2] = p;\n break;\n case 2:\n _RGB[0] = p;\n _RGB[1] = vn;\n _RGB[2] = t;\n break;\n case 3:\n _RGB[0] = p;\n _RGB[1] = q;\n _RGB[2] = vn;\n break;\n case 4:\n _RGB[0] = t;\n _RGB[1] = p;\n _RGB[2] = vn;\n break;\n default: // case 5 — not an error handler; i is always 0–5 for h in [0, 360)\n _RGB[0] = vn;\n _RGB[1] = p;\n _RGB[2] = q;\n break;\n }\n\n return clampRgb({ r: _RGB[0] * 255, g: _RGB[1] * 255, b: _RGB[2] * 255, alpha });\n};\n\n// HSV/HSVA is a non-standard, library-defined syntax (not part of any CSS spec).\n// Format mirrors HSL for consistency. Legacy comma form kept for back-compat input;\n// modern space form supports optional `%` and the CSS Color 4 `none` keyword.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSV_RE = new RegExp(\n `^hsva?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<v_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<v_s>${NUM_OR_NONE})(?<vp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHsvString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSV_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null;\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const v = parseNum((g.v_c ?? g.v_s)!);\n const rawA = g.al_c ?? g.al_s;\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hsvToRgb(clampHsv({ h, s, v, alpha }));\n};\n\nexport const parseHsvObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'v'])) return null;\n const { h, s, v, alpha = 1 } = input as { h: unknown; s: unknown; v: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(v) || !isAnyNumber(alpha)) return null;\n return hsvToRgb(clampHsv({ h: sanitize(h), s: sanitize(s), v: sanitize(v), alpha: sanitize(alpha) }));\n};\n"]} |
| 'use strict';var s=n=>{let r=Math.abs(n),e=r<=.04045?r/12.92:((r+.055)/1.055)**2.4;return n<0?-e:e},a=n=>{let r=Math.abs(n),e=r<=.0031308?12.92*r:1.055*r**(1/2.4)-.055;return n<0?-e:e},o=1.09929682680944,t=.018053968510807,b=n=>{let r=Math.abs(n),e=r<t*4.5?r/4.5:((r+o-1)/o)**(1/.45);return n<0?-e:e},c=n=>{let r=Math.abs(n),e=r<t?4.5*r:o*r**.45-(o-1);return n<0?-e:e},u=n=>{let r=Math.abs(n)**2.19921875;return n<0?-r:r},m=n=>{let r=Math.abs(n)**.4547069271758437;return n<0?-r:r},i=n=>{let r=Math.abs(n),e=r<=16/512?r/16:r**1.8;return n<0?-e:e},p=n=>{let r=Math.abs(n),e=r>=1/512?r**(1/1.8):16*r;return n<0?-e:e};exports.a=s;exports.b=a;exports.c=b;exports.d=c;exports.e=u;exports.f=m;exports.g=i;exports.h=p;//# sourceMappingURL=chunk-VSMEJU4Z.cjs.map | ||
| //# sourceMappingURL=chunk-VSMEJU4Z.cjs.map |
| {"version":3,"sources":["../src/transfer.ts"],"names":["srgbToLinear","c","abs","linear","srgbFromLinear","encoded","REC2020_ALPHA","REC2020_BETA","rec2020ToLinear","rec2020FromLinear","a98ToLinear","a98FromLinear","proph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AIF,CAAC,CAAA,EAAM,UAAA,CAC/B,OAAOA,CAAAA,CAAI,CAAA,CAAI,CAACE,CAAAA,CAASA,CAC3B,EAGaQ,CAAAA,CAAiB,CAAA,EAAsB,CAClD,IAAMN,CAAAA,CAAU,KAAK,GAAA,CAAI,CAAC,GAAM,iBAAA,CAChC,OAAO,EAAI,CAAA,CAAI,CAACA,EAAUA,CAC5B,CAAA,CAMaO,EAAoBX,CAAAA,EAAsB,CACrD,IAAMC,CAAAA,CAAM,IAAA,CAAK,IAAID,CAAC,CAAA,CAChBE,EAASD,CAAAA,EAAO,EAAA,CAAK,IAAMA,CAAAA,CAAM,EAAA,CAAKA,GAAO,GAAA,CACnD,OAAOD,EAAI,CAAA,CAAI,CAACE,EAASA,CAC3B,CAAA,CAGaU,EAAsB,CAAA,EAAsB,CACvD,IAAMX,CAAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,CAChBG,EAAUH,CAAAA,EAAO,CAAA,CAAI,IAAMA,CAAAA,GAAQ,CAAA,CAAI,KAAO,EAAA,CAAKA,CAAAA,CACzD,OAAO,CAAA,CAAI,CAAA,CAAI,CAACG,CAAAA,CAAUA,CAC5B","file":"chunk-VSMEJU4Z.cjs","sourcesContent":["/**\n * sRGB / Display-P3 transfer function (IEC 61966-2-1), extended to the full real line.\n * For in-gamut values [0, 1] this is the standard curve.\n * Extended to negative values using the mirror of the power curve (not the linear piece),\n * matching the CSS Color 4 spec for out-of-gamut channels.\n */\nexport const srgbToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs <= 0.04045 ? abs / 12.92 : ((abs + 0.055) / 1.055) ** 2.4;\n return c < 0 ? -linear : linear;\n};\n\n/**\n * Linear → gamma-encoded sRGB (extended piecewise, per CSS Color 4).\n * For in-gamut values [0, 1] this is the standard IEC 61966-2-1 curve.\n * Extended to negative values using the mirror of the power curve (not the linear piece),\n * matching the CSS Color 4 spec and display-p3 behaviour for out-of-gamut channels.\n */\nexport const srgbFromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs <= 0.0031308 ? 12.92 * abs : 1.055 * abs ** (1 / 2.4) - 0.055;\n return n < 0 ? -encoded : encoded;\n};\n\n/** BT.2020 transfer function constants. */\nconst REC2020_ALPHA = 1.09929682680944;\nconst REC2020_BETA = 0.018053968510807;\n\n/** BT.2020 gamma-encoded → linear. Extended to the full real line (sign-preserving). */\nexport const rec2020ToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs < REC2020_BETA * 4.5 ? abs / 4.5 : ((abs + REC2020_ALPHA - 1) / REC2020_ALPHA) ** (1 / 0.45);\n return c < 0 ? -linear : linear;\n};\n\n/** BT.2020 linear → gamma-encoded. Extended to the full real line (sign-preserving). */\nexport const rec2020FromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs < REC2020_BETA ? 4.5 * abs : REC2020_ALPHA * abs ** 0.45 - (REC2020_ALPHA - 1);\n return n < 0 ? -encoded : encoded;\n};\n\n/**\n * A98 (Adobe RGB 1998) transfer function. A simple power curve with exponent 563/256,\n * no linear segment (CSS Color 4). Extended to the full real line (sign-preserving).\n */\nexport const a98ToLinear = (c: number): number => {\n const linear = Math.abs(c) ** (563 / 256);\n return c < 0 ? -linear : linear;\n};\n\n/** A98 linear → gamma-encoded (exponent 256/563). Extended to the full real line. */\nexport const a98FromLinear = (n: number): number => {\n const encoded = Math.abs(n) ** (256 / 563);\n return n < 0 ? -encoded : encoded;\n};\n\n/**\n * ProPhoto (ROMM RGB) transfer function: gamma 1.8 with a short linear toe below\n * 16/512 in the gamma-encoded domain (CSS Color 4). Extended to the full real line.\n */\nexport const prophotoToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs <= 16 / 512 ? abs / 16 : abs ** 1.8;\n return c < 0 ? -linear : linear;\n};\n\n/** ProPhoto linear → gamma-encoded (gamma 1/1.8 with a linear toe below 1/512). */\nexport const prophotoFromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs >= 1 / 512 ? abs ** (1 / 1.8) : 16 * abs;\n return n < 0 ? -encoded : encoded;\n};\n"]} |
| var s=n=>{let r=Math.abs(n),e=r<=.04045?r/12.92:((r+.055)/1.055)**2.4;return n<0?-e:e},a=n=>{let r=Math.abs(n),e=r<=.0031308?12.92*r:1.055*r**(1/2.4)-.055;return n<0?-e:e},o=1.09929682680944,t=.018053968510807,b=n=>{let r=Math.abs(n),e=r<t*4.5?r/4.5:((r+o-1)/o)**(1/.45);return n<0?-e:e},c=n=>{let r=Math.abs(n),e=r<t?4.5*r:o*r**.45-(o-1);return n<0?-e:e},u=n=>{let r=Math.abs(n)**2.19921875;return n<0?-r:r},m=n=>{let r=Math.abs(n)**.4547069271758437;return n<0?-r:r},i=n=>{let r=Math.abs(n),e=r<=16/512?r/16:r**1.8;return n<0?-e:e},p=n=>{let r=Math.abs(n),e=r>=1/512?r**(1/1.8):16*r;return n<0?-e:e};export{s as a,a as b,b as c,c as d,u as e,m as f,i as g,p as h};//# sourceMappingURL=chunk-WGY6QKPW.mjs.map | ||
| //# sourceMappingURL=chunk-WGY6QKPW.mjs.map |
| {"version":3,"sources":["../src/transfer.ts"],"names":["srgbToLinear","c","abs","linear","srgbFromLinear","encoded","REC2020_ALPHA","REC2020_BETA","rec2020ToLinear","rec2020FromLinear","a98ToLinear","a98FromLinear","prophotoToLinear","prophotoFromLinear"],"mappings":"AAMO,IAAMA,CAAAA,CAAgBC,GAAsB,CACjD,IAAMC,EAAM,IAAA,CAAK,GAAA,CAAID,CAAC,CAAA,CAChBE,CAAAA,CAASD,GAAO,MAAA,CAAUA,CAAAA,CAAM,QAAUA,CAAAA,CAAM,IAAA,EAAS,QAAU,GAAA,CACzE,OAAOD,EAAI,CAAA,CAAI,CAACE,EAASA,CAC3B,CAAA,CAQaC,EAAkB,CAAA,EAAsB,CACnD,IAAMF,CAAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,CAChBG,EAAUH,CAAAA,EAAO,QAAA,CAAY,MAAQA,CAAAA,CAAM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AAA,CACnD,OAAOD,EAAI,CAAA,CAAI,CAACE,EAASA,CAC3B,CAAA,CAGaU,EAAsB,CAAA,EAAsB,CACvD,IAAMX,CAAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,CAChBG,EAAUH,CAAAA,EAAO,CAAA,CAAI,IAAMA,CAAAA,GAAQ,CAAA,CAAI,KAAO,EAAA,CAAKA,CAAAA,CACzD,OAAO,CAAA,CAAI,CAAA,CAAI,CAACG,CAAAA,CAAUA,CAC5B","file":"chunk-WGY6QKPW.mjs","sourcesContent":["/**\n * sRGB / Display-P3 transfer function (IEC 61966-2-1), extended to the full real line.\n * For in-gamut values [0, 1] this is the standard curve.\n * Extended to negative values using the mirror of the power curve (not the linear piece),\n * matching the CSS Color 4 spec for out-of-gamut channels.\n */\nexport const srgbToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs <= 0.04045 ? abs / 12.92 : ((abs + 0.055) / 1.055) ** 2.4;\n return c < 0 ? -linear : linear;\n};\n\n/**\n * Linear → gamma-encoded sRGB (extended piecewise, per CSS Color 4).\n * For in-gamut values [0, 1] this is the standard IEC 61966-2-1 curve.\n * Extended to negative values using the mirror of the power curve (not the linear piece),\n * matching the CSS Color 4 spec and display-p3 behaviour for out-of-gamut channels.\n */\nexport const srgbFromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs <= 0.0031308 ? 12.92 * abs : 1.055 * abs ** (1 / 2.4) - 0.055;\n return n < 0 ? -encoded : encoded;\n};\n\n/** BT.2020 transfer function constants. */\nconst REC2020_ALPHA = 1.09929682680944;\nconst REC2020_BETA = 0.018053968510807;\n\n/** BT.2020 gamma-encoded → linear. Extended to the full real line (sign-preserving). */\nexport const rec2020ToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs < REC2020_BETA * 4.5 ? abs / 4.5 : ((abs + REC2020_ALPHA - 1) / REC2020_ALPHA) ** (1 / 0.45);\n return c < 0 ? -linear : linear;\n};\n\n/** BT.2020 linear → gamma-encoded. Extended to the full real line (sign-preserving). */\nexport const rec2020FromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs < REC2020_BETA ? 4.5 * abs : REC2020_ALPHA * abs ** 0.45 - (REC2020_ALPHA - 1);\n return n < 0 ? -encoded : encoded;\n};\n\n/**\n * A98 (Adobe RGB 1998) transfer function. A simple power curve with exponent 563/256,\n * no linear segment (CSS Color 4). Extended to the full real line (sign-preserving).\n */\nexport const a98ToLinear = (c: number): number => {\n const linear = Math.abs(c) ** (563 / 256);\n return c < 0 ? -linear : linear;\n};\n\n/** A98 linear → gamma-encoded (exponent 256/563). Extended to the full real line. */\nexport const a98FromLinear = (n: number): number => {\n const encoded = Math.abs(n) ** (256 / 563);\n return n < 0 ? -encoded : encoded;\n};\n\n/**\n * ProPhoto (ROMM RGB) transfer function: gamma 1.8 with a short linear toe below\n * 16/512 in the gamma-encoded domain (CSS Color 4). Extended to the full real line.\n */\nexport const prophotoToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs <= 16 / 512 ? abs / 16 : abs ** 1.8;\n return c < 0 ? -linear : linear;\n};\n\n/** ProPhoto linear → gamma-encoded (gamma 1/1.8 with a linear toe below 1/512). */\nexport const prophotoFromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs >= 1 / 512 ? abs ** (1 / 1.8) : 16 * abs;\n return n < 0 ? -encoded : encoded;\n};\n"]} |
| import {a,b as b$1}from'./chunk-WGY6QKPW.mjs';import {a as a$2}from'./chunk-GLKEY6D3.mjs';import {a as a$1,b,h,i,e,f,g,l,k}from'./chunk-IOXRZECH.mjs';var L=96.4295675298354,O=100,w=82.51046025104603,lo=.4123907992659595,ao=.35758433938387796,co=.1804807884018343,eo=.21263900587151036,bo=.7151686787677559,po=.07219231536073371,uo=.01933081871559185,_o=.11919477979462599,yo=.9505321522496606,A=.032409699419045215,B=-0.015373831775700935,G=-0.004986107602930032,I=-0.009692436362808799,P=.018759675015077207,U=.0004155505740717561,F=.000556300796969936,H=-0.002039769588889766,K=.010569715142428786,Wo=1.0479297925449969,Eo=.022946870601609652,qo=-0.05019226628920524,jo=.02962780877005599,Ao=.9904344267538799,Bo=-0.017073799063418826,Go=-0.009243040646204504,Io=.015055191490298152,Po=.7518742814281371,xo=.955473421488075,go=-0.02309845494876471,mo=.06325924320057072,Do=-0.0283697093338637,zo=1.0099953980813041,io=.021041441191917323,Xo=.012314014864481998,ho=-0.020507649298898964,Co=1.330365926242124,sn=({r:n,g:o,b:t,alpha:s})=>{let r=a(n/255),l=a(o/255),a$2=a(t/255);return {x:100*(lo*r+ao*l+co*a$2),y:100*(eo*r+bo*l+po*a$2),z:100*(uo*r+_o*l+yo*a$2),alpha:a$1(b(s,3),0,1),colorSpace:"xyz-d65"}},Uo=(n,o,t)=>[A*n+B*o+G*t,I*n+P*o+U*t,F*n+H*o+K*t],fo=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=Uo(n,o,t);return {r:b$1(r)*255,g:b$1(l)*255,b:b$1(a)*255,alpha:s}},To=({r:n,g:o,b:t,alpha:s})=>{let r=a(n/255),l=a(o/255),a$2=a(t/255),u=100*(lo*r+ao*l+co*a$2),e=100*(eo*r+bo*l+po*a$2),x=100*(uo*r+_o*l+yo*a$2);return {x:Wo*u+Eo*e+qo*x,y:jo*u+Ao*e+Bo*x,z:Go*u+Io*e+Po*x,alpha:a$1(b(s,3),0,1)}},ln=(n,o,t,s)=>{let r=xo*o+go*t+mo*s,l=Do*o+zo*t+io*s,a=Xo*o+ho*t+Co*s;n[0]=A*r+B*l+G*a,n[1]=I*r+P*l+U*a,n[2]=F*r+H*l+K*a;},M=(n,o,t)=>{let s=xo*n+go*o+mo*t,r=Do*n+zo*o+io*t,l=Xo*n+ho*o+Co*t;return [A*s+B*r+G*l,I*s+P*r+U*l,F*s+H*r+K*l]},Ro=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=M(n,o,t);return a$2({r:b$1(r)*255,g:b$1(l)*255,b:b$1(a)*255,alpha:s})},So=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=M(n,o,t);return {r:b$1(r)*255,g:b$1(l)*255,b:b$1(a)*255,alpha:s}},an=n=>{if(!h(n)||n.colorSpace==="xyz-d65"||!i(n,["x","y","z"]))return null;let{x:o,y:t,z:s,alpha:r=1}=n;return !e(o)||!e(t)||!e(s)||!e(r)?null:So({x:o,y:t,z:s,alpha:a$1(r,0,1)})},cn=n=>{if(!h(n)||n.colorSpace!=="xyz-d65"||!i(n,["x","y","z"]))return null;let{x:o,y:t,z:s,alpha:r=1}=n;return !f(o)||!f(t)||!f(s)||!f(r)?null:fo({x:g(o),y:g(t),z:g(s),alpha:a$1(g(r),0,1)})},Fo=new RegExp(`^color\\(\\s*xyz-d65\\s+(?<x>${k})(?<xp>%?)\\s+(?<y>${k})(?<yp>%?)\\s+(?<z>${k})(?<zp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),Ho=new RegExp(`^color\\(\\s*xyz-d50\\s+(?<x>${k})(?<xp>%?)\\s+(?<y>${k})(?<yp>%?)\\s+(?<z>${k})(?<zp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),en=n=>{if(typeof n!="string")return null;let o=Fo.exec(n.trim())?.groups;if(!o)return null;let t=l(o.x),s=l(o.y),r=l(o.z),l$1=o.al===void 0?1:l(o.al)/(o.alp?100:1);return fo({x:t,y:s,z:r,alpha:a$1(l$1,0,1)})},bn=n=>{if(typeof n!="string")return null;let o=Ho.exec(n.trim())?.groups;if(!o)return null;let t=l(o.x),s=l(o.y),r=l(o.z),l$1=o.al===void 0?1:l(o.al)/(o.alp?100:1);return So({x:t,y:s,z:r,alpha:a$1(l$1,0,1)})};var Ko=.3127/.329*100,vo=100,Vo=(1-.3127-.329)/.329*100,S=216/24389,z=24389/27,C=n=>n>S?Math.cbrt(n):(z*n+16)/116,Jo=({x:n,y:o,z:t,alpha:s})=>{let r=C(o/O);return {l:116*r-16,a:500*(C(n/L)-r)||0,b:200*(r-C(t/w))||0,alpha:b(s,3),colorSpace:"lab"}},Lo=(n,o,t)=>{let s=(n+16)/116,r=o/500+s,l=s-t/200;return [(r**3>S?r**3:(116*r-16)/z)*L,(n>8?s**3:n/z)*O,(l**3>S?l**3:(116*l-16)/z)*w]},xn=(n,o,t,s)=>{let r=(o+16)/116,l=t/500+r,a=r-s/200;n[0]=(l**3>S?l**3:(116*l-16)/z)*L,n[1]=(o>8?r**3:o/z)*O,n[2]=(a**3>S?a**3:(116*a-16)/z)*w;},Qo=({l:n,a:o,b:t,alpha:s})=>{let[r,l,a]=Lo(n,o,t);return {x:r,y:l,z:a,alpha:s}},gn=n=>Jo(To(n)),mn=({r:n,g:o,b:t,alpha:s})=>{let r=a(n/255),l=a(o/255),a$1=a(t/255),u=100*(.4123907992659595*r+.35758433938387796*l+.1804807884018343*a$1),e=100*(.21263900587151036*r+.7151686787677559*l+.07219231536073371*a$1),x=100*(.01933081871559185*r+.11919477979462599*l+.9505321522496606*a$1),f=C(e/vo);return {l:116*f-16,a:500*(C(u/Ko)-f)||0,b:200*(f-C(x/Vo))||0,alpha:b(s,3),colorSpace:"lab"}},Dn=(n,o)=>{let{l:t,a:s,b:r}=n,{l,a,b:u}=o,e=Math.PI/180,x=180/Math.PI,f=Math.sqrt(s**2+r**2),wo=Math.sqrt(a**2+u**2),v=((f+wo)/2)**7,V=.5*(1-Math.sqrt(v/(v+25**7))),Y=s*(1+V),Z=a*(1+V),k=Math.sqrt(Y**2+r**2),$=Math.sqrt(Z**2+u**2),N=(k+$)/2,W=Y===0&&r===0?0:Math.atan2(r,Y)*x,E=Z===0&&u===0?0:Math.atan2(u,Z)*x,i=W<0?W+360:W,X=E<0?E+360:E,q=X-i,j=Math.abs(X-i);j>180&&X<=i?q+=360:j>180&&X>i&&(q-=360);let J=(t+l)/2,D=i+X;j<=180?D/=2:D=(i+X<360?D+360:D-360)/2;let Mo=1-.17*Math.cos(e*(D-30))+.24*Math.cos(2*e*D)+.32*Math.cos(e*(3*D+6))-.2*Math.cos(e*(4*D-63)),Yo=l-t,Q=$-k,oo=2*Math.sin(e*q/2)*Math.sqrt(k*$),Zo=1+.015*(J-50)**2/Math.sqrt(20+(J-50)**2),no=1+.045*N,ro=1+.015*N*Mo,to=N**7,ko=2*Math.sqrt(to/(to+25**7)),$o=30*Math.exp(-(((D-275)/25)**2)),No=-ko*Math.sin(2*e*$o);return Math.sqrt((Yo/Zo)**2+(Q/no)**2+(oo/ro)**2+No*(Q/no)*(oo/ro))},zn=n=>Ro(Qo(n)),Oo=({l:n,a:o,b:t,alpha:s})=>{let[r,l,a]=Lo(n,o,t),[u,e,x]=M(r,l,a);return {r:b$1(u)*255,g:b$1(e)*255,b:b$1(x)*255,alpha:s}},on=new RegExp(`^lab\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<a>${k})(?<ap>%?)\\s+(?<b>${k})(?<bp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),Xn=n=>{if(typeof n!="string")return null;let o=on.exec(n.trim())?.groups;if(!o)return null;let t=l(o.l),s=o.ap?l(o.a)*1.25:l(o.a),r=o.bp?l(o.b)*1.25:l(o.b),l$1=o.al===void 0?1:l(o.al)/(o.alp?100:1);return Oo({l:a$1(t,0,100),a:s,b:r,alpha:a$1(l$1,0,1)})},hn=n=>{if(!h(n)||n.colorSpace!=="lab"||!i(n,["l","a","b"]))return null;let{l:o,a:t,b:s,alpha:r=1}=n;return !f(o)||!f(t)||!f(s)||!f(r)?null:Oo({l:a$1(g(o),0,100),a:g(t),b:g(s),alpha:a$1(g(r),0,1)})};export{sn as a,Uo as b,To as c,ln as d,M as e,an as f,cn as g,en as h,bn as i,Lo as j,xn as k,Qo as l,gn as m,mn as n,Dn as o,zn as p,Oo as q,Xn as r,hn as s};//# sourceMappingURL=chunk-YQKSXMBN.mjs.map | ||
| //# sourceMappingURL=chunk-YQKSXMBN.mjs.map |
| {"version":3,"sources":["../src/colorModels/xyz.ts","../src/colorModels/lab.ts"],"names":["D50_WX","D50_WY","D50_WZ","S_XR","S_XG","S_XB","S_YR","S_YG","S_YB","S_ZR","S_ZG","S_ZB","X_RX","X_RY","X_RZ","X_GX","X_GY","X_GZ","X_BX","X_BY","X_BZ","D65_TO_D50_XX","D65_TO_D50_XY","D65_TO_D50_XZ","D65_TO_D50_YX","D65_TO_D50_YY","D65_TO_D50_YZ","D65_TO_D50_ZX","D65_TO_D50_ZY","D65_TO_D50_ZZ","D50_TO_D65_XX","D50_TO_D65_XY","D50_TO_D65_XZ","D50_TO_D65_YX","D50_TO_D65_YY","D50_TO_D65_YZ","D50_TO_D65_ZX","D50_TO_D65_ZY","D50_TO_D65_ZZ","rgbToXyzD65","r","g","b","alpha","lr","srgbToLinear","lg","lb","clamp","round","xyzD65ToLinearSrgb","x","y","z","xyzD65ToRgbUnclamped","srgbFromLinear","rgbToXyz","xd65","yd65","zd65","xyzD50ToLinearSrgbInto","out","xyzD50ToLinearSrgb","xyzToRgb","clampRgb","xyzToRgbUnclamped","parseXyzObject","input","isObject","hasKeys","isNumber","parseXyzD65Object","isAnyNumber","sanitize","XYZ_D65_RE","NUM_OR_NONE","XYZ_D50_RE","parseXyzD65String","parseNum","parseXyzD50String","D65_WX","D65_WY","D65_WZ","EPSILON","KAPPA","f","t","xyzToLab","fy","labToXyzValues","l","a","fx","fz","labToXyzValuesInto","labToXyz","rgbToLab","rgb","rgbToLabD65","deltaE2000","lab1","lab2","L1","a1","b1","L2","a2","b2","rad","deg","C1","C2","Cab","G","a1p","a2p","C1p","C2p","Cp","h1p","h2p","h1","h2","dhp","absDh","Lm","Hm","T","dLp","dCp","dHp","SL","SC","SH","RC7","RC","dTheta","RT","labToRgb","lab","labToRgbUnclamped","LAB_RE","parseLabString","parseLabObject"],"mappings":"sJAMO,IAAMA,CAAAA,CAAS,iBACTC,CAAAA,CAAS,GAAA,CACTC,EAAS,iBAAA,CAIhBC,EAAAA,CAAO,iBAAA,CACXC,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AS/B,CAAC,EACb,KAAA,CAAOM,GAAAA,CAAMyB,CAAAA,CAAS9B,CAAK,CAAA,CAAG,CAAA,CAAG,CAAC,CAEpC,CAAC,CACH","file":"chunk-YQKSXMBN.mjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { RgbColor, XyzColor, XyzD65Color } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\n// D50 white point (CSS Color 4: xy = 0.3457/0.3585)\nexport const D50_WX = 96.42956752983539;\nexport const D50_WY = 100;\nexport const D50_WZ = 82.51046025104603;\n\n// ── CSS Color 4 exact rational matrices ─────────────────────────────────────\n// sRGB linear → XYZ D65 (xyz in 0–1; callers scale to 0–100 by multiplying).\nconst S_XR = 0.41239079926595951,\n S_XG = 0.35758433938387796,\n S_XB = 0.18048078840183429;\nconst S_YR = 0.21263900587151036,\n S_YG = 0.71516867876775592,\n S_YB = 0.072192315360733714;\nconst S_ZR = 0.019330818715591849,\n S_ZG = 0.11919477979462599,\n S_ZB = 0.95053215224966059;\n\n// XYZ D65 (0–100 scale) → sRGB linear (0–1). Equals the CSS inverse matrix ÷100.\nconst X_RX = 0.032409699419045213,\n X_RY = -0.015373831775700935,\n X_RZ = -0.0049861076029300327;\nconst X_GX = -0.0096924363628087984,\n X_GY = 0.018759675015077206,\n X_GZ = 0.00041555057407175612;\nconst X_BX = 0.00055630079696993608,\n X_BY = -0.0020397695888897657,\n X_BZ = 0.010569715142428786;\n\n// Bradford D65 → D50 (CSS Color 4)\nconst D65_TO_D50_XX = 1.0479297925449969,\n D65_TO_D50_XY = 0.022946870601609652,\n D65_TO_D50_XZ = -0.05019226628920524;\nconst D65_TO_D50_YX = 0.02962780877005599,\n D65_TO_D50_YY = 0.9904344267538799,\n D65_TO_D50_YZ = -0.017073799063418826;\nconst D65_TO_D50_ZX = -0.009243040646204504,\n D65_TO_D50_ZY = 0.015055191490298152,\n D65_TO_D50_ZZ = 0.7518742814281371;\n\n// Bradford D50 → D65 (CSS Color 4, inverse of above)\nconst D50_TO_D65_XX = 0.955473421488075,\n D50_TO_D65_XY = -0.02309845494876471,\n D50_TO_D65_XZ = 0.06325924320057072;\nconst D50_TO_D65_YX = -0.0283697093338637,\n D50_TO_D65_YY = 1.0099953980813041,\n D50_TO_D65_YZ = 0.021041441191917323;\nconst D50_TO_D65_ZX = 0.012314014864481998,\n D50_TO_D65_ZY = -0.020507649298898964,\n D50_TO_D65_ZZ = 1.330365926242124;\n\n// ── RGB ↔ XYZ D65 ───────────────────────────────────────────────────────────\n\n/** sRGB (0–255) → XYZ D65 (0–100, screen-native, no Bradford adaptation). */\nexport const rgbToXyzD65 = ({ r, g, b, alpha }: RgbColor): XyzD65Color => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n return {\n x: 100 * (S_XR * lr + S_XG * lg + S_XB * lb),\n y: 100 * (S_YR * lr + S_YG * lg + S_YB * lb),\n z: 100 * (S_ZR * lr + S_ZG * lg + S_ZB * lb),\n alpha: clamp(round(alpha, 3), 0, 1),\n colorSpace: 'xyz-d65' as const,\n };\n};\n\n/** XYZ D65 (0–100) → linear sRGB (0–1, unclamped). */\nexport const xyzD65ToLinearSrgb = (x: number, y: number, z: number): [number, number, number] => [\n X_RX * x + X_RY * y + X_RZ * z,\n X_GX * x + X_GY * y + X_GZ * z,\n X_BX * x + X_BY * y + X_BZ * z,\n];\n\nconst xyzD65ToRgbUnclamped = ({ x, y, z, alpha }: XyzD65Color): RgbColor => {\n const [lr, lg, lb] = xyzD65ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// ── RGB ↔ XYZ D50 ───────────────────────────────────────────────────────────\n\nexport const rgbToXyz = ({ r, g, b, alpha }: RgbColor): XyzColor => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n const xd65 = 100 * (S_XR * lr + S_XG * lg + S_XB * lb);\n const yd65 = 100 * (S_YR * lr + S_YG * lg + S_YB * lb);\n const zd65 = 100 * (S_ZR * lr + S_ZG * lg + S_ZB * lb);\n return {\n x: D65_TO_D50_XX * xd65 + D65_TO_D50_XY * yd65 + D65_TO_D50_XZ * zd65,\n y: D65_TO_D50_YX * xd65 + D65_TO_D50_YY * yd65 + D65_TO_D50_YZ * zd65,\n z: D65_TO_D50_ZX * xd65 + D65_TO_D50_ZY * yd65 + D65_TO_D50_ZZ * zd65,\n alpha: clamp(round(alpha, 3), 0, 1),\n };\n};\n\n/** Zero-allocation sibling of xyzD50ToLinearSrgb — writes [lr, lg, lb] into `out`. */\nexport const xyzD50ToLinearSrgbInto = (out: Float64Array | number[], x: number, y: number, z: number): void => {\n const xd65 = D50_TO_D65_XX * x + D50_TO_D65_XY * y + D50_TO_D65_XZ * z;\n const yd65 = D50_TO_D65_YX * x + D50_TO_D65_YY * y + D50_TO_D65_YZ * z;\n const zd65 = D50_TO_D65_ZX * x + D50_TO_D65_ZY * y + D50_TO_D65_ZZ * z;\n out[0] = X_RX * xd65 + X_RY * yd65 + X_RZ * zd65;\n out[1] = X_GX * xd65 + X_GY * yd65 + X_GZ * zd65;\n out[2] = X_BX * xd65 + X_BY * yd65 + X_BZ * zd65;\n};\n\n/** XYZ D50 → linear sRGB (no gamma, no clamping). x/y/z are in 0–100 scale. */\nexport const xyzD50ToLinearSrgb = (x: number, y: number, z: number): [number, number, number] => {\n const xd65 = D50_TO_D65_XX * x + D50_TO_D65_XY * y + D50_TO_D65_XZ * z;\n const yd65 = D50_TO_D65_YX * x + D50_TO_D65_YY * y + D50_TO_D65_YZ * z;\n const zd65 = D50_TO_D65_ZX * x + D50_TO_D65_ZY * y + D50_TO_D65_ZZ * z;\n return [\n X_RX * xd65 + X_RY * yd65 + X_RZ * zd65,\n X_GX * xd65 + X_GY * yd65 + X_GZ * zd65,\n X_BX * xd65 + X_BY * yd65 + X_BZ * zd65,\n ];\n};\n\nexport const xyzToRgb = ({ x, y, z, alpha }: XyzColor): RgbColor => {\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return clampRgb({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n};\n\n/** Unclamped XYZ D50 → gamma-encoded sRGB. Channels may exceed [0, 255] for out-of-sRGB-gamut colors. */\nconst xyzToRgbUnclamped = ({ x, y, z, alpha }: XyzColor): RgbColor => {\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// ── Parsers ─────────────────────────────────────────────────────────────────\n\nexport const parseXyzObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Reject D65-discriminated objects — parseXyzD65Object owns those.\n if ((input as { colorSpace?: unknown }).colorSpace === 'xyz-d65') return null;\n if (!hasKeys(input, ['x', 'y', 'z'])) return null;\n const { x, y, z, alpha = 1 } = input as { x: unknown; y: unknown; z: unknown; alpha?: unknown };\n if (!isNumber(x) || !isNumber(y) || !isNumber(z) || !isNumber(alpha)) return null;\n return xyzToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n });\n};\n\nexport const parseXyzD65Object = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if ((input as { colorSpace?: unknown }).colorSpace !== 'xyz-d65') return null;\n if (!hasKeys(input, ['x', 'y', 'z'])) return null;\n const { x, y, z, alpha = 1 } = input as { x: unknown; y: unknown; z: unknown; alpha?: unknown };\n if (!isAnyNumber(x) || !isAnyNumber(y) || !isAnyNumber(z) || !isAnyNumber(alpha)) return null;\n return xyzD65ToRgbUnclamped({\n x: sanitize(x),\n y: sanitize(y),\n z: sanitize(z),\n alpha: clamp(sanitize(alpha), 0, 1),\n colorSpace: 'xyz-d65',\n });\n};\n\n// CSS Color 4: color(xyz-d65 x y z / alpha). Channels accept number|percentage|none.\n// The library uses a 0–100 XYZ scale (to match the existing XyzColor convention); percent is\n// treated as the same scale for symmetry with the emitted string (100% = 100).\nconst XYZ_D65_RE = new RegExp(\n `^color\\\\(\\\\s*xyz-d65\\\\s+(?<x>${NUM_OR_NONE})(?<xp>%?)\\\\s+(?<y>${NUM_OR_NONE})(?<yp>%?)` +\n `\\\\s+(?<z>${NUM_OR_NONE})(?<zp>%?)\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nconst XYZ_D50_RE = new RegExp(\n `^color\\\\(\\\\s*xyz-d50\\\\s+(?<x>${NUM_OR_NONE})(?<xp>%?)\\\\s+(?<y>${NUM_OR_NONE})(?<yp>%?)` +\n `\\\\s+(?<z>${NUM_OR_NONE})(?<zp>%?)\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseXyzD65String = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = XYZ_D65_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const x = parseNum(g.x!);\n const y = parseNum(g.y!);\n const z = parseNum(g.z!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return xyzD65ToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n colorSpace: 'xyz-d65',\n });\n};\n\nexport const parseXyzD50String = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = XYZ_D50_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const x = parseNum(g.x!);\n const y = parseNum(g.y!);\n const z = parseNum(g.z!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return xyzToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { LabColor, RgbColor, XyzColor } from '../types.js';\nimport { D50_WX as WX, D50_WY as WY, D50_WZ as WZ, rgbToXyz, xyzD50ToLinearSrgb, xyzToRgb } from './xyz.js';\n\n// D65 white point derived from CIE chromaticity (x=0.3127, y=0.329)\nconst D65_WX = (0.3127 / 0.329) * 100;\nconst D65_WY = 100;\nconst D65_WZ = ((1 - 0.3127 - 0.329) / 0.329) * 100;\n\nconst EPSILON = 216 / 24389;\nconst KAPPA = 24389 / 27;\n\nconst f = (t: number) => (t > EPSILON ? Math.cbrt(t) : (KAPPA * t + 16) / 116);\n\nexport const xyzToLab = ({ x, y, z, alpha }: XyzColor): LabColor => {\n const fy = f(y / WY);\n return {\n l: 116 * fy - 16,\n a: 500 * (f(x / WX) - fy) || 0, // || 0 suppresses −0; NaN is impossible since WX/WZ are non-zero constants\n b: 200 * (fy - f(z / WZ)) || 0,\n alpha: round(alpha, 3),\n colorSpace: 'lab' as const,\n };\n};\n\n/** Primitives-only Lab → XYZ D50. x/y/z in 0–100 scale. Shared with channels.ts hot paths. */\nexport const labToXyzValues = (l: number, a: number, b: number): [number, number, number] => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n return [\n (fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA) * WX,\n (l > 8 ? fy ** 3 : l / KAPPA) * WY,\n (fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA) * WZ,\n ];\n};\n\n/** Zero-allocation sibling of labToXyzValues — writes [x, y, z] into `out`. */\nexport const labToXyzValuesInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n out[0] = (fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA) * WX;\n out[1] = (l > 8 ? fy ** 3 : l / KAPPA) * WY;\n out[2] = (fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA) * WZ;\n};\n\nexport const labToXyz = ({ l, a, b, alpha }: LabColor): XyzColor => {\n const [x, y, z] = labToXyzValues(l, a, b);\n return { x, y, z, alpha };\n};\n\nexport const rgbToLab = (rgb: RgbColor): LabColor => xyzToLab(rgbToXyz(rgb));\n\n/** RGB → CIE Lab using D65 white point (screen-native; used for perceptual difference). */\nexport const rgbToLabD65 = ({ r, g, b, alpha }: RgbColor): LabColor => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n const x = 100 * (0.41239079926595951 * lr + 0.35758433938387796 * lg + 0.18048078840183429 * lb);\n const y = 100 * (0.21263900587151036 * lr + 0.71516867876775592 * lg + 0.072192315360733714 * lb);\n const z = 100 * (0.019330818715591849 * lr + 0.11919477979462599 * lg + 0.95053215224966059 * lb);\n const fy = f(y / D65_WY);\n return {\n l: 116 * fy - 16,\n a: 500 * (f(x / D65_WX) - fy) || 0,\n b: 200 * (fy - f(z / D65_WZ)) || 0,\n alpha: round(alpha, 3),\n colorSpace: 'lab' as const,\n };\n};\n\nexport const deltaE2000 = (lab1: LabColor, lab2: LabColor): number => {\n const { l: L1, a: a1, b: b1 } = lab1;\n const { l: L2, a: a2, b: b2 } = lab2;\n const rad = Math.PI / 180;\n const deg = 180 / Math.PI;\n\n const C1 = Math.sqrt(a1 ** 2 + b1 ** 2);\n const C2 = Math.sqrt(a2 ** 2 + b2 ** 2);\n const Cab = ((C1 + C2) / 2) ** 7;\n const G = 0.5 * (1 - Math.sqrt(Cab / (Cab + 25 ** 7)));\n const a1p = a1 * (1 + G);\n const a2p = a2 * (1 + G);\n const C1p = Math.sqrt(a1p ** 2 + b1 ** 2);\n const C2p = Math.sqrt(a2p ** 2 + b2 ** 2);\n const Cp = (C1p + C2p) / 2;\n\n const h1p = a1p === 0 && b1 === 0 ? 0 : Math.atan2(b1, a1p) * deg;\n const h2p = a2p === 0 && b2 === 0 ? 0 : Math.atan2(b2, a2p) * deg;\n const h1 = h1p < 0 ? h1p + 360 : h1p;\n const h2 = h2p < 0 ? h2p + 360 : h2p;\n\n let dhp = h2 - h1;\n const absDh = Math.abs(h2 - h1);\n if (absDh > 180 && h2 <= h1) dhp += 360;\n else if (absDh > 180 && h2 > h1) dhp -= 360;\n\n const Lm = (L1 + L2) / 2;\n let Hm = h1 + h2;\n if (absDh <= 180) Hm /= 2;\n else Hm = (h1 + h2 < 360 ? Hm + 360 : Hm - 360) / 2;\n\n const T =\n 1 -\n 0.17 * Math.cos(rad * (Hm - 30)) +\n 0.24 * Math.cos(2 * rad * Hm) +\n 0.32 * Math.cos(rad * (3 * Hm + 6)) -\n 0.2 * Math.cos(rad * (4 * Hm - 63));\n\n const dLp = L2 - L1;\n const dCp = C2p - C1p;\n const dHp = 2 * Math.sin((rad * dhp) / 2) * Math.sqrt(C1p * C2p);\n\n const SL = 1 + (0.015 * (Lm - 50) ** 2) / Math.sqrt(20 + (Lm - 50) ** 2);\n const SC = 1 + 0.045 * Cp;\n const SH = 1 + 0.015 * Cp * T;\n\n const RC7 = Cp ** 7;\n const RC = 2 * Math.sqrt(RC7 / (RC7 + 25 ** 7));\n const dTheta = 30 * Math.exp(-(((Hm - 275) / 25) ** 2));\n const RT = -RC * Math.sin(2 * rad * dTheta);\n\n return Math.sqrt((dLp / SL) ** 2 + (dCp / SC) ** 2 + (dHp / SH) ** 2 + RT * (dCp / SC) * (dHp / SH));\n};\n\nexport const labToRgb = (lab: LabColor): RgbColor => xyzToRgb(labToXyz(lab));\n\n/**\n * Unclamped Lab (D50) → gamma-encoded sRGB (0–255). Channels may exceed [0, 255] or go\n * negative for colors outside the sRGB gamut. Preserves out-of-gamut information so callers\n * (mapSrgb, inGamut*) can detect and map the color; sRGB output methods clamp at the edge.\n */\nexport const labToRgbUnclamped = ({ l, a, b, alpha }: LabColor): RgbColor => {\n const [x, y, z] = labToXyzValues(l, a, b);\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// CSS Color 4: lab(L a b / alpha). L: number|percentage|none (100% = 100).\n// a/b: number|percentage|none (100% = 125).\nconst LAB_RE = new RegExp(\n `^lab\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<a>${NUM_OR_NONE})(?<ap>%?)\\\\s+(?<b>${NUM_OR_NONE})(?<bp>%?)` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseLabString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = LAB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const l = parseNum(g.l!); // 100% = 100, so value is unchanged whether `%` present\n const a = g.ap ? parseNum(g.a!) * 1.25 : parseNum(g.a!);\n const b = g.bp ? parseNum(g.b!) * 1.25 : parseNum(g.b!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return labToRgbUnclamped({\n l: clamp(l, 0, 100),\n a,\n b,\n alpha: clamp(alpha, 0, 1),\n colorSpace: 'lab',\n });\n};\n\nexport const parseLabObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if ((input as { colorSpace?: unknown }).colorSpace !== 'lab') return null;\n if (!hasKeys(input, ['l', 'a', 'b'])) return null;\n const { l, a, b, alpha = 1 } = input as { l: unknown; a: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(a) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n return labToRgbUnclamped({\n l: clamp(sanitize(l), 0, 100),\n a: sanitize(a),\n b: sanitize(b),\n alpha: clamp(sanitize(alpha), 0, 1),\n colorSpace: 'lab',\n });\n};\n"]} |
| 'use strict';var chunkVSMEJU4Z_cjs=require('./chunk-VSMEJU4Z.cjs'),chunk2KB6V6KD_cjs=require('./chunk-2KB6V6KD.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var U=.4122214708,z=.5363325363,q=.0514459929,D=.2119034982,H=.6806995451,J=.1073969566,P=.0883024619,Q=.2817188376,V=.6299787005,W=.2104542553,X=.793617785,Y=-0.0040720468,Z=1.9779984951,nn=-2.428592205,on=.4505937099,rn=.0259040371,tn=.7827717662,sn=-0.808675766,I=.3963377774,S=.2158037573,O=-0.1055613458,B=-0.0638541728,h=-0.0894841775,x=-1.291485548,A=4.0767416613,C=-3.3077115904,w=.2309699287,T=-1.2684380041,y=2.6097574007,G=-0.3413193963,d=-0.0041960865,N=-0.7034186145,$=1.7076147009;var cn=(o,n,r)=>{let t=Math.cbrt(U*o+z*n+q*r),s=Math.cbrt(D*o+H*n+J*r),c=Math.cbrt(P*o+Q*n+V*r);return [W*t+X*s+Y*c,Z*t+nn*s+on*c,rn*t+tn*s+sn*c]},Mn=({r:o,g:n,b:r,alpha:t})=>{let[s,c,e]=cn(chunkVSMEJU4Z_cjs.a(o/255),chunkVSMEJU4Z_cjs.a(n/255),chunkVSMEJU4Z_cjs.a(r/255));return {l:s,a:c,b:e,alpha:t}},j=({l:o,a:n,b:r,alpha:t})=>{let[s,c,e]=en(o,n,r);return {r:chunkVSMEJU4Z_cjs.b(s)*255,g:chunkVSMEJU4Z_cjs.b(c)*255,b:chunkVSMEJU4Z_cjs.b(e)*255,alpha:t}},un=({l:o,a:n,b:r,alpha:t})=>{if(n===0&&r===0){let K=o**3,k=chunkVSMEJU4Z_cjs.b(chunkYISEJCI6_cjs.a(K,0,1))*255;return chunk2KB6V6KD_cjs.a({r:k,g:k,b:k,alpha:t})}let s=o+.3963377774*n+.2158037573*r,c=o-.1055613458*n-.0638541728*r,e=o-.0894841775*n-1.291485548*r,_=s**3,l=c**3,b=e**3,p=4.0767416613*_-3.3077115904*l+.2309699287*b,E=-1.2684380041*_+2.6097574007*l-.3413193963*b,F=-0.0041960865*_-.7034186145*l+1.7076147009*b;return chunk2KB6V6KD_cjs.a({r:chunkVSMEJU4Z_cjs.b(chunkYISEJCI6_cjs.a(p,0,1))*255,g:chunkVSMEJU4Z_cjs.b(chunkYISEJCI6_cjs.a(E,0,1))*255,b:chunkVSMEJU4Z_cjs.b(chunkYISEJCI6_cjs.a(F,0,1))*255,alpha:t})},mn=(o,n,r,t)=>{if(r===0&&t===0){let p=n**3;o[0]=p,o[1]=p,o[2]=p;return}let s=n+I*r+S*t,c=n+O*r+B*t,e=n+h*r+x*t,_=s**3,l=c**3,b=e**3;o[0]=A*_+C*l+w*b,o[1]=T*_+y*l+G*b,o[2]=d*_+N*l+$*b;},en=(o,n,r)=>{if(n===0&&r===0){let b=o**3;return [b,b,b]}let t=o+I*n+S*r,s=o+O*n+B*r,c=o+h*n+x*r,e=t**3,_=s**3,l=c**3;return [A*e+C*_+w*l,T*e+y*_+G*l,d*e+N*_+$*l]},pn=o=>{if(!chunkYISEJCI6_cjs.h(o)||o.colorSpace==="lab"||!chunkYISEJCI6_cjs.i(o,["l","a","b"])||"r"in o||"x"in o||"c"in o||"h"in o)return null;let{l:n,a:r,b:t,alpha:s=1}=o;return !chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(s)||chunkYISEJCI6_cjs.g(n)>1?null:j({l:chunkYISEJCI6_cjs.g(n),a:chunkYISEJCI6_cjs.g(r),b:chunkYISEJCI6_cjs.g(t),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(s),0,1)})},_n=new RegExp(`^oklab\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<a>${chunkYISEJCI6_cjs.k})(?<ap>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),vn=o=>{if(typeof o!="string")return null;let n=_n.exec(o.trim())?.groups;if(!n)return null;let r=n.lp?chunkYISEJCI6_cjs.l(n.l)/100:chunkYISEJCI6_cjs.l(n.l),t=n.ap?chunkYISEJCI6_cjs.l(n.a)*.004:chunkYISEJCI6_cjs.l(n.a),s=n.bp?chunkYISEJCI6_cjs.l(n.b)*.004:chunkYISEJCI6_cjs.l(n.b),c=n.al===void 0?1:chunkYISEJCI6_cjs.l(n.al)/(n.alp?100:1);return j({l:r,a:t,b:s,alpha:chunkYISEJCI6_cjs.a(c,0,1)})};exports.a=cn;exports.b=Mn;exports.c=j;exports.d=un;exports.e=mn;exports.f=en;exports.g=pn;exports.h=vn;//# sourceMappingURL=chunk-ZNT33DPT.cjs.map | ||
| //# sourceMappingURL=chunk-ZNT33DPT.cjs.map |
| {"version":3,"sources":["../src/colorModels/oklab.ts"],"names":["M1_LR","M1_LG","M1_LB","M1_MR","M1_MG","M1_MB","M1_SR","M1_SG","M1_SB","M2_L_L","M2_M_L","M2_S_L","M2_L_A","M2_M_A","M2_S_A","M2_L_B","M2_M_B","M2_S_B","M2I_A_L","M2I_B_L","M2I_A_M","M2I_B_M","M2I_A_S","M2I_B_S","M1I_L_R","M1I_M_R","M1I_S_R","M1I_L_G","M1I_M_G","M1I_S_G","M1I_L_B","M1I_M_B","M1I_S_B","linearSrgbToOklab","lr","lg","lb","lv","mv","sv","rgbToOklab","r","g","b","alpha","l","a","bv","srgbToLinear","oklabToRgbUnclamped","oklabToLinear","srgbFromLinear","oklabToRgb","v","srgb","clamp","clampRgb","l_","m_","s_","oklabToLinearInto","out","parseOklabObject","input","isObject","hasKeys","isAnyNumber","sanitize","OKLAB_RE","NUM_OR_NONE","parseOklabString","L","parseNum"],"mappings":"uKAQA,IAAMA,EAAQ,W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AA,CAAMX,CAAAA,CAAO,EAAG,CAAC,CAAE,CAAC,CACtE","file":"chunk-ZNT33DPT.cjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { OklabColor, RgbColor } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\n// Björn Ottosson's OKLab matrix coefficients. Referenced by both the allocating\n// and zero-alloc (*Into) variants so the math lives in one place.\n// sRGB linear → LMS (cubed roots taken at M1 stage)\nconst M1_LR = 0.4122214708,\n M1_LG = 0.5363325363,\n M1_LB = 0.0514459929;\nconst M1_MR = 0.2119034982,\n M1_MG = 0.6806995451,\n M1_MB = 0.1073969566;\nconst M1_SR = 0.0883024619,\n M1_SG = 0.2817188376,\n M1_SB = 0.6299787005;\n// LMS' → OKLab\nconst M2_L_L = 0.2104542553,\n M2_M_L = 0.793617785,\n M2_S_L = -0.0040720468;\nconst M2_L_A = 1.9779984951,\n M2_M_A = -2.428592205,\n M2_S_A = 0.4505937099;\nconst M2_L_B = 0.0259040371,\n M2_M_B = 0.7827717662,\n M2_S_B = -0.808675766;\n// OKLab → LMS' (inverse of M2)\nconst M2I_A_L = 0.3963377774,\n M2I_B_L = 0.2158037573;\nconst M2I_A_M = -0.1055613458,\n M2I_B_M = -0.0638541728;\nconst M2I_A_S = -0.0894841775,\n M2I_B_S = -1.291485548;\n// LMS → linear sRGB (inverse of M1)\nconst M1I_L_R = 4.0767416613,\n M1I_M_R = -3.3077115904,\n M1I_S_R = 0.2309699287;\nconst M1I_L_G = -1.2684380041,\n M1I_M_G = 2.6097574007,\n M1I_S_G = -0.3413193963;\nconst M1I_L_B = -0.0041960865,\n M1I_M_B = -0.7034186145,\n M1I_S_B = 1.7076147009;\n\n/** Zero-allocation sibling of linearSrgbToOklab — writes [l, a, b] into `out`. */\nexport const linearSrgbToOklabInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n const lv = Math.cbrt(M1_LR * lr + M1_LG * lg + M1_LB * lb);\n const mv = Math.cbrt(M1_MR * lr + M1_MG * lg + M1_MB * lb);\n const sv = Math.cbrt(M1_SR * lr + M1_SG * lg + M1_SB * lb);\n out[0] = M2_L_L * lv + M2_M_L * mv + M2_S_L * sv;\n out[1] = M2_L_A * lv + M2_M_A * mv + M2_S_A * sv;\n out[2] = M2_L_B * lv + M2_M_B * mv + M2_S_B * sv;\n};\n\n/** Convert linear sRGB channels to OKLab (Björn Ottosson). No gamma, no clamping. */\nexport const linearSrgbToOklab = (lr: number, lg: number, lb: number): [number, number, number] => {\n const lv = Math.cbrt(M1_LR * lr + M1_LG * lg + M1_LB * lb);\n const mv = Math.cbrt(M1_MR * lr + M1_MG * lg + M1_MB * lb);\n const sv = Math.cbrt(M1_SR * lr + M1_SG * lg + M1_SB * lb);\n return [\n M2_L_L * lv + M2_M_L * mv + M2_S_L * sv,\n M2_L_A * lv + M2_M_A * mv + M2_S_A * sv,\n M2_L_B * lv + M2_M_B * mv + M2_S_B * sv,\n ];\n};\n\nexport const rgbToOklab = ({ r, g, b, alpha }: RgbColor): OklabColor => {\n const [l, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n return { l, a, b: bv, alpha };\n};\n\n/** Unclamped OKLab → gamma-encoded sRGB. Channels may exceed [0, 255] for out-of-sRGB-gamut colors. */\nexport const oklabToRgbUnclamped = ({ l, a, b, alpha }: OklabColor): RgbColor => {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\nexport const oklabToRgb = ({ l, a, b, alpha }: OklabColor): RgbColor => {\n if (a === 0 && b === 0) {\n const v = l ** 3;\n const srgb = srgbFromLinear(clamp(v, 0, 1)) * 255;\n return clampRgb({ r: srgb, g: srgb, b: srgb, alpha });\n }\n\n const l_ = l + 0.3963377774 * a + 0.2158037573 * b;\n const m_ = l - 0.1055613458 * a - 0.0638541728 * b;\n const s_ = l - 0.0894841775 * a - 1.291485548 * b;\n\n const lv = l_ ** 3;\n const mv = m_ ** 3;\n const sv = s_ ** 3;\n\n const r = 4.0767416613 * lv - 3.3077115904 * mv + 0.2309699287 * sv;\n const g = -1.2684380041 * lv + 2.6097574007 * mv - 0.3413193963 * sv;\n const bv = -0.0041960865 * lv - 0.7034186145 * mv + 1.7076147009 * sv;\n\n return clampRgb({\n r: srgbFromLinear(clamp(r, 0, 1)) * 255,\n g: srgbFromLinear(clamp(g, 0, 1)) * 255,\n b: srgbFromLinear(clamp(bv, 0, 1)) * 255,\n alpha,\n });\n};\n\n/** Zero-allocation sibling of oklabToLinear — writes [lr, lg, lb] into `out`. */\nexport const oklabToLinearInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n // Achromatic short-circuit: M1⁻¹ rows sum to 1 mathematically, but floating-point\n // rounding leaves lr/lg/lb ~1 ULP apart, which gets amplified into a phantom hue\n // downstream in rgbToHslRaw. Explicitly return lv for all channels.\n if (a === 0 && b === 0) {\n const v = l ** 3;\n out[0] = v;\n out[1] = v;\n out[2] = v;\n return;\n }\n const l_ = l + M2I_A_L * a + M2I_B_L * b;\n const m_ = l + M2I_A_M * a + M2I_B_M * b;\n const s_ = l + M2I_A_S * a + M2I_B_S * b;\n const lv = l_ ** 3,\n mv = m_ ** 3,\n sv = s_ ** 3;\n out[0] = M1I_L_R * lv + M1I_M_R * mv + M1I_S_R * sv;\n out[1] = M1I_L_G * lv + M1I_M_G * mv + M1I_S_G * sv;\n out[2] = M1I_L_B * lv + M1I_M_B * mv + M1I_S_B * sv;\n};\n\n/** Unclamped linear sRGB channels from OKLab values. Channels may exceed [0, 1] for out-of-gamut colors. */\nexport const oklabToLinear = (l: number, a: number, b: number): [number, number, number] => {\n if (a === 0 && b === 0) {\n const v = l ** 3;\n return [v, v, v];\n }\n const l_ = l + M2I_A_L * a + M2I_B_L * b;\n const m_ = l + M2I_A_M * a + M2I_B_M * b;\n const s_ = l + M2I_A_S * a + M2I_B_S * b;\n const lv = l_ ** 3,\n mv = m_ ** 3,\n sv = s_ ** 3;\n return [\n M1I_L_R * lv + M1I_M_R * mv + M1I_S_R * sv,\n M1I_L_G * lv + M1I_M_G * mv + M1I_S_G * sv,\n M1I_L_B * lv + M1I_M_B * mv + M1I_S_B * sv,\n ];\n};\n\nexport const parseOklabObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lab' are CIE Lab, not OKLab — let parseLabObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lab') return null;\n if (!hasKeys(input, ['l', 'a', 'b'])) return null;\n if ('r' in input || 'x' in input || 'c' in input || 'h' in input) return null;\n const { l, a, b, alpha = 1 } = input as { l: unknown; a: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(a) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLab L is always [0, 1]; reject CIE Lab values passed without colorSpace branding\n return oklabToRgbUnclamped({\n l: sanitize(l),\n a: sanitize(a),\n b: sanitize(b),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLAB_RE = new RegExp(\n `^oklab\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<a>${NUM_OR_NONE})(?<ap>%?)\\\\s+(?<b>${NUM_OR_NONE})(?<bp>%?)` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklabString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLAB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const a = g.ap ? parseNum(g.a!) * 0.004 : parseNum(g.a!); // 100% = 0.4\n const b = g.bp ? parseNum(g.b!) * 0.004 : parseNum(g.b!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklabToRgbUnclamped({ l: L, a, b, alpha: clamp(alpha, 0, 1) });\n};\n"]} |
| /** sRGB color. r, g, b in [0, 255]; alpha in [0, 1]. */ | ||
| interface RgbColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `RgbColor` — `alpha` is optional and defaults to 1. */ | ||
| type RgbColorInput = Omit<RgbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HSL color. h in [0, 360); s, l in [0, 100]; alpha in [0, 1]. */ | ||
| interface HslColor { | ||
| h: number; | ||
| s: number; | ||
| l: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HslColor` — `alpha` is optional and defaults to 1. */ | ||
| type HslColorInput = Omit<HslColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HSV color. h in [0, 360); s, v in [0, 100]; alpha in [0, 1]. */ | ||
| interface HsvColor { | ||
| h: number; | ||
| s: number; | ||
| v: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HsvColor` — `alpha` is optional and defaults to 1. */ | ||
| type HsvColorInput = Omit<HsvColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HWB color. h in [0, 360); w, b in [0, 100]; alpha in [0, 1]. */ | ||
| interface HwbColor { | ||
| h: number; | ||
| /** Whiteness [0, 100]. */ | ||
| w: number; | ||
| /** Blackness [0, 100]. */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HwbColor` — `alpha` is optional and defaults to 1. */ | ||
| type HwbColorInput = Omit<HwbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE Lab (D50). L in [0, 100]; a, b roughly in [-128, 128]. */ | ||
| interface LabColor { | ||
| l: number; | ||
| /** Green–red axis. */ | ||
| a: number; | ||
| /** Blue–yellow axis. */ | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lab'; | ||
| } | ||
| /** Input shape of `LabColor` — `alpha` is optional and defaults to 1. */ | ||
| type LabColorInput = Omit<LabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE LCh (D50). L in [0, 100]; C in [0, ~150]; h in degrees. */ | ||
| interface LchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lch'; | ||
| } | ||
| /** Input shape of `LchColor` — `alpha` is optional and defaults to 1. */ | ||
| type LchColorInput = Omit<LchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D50). x, y, z on the library's 0–100 scale. */ | ||
| interface XyzColor { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `XyzColor` — `alpha` is optional and defaults to 1. */ | ||
| type XyzColorInput = Omit<XyzColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D65). x, y, z on the library's 0–100 scale. */ | ||
| interface XyzD65Color { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'xyz-d65'; | ||
| } | ||
| type XyzD65ColorInput = Omit<XyzD65Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CMYK color. c, m, y, k in [0, 100]; alpha in [0, 1]. */ | ||
| interface CmykColor { | ||
| c: number; | ||
| m: number; | ||
| y: number; | ||
| k: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `CmykColor` — `alpha` is optional and defaults to 1. */ | ||
| type CmykColorInput = Omit<CmykColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** OKLab. Perceptually uniform (D65). L in [0, 1]; a, b roughly in [-0.4, 0.4]. */ | ||
| interface OklabColor { | ||
| l: number; | ||
| /** Green–red axis. */ | ||
| a: number; | ||
| /** Blue–yellow axis. */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `OklabColor` — `alpha` is optional and defaults to 1. */ | ||
| type OklabColorInput = Omit<OklabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** OKLCh. Polar form of OKLab. L in [0, 1]; C in [0, ~0.4]; h in degrees. */ | ||
| interface OklchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `OklchColor` — `alpha` is optional and defaults to 1. */ | ||
| type OklchColorInput = Omit<OklchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Display-P3. r, g, b in [0, 1]. */ | ||
| interface P3Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'display-p3'; | ||
| } | ||
| /** Input shape of `P3Color` — `alpha` is optional and defaults to 1. */ | ||
| type P3ColorInput = Omit<P3Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Rec.2020. r, g, b in [0, 1]. */ | ||
| interface Rec2020Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'rec2020'; | ||
| } | ||
| /** Input shape of `Rec2020Color` — `alpha` is optional and defaults to 1. */ | ||
| type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 A98 (Adobe RGB 1998). r, g, b in [0, 1]. */ | ||
| interface A98Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'a98-rgb'; | ||
| } | ||
| /** Input shape of `A98Color` — `alpha` is optional and defaults to 1. */ | ||
| type A98ColorInput = Omit<A98Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 ProPhoto (ROMM RGB). r, g, b in [0, 1]. */ | ||
| interface ProPhotoColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'prophoto-rgb'; | ||
| } | ||
| /** Input shape of `ProPhotoColor` — `alpha` is optional and defaults to 1. */ | ||
| type ProPhotoColorInput = Omit<ProPhotoColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** Any color input accepted by `colordx()` and friends — a CSS string or one of the input objects. */ | ||
| type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | XyzD65ColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput | A98ColorInput | ProPhotoColorInput; | ||
| /** A parser registered by a plugin. Returns the sRGB equivalent or `null` if the input doesn't match. */ | ||
| type ColorParser<T = AnyColor> = (input: T) => RgbColor | null; | ||
| /** Format tags returned by `getFormat()`. */ | ||
| type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'xyz-d65' | 'cmyk' | 'p3' | 'rec2020' | 'a98-rgb' | 'prophoto-rgb' | 'name'; | ||
| declare const _SENTINEL: unique symbol; | ||
| /** | ||
| * Color value with parse, format, and manipulation methods. | ||
| * Construct via the `colordx()` helper or `new Colordx(input)`. Instances are immutable — | ||
| * mutators return a new `Colordx`. | ||
| */ | ||
| declare class Colordx { | ||
| private readonly _rgb; | ||
| private readonly _valid; | ||
| constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor); | ||
| private static _make; | ||
| /** | ||
| * Construct a Colordx from linear-sRGB channels, gamma-encoding to the internal ×255 storage. | ||
| * Channels may exceed [0, 1] — wide-gamut inputs (toGamutP3 / toGamutRec2020 applied to a | ||
| * color outside sRGB) land here after the target-space → linear-sRGB matrix, and the stored | ||
| * _rgb holds unclamped gamma-encoded ×255 so toP3() / toRec2020() can recover the wide-gamut | ||
| * channels. sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning. | ||
| * | ||
| * Replaces the prior _makeFromOklab: cssGamutMap hands back clipped linear-target channels | ||
| * directly, so callers skip the OKLab → linear round-trip that used to reintroduce 1-ULP | ||
| * asymmetries on gamut-boundary colors. | ||
| * | ||
| * A residual source of asymmetry remains — the clip itself. cssGamutMap's clip puts one | ||
| * channel exactly on 0 or 1 while the others sit where the input's hue landed, so an | ||
| * extreme-dark or extreme-light color ends up with genuinely asymmetric sub-byte channels | ||
| * (e.g. clipped linear (3e-6, 0, 8e-10) from oklch(0.001 0.001 0)). Math.round collapses all | ||
| * three to the same byte, but rgbToHslRaw / rgbToOklab read the raw floats and report | ||
| * phantom hue/saturation. Snap values within half a byte of 0 or 255 to the exact boundary; | ||
| * the band matches Math.round's own behavior so byte output is unchanged, while HSL / OKLab | ||
| * see a consistent pure white / black / primary. Values outside [0, 255] are wide-gamut | ||
| * (P3 / Rec.2020 targets) and pass through untouched. | ||
| */ | ||
| static _makeFromLinearSrgb(lr: number, lg: number, lb: number, alpha: number): Colordx; | ||
| /** True when the input parsed as a recognised color. */ | ||
| isValid(): boolean; | ||
| /** Returns sRGB channels rounded to integers in [0, 255], plus alpha in [0, 1]. */ | ||
| toRgb(): RgbColor; | ||
| /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */ | ||
| _rawRgb(): RgbColor; | ||
| /** | ||
| * Formats as a CSS `rgb()` / `rgba()` string. | ||
| * Default is CSS Color 4 modern syntax — `rgb(255 0 0 / 0.5)`. | ||
| * Pass `{ legacy: true }` for CSS Color 3 comma syntax (switches to `rgba()` when alpha < 1). | ||
| */ | ||
| toRgbString(options?: { | ||
| legacy?: boolean; | ||
| }): string; | ||
| /** Returns `#rrggbb` (or `#rrggbbaa` when alpha < 1). */ | ||
| toHex(): string; | ||
| /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */ | ||
| toHex8(): string; | ||
| /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */ | ||
| toNumber(): number; | ||
| /** Returns HSL channels: h in [0, 360), s/l in [0, 100], rounded to `precision` decimals. */ | ||
| toHsl(precision?: number): HslColor; | ||
| /** Formats as a CSS `hsl()` string. */ | ||
| toHslString(precision?: number): string; | ||
| /** Returns OKLab channels: L in [0, 1], a/b roughly in [-0.4, 0.4]. */ | ||
| toOklab(precision?: number): OklabColor; | ||
| /** Formats as a CSS `oklab()` string. */ | ||
| toOklabString(precision?: number): string; | ||
| /** Returns OKLCh channels: L in [0, 1], C in [0, ~0.4], H in degrees. */ | ||
| toOklch(precision?: number): OklchColor; | ||
| /** Formats as a CSS `oklch()` string. Hue is `none` when chroma is 0. */ | ||
| toOklchString(precision?: number): string; | ||
| /** Perceived brightness in [0, 1] using the ITU-R BT.601 weights. */ | ||
| brightness(): number; | ||
| /** True when `brightness()` is below 0.5. */ | ||
| isDark(): boolean; | ||
| /** True when `brightness()` is at or above 0.5. */ | ||
| isLight(): boolean; | ||
| /** Get or set the alpha channel (clamped to [0, 1]). Setter returns a new `Colordx`. */ | ||
| alpha(): number; | ||
| alpha(value: number): Colordx; | ||
| /** Get or set the HSL hue in degrees. Setter returns a new `Colordx`. */ | ||
| hue(): number; | ||
| hue(value: number): Colordx; | ||
| /** Get or set the OKLCh lightness in [0, 1]. Setter returns a new `Colordx`. */ | ||
| lightness(): number; | ||
| lightness(value: number): Colordx; | ||
| /** Get or set the OKLCh chroma in [0, 0.4]. Setter returns a new `Colordx`. */ | ||
| chroma(): number; | ||
| chroma(value: number): Colordx; | ||
| /** | ||
| * Lightens by `amount` (default 0.1) in HSL. Absolute by default — adds `amount * 100` to L. | ||
| * Pass `{ relative: true }` to multiply L by `1 + amount` instead. | ||
| */ | ||
| lighten(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Inverse of `lighten`. */ | ||
| darken(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** | ||
| * Saturates by `amount` (default 0.1) in HSL. Absolute by default — adds `amount * 100` to S. | ||
| * Pass `{ relative: true }` to multiply S by `1 + amount` instead. | ||
| */ | ||
| saturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Inverse of `saturate`. */ | ||
| desaturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Drops saturation to zero. */ | ||
| grayscale(): Colordx; | ||
| /** Inverts each RGB channel (255 − channel). */ | ||
| invert(): Colordx; | ||
| /** Shifts the HSL hue by `amount` degrees (default 15). */ | ||
| rotate(amount?: number): Colordx; | ||
| /** True when both colors round to the same RGBA tuple. */ | ||
| isEqual(color: AnyColor): boolean; | ||
| /** Returns the hex form (alias for `toHex()`). */ | ||
| toString(): string; | ||
| /** | ||
| * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255]. | ||
| * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`. | ||
| * Hue and lightness may shift noticeably for colors far outside sRGB. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| clampSrgb(): Colordx; | ||
| /** | ||
| * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm | ||
| * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma. | ||
| * Useful when hue stability matters — design tokens, palettes, color pickers. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| mapSrgb(): Colordx; | ||
| /** | ||
| * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm. | ||
| * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through. | ||
| */ | ||
| static toGamutSrgb: (input: AnyColor) => Colordx; | ||
| } | ||
| /** | ||
| * Plugin signature. Receives the `Colordx` class plus the parser arrays so a plugin | ||
| * can register conversions (by adding instance methods) and parsers (by pushing onto the arrays). | ||
| */ | ||
| type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void; | ||
| /** Constructs a `Colordx` from any supported color input. Existing instances pass through. */ | ||
| declare const colordx: (input: AnyColor | Colordx) => Colordx; | ||
| /** Emits an 8-digit `#rrggbbaa` hex for any color input. Shortcut for `colordx(c).toHex8()`. */ | ||
| declare const toHex8: (input: AnyColor | Colordx) => string; | ||
| /** Registers plugins. Each plugin is called once with the `Colordx` class and parser arrays. */ | ||
| declare const extend: (plugins: Plugin[]) => void; | ||
| /** | ||
| * Picks the candidate closest to `color` by Euclidean distance in OKLab. | ||
| * Throws when `candidates` is empty. | ||
| */ | ||
| declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T; | ||
| /** Returns a random opaque sRGB color. */ | ||
| declare const random: () => Colordx; | ||
| export { type AnyColor as A, extend as B, type ColorFormat as C, nearest as D, random as E, toHex8 as F, type XyzD65Color as G, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type A98Color as a, type A98ColorInput as b, type CmykColor as c, type CmykColorInput as d, type ColorParser as e, Colordx as f, type HslColorInput as g, type HsvColor as h, type HsvColorInput as i, type HwbColor as j, type HwbColorInput as k, type LabColorInput as l, type LchColor as m, type LchColorInput as n, type OklabColorInput as o, type OklchColor as p, type OklchColorInput as q, type P3ColorInput as r, type Plugin as s, type ProPhotoColor as t, type ProPhotoColorInput as u, type Rec2020ColorInput as v, type RgbColor as w, type RgbColorInput as x, type XyzColorInput as y, colordx as z }; |
| /** sRGB color. r, g, b in [0, 255]; alpha in [0, 1]. */ | ||
| interface RgbColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `RgbColor` — `alpha` is optional and defaults to 1. */ | ||
| type RgbColorInput = Omit<RgbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HSL color. h in [0, 360); s, l in [0, 100]; alpha in [0, 1]. */ | ||
| interface HslColor { | ||
| h: number; | ||
| s: number; | ||
| l: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HslColor` — `alpha` is optional and defaults to 1. */ | ||
| type HslColorInput = Omit<HslColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HSV color. h in [0, 360); s, v in [0, 100]; alpha in [0, 1]. */ | ||
| interface HsvColor { | ||
| h: number; | ||
| s: number; | ||
| v: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HsvColor` — `alpha` is optional and defaults to 1. */ | ||
| type HsvColorInput = Omit<HsvColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HWB color. h in [0, 360); w, b in [0, 100]; alpha in [0, 1]. */ | ||
| interface HwbColor { | ||
| h: number; | ||
| /** Whiteness [0, 100]. */ | ||
| w: number; | ||
| /** Blackness [0, 100]. */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HwbColor` — `alpha` is optional and defaults to 1. */ | ||
| type HwbColorInput = Omit<HwbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE Lab (D50). L in [0, 100]; a, b roughly in [-128, 128]. */ | ||
| interface LabColor { | ||
| l: number; | ||
| /** Green–red axis. */ | ||
| a: number; | ||
| /** Blue–yellow axis. */ | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lab'; | ||
| } | ||
| /** Input shape of `LabColor` — `alpha` is optional and defaults to 1. */ | ||
| type LabColorInput = Omit<LabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE LCh (D50). L in [0, 100]; C in [0, ~150]; h in degrees. */ | ||
| interface LchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lch'; | ||
| } | ||
| /** Input shape of `LchColor` — `alpha` is optional and defaults to 1. */ | ||
| type LchColorInput = Omit<LchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D50). x, y, z on the library's 0–100 scale. */ | ||
| interface XyzColor { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `XyzColor` — `alpha` is optional and defaults to 1. */ | ||
| type XyzColorInput = Omit<XyzColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D65). x, y, z on the library's 0–100 scale. */ | ||
| interface XyzD65Color { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'xyz-d65'; | ||
| } | ||
| type XyzD65ColorInput = Omit<XyzD65Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CMYK color. c, m, y, k in [0, 100]; alpha in [0, 1]. */ | ||
| interface CmykColor { | ||
| c: number; | ||
| m: number; | ||
| y: number; | ||
| k: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `CmykColor` — `alpha` is optional and defaults to 1. */ | ||
| type CmykColorInput = Omit<CmykColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** OKLab. Perceptually uniform (D65). L in [0, 1]; a, b roughly in [-0.4, 0.4]. */ | ||
| interface OklabColor { | ||
| l: number; | ||
| /** Green–red axis. */ | ||
| a: number; | ||
| /** Blue–yellow axis. */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `OklabColor` — `alpha` is optional and defaults to 1. */ | ||
| type OklabColorInput = Omit<OklabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** OKLCh. Polar form of OKLab. L in [0, 1]; C in [0, ~0.4]; h in degrees. */ | ||
| interface OklchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `OklchColor` — `alpha` is optional and defaults to 1. */ | ||
| type OklchColorInput = Omit<OklchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Display-P3. r, g, b in [0, 1]. */ | ||
| interface P3Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'display-p3'; | ||
| } | ||
| /** Input shape of `P3Color` — `alpha` is optional and defaults to 1. */ | ||
| type P3ColorInput = Omit<P3Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Rec.2020. r, g, b in [0, 1]. */ | ||
| interface Rec2020Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'rec2020'; | ||
| } | ||
| /** Input shape of `Rec2020Color` — `alpha` is optional and defaults to 1. */ | ||
| type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 A98 (Adobe RGB 1998). r, g, b in [0, 1]. */ | ||
| interface A98Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'a98-rgb'; | ||
| } | ||
| /** Input shape of `A98Color` — `alpha` is optional and defaults to 1. */ | ||
| type A98ColorInput = Omit<A98Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 ProPhoto (ROMM RGB). r, g, b in [0, 1]. */ | ||
| interface ProPhotoColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'prophoto-rgb'; | ||
| } | ||
| /** Input shape of `ProPhotoColor` — `alpha` is optional and defaults to 1. */ | ||
| type ProPhotoColorInput = Omit<ProPhotoColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** Any color input accepted by `colordx()` and friends — a CSS string or one of the input objects. */ | ||
| type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | XyzD65ColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput | A98ColorInput | ProPhotoColorInput; | ||
| /** A parser registered by a plugin. Returns the sRGB equivalent or `null` if the input doesn't match. */ | ||
| type ColorParser<T = AnyColor> = (input: T) => RgbColor | null; | ||
| /** Format tags returned by `getFormat()`. */ | ||
| type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'xyz-d65' | 'cmyk' | 'p3' | 'rec2020' | 'a98-rgb' | 'prophoto-rgb' | 'name'; | ||
| declare const _SENTINEL: unique symbol; | ||
| /** | ||
| * Color value with parse, format, and manipulation methods. | ||
| * Construct via the `colordx()` helper or `new Colordx(input)`. Instances are immutable — | ||
| * mutators return a new `Colordx`. | ||
| */ | ||
| declare class Colordx { | ||
| private readonly _rgb; | ||
| private readonly _valid; | ||
| constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor); | ||
| private static _make; | ||
| /** | ||
| * Construct a Colordx from linear-sRGB channels, gamma-encoding to the internal ×255 storage. | ||
| * Channels may exceed [0, 1] — wide-gamut inputs (toGamutP3 / toGamutRec2020 applied to a | ||
| * color outside sRGB) land here after the target-space → linear-sRGB matrix, and the stored | ||
| * _rgb holds unclamped gamma-encoded ×255 so toP3() / toRec2020() can recover the wide-gamut | ||
| * channels. sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning. | ||
| * | ||
| * Replaces the prior _makeFromOklab: cssGamutMap hands back clipped linear-target channels | ||
| * directly, so callers skip the OKLab → linear round-trip that used to reintroduce 1-ULP | ||
| * asymmetries on gamut-boundary colors. | ||
| * | ||
| * A residual source of asymmetry remains — the clip itself. cssGamutMap's clip puts one | ||
| * channel exactly on 0 or 1 while the others sit where the input's hue landed, so an | ||
| * extreme-dark or extreme-light color ends up with genuinely asymmetric sub-byte channels | ||
| * (e.g. clipped linear (3e-6, 0, 8e-10) from oklch(0.001 0.001 0)). Math.round collapses all | ||
| * three to the same byte, but rgbToHslRaw / rgbToOklab read the raw floats and report | ||
| * phantom hue/saturation. Snap values within half a byte of 0 or 255 to the exact boundary; | ||
| * the band matches Math.round's own behavior so byte output is unchanged, while HSL / OKLab | ||
| * see a consistent pure white / black / primary. Values outside [0, 255] are wide-gamut | ||
| * (P3 / Rec.2020 targets) and pass through untouched. | ||
| */ | ||
| static _makeFromLinearSrgb(lr: number, lg: number, lb: number, alpha: number): Colordx; | ||
| /** True when the input parsed as a recognised color. */ | ||
| isValid(): boolean; | ||
| /** Returns sRGB channels rounded to integers in [0, 255], plus alpha in [0, 1]. */ | ||
| toRgb(): RgbColor; | ||
| /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */ | ||
| _rawRgb(): RgbColor; | ||
| /** | ||
| * Formats as a CSS `rgb()` / `rgba()` string. | ||
| * Default is CSS Color 4 modern syntax — `rgb(255 0 0 / 0.5)`. | ||
| * Pass `{ legacy: true }` for CSS Color 3 comma syntax (switches to `rgba()` when alpha < 1). | ||
| */ | ||
| toRgbString(options?: { | ||
| legacy?: boolean; | ||
| }): string; | ||
| /** Returns `#rrggbb` (or `#rrggbbaa` when alpha < 1). */ | ||
| toHex(): string; | ||
| /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */ | ||
| toHex8(): string; | ||
| /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */ | ||
| toNumber(): number; | ||
| /** Returns HSL channels: h in [0, 360), s/l in [0, 100], rounded to `precision` decimals. */ | ||
| toHsl(precision?: number): HslColor; | ||
| /** Formats as a CSS `hsl()` string. */ | ||
| toHslString(precision?: number): string; | ||
| /** Returns OKLab channels: L in [0, 1], a/b roughly in [-0.4, 0.4]. */ | ||
| toOklab(precision?: number): OklabColor; | ||
| /** Formats as a CSS `oklab()` string. */ | ||
| toOklabString(precision?: number): string; | ||
| /** Returns OKLCh channels: L in [0, 1], C in [0, ~0.4], H in degrees. */ | ||
| toOklch(precision?: number): OklchColor; | ||
| /** Formats as a CSS `oklch()` string. Hue is `none` when chroma is 0. */ | ||
| toOklchString(precision?: number): string; | ||
| /** Perceived brightness in [0, 1] using the ITU-R BT.601 weights. */ | ||
| brightness(): number; | ||
| /** True when `brightness()` is below 0.5. */ | ||
| isDark(): boolean; | ||
| /** True when `brightness()` is at or above 0.5. */ | ||
| isLight(): boolean; | ||
| /** Get or set the alpha channel (clamped to [0, 1]). Setter returns a new `Colordx`. */ | ||
| alpha(): number; | ||
| alpha(value: number): Colordx; | ||
| /** Get or set the HSL hue in degrees. Setter returns a new `Colordx`. */ | ||
| hue(): number; | ||
| hue(value: number): Colordx; | ||
| /** Get or set the OKLCh lightness in [0, 1]. Setter returns a new `Colordx`. */ | ||
| lightness(): number; | ||
| lightness(value: number): Colordx; | ||
| /** Get or set the OKLCh chroma in [0, 0.4]. Setter returns a new `Colordx`. */ | ||
| chroma(): number; | ||
| chroma(value: number): Colordx; | ||
| /** | ||
| * Lightens by `amount` (default 0.1) in HSL. Absolute by default — adds `amount * 100` to L. | ||
| * Pass `{ relative: true }` to multiply L by `1 + amount` instead. | ||
| */ | ||
| lighten(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Inverse of `lighten`. */ | ||
| darken(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** | ||
| * Saturates by `amount` (default 0.1) in HSL. Absolute by default — adds `amount * 100` to S. | ||
| * Pass `{ relative: true }` to multiply S by `1 + amount` instead. | ||
| */ | ||
| saturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Inverse of `saturate`. */ | ||
| desaturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Drops saturation to zero. */ | ||
| grayscale(): Colordx; | ||
| /** Inverts each RGB channel (255 − channel). */ | ||
| invert(): Colordx; | ||
| /** Shifts the HSL hue by `amount` degrees (default 15). */ | ||
| rotate(amount?: number): Colordx; | ||
| /** True when both colors round to the same RGBA tuple. */ | ||
| isEqual(color: AnyColor): boolean; | ||
| /** Returns the hex form (alias for `toHex()`). */ | ||
| toString(): string; | ||
| /** | ||
| * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255]. | ||
| * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`. | ||
| * Hue and lightness may shift noticeably for colors far outside sRGB. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| clampSrgb(): Colordx; | ||
| /** | ||
| * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm | ||
| * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma. | ||
| * Useful when hue stability matters — design tokens, palettes, color pickers. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| mapSrgb(): Colordx; | ||
| /** | ||
| * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm. | ||
| * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through. | ||
| */ | ||
| static toGamutSrgb: (input: AnyColor) => Colordx; | ||
| } | ||
| /** | ||
| * Plugin signature. Receives the `Colordx` class plus the parser arrays so a plugin | ||
| * can register conversions (by adding instance methods) and parsers (by pushing onto the arrays). | ||
| */ | ||
| type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void; | ||
| /** Constructs a `Colordx` from any supported color input. Existing instances pass through. */ | ||
| declare const colordx: (input: AnyColor | Colordx) => Colordx; | ||
| /** Emits an 8-digit `#rrggbbaa` hex for any color input. Shortcut for `colordx(c).toHex8()`. */ | ||
| declare const toHex8: (input: AnyColor | Colordx) => string; | ||
| /** Registers plugins. Each plugin is called once with the `Colordx` class and parser arrays. */ | ||
| declare const extend: (plugins: Plugin[]) => void; | ||
| /** | ||
| * Picks the candidate closest to `color` by Euclidean distance in OKLab. | ||
| * Throws when `candidates` is empty. | ||
| */ | ||
| declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T; | ||
| /** Returns a random opaque sRGB color. */ | ||
| declare const random: () => Colordx; | ||
| export { type AnyColor as A, extend as B, type ColorFormat as C, nearest as D, random as E, toHex8 as F, type XyzD65Color as G, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type A98Color as a, type A98ColorInput as b, type CmykColor as c, type CmykColorInput as d, type ColorParser as e, Colordx as f, type HslColorInput as g, type HsvColor as h, type HsvColorInput as i, type HwbColor as j, type HwbColorInput as k, type LabColorInput as l, type LchColor as m, type LchColorInput as n, type OklabColorInput as o, type OklchColor as p, type OklchColorInput as q, type P3ColorInput as r, type Plugin as s, type ProPhotoColor as t, type ProPhotoColorInput as u, type Rec2020ColorInput as v, type RgbColor as w, type RgbColorInput as x, type XyzColorInput as y, colordx as z }; |
| 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkDCLFNJD3_cjs=require('../chunk-DCLFNJD3.cjs'),chunkZNT33DPT_cjs=require('../chunk-ZNT33DPT.cjs');require('../chunk-6FI7U3TH.cjs');var chunkVSMEJU4Z_cjs=require('../chunk-VSMEJU4Z.cjs');require('../chunk-2KB6V6KD.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var R=(r,o,e)=>chunkZNT33DPT_cjs.a(...chunkDCLFNJD3_cjs.c(r,o,e)),S=(r,o,e)=>{let[n,t,m]=chunkDCLFNJD3_cjs.b(r,o,e);return [chunkVSMEJU4Z_cjs.f(n),chunkVSMEJU4Z_cjs.f(t),chunkVSMEJU4Z_cjs.f(m)]},I=(r,o,e,n)=>{chunkDCLFNJD3_cjs.a(r,o,e,n),r[0]=chunkVSMEJU4Z_cjs.f(r[0]),r[1]=chunkVSMEJU4Z_cjs.f(r[1]),r[2]=chunkVSMEJU4Z_cjs.f(r[2]);},E=(r,o,e)=>S(...chunkDCLFNJD3_cjs.G(r,o,e)),q=(r,o,e,n)=>{chunkDCLFNJD3_cjs.H(r,o,e,n),I(r,r[0],r[1],r[2]);},k=Math.PI/180,v=(r,o,e)=>S(...chunkDCLFNJD3_cjs.O(r,o,e)),M=(r,o,e,n)=>{chunkDCLFNJD3_cjs.P(r,o,e,n),I(r,r[0],r[1],r[2]);},z=(r,o,e)=>{let n=e*k;return v(r,o*Math.cos(n),o*Math.sin(n))},H=(r,o,e,n)=>{let t=n*k;M(r,o,e*Math.cos(t),e*Math.sin(t));},J=r=>chunkDCLFNJD3_cjs.E(r,chunkDCLFNJD3_cjs.g),_=(r,o,e)=>{r.toGamutA98=n=>{let t=chunkDCLFNJD3_cjs.F(n,chunkDCLFNJD3_cjs.g,R);if(t===null)return new r(n);let[m,b,u]=t.linear,[F,G,$]=chunkDCLFNJD3_cjs.c(m,b,u);return r._makeFromLinearSrgb(F,G,$,t.alpha)},r.prototype.toA98=function(n=4){let{r:t,g:m,b,alpha:u}=chunkDCLFNJD3_cjs.d(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(t,n),g:chunkYISEJCI6_cjs.b(m,n),b:chunkYISEJCI6_cjs.b(b,n),alpha:u,colorSpace:"a98-rgb"}},r.prototype.toA98String=function(n=4){let{r:t,g:m,b,alpha:u}=this.toA98(n);return u<1?`color(a98-rgb ${t} ${m} ${b} / ${u})`:`color(a98-rgb ${t} ${m} ${b})`},o.push(chunkDCLFNJD3_cjs.f,chunkDCLFNJD3_cjs.e),e.push([chunkDCLFNJD3_cjs.f,"a98-rgb"],[chunkDCLFNJD3_cjs.e,"a98-rgb"]);},K=_;exports.default=K;exports.inGamutA98=J;exports.labToA98Channels=v;exports.labToA98ChannelsInto=M;exports.lchToA98Channels=z;exports.lchToA98ChannelsInto=H;exports.linearToA98Channels=S;exports.linearToA98ChannelsInto=I;exports.oklchToA98Channels=E;exports.oklchToA98ChannelsInto=q;//# sourceMappingURL=a98rgb.cjs.map | ||
| //# sourceMappingURL=a98rgb.cjs.map |
| {"version":3,"sources":["../../src/plugins/a98rgb.ts"],"names":["a98FromLinearConverter","g","b","linearSrgbToOklab","linearA98ToSrgb","linearToA98Channels","lr","lg","lb","r","srgbLinearToA98Linear","a98FromLinear","linearToA98ChannelsInto","out","srgbLinearToA98LinearInto","oklchToA98Channels","l","c","h","oklchToLinear","oklchToA98ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToA98Channels","a","labToLinearSrgb","labToA98ChannelsInto","labToLinearSrgbInto","lchToA98Channels","hRad","lchToA98ChannelsInto","inGamutA98","input","inGamutCustom","oklabToLinearA98","a98","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lrR","lrG","lrB","precision","alpha","rgbToA98Raw","round","parseA98String","parseA98Object","a98rgb_default"],"mappings":"gWAiBA,IAAMA,EAAyB,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GACpDC,mBAAAA,CAAkB,GAAGC,mBAAAA,CAAgB,CAAA,CAAGH,EAAGC,CAAC,CAAC,EAiBlCG,CAAAA,CAAsB,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CACnG,GAAM,CAACC,EAAGR,CAAAA,CAAGC,CAAC,EAAIQ,mBAAAA,CAAsBJ,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CAClD,OAAO,CAACG,mBAAAA,CAAcF,CAAC,CAAA,CAAGE,mBAAAA,CAAcV,CAAC,CAAA,CAAGU,mBAAAA,CAAcT,CAAC,CAAC,CAC9D,EAGaU,CAAAA,CAA0B,CAACC,EAA8BP,CAAAA,CAAYC,CAAAA,CAAYC,IAAqB,CACjHM,mBAAAA,CAA0BD,EAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACzCK,CAAAA,CAAI,CAAC,CAAA,CAAIF,mBAAAA,CAAcE,EAAI,CAAC,CAAE,EAC9BA,CAAAA,CAAI,CAAC,EAAIF,mBAAAA,CAAcE,CAAAA,CAAI,CAAC,CAAE,CAAA,CAC9BA,EAAI,CAAC,CAAA,CAAIF,oBAAcE,CAAAA,CAAI,CAAC,CAAE,EAChC,CAAA,CAOaE,EAAqB,CAACC,CAAAA,CAAWC,EAAWC,CAAAA,GACvDb,CAAAA,CAAoB,GAAGc,mBAAAA,CAAcH,CAAAA,CAAGC,EAAGC,CAAC,CAAC,CAAA,CAGlCE,CAAAA,CAAyB,CAACP,CAAAA,CAA8BG,CAAAA,CAAWC,EAAWC,CAAAA,GAAoB,CAC7GG,oBAAkBR,CAAAA,CAAKG,CAAAA,CAAGC,EAAG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A,EAAI,CAAC,MAAM4C,CAAK,CAAA,CAAA,CAAA,CAAM,iBAAiBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,GAC9F,CAAA,CACAoC,CAAAA,CAAQ,KAAKW,mBAAAA,CAAgBC,mBAAc,EAC3CX,CAAAA,CAAc,IAAA,CAAK,CAACU,mBAAAA,CAAgB,SAAS,EAAG,CAACC,mBAAAA,CAAgB,SAAS,CAAC,EAC7E,EAEOC,CAAAA,CAAQf","file":"a98rgb.cjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport {\n linearA98ToSrgb,\n oklabToLinearA98,\n parseA98Object,\n parseA98String,\n rgbToA98Raw,\n srgbLinearToA98Linear,\n srgbLinearToA98LinearInto,\n} from '../colorModels/a98rgb.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { a98FromLinear } from '../transfer.js';\nimport type { A98Color, AnyColor } from '../types.js';\n\nconst a98FromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearA98ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toA98(precision?: number): A98Color;\n toA98String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutA98(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded A98 channels.\n * This is the cheap step — only a matrix multiply + the A98 power curve, no cbrt.\n */\nexport const linearToA98Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToA98Linear(lr, lg, lb);\n return [a98FromLinear(r), a98FromLinear(g), a98FromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToA98Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToA98ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToA98LinearInto(out, lr, lg, lb);\n out[0] = a98FromLinear(out[0]!);\n out[1] = a98FromLinear(out[1]!);\n out[2] = a98FromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded A98 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n */\nexport const oklchToA98Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToA98Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToA98Channels — writes [rr, rg, rb] into `out`. */\nexport const oklchToA98ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToA98ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded A98 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear A98 → A98 gamma.\n */\nexport const labToA98Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToA98Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToA98Channels — writes [rr, rg, rb] into `out`. */\nexport const labToA98ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToA98ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded A98 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma A98.\n */\nexport const lchToA98Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToA98Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToA98Channels — writes [rr, rg, rb] into `out`. */\nexport const lchToA98ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToA98ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the A98 (Adobe RGB 1998) gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ A98).\n */\nexport const inGamutA98 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearA98);\n\nconst a98: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutA98 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearA98, a98FromLinearConverter);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-A98 → linear-sRGB (wide-gamut when the A98 color is outside sRGB),\n // then gamma-encode for storage. No round-trip through OKLab.\n const [lrR, lrG, lrB] = mapped.linear;\n const [lr, lg, lb] = linearA98ToSrgb(lrR, lrG, lrB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toA98 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToA98Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'a98-rgb' as const,\n };\n };\n ColordxClass.prototype.toA98String = function (precision = 4) {\n const { r, g, b, alpha } = this.toA98(precision);\n return alpha < 1 ? `color(a98-rgb ${r} ${g} ${b} / ${alpha})` : `color(a98-rgb ${r} ${g} ${b})`;\n };\n parsers.push(parseA98String, parseA98Object);\n formatParsers.push([parseA98String, 'a98-rgb'], [parseA98Object, 'a98-rgb']);\n};\n\nexport default a98;\n"]} |
| import { a as A98Color, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
| declare module '@colordx/core' { | ||
| interface Colordx { | ||
| toA98(precision?: number): A98Color; | ||
| toA98String(precision?: number): string; | ||
| } | ||
| namespace Colordx { | ||
| function toGamutA98(input: AnyColor): Colordx; | ||
| } | ||
| } | ||
| /** | ||
| * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded A98 channels. | ||
| * This is the cheap step — only a matrix multiply + the A98 power curve, no cbrt. | ||
| */ | ||
| declare const linearToA98Channels: (lr: number, lg: number, lb: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of linearToA98Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */ | ||
| declare const linearToA98ChannelsInto: (out: Float64Array | number[], lr: number, lg: number, lb: number) => void; | ||
| /** | ||
| * Convert OKLCH to gamma-encoded A98 channels without object allocation. | ||
| * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may | ||
| * exceed this range — callers are responsible for clamping before byte encoding. | ||
| */ | ||
| declare const oklchToA98Channels: (l: number, c: number, h: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of oklchToA98Channels — writes [rr, rg, rb] into `out`. */ | ||
| declare const oklchToA98ChannelsInto: (out: Float64Array | number[], l: number, c: number, h: number) => void; | ||
| /** | ||
| * Convert CIE Lab (D50) to gamma-encoded A98 channels without object allocation. | ||
| * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1]. | ||
| * Goes Lab → XYZ D50 → linear sRGB → linear A98 → A98 gamma. | ||
| */ | ||
| declare const labToA98Channels: (l: number, a: number, b: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of labToA98Channels — writes [rr, rg, rb] into `out`. */ | ||
| declare const labToA98ChannelsInto: (out: Float64Array | number[], l: number, a: number, b: number) => void; | ||
| /** | ||
| * Convert CIE LCH (D50) to gamma-encoded A98 channels without object allocation. | ||
| * Polar-to-rectangular to Lab, then Lab → gamma A98. | ||
| */ | ||
| declare const lchToA98Channels: (l: number, c: number, h: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of lchToA98Channels — writes [rr, rg, rb] into `out`. */ | ||
| declare const lchToA98ChannelsInto: (out: Float64Array | number[], l: number, c: number, h: number) => void; | ||
| /** | ||
| * Returns true if the color is within the A98 (Adobe RGB 1998) gamut. | ||
| * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ A98). | ||
| */ | ||
| declare const inGamutA98: (input: AnyColor) => boolean; | ||
| declare const a98: Plugin; | ||
| export { a98 as default, inGamutA98, labToA98Channels, labToA98ChannelsInto, lchToA98Channels, lchToA98ChannelsInto, linearToA98Channels, linearToA98ChannelsInto, oklchToA98Channels, oklchToA98ChannelsInto }; |
| import { a as A98Color, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
| declare module '@colordx/core' { | ||
| interface Colordx { | ||
| toA98(precision?: number): A98Color; | ||
| toA98String(precision?: number): string; | ||
| } | ||
| namespace Colordx { | ||
| function toGamutA98(input: AnyColor): Colordx; | ||
| } | ||
| } | ||
| /** | ||
| * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded A98 channels. | ||
| * This is the cheap step — only a matrix multiply + the A98 power curve, no cbrt. | ||
| */ | ||
| declare const linearToA98Channels: (lr: number, lg: number, lb: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of linearToA98Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */ | ||
| declare const linearToA98ChannelsInto: (out: Float64Array | number[], lr: number, lg: number, lb: number) => void; | ||
| /** | ||
| * Convert OKLCH to gamma-encoded A98 channels without object allocation. | ||
| * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may | ||
| * exceed this range — callers are responsible for clamping before byte encoding. | ||
| */ | ||
| declare const oklchToA98Channels: (l: number, c: number, h: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of oklchToA98Channels — writes [rr, rg, rb] into `out`. */ | ||
| declare const oklchToA98ChannelsInto: (out: Float64Array | number[], l: number, c: number, h: number) => void; | ||
| /** | ||
| * Convert CIE Lab (D50) to gamma-encoded A98 channels without object allocation. | ||
| * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1]. | ||
| * Goes Lab → XYZ D50 → linear sRGB → linear A98 → A98 gamma. | ||
| */ | ||
| declare const labToA98Channels: (l: number, a: number, b: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of labToA98Channels — writes [rr, rg, rb] into `out`. */ | ||
| declare const labToA98ChannelsInto: (out: Float64Array | number[], l: number, a: number, b: number) => void; | ||
| /** | ||
| * Convert CIE LCH (D50) to gamma-encoded A98 channels without object allocation. | ||
| * Polar-to-rectangular to Lab, then Lab → gamma A98. | ||
| */ | ||
| declare const lchToA98Channels: (l: number, c: number, h: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of lchToA98Channels — writes [rr, rg, rb] into `out`. */ | ||
| declare const lchToA98ChannelsInto: (out: Float64Array | number[], l: number, c: number, h: number) => void; | ||
| /** | ||
| * Returns true if the color is within the A98 (Adobe RGB 1998) gamut. | ||
| * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ A98). | ||
| */ | ||
| declare const inGamutA98: (input: AnyColor) => boolean; | ||
| declare const a98: Plugin; | ||
| export { a98 as default, inGamutA98, labToA98Channels, labToA98ChannelsInto, lchToA98Channels, lchToA98ChannelsInto, linearToA98Channels, linearToA98ChannelsInto, oklchToA98Channels, oklchToA98ChannelsInto }; |
| import {b,a,G,H as H$1,O,P,E as E$1,g,F,c,d,f as f$1,e}from'../chunk-JT2PPQ6V.mjs';import {a as a$1}from'../chunk-2FEDFNW7.mjs';import'../chunk-YQKSXMBN.mjs';import {f}from'../chunk-WGY6QKPW.mjs';import'../chunk-GLKEY6D3.mjs';import {b as b$1}from'../chunk-IOXRZECH.mjs';var R=(r,o,e)=>a$1(...c(r,o,e)),S=(r,o,e)=>{let[n,t,m]=b(r,o,e);return [f(n),f(t),f(m)]},I=(r,o,e,n)=>{a(r,o,e,n),r[0]=f(r[0]),r[1]=f(r[1]),r[2]=f(r[2]);},E=(r,o,e)=>S(...G(r,o,e)),q=(r,o,e,n)=>{H$1(r,o,e,n),I(r,r[0],r[1],r[2]);},k=Math.PI/180,v=(r,o,e)=>S(...O(r,o,e)),M=(r,o,e,n)=>{P(r,o,e,n),I(r,r[0],r[1],r[2]);},z=(r,o,e)=>{let n=e*k;return v(r,o*Math.cos(n),o*Math.sin(n))},H=(r,o,e,n)=>{let t=n*k;M(r,o,e*Math.cos(t),e*Math.sin(t));},J=r=>E$1(r,g),_=(r,o,e$1)=>{r.toGamutA98=n=>{let t=F(n,g,R);if(t===null)return new r(n);let[m,b,u]=t.linear,[F$1,G,$]=c(m,b,u);return r._makeFromLinearSrgb(F$1,G,$,t.alpha)},r.prototype.toA98=function(n=4){let{r:t,g:m,b,alpha:u}=d(this._rawRgb());return {r:b$1(t,n),g:b$1(m,n),b:b$1(b,n),alpha:u,colorSpace:"a98-rgb"}},r.prototype.toA98String=function(n=4){let{r:t,g:m,b,alpha:u}=this.toA98(n);return u<1?`color(a98-rgb ${t} ${m} ${b} / ${u})`:`color(a98-rgb ${t} ${m} ${b})`},o.push(f$1,e),e$1.push([f$1,"a98-rgb"],[e,"a98-rgb"]);},K=_;export{K as default,J as inGamutA98,v as labToA98Channels,M as labToA98ChannelsInto,z as lchToA98Channels,H as lchToA98ChannelsInto,S as linearToA98Channels,I as linearToA98ChannelsInto,E as oklchToA98Channels,q as oklchToA98ChannelsInto};//# sourceMappingURL=a98rgb.mjs.map | ||
| //# sourceMappingURL=a98rgb.mjs.map |
| {"version":3,"sources":["../../src/plugins/a98rgb.ts"],"names":["a98FromLinearConverter","g","b","linearSrgbToOklab","linearA98ToSrgb","linearToA98Channels","lr","lg","lb","r","srgbLinearToA98Linear","a98FromLinear","linearToA98ChannelsInto","out","srgbLinearToA98LinearInto","oklchToA98Channels","l","c","h","oklchToLinear","oklchToA98ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToA98Channels","a","labToLinearSrgb","labToA98ChannelsInto","labToLinearSrgbInto","lchToA98Channels","hRad","lchToA98ChannelsInto","inGamutA98","input","inGamutCustom","oklabToLinearA98","a98","ColordxClass","parsers","formatParsers","mapped","toG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EAAI,CAAC,GAC9F,CAAA,CACAoC,CAAAA,CAAQ,KAAKW,GAAAA,CAAgBC,CAAc,EAC3CX,GAAAA,CAAc,IAAA,CAAK,CAACU,GAAAA,CAAgB,SAAS,EAAG,CAACC,CAAAA,CAAgB,SAAS,CAAC,EAC7E,EAEOC,CAAAA,CAAQf","file":"a98rgb.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport {\n linearA98ToSrgb,\n oklabToLinearA98,\n parseA98Object,\n parseA98String,\n rgbToA98Raw,\n srgbLinearToA98Linear,\n srgbLinearToA98LinearInto,\n} from '../colorModels/a98rgb.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { a98FromLinear } from '../transfer.js';\nimport type { A98Color, AnyColor } from '../types.js';\n\nconst a98FromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearA98ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toA98(precision?: number): A98Color;\n toA98String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutA98(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded A98 channels.\n * This is the cheap step — only a matrix multiply + the A98 power curve, no cbrt.\n */\nexport const linearToA98Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToA98Linear(lr, lg, lb);\n return [a98FromLinear(r), a98FromLinear(g), a98FromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToA98Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToA98ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToA98LinearInto(out, lr, lg, lb);\n out[0] = a98FromLinear(out[0]!);\n out[1] = a98FromLinear(out[1]!);\n out[2] = a98FromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded A98 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n */\nexport const oklchToA98Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToA98Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToA98Channels — writes [rr, rg, rb] into `out`. */\nexport const oklchToA98ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToA98ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded A98 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear A98 → A98 gamma.\n */\nexport const labToA98Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToA98Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToA98Channels — writes [rr, rg, rb] into `out`. */\nexport const labToA98ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToA98ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded A98 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma A98.\n */\nexport const lchToA98Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToA98Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToA98Channels — writes [rr, rg, rb] into `out`. */\nexport const lchToA98ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToA98ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the A98 (Adobe RGB 1998) gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ A98).\n */\nexport const inGamutA98 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearA98);\n\nconst a98: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutA98 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearA98, a98FromLinearConverter);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-A98 → linear-sRGB (wide-gamut when the A98 color is outside sRGB),\n // then gamma-encode for storage. No round-trip through OKLab.\n const [lrR, lrG, lrB] = mapped.linear;\n const [lr, lg, lb] = linearA98ToSrgb(lrR, lrG, lrB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toA98 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToA98Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'a98-rgb' as const,\n };\n };\n ColordxClass.prototype.toA98String = function (precision = 4) {\n const { r, g, b, alpha } = this.toA98(precision);\n return alpha < 1 ? `color(a98-rgb ${r} ${g} ${b} / ${alpha})` : `color(a98-rgb ${r} ${g} ${b})`;\n };\n parsers.push(parseA98String, parseA98Object);\n formatParsers.push([parseA98String, 'a98-rgb'], [parseA98Object, 'a98-rgb']);\n};\n\nexport default a98;\n"]} |
| 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkDCLFNJD3_cjs=require('../chunk-DCLFNJD3.cjs'),chunkZNT33DPT_cjs=require('../chunk-ZNT33DPT.cjs');require('../chunk-6FI7U3TH.cjs');var chunkVSMEJU4Z_cjs=require('../chunk-VSMEJU4Z.cjs');require('../chunk-2KB6V6KD.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var $=(o,n,t)=>chunkZNT33DPT_cjs.a(...chunkDCLFNJD3_cjs.q(o,n,t)),A=(o,n,t)=>{let[r,e,m]=chunkDCLFNJD3_cjs.p(o,n,t);return [chunkVSMEJU4Z_cjs.h(r),chunkVSMEJU4Z_cjs.h(e),chunkVSMEJU4Z_cjs.h(m)]},S=(o,n,t,r)=>{chunkDCLFNJD3_cjs.o(o,n,t,r),o[0]=chunkVSMEJU4Z_cjs.h(o[0]),o[1]=chunkVSMEJU4Z_cjs.h(o[1]),o[2]=chunkVSMEJU4Z_cjs.h(o[2]);},E=(o,n,t)=>A(...chunkDCLFNJD3_cjs.G(o,n,t)),q=(o,n,t,r)=>{chunkDCLFNJD3_cjs.H(o,n,t,r),S(o,o[0],o[1],o[2]);},I=Math.PI/180,R=(o,n,t)=>A(...chunkDCLFNJD3_cjs.O(o,n,t)),v=(o,n,t,r)=>{chunkDCLFNJD3_cjs.P(o,n,t,r),S(o,o[0],o[1],o[2]);},z=(o,n,t)=>{let r=t*I;return R(o,n*Math.cos(r),n*Math.sin(r))},H=(o,n,t,r)=>{let e=r*I;v(o,n,t*Math.cos(e),t*Math.sin(e));},J=o=>chunkDCLFNJD3_cjs.E(o,chunkDCLFNJD3_cjs.u),M=(o,n,t)=>{o.toGamutProphoto=r=>{let e=chunkDCLFNJD3_cjs.F(r,chunkDCLFNJD3_cjs.u,$);if(e===null)return new o(r);let[m,p,a]=e.linear,[k,F,G]=chunkDCLFNJD3_cjs.q(m,p,a);return o._makeFromLinearSrgb(k,F,G,e.alpha)},o.prototype.toProphoto=function(r=4){let{r:e,g:m,b:p,alpha:a}=chunkDCLFNJD3_cjs.r(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(e,r),g:chunkYISEJCI6_cjs.b(m,r),b:chunkYISEJCI6_cjs.b(p,r),alpha:a,colorSpace:"prophoto-rgb"}},o.prototype.toProphotoString=function(r=4){let{r:e,g:m,b:p,alpha:a}=this.toProphoto(r);return a<1?`color(prophoto-rgb ${e} ${m} ${p} / ${a})`:`color(prophoto-rgb ${e} ${m} ${p})`},n.push(chunkDCLFNJD3_cjs.t,chunkDCLFNJD3_cjs.s),t.push([chunkDCLFNJD3_cjs.t,"prophoto-rgb"],[chunkDCLFNJD3_cjs.s,"prophoto-rgb"]);},K=M;exports.default=K;exports.inGamutProphoto=J;exports.labToProphotoChannels=R;exports.labToProphotoChannelsInto=v;exports.lchToProphotoChannels=z;exports.lchToProphotoChannelsInto=H;exports.linearToProphotoChannels=A;exports.linearToProphotoChannelsInto=S;exports.oklchToProphotoChannels=E;exports.oklchToProphotoChannelsInto=q;//# sourceMappingURL=prophoto.cjs.map | ||
| //# sourceMappingURL=prophoto.cjs.map |
| {"version":3,"sources":["../../src/plugins/prophoto.ts"],"names":["prophotoFromLinearConverter","r","g","b","linearSrgbToOklab","linearProphotoToSrgb","linearToProphotoChannels","lr","lg","lb","srgbLinearToProphotoLinear","prophotoFromLinear","linearToProphotoChannelsInto","out","srgbLinearToProphotoLinearInto","oklchToProphotoChannels","l","c","h","oklchToLinear","oklchToProphotoChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToProphotoChannels","a","labToLinearSrgb","labToProphotoChannelsInto","labToLinearSrgbInto","lchToProphotoChannels","hRad","lchToProphotoChannelsInto","inGamutProphoto","input","inGamutCustom","oklabToLinearProphoto","prophoto","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lrR","lrG","lrB","precision","alpha","rgbToProphotoRaw","round","parseProphotoString","parseProphotoObject","prophoto_default"],"mappings":"gWAiBA,IAAMA,EAA8B,CAACC,CAAAA,CAAWC,EAAWC,CAAAA,GACzDC,mBAAAA,CAAkB,GAAGC,mBAAAA,CAAqBJ,CAAAA,CAAGC,EAAGC,CAAC,CAAC,EAiBvCG,CAAAA,CAA2B,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CACxG,GAAM,CAAC,EAAGP,CAAAA,CAAGC,CAAC,EAAIO,mBAAAA,CAA2BH,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACvD,O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AClE,EACAH,CAAAA,CAAa,SAAA,CAAU,WAAa,SAAUQ,CAAAA,CAAY,EAAG,CAC3D,GAAM,CAAE,CAAA,CAAA3C,CAAAA,CAAG,EAAAC,CAAAA,CAAG,CAAA,CAAAC,EAAG,KAAA,CAAA0C,CAAM,EAAIC,mBAAAA,CAAiB,IAAA,CAAK,SAAS,CAAA,CAC1D,OAAO,CACL,CAAA,CAAGC,oBAAM9C,CAAAA,CAAG2C,CAAS,EACrB,CAAA,CAAGG,mBAAAA,CAAM7C,EAAG0C,CAAS,CAAA,CACrB,EAAGG,mBAAAA,CAAM5C,CAAAA,CAAGyC,CAAS,CAAA,CACrB,KAAA,CAAAC,EACA,UAAA,CAAY,cACd,CACF,CAAA,CACAT,CAAAA,CAAa,UAAU,gBAAA,CAAmB,SAAUQ,EAAY,CAAA,CAAG,CACjE,GAAM,CAAE,CAAA,CAAA3C,EAAG,CAAA,CAAAC,CAAAA,CAAG,EAAAC,CAAAA,CAAG,KAAA,CAAA0C,CAAM,CAAA,CAAI,IAAA,CAAK,WAAWD,CAAS,CAAA,CACpD,OAAOC,CAAAA,CAAQ,CAAA,CAAI,sBAAsB5C,CAAC,CAAA,CAAA,EAAIC,CAAC,CAAA,CAAA,EAAIC,CAAC,MAAM0C,CAAK,CAAA,CAAA,CAAA,CAAM,sBAAsB5C,CAAC,CAAA,CAAA,EAAIC,CAAC,CAAA,CAAA,EAAIC,CAAC,GACxG,CAAA,CACAkC,CAAAA,CAAQ,KAAKW,mBAAAA,CAAqBC,mBAAmB,EACrDX,CAAAA,CAAc,IAAA,CAAK,CAACU,mBAAAA,CAAqB,cAAc,EAAG,CAACC,mBAAAA,CAAqB,cAAc,CAAC,EACjG,EAEOC,CAAAA,CAAQf","file":"prophoto.cjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearProphotoToSrgb,\n oklabToLinearProphoto,\n parseProphotoObject,\n parseProphotoString,\n rgbToProphotoRaw,\n srgbLinearToProphotoLinear,\n srgbLinearToProphotoLinearInto,\n} from '../colorModels/prophoto.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { prophotoFromLinear } from '../transfer.js';\nimport type { AnyColor, ProPhotoColor } from '../types.js';\n\nconst prophotoFromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearProphotoToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toProphoto(precision?: number): ProPhotoColor;\n toProphotoString(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutProphoto(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded ProPhoto channels.\n * This is the cheap step — only a matrix multiply + the ProPhoto gamma 1.8 curve, no cbrt.\n */\nexport const linearToProphotoChannels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToProphotoLinear(lr, lg, lb);\n return [prophotoFromLinear(r), prophotoFromLinear(g), prophotoFromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToProphotoChannels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToProphotoChannelsInto = (\n out: Float64Array | number[],\n lr: number,\n lg: number,\n lb: number\n): void => {\n srgbLinearToProphotoLinearInto(out, lr, lg, lb);\n out[0] = prophotoFromLinear(out[0]!);\n out[1] = prophotoFromLinear(out[1]!);\n out[2] = prophotoFromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded ProPhoto channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n */\nexport const oklchToProphotoChannels = (l: number, c: number, h: number): [number, number, number] =>\n linearToProphotoChannels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToProphotoChannels — writes [rr, rg, rb] into `out`. */\nexport const oklchToProphotoChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToProphotoChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded ProPhoto channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear ProPhoto → ProPhoto gamma.\n */\nexport const labToProphotoChannels = (l: number, a: number, b: number): [number, number, number] =>\n linearToProphotoChannels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToProphotoChannels — writes [rr, rg, rb] into `out`. */\nexport const labToProphotoChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToProphotoChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded ProPhoto channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma ProPhoto.\n */\nexport const lchToProphotoChannels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToProphotoChannels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToProphotoChannels — writes [rr, rg, rb] into `out`. */\nexport const lchToProphotoChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToProphotoChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the ProPhoto (ROMM RGB) gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ ProPhoto).\n */\nexport const inGamutProphoto = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearProphoto);\n\nconst prophoto: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutProphoto = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearProphoto, prophotoFromLinearConverter);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-ProPhoto → linear-sRGB (wide-gamut when the ProPhoto color is outside\n // sRGB), then gamma-encode for storage. No round-trip through OKLab.\n const [lrR, lrG, lrB] = mapped.linear;\n const [lr, lg, lb] = linearProphotoToSrgb(lrR, lrG, lrB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toProphoto = function (precision = 4) {\n const { r, g, b, alpha } = rgbToProphotoRaw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'prophoto-rgb' as const,\n };\n };\n ColordxClass.prototype.toProphotoString = function (precision = 4) {\n const { r, g, b, alpha } = this.toProphoto(precision);\n return alpha < 1 ? `color(prophoto-rgb ${r} ${g} ${b} / ${alpha})` : `color(prophoto-rgb ${r} ${g} ${b})`;\n };\n parsers.push(parseProphotoString, parseProphotoObject);\n formatParsers.push([parseProphotoString, 'prophoto-rgb'], [parseProphotoObject, 'prophoto-rgb']);\n};\n\nexport default prophoto;\n"]} |
| import { t as ProPhotoColor, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
| declare module '@colordx/core' { | ||
| interface Colordx { | ||
| toProphoto(precision?: number): ProPhotoColor; | ||
| toProphotoString(precision?: number): string; | ||
| } | ||
| namespace Colordx { | ||
| function toGamutProphoto(input: AnyColor): Colordx; | ||
| } | ||
| } | ||
| /** | ||
| * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded ProPhoto channels. | ||
| * This is the cheap step — only a matrix multiply + the ProPhoto gamma 1.8 curve, no cbrt. | ||
| */ | ||
| declare const linearToProphotoChannels: (lr: number, lg: number, lb: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of linearToProphotoChannels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */ | ||
| declare const linearToProphotoChannelsInto: (out: Float64Array | number[], lr: number, lg: number, lb: number) => void; | ||
| /** | ||
| * Convert OKLCH to gamma-encoded ProPhoto channels without object allocation. | ||
| * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may | ||
| * exceed this range — callers are responsible for clamping before byte encoding. | ||
| */ | ||
| declare const oklchToProphotoChannels: (l: number, c: number, h: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of oklchToProphotoChannels — writes [rr, rg, rb] into `out`. */ | ||
| declare const oklchToProphotoChannelsInto: (out: Float64Array | number[], l: number, c: number, h: number) => void; | ||
| /** | ||
| * Convert CIE Lab (D50) to gamma-encoded ProPhoto channels without object allocation. | ||
| * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1]. | ||
| * Goes Lab → XYZ D50 → linear sRGB → linear ProPhoto → ProPhoto gamma. | ||
| */ | ||
| declare const labToProphotoChannels: (l: number, a: number, b: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of labToProphotoChannels — writes [rr, rg, rb] into `out`. */ | ||
| declare const labToProphotoChannelsInto: (out: Float64Array | number[], l: number, a: number, b: number) => void; | ||
| /** | ||
| * Convert CIE LCH (D50) to gamma-encoded ProPhoto channels without object allocation. | ||
| * Polar-to-rectangular to Lab, then Lab → gamma ProPhoto. | ||
| */ | ||
| declare const lchToProphotoChannels: (l: number, c: number, h: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of lchToProphotoChannels — writes [rr, rg, rb] into `out`. */ | ||
| declare const lchToProphotoChannelsInto: (out: Float64Array | number[], l: number, c: number, h: number) => void; | ||
| /** | ||
| * Returns true if the color is within the ProPhoto (ROMM RGB) gamut. | ||
| * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ ProPhoto). | ||
| */ | ||
| declare const inGamutProphoto: (input: AnyColor) => boolean; | ||
| declare const prophoto: Plugin; | ||
| export { prophoto as default, inGamutProphoto, labToProphotoChannels, labToProphotoChannelsInto, lchToProphotoChannels, lchToProphotoChannelsInto, linearToProphotoChannels, linearToProphotoChannelsInto, oklchToProphotoChannels, oklchToProphotoChannelsInto }; |
| import { t as ProPhotoColor, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
| declare module '@colordx/core' { | ||
| interface Colordx { | ||
| toProphoto(precision?: number): ProPhotoColor; | ||
| toProphotoString(precision?: number): string; | ||
| } | ||
| namespace Colordx { | ||
| function toGamutProphoto(input: AnyColor): Colordx; | ||
| } | ||
| } | ||
| /** | ||
| * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded ProPhoto channels. | ||
| * This is the cheap step — only a matrix multiply + the ProPhoto gamma 1.8 curve, no cbrt. | ||
| */ | ||
| declare const linearToProphotoChannels: (lr: number, lg: number, lb: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of linearToProphotoChannels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */ | ||
| declare const linearToProphotoChannelsInto: (out: Float64Array | number[], lr: number, lg: number, lb: number) => void; | ||
| /** | ||
| * Convert OKLCH to gamma-encoded ProPhoto channels without object allocation. | ||
| * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may | ||
| * exceed this range — callers are responsible for clamping before byte encoding. | ||
| */ | ||
| declare const oklchToProphotoChannels: (l: number, c: number, h: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of oklchToProphotoChannels — writes [rr, rg, rb] into `out`. */ | ||
| declare const oklchToProphotoChannelsInto: (out: Float64Array | number[], l: number, c: number, h: number) => void; | ||
| /** | ||
| * Convert CIE Lab (D50) to gamma-encoded ProPhoto channels without object allocation. | ||
| * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1]. | ||
| * Goes Lab → XYZ D50 → linear sRGB → linear ProPhoto → ProPhoto gamma. | ||
| */ | ||
| declare const labToProphotoChannels: (l: number, a: number, b: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of labToProphotoChannels — writes [rr, rg, rb] into `out`. */ | ||
| declare const labToProphotoChannelsInto: (out: Float64Array | number[], l: number, a: number, b: number) => void; | ||
| /** | ||
| * Convert CIE LCH (D50) to gamma-encoded ProPhoto channels without object allocation. | ||
| * Polar-to-rectangular to Lab, then Lab → gamma ProPhoto. | ||
| */ | ||
| declare const lchToProphotoChannels: (l: number, c: number, h: number) => [number, number, number]; | ||
| /** Zero-allocation sibling of lchToProphotoChannels — writes [rr, rg, rb] into `out`. */ | ||
| declare const lchToProphotoChannelsInto: (out: Float64Array | number[], l: number, c: number, h: number) => void; | ||
| /** | ||
| * Returns true if the color is within the ProPhoto (ROMM RGB) gamut. | ||
| * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ ProPhoto). | ||
| */ | ||
| declare const inGamutProphoto: (input: AnyColor) => boolean; | ||
| declare const prophoto: Plugin; | ||
| export { prophoto as default, inGamutProphoto, labToProphotoChannels, labToProphotoChannelsInto, lchToProphotoChannels, lchToProphotoChannelsInto, linearToProphotoChannels, linearToProphotoChannelsInto, oklchToProphotoChannels, oklchToProphotoChannelsInto }; |
| import {p,o,G,H as H$1,O,P,E as E$1,u,F,q as q$1,r,t,s}from'../chunk-JT2PPQ6V.mjs';import {a}from'../chunk-2FEDFNW7.mjs';import'../chunk-YQKSXMBN.mjs';import {h}from'../chunk-WGY6QKPW.mjs';import'../chunk-GLKEY6D3.mjs';import {b}from'../chunk-IOXRZECH.mjs';var $=(o,n,t)=>a(...q$1(o,n,t)),A=(o,n,t)=>{let[r,e,m]=p(o,n,t);return [h(r),h(e),h(m)]},S=(o$1,n,t,r)=>{o(o$1,n,t,r),o$1[0]=h(o$1[0]),o$1[1]=h(o$1[1]),o$1[2]=h(o$1[2]);},E=(o,n,t)=>A(...G(o,n,t)),q=(o,n,t,r)=>{H$1(o,n,t,r),S(o,o[0],o[1],o[2]);},I=Math.PI/180,R=(o,n,t)=>A(...O(o,n,t)),v=(o,n,t,r)=>{P(o,n,t,r),S(o,o[0],o[1],o[2]);},z=(o,n,t)=>{let r=t*I;return R(o,n*Math.cos(r),n*Math.sin(r))},H=(o,n,t,r)=>{let e=r*I;v(o,n,t*Math.cos(e),t*Math.sin(e));},J=o=>E$1(o,u),M=(o,n,t$1)=>{o.toGamutProphoto=r=>{let e=F(r,u,$);if(e===null)return new o(r);let[m,p,a]=e.linear,[k,F$1,G]=q$1(m,p,a);return o._makeFromLinearSrgb(k,F$1,G,e.alpha)},o.prototype.toProphoto=function(r$1=4){let{r:e,g:m,b:p,alpha:a}=r(this._rawRgb());return {r:b(e,r$1),g:b(m,r$1),b:b(p,r$1),alpha:a,colorSpace:"prophoto-rgb"}},o.prototype.toProphotoString=function(r=4){let{r:e,g:m,b:p,alpha:a}=this.toProphoto(r);return a<1?`color(prophoto-rgb ${e} ${m} ${p} / ${a})`:`color(prophoto-rgb ${e} ${m} ${p})`},n.push(t,s),t$1.push([t,"prophoto-rgb"],[s,"prophoto-rgb"]);},K=M;export{K as default,J as inGamutProphoto,R as labToProphotoChannels,v as labToProphotoChannelsInto,z as lchToProphotoChannels,H as lchToProphotoChannelsInto,A as linearToProphotoChannels,S as linearToProphotoChannelsInto,E as oklchToProphotoChannels,q as oklchToProphotoChannelsInto};//# sourceMappingURL=prophoto.mjs.map | ||
| //# sourceMappingURL=prophoto.mjs.map |
| {"version":3,"sources":["../../src/plugins/prophoto.ts"],"names":["prophotoFromLinearConverter","r","g","b","linearSrgbToOklab","linearProphotoToSrgb","linearToProphotoChannels","lr","lg","lb","srgbLinearToProphotoLinear","prophotoFromLinear","linearToProphotoChannelsInto","out","srgbLinearToProphotoLinearInto","oklchToProphotoChannels","l","c","h","oklchToLinear","oklchToProphotoChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToProphotoChannels","a","labToLinearSrgb","labToProphotoChannelsInto","labToLinearSrgbInto","lchToProphotoChannels","hRad","lchToProphotoChannelsInto","inGamutProphoto","input","inGamutCustom","oklabToLinearProphoto","prophoto","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lrR","lrG","lrB","precision","alpha","rgbToProphotoRaw","round","parseProphotoString","parseProphotoObject","prophoto_default"],"mappings":"iQAiBA,IAAMA,EAA8B,CAACC,CAAAA,CAAWC,EAAWC,CAAAA,GACzDC,CAAAA,CAAkB,GAAGC,GAAAA,CAAqBJ,CAAAA,CAAGC,EAAGC,CAAC,CAAC,EAiBvCG,CAAAA,CAA2B,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CACxG,GAAM,CAAC,EAAGP,CAAAA,CAAGC,CAAC,EAAIO,CAAAA,CAA2BH,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACvD,OAAO,CAACE,CAAAA,CAAmB,CAAC,CAAA,CAAGA,CAAAA,CAAmBT,CAAC,CAAA,CAAGS,CAAAA,CAAmBR,CAAC,CAAC,CAC7E,EAGaS,CAAAA,CAA+B,CAC1CC,IACAN,CAAAA,CACAC,CAAAA,CACAC,IACS,CACTK,CAAAA,CAA+BD,IAAKN,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CAC9CI,GAAAA,CAAI,CAAC,CAAA,CAAIF,CAAAA,CAAmBE,IAAI,CAAC,CAAE,EACnCA,GAAAA,CAAI,CAAC,EAAIF,CAAAA,CAAmBE,GAAAA,CAAI,CAAC,CAAE,CAAA,CACnCA,IAAI,CAAC,CAAA,CAAIF,EAAmBE,GAAAA,CAAI,CAAC,CAAE,EACrC,CAAA,CAOaE,EAA0B,CAACC,CAAAA,CAAWC,EAAWC,CAAAA,GAC5DZ,CAAAA,CAAyB,GAAGa,CAAAA,CAAcH,CAAAA,CAAGC,EAAGC,CAAC,CAAC,EAGvCE,CAAAA,CAA8B,CAACP,EAA8BG,CAAAA,CAAWC,CAAAA,CAAWC,IAAoB,CAClHG,GAAAA,CAAkBR,EAAKG,CAAAA,CAAGC,CAAAA,CAAGC,CAAC,CAAA,CAC9BN,CAAAA,CAA6BC,EAAKA,CAAAA,CAAI,CAAC,EAAI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AAA,EAAIC,CAAC,CAAA,CAAA,EAAIC,CAAC,GACxG,CAAA,CACAkC,CAAAA,CAAQ,KAAKW,CAAAA,CAAqBC,CAAmB,EACrDX,GAAAA,CAAc,IAAA,CAAK,CAACU,CAAAA,CAAqB,cAAc,EAAG,CAACC,CAAAA,CAAqB,cAAc,CAAC,EACjG,EAEOC,CAAAA,CAAQf","file":"prophoto.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearProphotoToSrgb,\n oklabToLinearProphoto,\n parseProphotoObject,\n parseProphotoString,\n rgbToProphotoRaw,\n srgbLinearToProphotoLinear,\n srgbLinearToProphotoLinearInto,\n} from '../colorModels/prophoto.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { prophotoFromLinear } from '../transfer.js';\nimport type { AnyColor, ProPhotoColor } from '../types.js';\n\nconst prophotoFromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearProphotoToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toProphoto(precision?: number): ProPhotoColor;\n toProphotoString(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutProphoto(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded ProPhoto channels.\n * This is the cheap step — only a matrix multiply + the ProPhoto gamma 1.8 curve, no cbrt.\n */\nexport const linearToProphotoChannels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToProphotoLinear(lr, lg, lb);\n return [prophotoFromLinear(r), prophotoFromLinear(g), prophotoFromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToProphotoChannels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToProphotoChannelsInto = (\n out: Float64Array | number[],\n lr: number,\n lg: number,\n lb: number\n): void => {\n srgbLinearToProphotoLinearInto(out, lr, lg, lb);\n out[0] = prophotoFromLinear(out[0]!);\n out[1] = prophotoFromLinear(out[1]!);\n out[2] = prophotoFromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded ProPhoto channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n */\nexport const oklchToProphotoChannels = (l: number, c: number, h: number): [number, number, number] =>\n linearToProphotoChannels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToProphotoChannels — writes [rr, rg, rb] into `out`. */\nexport const oklchToProphotoChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToProphotoChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded ProPhoto channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear ProPhoto → ProPhoto gamma.\n */\nexport const labToProphotoChannels = (l: number, a: number, b: number): [number, number, number] =>\n linearToProphotoChannels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToProphotoChannels — writes [rr, rg, rb] into `out`. */\nexport const labToProphotoChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToProphotoChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded ProPhoto channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma ProPhoto.\n */\nexport const lchToProphotoChannels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToProphotoChannels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToProphotoChannels — writes [rr, rg, rb] into `out`. */\nexport const lchToProphotoChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToProphotoChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the ProPhoto (ROMM RGB) gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ ProPhoto).\n */\nexport const inGamutProphoto = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearProphoto);\n\nconst prophoto: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutProphoto = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearProphoto, prophotoFromLinearConverter);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-ProPhoto → linear-sRGB (wide-gamut when the ProPhoto color is outside\n // sRGB), then gamma-encode for storage. No round-trip through OKLab.\n const [lrR, lrG, lrB] = mapped.linear;\n const [lr, lg, lb] = linearProphotoToSrgb(lrR, lrG, lrB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toProphoto = function (precision = 4) {\n const { r, g, b, alpha } = rgbToProphotoRaw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'prophoto-rgb' as const,\n };\n };\n ColordxClass.prototype.toProphotoString = function (precision = 4) {\n const { r, g, b, alpha } = this.toProphoto(precision);\n return alpha < 1 ? `color(prophoto-rgb ${r} ${g} ${b} / ${alpha})` : `color(prophoto-rgb ${r} ${g} ${b})`;\n };\n parsers.push(parseProphotoString, parseProphotoObject);\n formatParsers.push([parseProphotoString, 'prophoto-rgb'], [parseProphotoObject, 'prophoto-rgb']);\n};\n\nexport default prophoto;\n"]} |
+1
-1
@@ -1,2 +0,2 @@ | ||
| 'use strict';var chunkUAXI5JGL_cjs=require('./chunk-UAXI5JGL.cjs'),chunkYXTI4MTI_cjs=require('./chunk-YXTI4MTI.cjs'),chunkTRRLWCL6_cjs=require('./chunk-TRRLWCL6.cjs');require('./chunk-PI5KJ3ZM.cjs');var chunkINDSIUQQ_cjs=require('./chunk-INDSIUQQ.cjs'),chunk3V4MONNR_cjs=require('./chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var X=n=>({h:chunkYISEJCI6_cjs.c(n.h),s:chunkYISEJCI6_cjs.a(n.s,0,100),l:chunkYISEJCI6_cjs.a(n.l,0,100),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(n.alpha,3),0,1)}),y={h:0,s:0,l:0,alpha:0},O=({r:n,g:r,b:o,alpha:t})=>{let e=n/255,l=r/255,s=o/255,a=Math.max(e,l,s),c=Math.min(e,l,s),m=(a+c)/2,d=0,f=0;if(a!==c){let R=a-c;switch(f=m>.5?R/(2-a-c):R/(a+c),a){case e:d=((l-s)/R+(l<s?6:0))/6;break;case l:d=((s-e)/R+2)/6;break;case s:d=((e-l)/R+4)/6;break}}let k=d*360;return y.h=k>=0&&k<360?k:(k%360+360)%360,y.s=chunkYISEJCI6_cjs.a(f*100,0,100),y.l=chunkYISEJCI6_cjs.a(m*100,0,100),y.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t,3),0,1),y};var v=(n,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?n+(r-n)*6*o:o<1/2?r:o<2/3?n+(r-n)*(2/3-o)*6:n),_=({h:n,s:r,l:o,alpha:t})=>{let e=r/100,l=o/100,s=l<.5?l*(1+e):l+e-l*e,a=2*l-s,c=(n%360+360)%360/360;return {r:v(a,s,c+1/3)*255,g:v(a,s,c)*255,b:v(a,s,c-1/3)*255,alpha:t}},V=n=>{if(!chunkYISEJCI6_cjs.h(n)||!chunkYISEJCI6_cjs.i(n,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:e=1}=n;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(e)?null:_(X({h:chunkYISEJCI6_cjs.g(r),s:chunkYISEJCI6_cjs.g(o),l:chunkYISEJCI6_cjs.g(t),alpha:chunkYISEJCI6_cjs.g(e)}))},Lr=new RegExp(`^hsla?\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${chunkYISEJCI6_cjs.j})%\\s*,\\s*(?<l_c>${chunkYISEJCI6_cjs.j})%(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${chunkYISEJCI6_cjs.k})(?<sp_s>%?)\\s+(?<l_s>${chunkYISEJCI6_cjs.k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),J=n=>{if(typeof n!="string")return null;let r=Lr.exec(n.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",e=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[t]??1),l=chunkYISEJCI6_cjs.l(r.s_c??r.s_s),s=chunkYISEJCI6_cjs.l(r.l_c??r.l_s),a=r.al_c??r.al_s,c=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let m=a===void 0?1:chunkYISEJCI6_cjs.l(a)/(c?100:1);return _(X({h:e,s:l,l:s,alpha:m}))};var Q=({l:n,c:r,h:o,alpha:t})=>({l:n,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),W=n=>{let{l:r,a:o,b:t,alpha:e}=chunkTRRLWCL6_cjs.b(n),l=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:l,h:l<4e-6?0:chunkYISEJCI6_cjs.c(s),alpha:e}},M=n=>chunkTRRLWCL6_cjs.d(Q(n)),Y=n=>chunkTRRLWCL6_cjs.c(Q(n)),Z=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace==="lch"||!chunkYISEJCI6_cjs.i(n,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:e=1}=n;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(e)||chunkYISEJCI6_cjs.g(r)>1?null:Y({l:chunkYISEJCI6_cjs.g(r),c:Math.max(0,chunkYISEJCI6_cjs.g(o)),h:chunkYISEJCI6_cjs.c(chunkYISEJCI6_cjs.g(t)),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(e),0,1)})},Ir=new RegExp(`^oklch\\(\\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"),rr=n=>{if(typeof n!="string")return null;let r=Ir.exec(n.trim())?.groups;if(!r)return null;let o=r.lp?chunkYISEJCI6_cjs.l(r.l)/100:chunkYISEJCI6_cjs.l(r.l),t=Math.max(0,r.cp?chunkYISEJCI6_cjs.l(r.c)*.004:chunkYISEJCI6_cjs.l(r.c)),e=r.hu?.toLowerCase()??"deg",l=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[e]??1),s=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return Y({l:o,c:t,h:chunkYISEJCI6_cjs.c(l),alpha:chunkYISEJCI6_cjs.a(s,0,1)})};var or=[[chunkUAXI5JGL_cjs.b,"hex"],[chunk3V4MONNR_cjs.c,"rgb"],[J,"hsl"],[rr,"oklch"],[chunkTRRLWCL6_cjs.h,"oklab"]],tr=[[chunk3V4MONNR_cjs.b,"rgb"],[V,"hsl"],[chunkTRRLWCL6_cjs.g,"oklab"],[Z,"oklch"]],nr=or.map(([n])=>n),lr=tr.map(([n])=>n),er=[...nr,...lr],P=[...er],N=[],sr=n=>{if(n==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof n=="string"?nr:lr;for(let o of r){let t=o(n);if(t)return t}for(let o=er.length;o<P.length;o++){let t=P[o](n);if(t)return t}return null},Pr=n=>{if(n==="transparent")return "name";let r=typeof n=="string"?or:tr;for(let[o,t]of r)if(o(n))return t;for(let[o,t]of N)if(o(n))return t};var ar=Symbol(),u=class n{_rgb;_valid;constructor(r,o){if(r===ar)this._valid=true,this._rgb=o;else if(r instanceof n){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=sr(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(this._rgb.alpha,3),0,1);}static _make(r){return new n(ar,r)}static _makeFromLinearSrgb(r,o,t,e){let l=chunkINDSIUQQ_cjs.b(r)*255,s=chunkINDSIUQQ_cjs.b(o)*255,a=chunkINDSIUQQ_cjs.b(t)*255;return n._make({r:l>=0&&l<.5?0:l>254.5&&l<=255?255:l,g:s>=0&&s<.5?0:s>254.5&&s<=255?255:s,b:a>=0&&a<.5?0:a>254.5&&a<=255?255:a,alpha:e})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return {r:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255),g:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),b:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),alpha:e}}_rawRgb(){return this._rgb}toRgbString(r){let{r:o,g:t,b:e,alpha:l}=this._rgb,s=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),a=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),c=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(e),0,255);return r?.legacy?l<1?`rgba(${s}, ${a}, ${c}, ${l})`:`rgb(${s}, ${a}, ${c})`:l<1?`rgb(${s} ${a} ${c} / ${l})`:`rgb(${s} ${a} ${c})`}toHex(){return chunkUAXI5JGL_cjs.c(this._rgb)}toHex8(){return chunkUAXI5JGL_cjs.d(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255)<<16|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255)<<8|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255)}toHsl(r=2){let{h:o,s:t,l:e,alpha:l}=O(this._rgb),s=chunkYISEJCI6_cjs.b(o,r);return {h:s>=360?0:s,s:chunkYISEJCI6_cjs.b(t,r),l:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toHslString(r=2){let{h:o,s:t,l:e,alpha:l}=this.toHsl(r);return l<1?`hsl(${o} ${t}% ${e}% / ${l})`:`hsl(${o} ${t}% ${e}%)`}toOklab(r=5){let{l:o,a:t,b:e,alpha:l}=chunkTRRLWCL6_cjs.b(this._rgb);return {l:chunkYISEJCI6_cjs.b(o,r),a:chunkYISEJCI6_cjs.b(t,r),b:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toOklabString(r=5){let{l:o,a:t,b:e,alpha:l}=this.toOklab(r);return l<1?`oklab(${o} ${t} ${e} / ${l})`:`oklab(${o} ${t} ${e})`}toOklch(r=5){let{l:o,c:t,h:e,alpha:l}=W(this._rgb);return {l:chunkYISEJCI6_cjs.b(o,r),c:chunkYISEJCI6_cjs.b(t,r),h:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toOklchString(r=5){let{l:o,c:t,h:e,alpha:l}=this.toOklch(r),s=t===0?"none":e;return l<1?`oklch(${o} ${t} ${s} / ${l})`:`oklch(${o} ${t} ${s})`}brightness(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.b((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:n._make({...this._rgb,alpha:chunkYISEJCI6_cjs.b(chunkYISEJCI6_cjs.a(r,0,1),3)})}hue(r){let{h:o,s:t,l:e,alpha:l}=O(this._rgb);if(r===void 0){let s=chunkYISEJCI6_cjs.b(o,2);return s>=360?0:s}return n._make(_({h:r,s:t,l:e,alpha:l}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:n._make(M({...o,l:chunkYISEJCI6_cjs.a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:n._make(M({...o,c:chunkYISEJCI6_cjs.a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a=o?.relative?l*(1+r):l+r*100;return n._make(_({h:t,s:e,l:chunkYISEJCI6_cjs.a(a,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a=o?.relative?e*(1+r):e+r*100;return n._make(_({h:t,s:chunkYISEJCI6_cjs.a(a,0,100),l,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:e}=this._rgb;return n._make({r:255-r,g:255-o,b:255-t,alpha:e})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new n(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:n._make({r:chunkYISEJCI6_cjs.a(r,0,255),g:chunkYISEJCI6_cjs.a(o,0,255),b:chunkYISEJCI6_cjs.a(t,0,255),alpha:e})}mapSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[l,s,a]=chunkTRRLWCL6_cjs.a(chunkINDSIUQQ_cjs.a(r/255),chunkINDSIUQQ_cjs.a(o/255),chunkINDSIUQQ_cjs.a(t/255)),c=l>1-1e-7?1:l<1e-7?0:l,m=chunkYXTI4MTI_cjs.p({l:c,a:s,b:a,alpha:e});if(m===null)return this;let[d,f,k]=m.linear;return n._makeFromLinearSrgb(d,f,k,m.alpha)}static toGamutSrgb},Ar=n=>new u(n),vr=n=>new u(n).toHex8(),Mr=n=>{n.forEach(r=>r(u,P,N));},Nr=(n,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:e}=new u(n).toOklab(),l=1/0,s=r[0];for(let a of r){let{l:c,a:m,b:d}=new u(a).toOklab(),f=(c-o)**2+(m-t)**2+(d-e)**2;f<l&&(l=f,s=a);}return s},Fr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=n=>{let r=chunkYXTI4MTI_cjs.p(n);if(r===null)return new u(n);let[o,t,e]=r.linear;return u._makeFromLinearSrgb(o,t,e,r.alpha)};Object.defineProperty(exports,"toHexByte",{enumerable:true,get:function(){return chunkUAXI5JGL_cjs.a}});Object.defineProperty(exports,"inGamutSrgb",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.o}});Object.defineProperty(exports,"labToLinearAndSrgb",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.I}});Object.defineProperty(exports,"labToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.J}});Object.defineProperty(exports,"labToLinearSrgb",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.A}});Object.defineProperty(exports,"labToLinearSrgbInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.B}});Object.defineProperty(exports,"labToRgbChannels",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.E}});Object.defineProperty(exports,"labToRgbChannelsInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.F}});Object.defineProperty(exports,"lchToLinearAndSrgb",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.K}});Object.defineProperty(exports,"lchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.L}});Object.defineProperty(exports,"lchToLinearSrgb",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.C}});Object.defineProperty(exports,"lchToLinearSrgbInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.D}});Object.defineProperty(exports,"lchToRgbChannels",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.G}});Object.defineProperty(exports,"lchToRgbChannelsInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.H}});Object.defineProperty(exports,"oklchToLinear",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.s}});Object.defineProperty(exports,"oklchToLinearAndSrgb",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.w}});Object.defineProperty(exports,"oklchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.x}});Object.defineProperty(exports,"oklchToLinearInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.t}});Object.defineProperty(exports,"oklchToRgbChannels",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.u}});Object.defineProperty(exports,"oklchToRgbChannelsInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.v}});Object.defineProperty(exports,"rgbToLinear",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.y}});Object.defineProperty(exports,"rgbToLinearInto",{enumerable:true,get:function(){return chunkYXTI4MTI_cjs.z}});exports.Colordx=u;exports.colordx=Ar;exports.extend=Mr;exports.getFormat=Pr;exports.nearest=Nr;exports.random=Fr;exports.toHex8=vr;//# sourceMappingURL=index.cjs.map | ||
| 'use strict';var chunkUAXI5JGL_cjs=require('./chunk-UAXI5JGL.cjs'),chunkDCLFNJD3_cjs=require('./chunk-DCLFNJD3.cjs'),chunkZNT33DPT_cjs=require('./chunk-ZNT33DPT.cjs');require('./chunk-6FI7U3TH.cjs');var chunkVSMEJU4Z_cjs=require('./chunk-VSMEJU4Z.cjs'),chunk2KB6V6KD_cjs=require('./chunk-2KB6V6KD.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var X=n=>({h:chunkYISEJCI6_cjs.c(n.h),s:chunkYISEJCI6_cjs.a(n.s,0,100),l:chunkYISEJCI6_cjs.a(n.l,0,100),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(n.alpha,3),0,1)}),y={h:0,s:0,l:0,alpha:0},O=({r:n,g:r,b:o,alpha:t})=>{let e=n/255,l=r/255,s=o/255,a=Math.max(e,l,s),c=Math.min(e,l,s),p=(a+c)/2,d=0,f=0;if(a!==c){let R=a-c;switch(f=p>.5?R/(2-a-c):R/(a+c),a){case e:d=((l-s)/R+(l<s?6:0))/6;break;case l:d=((s-e)/R+2)/6;break;case s:d=((e-l)/R+4)/6;break}}let k=d*360;return y.h=k>=0&&k<360?k:(k%360+360)%360,y.s=chunkYISEJCI6_cjs.a(f*100,0,100),y.l=chunkYISEJCI6_cjs.a(p*100,0,100),y.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t,3),0,1),y};var v=(n,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?n+(r-n)*6*o:o<1/2?r:o<2/3?n+(r-n)*(2/3-o)*6:n),_=({h:n,s:r,l:o,alpha:t})=>{let e=r/100,l=o/100,s=l<.5?l*(1+e):l+e-l*e,a=2*l-s,c=(n%360+360)%360/360;return {r:v(a,s,c+1/3)*255,g:v(a,s,c)*255,b:v(a,s,c-1/3)*255,alpha:t}},V=n=>{if(!chunkYISEJCI6_cjs.h(n)||!chunkYISEJCI6_cjs.i(n,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:e=1}=n;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(e)?null:_(X({h:chunkYISEJCI6_cjs.g(r),s:chunkYISEJCI6_cjs.g(o),l:chunkYISEJCI6_cjs.g(t),alpha:chunkYISEJCI6_cjs.g(e)}))},Lr=new RegExp(`^hsla?\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${chunkYISEJCI6_cjs.j})%\\s*,\\s*(?<l_c>${chunkYISEJCI6_cjs.j})%(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${chunkYISEJCI6_cjs.k})(?<sp_s>%?)\\s+(?<l_s>${chunkYISEJCI6_cjs.k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),J=n=>{if(typeof n!="string")return null;let r=Lr.exec(n.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",e=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[t]??1),l=chunkYISEJCI6_cjs.l(r.s_c??r.s_s),s=chunkYISEJCI6_cjs.l(r.l_c??r.l_s),a=r.al_c??r.al_s,c=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let p=a===void 0?1:chunkYISEJCI6_cjs.l(a)/(c?100:1);return _(X({h:e,s:l,l:s,alpha:p}))};var Q=({l:n,c:r,h:o,alpha:t})=>({l:n,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),W=n=>{let{l:r,a:o,b:t,alpha:e}=chunkZNT33DPT_cjs.b(n),l=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:l,h:l<4e-6?0:chunkYISEJCI6_cjs.c(s),alpha:e}},M=n=>chunkZNT33DPT_cjs.d(Q(n)),Y=n=>chunkZNT33DPT_cjs.c(Q(n)),Z=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace==="lch"||!chunkYISEJCI6_cjs.i(n,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:e=1}=n;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(e)||chunkYISEJCI6_cjs.g(r)>1?null:Y({l:chunkYISEJCI6_cjs.g(r),c:Math.max(0,chunkYISEJCI6_cjs.g(o)),h:chunkYISEJCI6_cjs.c(chunkYISEJCI6_cjs.g(t)),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(e),0,1)})},Pr=new RegExp(`^oklch\\(\\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"),rr=n=>{if(typeof n!="string")return null;let r=Pr.exec(n.trim())?.groups;if(!r)return null;let o=r.lp?chunkYISEJCI6_cjs.l(r.l)/100:chunkYISEJCI6_cjs.l(r.l),t=Math.max(0,r.cp?chunkYISEJCI6_cjs.l(r.c)*.004:chunkYISEJCI6_cjs.l(r.c)),e=r.hu?.toLowerCase()??"deg",l=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[e]??1),s=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return Y({l:o,c:t,h:chunkYISEJCI6_cjs.c(l),alpha:chunkYISEJCI6_cjs.a(s,0,1)})};var or=[[chunkUAXI5JGL_cjs.b,"hex"],[chunk2KB6V6KD_cjs.c,"rgb"],[J,"hsl"],[rr,"oklch"],[chunkZNT33DPT_cjs.h,"oklab"]],tr=[[chunk2KB6V6KD_cjs.b,"rgb"],[V,"hsl"],[chunkZNT33DPT_cjs.g,"oklab"],[Z,"oklch"]],nr=or.map(([n])=>n),lr=tr.map(([n])=>n),er=[...nr,...lr],I=[...er],N=[],sr=n=>{if(n==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof n=="string"?nr:lr;for(let o of r){let t=o(n);if(t)return t}for(let o=er.length;o<I.length;o++){let t=I[o](n);if(t)return t}return null},Ir=n=>{if(n==="transparent")return "name";let r=typeof n=="string"?or:tr;for(let[o,t]of r)if(o(n))return t;for(let[o,t]of N)if(o(n))return t};var ar=Symbol(),u=class n{_rgb;_valid;constructor(r,o){if(r===ar)this._valid=true,this._rgb=o;else if(r instanceof n){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=sr(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(this._rgb.alpha,3),0,1);}static _make(r){return new n(ar,r)}static _makeFromLinearSrgb(r,o,t,e){let l=chunkVSMEJU4Z_cjs.b(r)*255,s=chunkVSMEJU4Z_cjs.b(o)*255,a=chunkVSMEJU4Z_cjs.b(t)*255;return n._make({r:l>=0&&l<.5?0:l>254.5&&l<=255?255:l,g:s>=0&&s<.5?0:s>254.5&&s<=255?255:s,b:a>=0&&a<.5?0:a>254.5&&a<=255?255:a,alpha:e})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return {r:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255),g:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),b:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),alpha:e}}_rawRgb(){return this._rgb}toRgbString(r){let{r:o,g:t,b:e,alpha:l}=this._rgb,s=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),a=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),c=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(e),0,255);return r?.legacy?l<1?`rgba(${s}, ${a}, ${c}, ${l})`:`rgb(${s}, ${a}, ${c})`:l<1?`rgb(${s} ${a} ${c} / ${l})`:`rgb(${s} ${a} ${c})`}toHex(){return chunkUAXI5JGL_cjs.c(this._rgb)}toHex8(){return chunkUAXI5JGL_cjs.d(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255)<<16|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255)<<8|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255)}toHsl(r=2){let{h:o,s:t,l:e,alpha:l}=O(this._rgb),s=chunkYISEJCI6_cjs.b(o,r);return {h:s>=360?0:s,s:chunkYISEJCI6_cjs.b(t,r),l:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toHslString(r=2){let{h:o,s:t,l:e,alpha:l}=this.toHsl(r);return l<1?`hsl(${o} ${t}% ${e}% / ${l})`:`hsl(${o} ${t}% ${e}%)`}toOklab(r=5){let{l:o,a:t,b:e,alpha:l}=chunkZNT33DPT_cjs.b(this._rgb);return {l:chunkYISEJCI6_cjs.b(o,r),a:chunkYISEJCI6_cjs.b(t,r),b:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toOklabString(r=5){let{l:o,a:t,b:e,alpha:l}=this.toOklab(r);return l<1?`oklab(${o} ${t} ${e} / ${l})`:`oklab(${o} ${t} ${e})`}toOklch(r=5){let{l:o,c:t,h:e,alpha:l}=W(this._rgb);return {l:chunkYISEJCI6_cjs.b(o,r),c:chunkYISEJCI6_cjs.b(t,r),h:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toOklchString(r=5){let{l:o,c:t,h:e,alpha:l}=this.toOklch(r),s=t===0?"none":e;return l<1?`oklch(${o} ${t} ${s} / ${l})`:`oklch(${o} ${t} ${s})`}brightness(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.b((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:n._make({...this._rgb,alpha:chunkYISEJCI6_cjs.b(chunkYISEJCI6_cjs.a(r,0,1),3)})}hue(r){let{h:o,s:t,l:e,alpha:l}=O(this._rgb);if(r===void 0){let s=chunkYISEJCI6_cjs.b(o,2);return s>=360?0:s}return n._make(_({h:r,s:t,l:e,alpha:l}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:n._make(M({...o,l:chunkYISEJCI6_cjs.a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:n._make(M({...o,c:chunkYISEJCI6_cjs.a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a=o?.relative?l*(1+r):l+r*100;return n._make(_({h:t,s:e,l:chunkYISEJCI6_cjs.a(a,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a=o?.relative?e*(1+r):e+r*100;return n._make(_({h:t,s:chunkYISEJCI6_cjs.a(a,0,100),l,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:e}=this._rgb;return n._make({r:255-r,g:255-o,b:255-t,alpha:e})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new n(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:n._make({r:chunkYISEJCI6_cjs.a(r,0,255),g:chunkYISEJCI6_cjs.a(o,0,255),b:chunkYISEJCI6_cjs.a(t,0,255),alpha:e})}mapSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[l,s,a]=chunkZNT33DPT_cjs.a(chunkVSMEJU4Z_cjs.a(r/255),chunkVSMEJU4Z_cjs.a(o/255),chunkVSMEJU4Z_cjs.a(t/255)),c=l>1-1e-7?1:l<1e-7?0:l,p=chunkDCLFNJD3_cjs.D({l:c,a:s,b:a,alpha:e});if(p===null)return this;let[d,f,k]=p.linear;return n._makeFromLinearSrgb(d,f,k,p.alpha)}static toGamutSrgb},Ar=n=>new u(n),vr=n=>new u(n).toHex8(),Mr=n=>{n.forEach(r=>r(u,I,N));},Nr=(n,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:e}=new u(n).toOklab(),l=1/0,s=r[0];for(let a of r){let{l:c,a:p,b:d}=new u(a).toOklab(),f=(c-o)**2+(p-t)**2+(d-e)**2;f<l&&(l=f,s=a);}return s},Fr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=n=>{let r=chunkDCLFNJD3_cjs.D(n);if(r===null)return new u(n);let[o,t,e]=r.linear;return u._makeFromLinearSrgb(o,t,e,r.alpha)};Object.defineProperty(exports,"toHexByte",{enumerable:true,get:function(){return chunkUAXI5JGL_cjs.a}});Object.defineProperty(exports,"inGamutSrgb",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.C}});Object.defineProperty(exports,"labToLinearAndSrgb",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.W}});Object.defineProperty(exports,"labToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.X}});Object.defineProperty(exports,"labToLinearSrgb",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.O}});Object.defineProperty(exports,"labToLinearSrgbInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.P}});Object.defineProperty(exports,"labToRgbChannels",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.S}});Object.defineProperty(exports,"labToRgbChannelsInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.T}});Object.defineProperty(exports,"lchToLinearAndSrgb",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.Y}});Object.defineProperty(exports,"lchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.Z}});Object.defineProperty(exports,"lchToLinearSrgb",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.Q}});Object.defineProperty(exports,"lchToLinearSrgbInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.R}});Object.defineProperty(exports,"lchToRgbChannels",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.U}});Object.defineProperty(exports,"lchToRgbChannelsInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.V}});Object.defineProperty(exports,"oklchToLinear",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.G}});Object.defineProperty(exports,"oklchToLinearAndSrgb",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.K}});Object.defineProperty(exports,"oklchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.L}});Object.defineProperty(exports,"oklchToLinearInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.H}});Object.defineProperty(exports,"oklchToRgbChannels",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.I}});Object.defineProperty(exports,"oklchToRgbChannelsInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.J}});Object.defineProperty(exports,"rgbToLinear",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.M}});Object.defineProperty(exports,"rgbToLinearInto",{enumerable:true,get:function(){return chunkDCLFNJD3_cjs.N}});exports.Colordx=u;exports.colordx=Ar;exports.extend=Mr;exports.getFormat=Ir;exports.nearest=Nr;exports.random=Fr;exports.toHex8=vr;//# sourceMappingURL=index.cjs.map | ||
| //# sourceMappingURL=index.cjs.map |
+2
-2
@@ -1,3 +0,3 @@ | ||
| import { A as AnyColor, C as ColorFormat } from './colordx-dFaFF5rN.cjs'; | ||
| export { a as CmykColor, b as CmykColorInput, c as ColorParser, d as Colordx, H as HslColor, e as HslColorInput, f as HsvColor, g as HsvColorInput, h as HwbColor, i as HwbColorInput, L as LabColor, j as LabColorInput, k as LchColor, l as LchColorInput, O as OklabColor, m as OklabColorInput, n as OklchColor, o as OklchColorInput, P as P3Color, p as P3ColorInput, q as Plugin, R as Rec2020Color, r as Rec2020ColorInput, s as RgbColor, t as RgbColorInput, X as XyzColor, u as XyzColorInput, v as colordx, w as extend, x as nearest, y as random, z as toHex8 } from './colordx-dFaFF5rN.cjs'; | ||
| import { A as AnyColor, C as ColorFormat } from './colordx-DmR1sN5A.cjs'; | ||
| export { a as A98Color, b as A98ColorInput, c as CmykColor, d as CmykColorInput, e as ColorParser, f as Colordx, H as HslColor, g as HslColorInput, h as HsvColor, i as HsvColorInput, j as HwbColor, k as HwbColorInput, L as LabColor, l as LabColorInput, m as LchColor, n as LchColorInput, O as OklabColor, o as OklabColorInput, p as OklchColor, q as OklchColorInput, P as P3Color, r as P3ColorInput, s as Plugin, t as ProPhotoColor, u as ProPhotoColorInput, R as Rec2020Color, v as Rec2020ColorInput, w as RgbColor, x as RgbColorInput, X as XyzColor, y as XyzColorInput, z as colordx, B as extend, D as nearest, E as random, F as toHex8 } from './colordx-DmR1sN5A.cjs'; | ||
@@ -4,0 +4,0 @@ /** Convert a number in [0, 255] to a 2-char lowercase hex byte. Clamps and rounds out-of-range inputs. */ |
+2
-2
@@ -1,3 +0,3 @@ | ||
| import { A as AnyColor, C as ColorFormat } from './colordx-dFaFF5rN.js'; | ||
| export { a as CmykColor, b as CmykColorInput, c as ColorParser, d as Colordx, H as HslColor, e as HslColorInput, f as HsvColor, g as HsvColorInput, h as HwbColor, i as HwbColorInput, L as LabColor, j as LabColorInput, k as LchColor, l as LchColorInput, O as OklabColor, m as OklabColorInput, n as OklchColor, o as OklchColorInput, P as P3Color, p as P3ColorInput, q as Plugin, R as Rec2020Color, r as Rec2020ColorInput, s as RgbColor, t as RgbColorInput, X as XyzColor, u as XyzColorInput, v as colordx, w as extend, x as nearest, y as random, z as toHex8 } from './colordx-dFaFF5rN.js'; | ||
| import { A as AnyColor, C as ColorFormat } from './colordx-DmR1sN5A.js'; | ||
| export { a as A98Color, b as A98ColorInput, c as CmykColor, d as CmykColorInput, e as ColorParser, f as Colordx, H as HslColor, g as HslColorInput, h as HsvColor, i as HsvColorInput, j as HwbColor, k as HwbColorInput, L as LabColor, l as LabColorInput, m as LchColor, n as LchColorInput, O as OklabColor, o as OklabColorInput, p as OklchColor, q as OklchColorInput, P as P3Color, r as P3ColorInput, s as Plugin, t as ProPhotoColor, u as ProPhotoColorInput, R as Rec2020Color, v as Rec2020ColorInput, w as RgbColor, x as RgbColorInput, X as XyzColor, y as XyzColorInput, z as colordx, B as extend, D as nearest, E as random, F as toHex8 } from './colordx-DmR1sN5A.js'; | ||
@@ -4,0 +4,0 @@ /** Convert a number in [0, 255] to a 2-char lowercase hex byte. Clamps and rounds out-of-range inputs. */ |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import {b,c as c$3,d as d$1}from'./chunk-RJNXPIQM.mjs';export{a as toHexByte}from'./chunk-RJNXPIQM.mjs';import {p}from'./chunk-3LS3HCHH.mjs';export{o as inGamutSrgb,I as labToLinearAndSrgb,J as labToLinearAndSrgbInto,A as labToLinearSrgb,B as labToLinearSrgbInto,E as labToRgbChannels,F as labToRgbChannelsInto,K as lchToLinearAndSrgb,L as lchToLinearAndSrgbInto,C as lchToLinearSrgb,D as lchToLinearSrgbInto,G as lchToRgbChannels,H as lchToRgbChannelsInto,s as oklchToLinear,w as oklchToLinearAndSrgb,x as oklchToLinearAndSrgbInto,t as oklchToLinearInto,u as oklchToRgbChannels,v as oklchToRgbChannelsInto,y as rgbToLinear,z as rgbToLinearInto}from'./chunk-3LS3HCHH.mjs';import {h,g,c as c$2,b as b$4,a as a$1,d as d$2}from'./chunk-OX5CMKKI.mjs';import'./chunk-F4W4HJCD.mjs';import {b as b$3,a as a$2}from'./chunk-YLJRINFM.mjs';import {c,b as b$1}from'./chunk-Q3O3QQ4H.mjs';import {l,d,a,c as c$1,h as h$1,i,f,g as g$1,k,j,b as b$2}from'./chunk-IOXRZECH.mjs';var X=n=>({h:c$1(n.h),s:a(n.s,0,100),l:a(n.l,0,100),alpha:a(b$2(n.alpha,3),0,1)}),y={h:0,s:0,l:0,alpha:0},O=({r:n,g:r,b:o,alpha:t})=>{let e=n/255,l=r/255,s=o/255,a$1=Math.max(e,l,s),c=Math.min(e,l,s),m=(a$1+c)/2,d=0,f=0;if(a$1!==c){let R=a$1-c;switch(f=m>.5?R/(2-a$1-c):R/(a$1+c),a$1){case e:d=((l-s)/R+(l<s?6:0))/6;break;case l:d=((s-e)/R+2)/6;break;case s:d=((e-l)/R+4)/6;break}}let k=d*360;return y.h=k>=0&&k<360?k:(k%360+360)%360,y.s=a(f*100,0,100),y.l=a(m*100,0,100),y.alpha=a(b$2(t,3),0,1),y};var v=(n,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?n+(r-n)*6*o:o<1/2?r:o<2/3?n+(r-n)*(2/3-o)*6:n),_=({h:n,s:r,l:o,alpha:t})=>{let e=r/100,l=o/100,s=l<.5?l*(1+e):l+e-l*e,a=2*l-s,c=(n%360+360)%360/360;return {r:v(a,s,c+1/3)*255,g:v(a,s,c)*255,b:v(a,s,c-1/3)*255,alpha:t}},V=n=>{if(!h$1(n)||!i(n,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:e=1}=n;return !f(r)||!f(o)||!f(t)||!f(e)?null:_(X({h:g$1(r),s:g$1(o),l:g$1(t),alpha:g$1(e)}))},Lr=new RegExp(`^hsla?\\(\\s*(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${j})%\\s*,\\s*(?<l_c>${j})%(?:\\s*,\\s*(?<al_c>${j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${k})(?<sp_s>%?)\\s+(?<l_s>${k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),J=n=>{if(typeof n!="string")return null;let r=Lr.exec(n.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",e=l(r.h)*(d[t]??1),l$1=l(r.s_c??r.s_s),s=l(r.l_c??r.l_s),a=r.al_c??r.al_s,c=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let m=a===void 0?1:l(a)/(c?100:1);return _(X({h:e,s:l$1,l:s,alpha:m}))};var Q=({l:n,c:r,h:o,alpha:t})=>({l:n,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),W=n=>{let{l:r,a:o,b:t,alpha:e}=b$4(n),l=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:l,h:l<4e-6?0:c$1(s),alpha:e}},M=n=>d$2(Q(n)),Y=n=>c$2(Q(n)),Z=n=>{if(!h$1(n)||n.colorSpace==="lch"||!i(n,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:e=1}=n;return !f(r)||!f(o)||!f(t)||!f(e)||g$1(r)>1?null:Y({l:g$1(r),c:Math.max(0,g$1(o)),h:c$1(g$1(t)),alpha:a(g$1(e),0,1)})},Ir=new RegExp(`^oklch\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<c>${k})(?<cp>%?)\\s+(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),rr=n=>{if(typeof n!="string")return null;let r=Ir.exec(n.trim())?.groups;if(!r)return null;let o=r.lp?l(r.l)/100:l(r.l),t=Math.max(0,r.cp?l(r.c)*.004:l(r.c)),e=r.hu?.toLowerCase()??"deg",l$1=l(r.h)*(d[e]??1),s=r.al===void 0?1:l(r.al)/(r.alp?100:1);return Y({l:o,c:t,h:c$1(l$1),alpha:a(s,0,1)})};var or=[[b,"hex"],[c,"rgb"],[J,"hsl"],[rr,"oklch"],[h,"oklab"]],tr=[[b$1,"rgb"],[V,"hsl"],[g,"oklab"],[Z,"oklch"]],nr=or.map(([n])=>n),lr=tr.map(([n])=>n),er=[...nr,...lr],P=[...er],N=[],sr=n=>{if(n==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof n=="string"?nr:lr;for(let o of r){let t=o(n);if(t)return t}for(let o=er.length;o<P.length;o++){let t=P[o](n);if(t)return t}return null},Pr=n=>{if(n==="transparent")return "name";let r=typeof n=="string"?or:tr;for(let[o,t]of r)if(o(n))return t;for(let[o,t]of N)if(o(n))return t};var ar=Symbol(),u=class n{_rgb;_valid;constructor(r,o){if(r===ar)this._valid=true,this._rgb=o;else if(r instanceof n){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=sr(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=a(b$2(this._rgb.alpha,3),0,1);}static _make(r){return new n(ar,r)}static _makeFromLinearSrgb(r,o,t,e){let l=b$3(r)*255,s=b$3(o)*255,a=b$3(t)*255;return n._make({r:l>=0&&l<.5?0:l>254.5&&l<=255?255:l,g:s>=0&&s<.5?0:s>254.5&&s<=255?255:s,b:a>=0&&a<.5?0:a>254.5&&a<=255?255:a,alpha:e})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return {r:a(b$2(r),0,255),g:a(b$2(o),0,255),b:a(b$2(t),0,255),alpha:e}}_rawRgb(){return this._rgb}toRgbString(r){let{r:o,g:t,b:e,alpha:l}=this._rgb,s=a(b$2(o),0,255),a$1=a(b$2(t),0,255),c=a(b$2(e),0,255);return r?.legacy?l<1?`rgba(${s}, ${a$1}, ${c}, ${l})`:`rgb(${s}, ${a$1}, ${c})`:l<1?`rgb(${s} ${a$1} ${c} / ${l})`:`rgb(${s} ${a$1} ${c})`}toHex(){return c$3(this._rgb)}toHex8(){return d$1(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return a(b$2(r),0,255)<<16|a(b$2(o),0,255)<<8|a(b$2(t),0,255)}toHsl(r=2){let{h:o,s:t,l:e,alpha:l}=O(this._rgb),s=b$2(o,r);return {h:s>=360?0:s,s:b$2(t,r),l:b$2(e,r),alpha:l}}toHslString(r=2){let{h:o,s:t,l:e,alpha:l}=this.toHsl(r);return l<1?`hsl(${o} ${t}% ${e}% / ${l})`:`hsl(${o} ${t}% ${e}%)`}toOklab(r=5){let{l:o,a:t,b:e,alpha:l}=b$4(this._rgb);return {l:b$2(o,r),a:b$2(t,r),b:b$2(e,r),alpha:l}}toOklabString(r=5){let{l:o,a:t,b:e,alpha:l}=this.toOklab(r);return l<1?`oklab(${o} ${t} ${e} / ${l})`:`oklab(${o} ${t} ${e})`}toOklch(r=5){let{l:o,c:t,h:e,alpha:l}=W(this._rgb);return {l:b$2(o,r),c:b$2(t,r),h:b$2(e,r),alpha:l}}toOklchString(r=5){let{l:o,c:t,h:e,alpha:l}=this.toOklch(r),s=t===0?"none":e;return l<1?`oklch(${o} ${t} ${s} / ${l})`:`oklch(${o} ${t} ${s})`}brightness(){let{r,g:o,b:t}=this._rgb;return b$2((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:n._make({...this._rgb,alpha:b$2(a(r,0,1),3)})}hue(r){let{h:o,s:t,l:e,alpha:l}=O(this._rgb);if(r===void 0){let s=b$2(o,2);return s>=360?0:s}return n._make(_({h:r,s:t,l:e,alpha:l}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:n._make(M({...o,l:a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:n._make(M({...o,c:a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a$1=o?.relative?l*(1+r):l+r*100;return n._make(_({h:t,s:e,l:a(a$1,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a$1=o?.relative?e*(1+r):e+r*100;return n._make(_({h:t,s:a(a$1,0,100),l,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:e}=this._rgb;return n._make({r:255-r,g:255-o,b:255-t,alpha:e})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new n(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:n._make({r:a(r,0,255),g:a(o,0,255),b:a(t,0,255),alpha:e})}mapSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[l,s,a]=a$1(a$2(r/255),a$2(o/255),a$2(t/255)),c=l>1-1e-7?1:l<1e-7?0:l,m=p({l:c,a:s,b:a,alpha:e});if(m===null)return this;let[d,f,k]=m.linear;return n._makeFromLinearSrgb(d,f,k,m.alpha)}static toGamutSrgb},Ar=n=>new u(n),vr=n=>new u(n).toHex8(),Mr=n=>{n.forEach(r=>r(u,P,N));},Nr=(n,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:e}=new u(n).toOklab(),l=1/0,s=r[0];for(let a of r){let{l:c,a:m,b:d}=new u(a).toOklab(),f=(c-o)**2+(m-t)**2+(d-e)**2;f<l&&(l=f,s=a);}return s},Fr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=n=>{let r=p(n);if(r===null)return new u(n);let[o,t,e]=r.linear;return u._makeFromLinearSrgb(o,t,e,r.alpha)};export{u as Colordx,Ar as colordx,Mr as extend,Pr as getFormat,Nr as nearest,Fr as random,vr as toHex8};//# sourceMappingURL=index.mjs.map | ||
| import {b,c as c$3,d as d$1}from'./chunk-RJNXPIQM.mjs';export{a as toHexByte}from'./chunk-RJNXPIQM.mjs';import {D}from'./chunk-JT2PPQ6V.mjs';export{C as inGamutSrgb,W as labToLinearAndSrgb,X as labToLinearAndSrgbInto,O as labToLinearSrgb,P as labToLinearSrgbInto,S as labToRgbChannels,T as labToRgbChannelsInto,Y as lchToLinearAndSrgb,Z as lchToLinearAndSrgbInto,Q as lchToLinearSrgb,R as lchToLinearSrgbInto,U as lchToRgbChannels,V as lchToRgbChannelsInto,G as oklchToLinear,K as oklchToLinearAndSrgb,L as oklchToLinearAndSrgbInto,H as oklchToLinearInto,I as oklchToRgbChannels,J as oklchToRgbChannelsInto,M as rgbToLinear,N as rgbToLinearInto}from'./chunk-JT2PPQ6V.mjs';import {h,g,c as c$2,b as b$4,a as a$1,d as d$2}from'./chunk-2FEDFNW7.mjs';import'./chunk-YQKSXMBN.mjs';import {b as b$3,a as a$2}from'./chunk-WGY6QKPW.mjs';import {c,b as b$1}from'./chunk-GLKEY6D3.mjs';import {l,d,a,c as c$1,h as h$1,i,f,g as g$1,k,j,b as b$2}from'./chunk-IOXRZECH.mjs';var X=n=>({h:c$1(n.h),s:a(n.s,0,100),l:a(n.l,0,100),alpha:a(b$2(n.alpha,3),0,1)}),y={h:0,s:0,l:0,alpha:0},O=({r:n,g:r,b:o,alpha:t})=>{let e=n/255,l=r/255,s=o/255,a$1=Math.max(e,l,s),c=Math.min(e,l,s),p=(a$1+c)/2,d=0,f=0;if(a$1!==c){let R=a$1-c;switch(f=p>.5?R/(2-a$1-c):R/(a$1+c),a$1){case e:d=((l-s)/R+(l<s?6:0))/6;break;case l:d=((s-e)/R+2)/6;break;case s:d=((e-l)/R+4)/6;break}}let k=d*360;return y.h=k>=0&&k<360?k:(k%360+360)%360,y.s=a(f*100,0,100),y.l=a(p*100,0,100),y.alpha=a(b$2(t,3),0,1),y};var v=(n,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?n+(r-n)*6*o:o<1/2?r:o<2/3?n+(r-n)*(2/3-o)*6:n),_=({h:n,s:r,l:o,alpha:t})=>{let e=r/100,l=o/100,s=l<.5?l*(1+e):l+e-l*e,a=2*l-s,c=(n%360+360)%360/360;return {r:v(a,s,c+1/3)*255,g:v(a,s,c)*255,b:v(a,s,c-1/3)*255,alpha:t}},V=n=>{if(!h$1(n)||!i(n,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:e=1}=n;return !f(r)||!f(o)||!f(t)||!f(e)?null:_(X({h:g$1(r),s:g$1(o),l:g$1(t),alpha:g$1(e)}))},Lr=new RegExp(`^hsla?\\(\\s*(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${j})%\\s*,\\s*(?<l_c>${j})%(?:\\s*,\\s*(?<al_c>${j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${k})(?<sp_s>%?)\\s+(?<l_s>${k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),J=n=>{if(typeof n!="string")return null;let r=Lr.exec(n.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",e=l(r.h)*(d[t]??1),l$1=l(r.s_c??r.s_s),s=l(r.l_c??r.l_s),a=r.al_c??r.al_s,c=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let p=a===void 0?1:l(a)/(c?100:1);return _(X({h:e,s:l$1,l:s,alpha:p}))};var Q=({l:n,c:r,h:o,alpha:t})=>({l:n,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),W=n=>{let{l:r,a:o,b:t,alpha:e}=b$4(n),l=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:l,h:l<4e-6?0:c$1(s),alpha:e}},M=n=>d$2(Q(n)),Y=n=>c$2(Q(n)),Z=n=>{if(!h$1(n)||n.colorSpace==="lch"||!i(n,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:e=1}=n;return !f(r)||!f(o)||!f(t)||!f(e)||g$1(r)>1?null:Y({l:g$1(r),c:Math.max(0,g$1(o)),h:c$1(g$1(t)),alpha:a(g$1(e),0,1)})},Pr=new RegExp(`^oklch\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<c>${k})(?<cp>%?)\\s+(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),rr=n=>{if(typeof n!="string")return null;let r=Pr.exec(n.trim())?.groups;if(!r)return null;let o=r.lp?l(r.l)/100:l(r.l),t=Math.max(0,r.cp?l(r.c)*.004:l(r.c)),e=r.hu?.toLowerCase()??"deg",l$1=l(r.h)*(d[e]??1),s=r.al===void 0?1:l(r.al)/(r.alp?100:1);return Y({l:o,c:t,h:c$1(l$1),alpha:a(s,0,1)})};var or=[[b,"hex"],[c,"rgb"],[J,"hsl"],[rr,"oklch"],[h,"oklab"]],tr=[[b$1,"rgb"],[V,"hsl"],[g,"oklab"],[Z,"oklch"]],nr=or.map(([n])=>n),lr=tr.map(([n])=>n),er=[...nr,...lr],I=[...er],N=[],sr=n=>{if(n==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof n=="string"?nr:lr;for(let o of r){let t=o(n);if(t)return t}for(let o=er.length;o<I.length;o++){let t=I[o](n);if(t)return t}return null},Ir=n=>{if(n==="transparent")return "name";let r=typeof n=="string"?or:tr;for(let[o,t]of r)if(o(n))return t;for(let[o,t]of N)if(o(n))return t};var ar=Symbol(),u=class n{_rgb;_valid;constructor(r,o){if(r===ar)this._valid=true,this._rgb=o;else if(r instanceof n){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=sr(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=a(b$2(this._rgb.alpha,3),0,1);}static _make(r){return new n(ar,r)}static _makeFromLinearSrgb(r,o,t,e){let l=b$3(r)*255,s=b$3(o)*255,a=b$3(t)*255;return n._make({r:l>=0&&l<.5?0:l>254.5&&l<=255?255:l,g:s>=0&&s<.5?0:s>254.5&&s<=255?255:s,b:a>=0&&a<.5?0:a>254.5&&a<=255?255:a,alpha:e})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return {r:a(b$2(r),0,255),g:a(b$2(o),0,255),b:a(b$2(t),0,255),alpha:e}}_rawRgb(){return this._rgb}toRgbString(r){let{r:o,g:t,b:e,alpha:l}=this._rgb,s=a(b$2(o),0,255),a$1=a(b$2(t),0,255),c=a(b$2(e),0,255);return r?.legacy?l<1?`rgba(${s}, ${a$1}, ${c}, ${l})`:`rgb(${s}, ${a$1}, ${c})`:l<1?`rgb(${s} ${a$1} ${c} / ${l})`:`rgb(${s} ${a$1} ${c})`}toHex(){return c$3(this._rgb)}toHex8(){return d$1(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return a(b$2(r),0,255)<<16|a(b$2(o),0,255)<<8|a(b$2(t),0,255)}toHsl(r=2){let{h:o,s:t,l:e,alpha:l}=O(this._rgb),s=b$2(o,r);return {h:s>=360?0:s,s:b$2(t,r),l:b$2(e,r),alpha:l}}toHslString(r=2){let{h:o,s:t,l:e,alpha:l}=this.toHsl(r);return l<1?`hsl(${o} ${t}% ${e}% / ${l})`:`hsl(${o} ${t}% ${e}%)`}toOklab(r=5){let{l:o,a:t,b:e,alpha:l}=b$4(this._rgb);return {l:b$2(o,r),a:b$2(t,r),b:b$2(e,r),alpha:l}}toOklabString(r=5){let{l:o,a:t,b:e,alpha:l}=this.toOklab(r);return l<1?`oklab(${o} ${t} ${e} / ${l})`:`oklab(${o} ${t} ${e})`}toOklch(r=5){let{l:o,c:t,h:e,alpha:l}=W(this._rgb);return {l:b$2(o,r),c:b$2(t,r),h:b$2(e,r),alpha:l}}toOklchString(r=5){let{l:o,c:t,h:e,alpha:l}=this.toOklch(r),s=t===0?"none":e;return l<1?`oklch(${o} ${t} ${s} / ${l})`:`oklch(${o} ${t} ${s})`}brightness(){let{r,g:o,b:t}=this._rgb;return b$2((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:n._make({...this._rgb,alpha:b$2(a(r,0,1),3)})}hue(r){let{h:o,s:t,l:e,alpha:l}=O(this._rgb);if(r===void 0){let s=b$2(o,2);return s>=360?0:s}return n._make(_({h:r,s:t,l:e,alpha:l}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:n._make(M({...o,l:a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:n._make(M({...o,c:a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a$1=o?.relative?l*(1+r):l+r*100;return n._make(_({h:t,s:e,l:a(a$1,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a$1=o?.relative?e*(1+r):e+r*100;return n._make(_({h:t,s:a(a$1,0,100),l,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:e}=this._rgb;return n._make({r:255-r,g:255-o,b:255-t,alpha:e})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new n(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:n._make({r:a(r,0,255),g:a(o,0,255),b:a(t,0,255),alpha:e})}mapSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[l,s,a]=a$1(a$2(r/255),a$2(o/255),a$2(t/255)),c=l>1-1e-7?1:l<1e-7?0:l,p=D({l:c,a:s,b:a,alpha:e});if(p===null)return this;let[d,f,k]=p.linear;return n._makeFromLinearSrgb(d,f,k,p.alpha)}static toGamutSrgb},Ar=n=>new u(n),vr=n=>new u(n).toHex8(),Mr=n=>{n.forEach(r=>r(u,I,N));},Nr=(n,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:e}=new u(n).toOklab(),l=1/0,s=r[0];for(let a of r){let{l:c,a:p,b:d}=new u(a).toOklab(),f=(c-o)**2+(p-t)**2+(d-e)**2;f<l&&(l=f,s=a);}return s},Fr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=n=>{let r=D(n);if(r===null)return new u(n);let[o,t,e]=r.linear;return u._makeFromLinearSrgb(o,t,e,r.alpha)};export{u as Colordx,Ar as colordx,Mr as extend,Ir as getFormat,Nr as nearest,Fr as random,vr as toHex8};//# sourceMappingURL=index.mjs.map | ||
| //# sourceMappingURL=index.mjs.map |
@@ -1,2 +0,2 @@ | ||
| 'use strict';var chunkINDSIUQQ_cjs=require('../chunk-INDSIUQQ.cjs'),chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var f={Rsco:.2126729,Gsco:.7151522,Bsco:.072175},a={normBG:.56,normTXT:.57,revBG:.65,revTXT:.62,scale:1.14,loClip:.1,offset:.027,blkThrs:.022,blkClmp:1.414,deltaYmin:5e-4};function A(e,t,n){let o=l=>(l/255)**2.4,r=f.Rsco*o(e)+f.Gsco*o(t)+f.Bsco*o(n);return r>a.blkThrs?r:r+(a.blkThrs-r)**a.blkClmp}function p(e,t){let n=A(e.r,e.g,e.b),o=A(t.r,t.g,t.b);if(Math.abs(o-n)<a.deltaYmin)return 0;if(o>n){let r=(o**a.normBG-n**a.normTXT)*a.scale;return r<a.loClip?0:(r-a.offset)*100}else {let r=(o**a.revBG-n**a.revTXT)*a.scale;return r>-0.1?0:(r+a.offset)*100}}var h=e=>{e.prototype.luminance=function(){let{r:t,g:n,b:o}=this._rawRgb();return chunkYISEJCI6_cjs.b(.2126*chunkINDSIUQQ_cjs.a(t/255)+.7152*chunkINDSIUQQ_cjs.a(n/255)+.0722*chunkINDSIUQQ_cjs.a(o/255),4)},e.prototype.contrast=function(t="#fff"){let n=new e(t),o=n._rawRgb(),r=this._rawRgb(),s=(r.alpha<1?new e({r:r.alpha*r.r+(1-r.alpha)*o.r,g:r.alpha*r.g+(1-r.alpha)*o.g,b:r.alpha*r.b+(1-r.alpha)*o.b,alpha:1}):this).luminance(),c=n.luminance(),i=Math.max(s,c),m=Math.min(s,c);return chunkYISEJCI6_cjs.b((i+.05)/(m+.05),2)},e.prototype.apcaContrast=function(t="#fff"){let n=new e(t).toRgb(),o=this.toRgb(),r=o.alpha<1?{r:o.alpha*o.r+(1-o.alpha)*n.r,g:o.alpha*o.g+(1-o.alpha)*n.g,b:o.alpha*o.b+(1-o.alpha)*n.b}:o;return Math.round(p(r,n)*10)/10},e.prototype.isReadableApca=function(t="#fff",n={}){let{size:o="normal"}=n,r=Math.abs(this.apcaContrast(t));return o==="large"?r>=60:r>=75},e.prototype.readableScore=function(t="#fff"){let n=this.contrast(t);return n>=7?"AAA":n>=4.5?"AA":n>=3?"AA large":"fail"},e.prototype.isReadable=function(t="#fff",n={}){let{level:o="AA",size:r="normal"}=n,l=this.contrast(t);return o==="AAA"?r==="large"?l>=4.5:l>=7:r==="large"?l>=3:l>=4.5},e.prototype.minReadable=function(t="#fff"){let n=new e(t).luminance(),o=(n+.05)/.05,r=1.05/(n+.05),l=o>=r,s=i=>l?i.darken(.01):i.lighten(.01);if(this.contrast(t)>=4.5)return this;let c=s(this);for(let i=1;i<100&&!(c.contrast(t)>=4.5);i++)c=s(c);return c};},y=h;module.exports=y;//# sourceMappingURL=a11y.cjs.map | ||
| 'use strict';var chunkVSMEJU4Z_cjs=require('../chunk-VSMEJU4Z.cjs'),chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var f={Rsco:.2126729,Gsco:.7151522,Bsco:.072175},a={normBG:.56,normTXT:.57,revBG:.65,revTXT:.62,scale:1.14,loClip:.1,offset:.027,blkThrs:.022,blkClmp:1.414,deltaYmin:5e-4};function A(e,t,n){let o=l=>(l/255)**2.4,r=f.Rsco*o(e)+f.Gsco*o(t)+f.Bsco*o(n);return r>a.blkThrs?r:r+(a.blkThrs-r)**a.blkClmp}function p(e,t){let n=A(e.r,e.g,e.b),o=A(t.r,t.g,t.b);if(Math.abs(o-n)<a.deltaYmin)return 0;if(o>n){let r=(o**a.normBG-n**a.normTXT)*a.scale;return r<a.loClip?0:(r-a.offset)*100}else {let r=(o**a.revBG-n**a.revTXT)*a.scale;return r>-0.1?0:(r+a.offset)*100}}var h=e=>{e.prototype.luminance=function(){let{r:t,g:n,b:o}=this._rawRgb();return chunkYISEJCI6_cjs.b(.2126*chunkVSMEJU4Z_cjs.a(t/255)+.7152*chunkVSMEJU4Z_cjs.a(n/255)+.0722*chunkVSMEJU4Z_cjs.a(o/255),4)},e.prototype.contrast=function(t="#fff"){let n=new e(t),o=n._rawRgb(),r=this._rawRgb(),s=(r.alpha<1?new e({r:r.alpha*r.r+(1-r.alpha)*o.r,g:r.alpha*r.g+(1-r.alpha)*o.g,b:r.alpha*r.b+(1-r.alpha)*o.b,alpha:1}):this).luminance(),c=n.luminance(),i=Math.max(s,c),m=Math.min(s,c);return chunkYISEJCI6_cjs.b((i+.05)/(m+.05),2)},e.prototype.apcaContrast=function(t="#fff"){let n=new e(t).toRgb(),o=this.toRgb(),r=o.alpha<1?{r:o.alpha*o.r+(1-o.alpha)*n.r,g:o.alpha*o.g+(1-o.alpha)*n.g,b:o.alpha*o.b+(1-o.alpha)*n.b}:o;return Math.round(p(r,n)*10)/10},e.prototype.isReadableApca=function(t="#fff",n={}){let{size:o="normal"}=n,r=Math.abs(this.apcaContrast(t));return o==="large"?r>=60:r>=75},e.prototype.readableScore=function(t="#fff"){let n=this.contrast(t);return n>=7?"AAA":n>=4.5?"AA":n>=3?"AA large":"fail"},e.prototype.isReadable=function(t="#fff",n={}){let{level:o="AA",size:r="normal"}=n,l=this.contrast(t);return o==="AAA"?r==="large"?l>=4.5:l>=7:r==="large"?l>=3:l>=4.5},e.prototype.minReadable=function(t="#fff"){let n=new e(t).luminance(),o=(n+.05)/.05,r=1.05/(n+.05),l=o>=r,s=i=>l?i.darken(.01):i.lighten(.01);if(this.contrast(t)>=4.5)return this;let c=s(this);for(let i=1;i<100&&!(c.contrast(t)>=4.5);i++)c=s(c);return c};},y=h;module.exports=y;//# sourceMappingURL=a11y.cjs.map | ||
| //# sourceMappingURL=a11y.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {a as a$1}from'../chunk-YLJRINFM.mjs';import {b}from'../chunk-IOXRZECH.mjs';var f={Rsco:.2126729,Gsco:.7151522,Bsco:.072175},a={normBG:.56,normTXT:.57,revBG:.65,revTXT:.62,scale:1.14,loClip:.1,offset:.027,blkThrs:.022,blkClmp:1.414,deltaYmin:5e-4};function A(e,t,n){let o=l=>(l/255)**2.4,r=f.Rsco*o(e)+f.Gsco*o(t)+f.Bsco*o(n);return r>a.blkThrs?r:r+(a.blkThrs-r)**a.blkClmp}function p(e,t){let n=A(e.r,e.g,e.b),o=A(t.r,t.g,t.b);if(Math.abs(o-n)<a.deltaYmin)return 0;if(o>n){let r=(o**a.normBG-n**a.normTXT)*a.scale;return r<a.loClip?0:(r-a.offset)*100}else {let r=(o**a.revBG-n**a.revTXT)*a.scale;return r>-0.1?0:(r+a.offset)*100}}var h=e=>{e.prototype.luminance=function(){let{r:t,g:n,b:o}=this._rawRgb();return b(.2126*a$1(t/255)+.7152*a$1(n/255)+.0722*a$1(o/255),4)},e.prototype.contrast=function(t="#fff"){let n=new e(t),o=n._rawRgb(),r=this._rawRgb(),s=(r.alpha<1?new e({r:r.alpha*r.r+(1-r.alpha)*o.r,g:r.alpha*r.g+(1-r.alpha)*o.g,b:r.alpha*r.b+(1-r.alpha)*o.b,alpha:1}):this).luminance(),c=n.luminance(),i=Math.max(s,c),m=Math.min(s,c);return b((i+.05)/(m+.05),2)},e.prototype.apcaContrast=function(t="#fff"){let n=new e(t).toRgb(),o=this.toRgb(),r=o.alpha<1?{r:o.alpha*o.r+(1-o.alpha)*n.r,g:o.alpha*o.g+(1-o.alpha)*n.g,b:o.alpha*o.b+(1-o.alpha)*n.b}:o;return Math.round(p(r,n)*10)/10},e.prototype.isReadableApca=function(t="#fff",n={}){let{size:o="normal"}=n,r=Math.abs(this.apcaContrast(t));return o==="large"?r>=60:r>=75},e.prototype.readableScore=function(t="#fff"){let n=this.contrast(t);return n>=7?"AAA":n>=4.5?"AA":n>=3?"AA large":"fail"},e.prototype.isReadable=function(t="#fff",n={}){let{level:o="AA",size:r="normal"}=n,l=this.contrast(t);return o==="AAA"?r==="large"?l>=4.5:l>=7:r==="large"?l>=3:l>=4.5},e.prototype.minReadable=function(t="#fff"){let n=new e(t).luminance(),o=(n+.05)/.05,r=1.05/(n+.05),l=o>=r,s=i=>l?i.darken(.01):i.lighten(.01);if(this.contrast(t)>=4.5)return this;let c=s(this);for(let i=1;i<100&&!(c.contrast(t)>=4.5);i++)c=s(c);return c};},y=h;export{y as default};//# sourceMappingURL=a11y.mjs.map | ||
| import {a as a$1}from'../chunk-WGY6QKPW.mjs';import {b}from'../chunk-IOXRZECH.mjs';var f={Rsco:.2126729,Gsco:.7151522,Bsco:.072175},a={normBG:.56,normTXT:.57,revBG:.65,revTXT:.62,scale:1.14,loClip:.1,offset:.027,blkThrs:.022,blkClmp:1.414,deltaYmin:5e-4};function A(e,t,n){let o=l=>(l/255)**2.4,r=f.Rsco*o(e)+f.Gsco*o(t)+f.Bsco*o(n);return r>a.blkThrs?r:r+(a.blkThrs-r)**a.blkClmp}function p(e,t){let n=A(e.r,e.g,e.b),o=A(t.r,t.g,t.b);if(Math.abs(o-n)<a.deltaYmin)return 0;if(o>n){let r=(o**a.normBG-n**a.normTXT)*a.scale;return r<a.loClip?0:(r-a.offset)*100}else {let r=(o**a.revBG-n**a.revTXT)*a.scale;return r>-0.1?0:(r+a.offset)*100}}var h=e=>{e.prototype.luminance=function(){let{r:t,g:n,b:o}=this._rawRgb();return b(.2126*a$1(t/255)+.7152*a$1(n/255)+.0722*a$1(o/255),4)},e.prototype.contrast=function(t="#fff"){let n=new e(t),o=n._rawRgb(),r=this._rawRgb(),s=(r.alpha<1?new e({r:r.alpha*r.r+(1-r.alpha)*o.r,g:r.alpha*r.g+(1-r.alpha)*o.g,b:r.alpha*r.b+(1-r.alpha)*o.b,alpha:1}):this).luminance(),c=n.luminance(),i=Math.max(s,c),m=Math.min(s,c);return b((i+.05)/(m+.05),2)},e.prototype.apcaContrast=function(t="#fff"){let n=new e(t).toRgb(),o=this.toRgb(),r=o.alpha<1?{r:o.alpha*o.r+(1-o.alpha)*n.r,g:o.alpha*o.g+(1-o.alpha)*n.g,b:o.alpha*o.b+(1-o.alpha)*n.b}:o;return Math.round(p(r,n)*10)/10},e.prototype.isReadableApca=function(t="#fff",n={}){let{size:o="normal"}=n,r=Math.abs(this.apcaContrast(t));return o==="large"?r>=60:r>=75},e.prototype.readableScore=function(t="#fff"){let n=this.contrast(t);return n>=7?"AAA":n>=4.5?"AA":n>=3?"AA large":"fail"},e.prototype.isReadable=function(t="#fff",n={}){let{level:o="AA",size:r="normal"}=n,l=this.contrast(t);return o==="AAA"?r==="large"?l>=4.5:l>=7:r==="large"?l>=3:l>=4.5},e.prototype.minReadable=function(t="#fff"){let n=new e(t).luminance(),o=(n+.05)/.05,r=1.05/(n+.05),l=o>=r,s=i=>l?i.darken(.01):i.lighten(.01);if(this.contrast(t)>=4.5)return this;let c=s(this);for(let i=1;i<100&&!(c.contrast(t)>=4.5);i++)c=s(c);return c};},y=h;export{y as default};//# sourceMappingURL=a11y.mjs.map | ||
| //# sourceMappingURL=a11y.mjs.map |
@@ -1,2 +0,2 @@ | ||
| 'use strict';var chunk3V4MONNR_cjs=require('../chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var h=r=>({c:chunkYISEJCI6_cjs.a(r.c,0,100),m:chunkYISEJCI6_cjs.a(r.m,0,100),y:chunkYISEJCI6_cjs.a(r.y,0,100),k:chunkYISEJCI6_cjs.a(r.k,0,100),alpha:chunkYISEJCI6_cjs.a(r.alpha,0,1)}),R=({r,g:o,b:m,alpha:t})=>{let n=1-Math.max(r/255,o/255,m/255);return n===1?{c:0,m:0,y:0,k:100,alpha:t}:{c:(1-r/255-n)/(1-n)*100,m:(1-o/255-n)/(1-n)*100,y:(1-m/255-n)/(1-n)*100,k:n*100,alpha:t}};var d=({c:r,m:o,y:m,k:t,alpha:n})=>chunk3V4MONNR_cjs.a({r:255*(1-r/100)*(1-t/100),g:255*(1-o/100)*(1-t/100),b:255*(1-m/100)*(1-t/100),alpha:n}),i=r=>{if(!chunkYISEJCI6_cjs.h(r)||!chunkYISEJCI6_cjs.i(r,["c","m","y","k"]))return null;let{c:o,m,y:t,k:n,alpha:e=1}=r;return !chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(m)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(e)?null:d(h({c:chunkYISEJCI6_cjs.g(o),m:chunkYISEJCI6_cjs.g(m),y:chunkYISEJCI6_cjs.g(t),k:chunkYISEJCI6_cjs.g(n),alpha:chunkYISEJCI6_cjs.g(e)}))},w=new RegExp(`^device-cmyk\\(\\s*(?<c>${chunkYISEJCI6_cjs.k})(?<cp>%?)\\s+(?<m>${chunkYISEJCI6_cjs.k})(?<mp>%?)\\s+(?<y>${chunkYISEJCI6_cjs.k})(?<yp>%?)\\s+(?<k>${chunkYISEJCI6_cjs.k})(?<kp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),g=r=>{if(typeof r!="string")return null;let o=w.exec(r.trim())?.groups;if(!o)return null;let m=(t,n)=>chunkYISEJCI6_cjs.l(t)*(n?1:100);return d(h({c:m(o.c,o.cp),m:m(o.m,o.mp),y:m(o.y,o.yp),k:m(o.k,o.kp),alpha:o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1)}))};var x=(r,o,m)=>{r.prototype.toCmyk=function(t=2){let{c:n,m:e,y:s,k:a,alpha:u}=R(this._rawRgb());return {c:chunkYISEJCI6_cjs.b(n,t),m:chunkYISEJCI6_cjs.b(e,t),y:chunkYISEJCI6_cjs.b(s,t),k:chunkYISEJCI6_cjs.b(a,t),alpha:u}},r.prototype.toCmykString=function(t=2){let{c:n,m:e,y:s,k:a,alpha:u}=this.toCmyk(t);return u<1?`device-cmyk(${n}% ${e}% ${s}% ${a}% / ${u})`:`device-cmyk(${n}% ${e}% ${s}% ${a}%)`},o.push(i,g),m.push([i,"cmyk"],[g,"cmyk"]);},_=x;module.exports=_;//# sourceMappingURL=cmyk.cjs.map | ||
| 'use strict';var chunk2KB6V6KD_cjs=require('../chunk-2KB6V6KD.cjs'),chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var h=r=>({c:chunkYISEJCI6_cjs.a(r.c,0,100),m:chunkYISEJCI6_cjs.a(r.m,0,100),y:chunkYISEJCI6_cjs.a(r.y,0,100),k:chunkYISEJCI6_cjs.a(r.k,0,100),alpha:chunkYISEJCI6_cjs.a(r.alpha,0,1)}),R=({r,g:o,b:m,alpha:t})=>{let n=1-Math.max(r/255,o/255,m/255);return n===1?{c:0,m:0,y:0,k:100,alpha:t}:{c:(1-r/255-n)/(1-n)*100,m:(1-o/255-n)/(1-n)*100,y:(1-m/255-n)/(1-n)*100,k:n*100,alpha:t}};var d=({c:r,m:o,y:m,k:t,alpha:n})=>chunk2KB6V6KD_cjs.a({r:255*(1-r/100)*(1-t/100),g:255*(1-o/100)*(1-t/100),b:255*(1-m/100)*(1-t/100),alpha:n}),i=r=>{if(!chunkYISEJCI6_cjs.h(r)||!chunkYISEJCI6_cjs.i(r,["c","m","y","k"]))return null;let{c:o,m,y:t,k:n,alpha:e=1}=r;return !chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(m)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(e)?null:d(h({c:chunkYISEJCI6_cjs.g(o),m:chunkYISEJCI6_cjs.g(m),y:chunkYISEJCI6_cjs.g(t),k:chunkYISEJCI6_cjs.g(n),alpha:chunkYISEJCI6_cjs.g(e)}))},w=new RegExp(`^device-cmyk\\(\\s*(?<c>${chunkYISEJCI6_cjs.k})(?<cp>%?)\\s+(?<m>${chunkYISEJCI6_cjs.k})(?<mp>%?)\\s+(?<y>${chunkYISEJCI6_cjs.k})(?<yp>%?)\\s+(?<k>${chunkYISEJCI6_cjs.k})(?<kp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),g=r=>{if(typeof r!="string")return null;let o=w.exec(r.trim())?.groups;if(!o)return null;let m=(t,n)=>chunkYISEJCI6_cjs.l(t)*(n?1:100);return d(h({c:m(o.c,o.cp),m:m(o.m,o.mp),y:m(o.y,o.yp),k:m(o.k,o.kp),alpha:o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1)}))};var x=(r,o,m)=>{r.prototype.toCmyk=function(t=2){let{c:n,m:e,y:s,k:a,alpha:u}=R(this._rawRgb());return {c:chunkYISEJCI6_cjs.b(n,t),m:chunkYISEJCI6_cjs.b(e,t),y:chunkYISEJCI6_cjs.b(s,t),k:chunkYISEJCI6_cjs.b(a,t),alpha:u}},r.prototype.toCmykString=function(t=2){let{c:n,m:e,y:s,k:a,alpha:u}=this.toCmyk(t);return u<1?`device-cmyk(${n}% ${e}% ${s}% ${a}% / ${u})`:`device-cmyk(${n}% ${e}% ${s}% ${a}%)`},o.push(i,g),m.push([i,"cmyk"],[g,"cmyk"]);},_=x;module.exports=_;//# sourceMappingURL=cmyk.cjs.map | ||
| //# sourceMappingURL=cmyk.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { a as CmykColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { c as CmykColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { a as CmykColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { c as CmykColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {a}from'../chunk-Q3O3QQ4H.mjs';import {b,h as h$1,i as i$1,f,g as g$1,l,a as a$1,k}from'../chunk-IOXRZECH.mjs';var h=r=>({c:a$1(r.c,0,100),m:a$1(r.m,0,100),y:a$1(r.y,0,100),k:a$1(r.k,0,100),alpha:a$1(r.alpha,0,1)}),R=({r,g:o,b:m,alpha:t})=>{let n=1-Math.max(r/255,o/255,m/255);return n===1?{c:0,m:0,y:0,k:100,alpha:t}:{c:(1-r/255-n)/(1-n)*100,m:(1-o/255-n)/(1-n)*100,y:(1-m/255-n)/(1-n)*100,k:n*100,alpha:t}};var d=({c:r,m:o,y:m,k:t,alpha:n})=>a({r:255*(1-r/100)*(1-t/100),g:255*(1-o/100)*(1-t/100),b:255*(1-m/100)*(1-t/100),alpha:n}),i=r=>{if(!h$1(r)||!i$1(r,["c","m","y","k"]))return null;let{c:o,m,y:t,k:n,alpha:e=1}=r;return !f(o)||!f(m)||!f(t)||!f(n)||!f(e)?null:d(h({c:g$1(o),m:g$1(m),y:g$1(t),k:g$1(n),alpha:g$1(e)}))},w=new RegExp(`^device-cmyk\\(\\s*(?<c>${k})(?<cp>%?)\\s+(?<m>${k})(?<mp>%?)\\s+(?<y>${k})(?<yp>%?)\\s+(?<k>${k})(?<kp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),g=r=>{if(typeof r!="string")return null;let o=w.exec(r.trim())?.groups;if(!o)return null;let m=(t,n)=>l(t)*(n?1:100);return d(h({c:m(o.c,o.cp),m:m(o.m,o.mp),y:m(o.y,o.yp),k:m(o.k,o.kp),alpha:o.al===void 0?1:l(o.al)/(o.alp?100:1)}))};var x=(r,o,m)=>{r.prototype.toCmyk=function(t=2){let{c:n,m:e,y:s,k:a,alpha:u}=R(this._rawRgb());return {c:b(n,t),m:b(e,t),y:b(s,t),k:b(a,t),alpha:u}},r.prototype.toCmykString=function(t=2){let{c:n,m:e,y:s,k:a,alpha:u}=this.toCmyk(t);return u<1?`device-cmyk(${n}% ${e}% ${s}% ${a}% / ${u})`:`device-cmyk(${n}% ${e}% ${s}% ${a}%)`},o.push(i,g),m.push([i,"cmyk"],[g,"cmyk"]);},_=x;export{_ as default};//# sourceMappingURL=cmyk.mjs.map | ||
| import {a}from'../chunk-GLKEY6D3.mjs';import {b,h as h$1,i as i$1,f,g as g$1,l,a as a$1,k}from'../chunk-IOXRZECH.mjs';var h=r=>({c:a$1(r.c,0,100),m:a$1(r.m,0,100),y:a$1(r.y,0,100),k:a$1(r.k,0,100),alpha:a$1(r.alpha,0,1)}),R=({r,g:o,b:m,alpha:t})=>{let n=1-Math.max(r/255,o/255,m/255);return n===1?{c:0,m:0,y:0,k:100,alpha:t}:{c:(1-r/255-n)/(1-n)*100,m:(1-o/255-n)/(1-n)*100,y:(1-m/255-n)/(1-n)*100,k:n*100,alpha:t}};var d=({c:r,m:o,y:m,k:t,alpha:n})=>a({r:255*(1-r/100)*(1-t/100),g:255*(1-o/100)*(1-t/100),b:255*(1-m/100)*(1-t/100),alpha:n}),i=r=>{if(!h$1(r)||!i$1(r,["c","m","y","k"]))return null;let{c:o,m,y:t,k:n,alpha:e=1}=r;return !f(o)||!f(m)||!f(t)||!f(n)||!f(e)?null:d(h({c:g$1(o),m:g$1(m),y:g$1(t),k:g$1(n),alpha:g$1(e)}))},w=new RegExp(`^device-cmyk\\(\\s*(?<c>${k})(?<cp>%?)\\s+(?<m>${k})(?<mp>%?)\\s+(?<y>${k})(?<yp>%?)\\s+(?<k>${k})(?<kp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),g=r=>{if(typeof r!="string")return null;let o=w.exec(r.trim())?.groups;if(!o)return null;let m=(t,n)=>l(t)*(n?1:100);return d(h({c:m(o.c,o.cp),m:m(o.m,o.mp),y:m(o.y,o.yp),k:m(o.k,o.kp),alpha:o.al===void 0?1:l(o.al)/(o.alp?100:1)}))};var x=(r,o,m)=>{r.prototype.toCmyk=function(t=2){let{c:n,m:e,y:s,k:a,alpha:u}=R(this._rawRgb());return {c:b(n,t),m:b(e,t),y:b(s,t),k:b(a,t),alpha:u}},r.prototype.toCmykString=function(t=2){let{c:n,m:e,y:s,k:a,alpha:u}=this.toCmyk(t);return u<1?`device-cmyk(${n}% ${e}% ${s}% ${a}% / ${u})`:`device-cmyk(${n}% ${e}% ${s}% ${a}%)`},o.push(i,g),m.push([i,"cmyk"],[g,"cmyk"]);},_=x;export{_ as default};//# sourceMappingURL=cmyk.mjs.map | ||
| //# sourceMappingURL=cmyk.mjs.map |
@@ -1,2 +0,2 @@ | ||
| import { q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ type HarmonyType = 'complementary' | 'analogous' | 'triadic' | 'tetradic' | 'split-complementary' | 'double-split-complementary' | 'rectangle'; |
@@ -1,2 +0,2 @@ | ||
| import { q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ type HarmonyType = 'complementary' | 'analogous' | 'triadic' | 'tetradic' | 'split-complementary' | 'double-split-complementary' | 'rectangle'; |
@@ -1,2 +0,2 @@ | ||
| 'use strict';var chunkBLKDDW2U_cjs=require('../chunk-BLKDDW2U.cjs');require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var m=(p,u,c)=>{p.prototype.toHsv=function(o=2){let{h:r,s:t,v:s,alpha:n}=chunkBLKDDW2U_cjs.a(this._rawRgb()),h=chunkYISEJCI6_cjs.b(r,o);return {h:h>=360?0:h,s:chunkYISEJCI6_cjs.b(t,o),v:chunkYISEJCI6_cjs.b(s,o),alpha:n}},p.prototype.toHsvString=function(o=2){let{h:r,s:t,v:s,alpha:n}=this.toHsv(o);return n<1?`hsv(${r} ${t}% ${s}% / ${n})`:`hsv(${r} ${t}% ${s}%)`},u.push(chunkBLKDDW2U_cjs.c,chunkBLKDDW2U_cjs.d),c.push([chunkBLKDDW2U_cjs.c,"hsv"],[chunkBLKDDW2U_cjs.d,"hsv"]);},d=m;module.exports=d;//# sourceMappingURL=hsv.cjs.map | ||
| 'use strict';var chunkSVWD7LPC_cjs=require('../chunk-SVWD7LPC.cjs');require('../chunk-2KB6V6KD.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var m=(p,u,c)=>{p.prototype.toHsv=function(o=2){let{h:r,s:t,v:s,alpha:n}=chunkSVWD7LPC_cjs.a(this._rawRgb()),h=chunkYISEJCI6_cjs.b(r,o);return {h:h>=360?0:h,s:chunkYISEJCI6_cjs.b(t,o),v:chunkYISEJCI6_cjs.b(s,o),alpha:n}},p.prototype.toHsvString=function(o=2){let{h:r,s:t,v:s,alpha:n}=this.toHsv(o);return n<1?`hsv(${r} ${t}% ${s}% / ${n})`:`hsv(${r} ${t}% ${s}%)`},u.push(chunkSVWD7LPC_cjs.c,chunkSVWD7LPC_cjs.d),c.push([chunkSVWD7LPC_cjs.c,"hsv"],[chunkSVWD7LPC_cjs.d,"hsv"]);},d=m;module.exports=d;//# sourceMappingURL=hsv.cjs.map | ||
| //# sourceMappingURL=hsv.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { f as HsvColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { h as HsvColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { f as HsvColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { h as HsvColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {a,c,d as d$1}from'../chunk-6JXMCEQE.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b}from'../chunk-IOXRZECH.mjs';var m=(p,u,c$1)=>{p.prototype.toHsv=function(o=2){let{h:r,s:t,v:s,alpha:n}=a(this._rawRgb()),h=b(r,o);return {h:h>=360?0:h,s:b(t,o),v:b(s,o),alpha:n}},p.prototype.toHsvString=function(o=2){let{h:r,s:t,v:s,alpha:n}=this.toHsv(o);return n<1?`hsv(${r} ${t}% ${s}% / ${n})`:`hsv(${r} ${t}% ${s}%)`},u.push(c,d$1),c$1.push([c,"hsv"],[d$1,"hsv"]);},d=m;export{d as default};//# sourceMappingURL=hsv.mjs.map | ||
| import {a,c,d as d$1}from'../chunk-LAE55ZGF.mjs';import'../chunk-GLKEY6D3.mjs';import {b}from'../chunk-IOXRZECH.mjs';var m=(p,u,c$1)=>{p.prototype.toHsv=function(o=2){let{h:r,s:t,v:s,alpha:n}=a(this._rawRgb()),h=b(r,o);return {h:h>=360?0:h,s:b(t,o),v:b(s,o),alpha:n}},p.prototype.toHsvString=function(o=2){let{h:r,s:t,v:s,alpha:n}=this.toHsv(o);return n<1?`hsv(${r} ${t}% ${s}% / ${n})`:`hsv(${r} ${t}% ${s}%)`},u.push(c,d$1),c$1.push([c,"hsv"],[d$1,"hsv"]);},d=m;export{d as default};//# sourceMappingURL=hsv.mjs.map | ||
| //# sourceMappingURL=hsv.mjs.map |
@@ -1,2 +0,2 @@ | ||
| 'use strict';var chunkBLKDDW2U_cjs=require('../chunk-BLKDDW2U.cjs');require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var c=o=>{let r=chunkYISEJCI6_cjs.a(o.w,0,1/0),t=chunkYISEJCI6_cjs.a(o.b,0,1/0),n=r+t;return {h:chunkYISEJCI6_cjs.c(o.h),w:n>100?r/n*100:r,b:n>100?t/n*100:t,alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o.alpha,3),0,1)}},R=o=>{let{h:r}=chunkBLKDDW2U_cjs.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 chunkBLKDDW2U_cjs.b({h:o,s:e,v:100-t,alpha:n})},m=o=>{if(!chunkYISEJCI6_cjs.h(o)||!chunkYISEJCI6_cjs.i(o,["h","w","b"]))return null;let{h:r,w:t,b:n,alpha:e=1}=o;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(e)?null:$(c({h:chunkYISEJCI6_cjs.g(r),w:chunkYISEJCI6_cjs.g(t),b:chunkYISEJCI6_cjs.g(n),alpha:chunkYISEJCI6_cjs.g(e)}))},N=new RegExp(`^hwb\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s+(?<w>${chunkYISEJCI6_cjs.k})(?<wp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.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=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[t]??1),e=chunkYISEJCI6_cjs.l(r.w),l=chunkYISEJCI6_cjs.l(r.b),b=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return $(c({h:n,w:e,b:l,alpha:b}))};var j=(o,r,t)=>{o.prototype.toHwb=function(n=0){let{h:e,w:l,b,alpha:h}=R(this._rawRgb());return {h:chunkYISEJCI6_cjs.b(e,n),w:chunkYISEJCI6_cjs.b(l,n),b:chunkYISEJCI6_cjs.b(b,n),alpha:chunkYISEJCI6_cjs.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;module.exports=E;//# sourceMappingURL=hwb.cjs.map | ||
| 'use strict';var chunkSVWD7LPC_cjs=require('../chunk-SVWD7LPC.cjs');require('../chunk-2KB6V6KD.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var c=o=>{let r=chunkYISEJCI6_cjs.a(o.w,0,1/0),t=chunkYISEJCI6_cjs.a(o.b,0,1/0),n=r+t;return {h:chunkYISEJCI6_cjs.c(o.h),w:n>100?r/n*100:r,b:n>100?t/n*100:t,alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o.alpha,3),0,1)}},R=o=>{let{h:r}=chunkSVWD7LPC_cjs.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 chunkSVWD7LPC_cjs.b({h:o,s:e,v:100-t,alpha:n})},m=o=>{if(!chunkYISEJCI6_cjs.h(o)||!chunkYISEJCI6_cjs.i(o,["h","w","b"]))return null;let{h:r,w:t,b:n,alpha:e=1}=o;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(e)?null:$(c({h:chunkYISEJCI6_cjs.g(r),w:chunkYISEJCI6_cjs.g(t),b:chunkYISEJCI6_cjs.g(n),alpha:chunkYISEJCI6_cjs.g(e)}))},N=new RegExp(`^hwb\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s+(?<w>${chunkYISEJCI6_cjs.k})(?<wp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.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=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[t]??1),e=chunkYISEJCI6_cjs.l(r.w),l=chunkYISEJCI6_cjs.l(r.b),b=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return $(c({h:n,w:e,b:l,alpha:b}))};var j=(o,r,t)=>{o.prototype.toHwb=function(n=0){let{h:e,w:l,b,alpha:h}=R(this._rawRgb());return {h:chunkYISEJCI6_cjs.b(e,n),w:chunkYISEJCI6_cjs.b(l,n),b:chunkYISEJCI6_cjs.b(b,n),alpha:chunkYISEJCI6_cjs.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;module.exports=E;//# sourceMappingURL=hwb.cjs.map | ||
| //# sourceMappingURL=hwb.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { h as HwbColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { j as HwbColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { h as HwbColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { j as HwbColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| 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 | ||
| import {a,b as b$1}from'../chunk-LAE55ZGF.mjs';import'../chunk-GLKEY6D3.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 |
@@ -1,2 +0,2 @@ | ||
| '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 d=(b,f,x)=>{b.prototype.toLab=function(t=2){let{l:a,a:r,b:n,alpha:o}=chunkPI5KJ3ZM_cjs.m(this._rawRgb());return {l:chunkYISEJCI6_cjs.b(a,t),a:chunkYISEJCI6_cjs.b(r,t)||0,b:chunkYISEJCI6_cjs.b(n,t)||0,alpha:o,colorSpace:"lab"}},b.prototype.toLabString=function(t=2){let{l:a,a:r,b:n,alpha:o}=this.toLab(t);return o<1?`lab(${a} ${r} ${n} / ${o})`:`lab(${a} ${r} ${n})`},b.prototype.toXyz=function(t=2){let{x:a,y:r,z:n,alpha:o}=chunkPI5KJ3ZM_cjs.c(this._rawRgb());return {x:chunkYISEJCI6_cjs.b(a,t),y:chunkYISEJCI6_cjs.b(r,t),z:chunkYISEJCI6_cjs.b(n,t),alpha:o}},b.prototype.toXyzString=function(t=2){let{x:a,y:r,z:n,alpha:o}=this.toXyz(t);return o<1?`color(xyz-d50 ${a} ${r} ${n} / ${o})`:`color(xyz-d50 ${a} ${r} ${n})`},b.prototype.toXyzD65=function(t=2){let{x:a,y:r,z:n,alpha:o}=chunkPI5KJ3ZM_cjs.a(this._rawRgb());return {x:chunkYISEJCI6_cjs.b(a,t),y:chunkYISEJCI6_cjs.b(r,t),z:chunkYISEJCI6_cjs.b(n,t),alpha:o,colorSpace:"xyz-d65"}},b.prototype.toXyzD65String=function(t=2){let{x:a,y:r,z:n,alpha:o}=this.toXyzD65(t);return o<1?`color(xyz-d65 ${a} ${r} ${n} / ${o})`:`color(xyz-d65 ${a} ${r} ${n})`},b.prototype.mixLab=function(t,a=.5){let r=chunkPI5KJ3ZM_cjs.m(this._rawRgb()),n=chunkPI5KJ3ZM_cjs.m(new b(t)._rawRgb()),o=chunkYISEJCI6_cjs.a(a,0,1);return new b(chunkPI5KJ3ZM_cjs.p({l:r.l*(1-o)+n.l*o,a:r.a*(1-o)+n.a*o,b:r.b*(1-o)+n.b*o,alpha:chunkYISEJCI6_cjs.b(r.alpha*(1-o)+n.alpha*o,3),colorSpace:"lab"}))},b.prototype.delta=function(t="#fff"){return chunkYISEJCI6_cjs.b(chunkPI5KJ3ZM_cjs.o(chunkPI5KJ3ZM_cjs.n(this._rawRgb()),chunkPI5KJ3ZM_cjs.n(new b(t)._rawRgb()))/100,3)},f.push(chunkPI5KJ3ZM_cjs.r,chunkPI5KJ3ZM_cjs.s,chunkPI5KJ3ZM_cjs.h,chunkPI5KJ3ZM_cjs.g,chunkPI5KJ3ZM_cjs.i,chunkPI5KJ3ZM_cjs.f),x.push([chunkPI5KJ3ZM_cjs.r,"lab"],[chunkPI5KJ3ZM_cjs.s,"lab"],[chunkPI5KJ3ZM_cjs.h,"xyz-d65"],[chunkPI5KJ3ZM_cjs.g,"xyz-d65"],[chunkPI5KJ3ZM_cjs.i,"xyz"],[chunkPI5KJ3ZM_cjs.f,"xyz"]);},w=d;module.exports=w;//# sourceMappingURL=lab.cjs.map | ||
| 'use strict';var chunk6FI7U3TH_cjs=require('../chunk-6FI7U3TH.cjs');require('../chunk-VSMEJU4Z.cjs'),require('../chunk-2KB6V6KD.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var d=(b,f,x)=>{b.prototype.toLab=function(t=2){let{l:a,a:r,b:n,alpha:o}=chunk6FI7U3TH_cjs.m(this._rawRgb());return {l:chunkYISEJCI6_cjs.b(a,t),a:chunkYISEJCI6_cjs.b(r,t)||0,b:chunkYISEJCI6_cjs.b(n,t)||0,alpha:o,colorSpace:"lab"}},b.prototype.toLabString=function(t=2){let{l:a,a:r,b:n,alpha:o}=this.toLab(t);return o<1?`lab(${a} ${r} ${n} / ${o})`:`lab(${a} ${r} ${n})`},b.prototype.toXyz=function(t=2){let{x:a,y:r,z:n,alpha:o}=chunk6FI7U3TH_cjs.c(this._rawRgb());return {x:chunkYISEJCI6_cjs.b(a,t),y:chunkYISEJCI6_cjs.b(r,t),z:chunkYISEJCI6_cjs.b(n,t),alpha:o}},b.prototype.toXyzString=function(t=2){let{x:a,y:r,z:n,alpha:o}=this.toXyz(t);return o<1?`color(xyz-d50 ${a} ${r} ${n} / ${o})`:`color(xyz-d50 ${a} ${r} ${n})`},b.prototype.toXyzD65=function(t=2){let{x:a,y:r,z:n,alpha:o}=chunk6FI7U3TH_cjs.a(this._rawRgb());return {x:chunkYISEJCI6_cjs.b(a,t),y:chunkYISEJCI6_cjs.b(r,t),z:chunkYISEJCI6_cjs.b(n,t),alpha:o,colorSpace:"xyz-d65"}},b.prototype.toXyzD65String=function(t=2){let{x:a,y:r,z:n,alpha:o}=this.toXyzD65(t);return o<1?`color(xyz-d65 ${a} ${r} ${n} / ${o})`:`color(xyz-d65 ${a} ${r} ${n})`},b.prototype.mixLab=function(t,a=.5){let r=chunk6FI7U3TH_cjs.m(this._rawRgb()),n=chunk6FI7U3TH_cjs.m(new b(t)._rawRgb()),o=chunkYISEJCI6_cjs.a(a,0,1);return new b(chunk6FI7U3TH_cjs.p({l:r.l*(1-o)+n.l*o,a:r.a*(1-o)+n.a*o,b:r.b*(1-o)+n.b*o,alpha:chunkYISEJCI6_cjs.b(r.alpha*(1-o)+n.alpha*o,3),colorSpace:"lab"}))},b.prototype.delta=function(t="#fff"){return chunkYISEJCI6_cjs.b(chunk6FI7U3TH_cjs.o(chunk6FI7U3TH_cjs.n(this._rawRgb()),chunk6FI7U3TH_cjs.n(new b(t)._rawRgb()))/100,3)},f.push(chunk6FI7U3TH_cjs.r,chunk6FI7U3TH_cjs.s,chunk6FI7U3TH_cjs.h,chunk6FI7U3TH_cjs.g,chunk6FI7U3TH_cjs.i,chunk6FI7U3TH_cjs.f),x.push([chunk6FI7U3TH_cjs.r,"lab"],[chunk6FI7U3TH_cjs.s,"lab"],[chunk6FI7U3TH_cjs.h,"xyz-d65"],[chunk6FI7U3TH_cjs.g,"xyz-d65"],[chunk6FI7U3TH_cjs.i,"xyz"],[chunk6FI7U3TH_cjs.f,"xyz"]);},w=d;module.exports=w;//# sourceMappingURL=lab.cjs.map | ||
| //# sourceMappingURL=lab.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { L as LabColor, X as XyzColor, B as XyzD65Color, A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { L as LabColor, X as XyzColor, G as XyzD65Color, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { L as LabColor, X as XyzColor, B as XyzD65Color, A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { L as LabColor, X as XyzColor, G as XyzD65Color, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {m,c,a,p,o,n,r,s,h,g,i,f}from'../chunk-F4W4HJCD.mjs';import'../chunk-YLJRINFM.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b,a as a$1}from'../chunk-IOXRZECH.mjs';var d=(b$1,f$1,x)=>{b$1.prototype.toLab=function(t=2){let{l:a,a:r,b:n,alpha:o}=m(this._rawRgb());return {l:b(a,t),a:b(r,t)||0,b:b(n,t)||0,alpha:o,colorSpace:"lab"}},b$1.prototype.toLabString=function(t=2){let{l:a,a:r,b:n,alpha:o}=this.toLab(t);return o<1?`lab(${a} ${r} ${n} / ${o})`:`lab(${a} ${r} ${n})`},b$1.prototype.toXyz=function(t=2){let{x:a,y:r,z:n,alpha:o}=c(this._rawRgb());return {x:b(a,t),y:b(r,t),z:b(n,t),alpha:o}},b$1.prototype.toXyzString=function(t=2){let{x:a,y:r,z:n,alpha:o}=this.toXyz(t);return o<1?`color(xyz-d50 ${a} ${r} ${n} / ${o})`:`color(xyz-d50 ${a} ${r} ${n})`},b$1.prototype.toXyzD65=function(t=2){let{x:a$1,y:r,z:n,alpha:o}=a(this._rawRgb());return {x:b(a$1,t),y:b(r,t),z:b(n,t),alpha:o,colorSpace:"xyz-d65"}},b$1.prototype.toXyzD65String=function(t=2){let{x:a,y:r,z:n,alpha:o}=this.toXyzD65(t);return o<1?`color(xyz-d65 ${a} ${r} ${n} / ${o})`:`color(xyz-d65 ${a} ${r} ${n})`},b$1.prototype.mixLab=function(t,a=.5){let r=m(this._rawRgb()),n=m(new b$1(t)._rawRgb()),o=a$1(a,0,1);return new b$1(p({l:r.l*(1-o)+n.l*o,a:r.a*(1-o)+n.a*o,b:r.b*(1-o)+n.b*o,alpha:b(r.alpha*(1-o)+n.alpha*o,3),colorSpace:"lab"}))},b$1.prototype.delta=function(t="#fff"){return b(o(n(this._rawRgb()),n(new b$1(t)._rawRgb()))/100,3)},f$1.push(r,s,h,g,i,f),x.push([r,"lab"],[s,"lab"],[h,"xyz-d65"],[g,"xyz-d65"],[i,"xyz"],[f,"xyz"]);},w=d;export{w as default};//# sourceMappingURL=lab.mjs.map | ||
| import {m,c,a,p,o,n,r,s,h,g,i,f}from'../chunk-YQKSXMBN.mjs';import'../chunk-WGY6QKPW.mjs';import'../chunk-GLKEY6D3.mjs';import {b,a as a$1}from'../chunk-IOXRZECH.mjs';var d=(b$1,f$1,x)=>{b$1.prototype.toLab=function(t=2){let{l:a,a:r,b:n,alpha:o}=m(this._rawRgb());return {l:b(a,t),a:b(r,t)||0,b:b(n,t)||0,alpha:o,colorSpace:"lab"}},b$1.prototype.toLabString=function(t=2){let{l:a,a:r,b:n,alpha:o}=this.toLab(t);return o<1?`lab(${a} ${r} ${n} / ${o})`:`lab(${a} ${r} ${n})`},b$1.prototype.toXyz=function(t=2){let{x:a,y:r,z:n,alpha:o}=c(this._rawRgb());return {x:b(a,t),y:b(r,t),z:b(n,t),alpha:o}},b$1.prototype.toXyzString=function(t=2){let{x:a,y:r,z:n,alpha:o}=this.toXyz(t);return o<1?`color(xyz-d50 ${a} ${r} ${n} / ${o})`:`color(xyz-d50 ${a} ${r} ${n})`},b$1.prototype.toXyzD65=function(t=2){let{x:a$1,y:r,z:n,alpha:o}=a(this._rawRgb());return {x:b(a$1,t),y:b(r,t),z:b(n,t),alpha:o,colorSpace:"xyz-d65"}},b$1.prototype.toXyzD65String=function(t=2){let{x:a,y:r,z:n,alpha:o}=this.toXyzD65(t);return o<1?`color(xyz-d65 ${a} ${r} ${n} / ${o})`:`color(xyz-d65 ${a} ${r} ${n})`},b$1.prototype.mixLab=function(t,a=.5){let r=m(this._rawRgb()),n=m(new b$1(t)._rawRgb()),o=a$1(a,0,1);return new b$1(p({l:r.l*(1-o)+n.l*o,a:r.a*(1-o)+n.a*o,b:r.b*(1-o)+n.b*o,alpha:b(r.alpha*(1-o)+n.alpha*o,3),colorSpace:"lab"}))},b$1.prototype.delta=function(t="#fff"){return b(o(n(this._rawRgb()),n(new b$1(t)._rawRgb()))/100,3)},f$1.push(r,s,h,g,i,f),x.push([r,"lab"],[s,"lab"],[h,"xyz-d65"],[g,"xyz-d65"],[i,"xyz"],[f,"xyz"]);},w=d;export{w as default};//# sourceMappingURL=lab.mjs.map | ||
| //# sourceMappingURL=lab.mjs.map |
@@ -1,2 +0,2 @@ | ||
| '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 | ||
| 'use strict';var chunk6FI7U3TH_cjs=require('../chunk-6FI7U3TH.cjs');require('../chunk-VSMEJU4Z.cjs'),require('../chunk-2KB6V6KD.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=chunk6FI7U3TH_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})=>chunk6FI7U3TH_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 |
@@ -1,2 +0,2 @@ | ||
| import { k as LchColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { m as LchColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { k as LchColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { m as LchColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {m as m$1,q}from'../chunk-F4W4HJCD.mjs';import'../chunk-YLJRINFM.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b,h,i,f,g,l,d,a,c,k}from'../chunk-IOXRZECH.mjs';var w=c$1=>({l:a(c$1.l,0,100),c:Math.max(0,c$1.c),h:c(c$1.h),alpha:a(c$1.alpha,0,1),colorSpace:"lch"}),$=c=>{let o=m$1(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})=>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(!h(c)||c.colorSpace!=="lch"||!i(c,["l","c","h"]))return null;let{l:o,c:l,h:r,alpha:t=1}=c;return !f(o)||!f(l)||!f(r)||!f(t)?null:x(w({l:g(o),c:g(l),h:g(r),alpha:g(t)}))},y=new RegExp(`^lch\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<c>${k})(?<cp>%?)\\s+(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${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$1=l(o.l),r=o.cp?l(o.c)*1.5:l(o.c),t=o.hu?.toLowerCase()??"deg",n=l(o.h)*(d[t]??1),h=o.al===void 0?1:l(o.al)/(o.alp?100:1);return x(w({l: l$1,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$1=b(n,r);return {l:b(t,r),c:b$1,h:n<.0015?0: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;export{_ as default};//# sourceMappingURL=lch.mjs.map | ||
| import {m as m$1,q}from'../chunk-YQKSXMBN.mjs';import'../chunk-WGY6QKPW.mjs';import'../chunk-GLKEY6D3.mjs';import {b,h,i,f,g,l,d,a,c,k}from'../chunk-IOXRZECH.mjs';var w=c$1=>({l:a(c$1.l,0,100),c:Math.max(0,c$1.c),h:c(c$1.h),alpha:a(c$1.alpha,0,1),colorSpace:"lch"}),$=c=>{let o=m$1(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})=>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(!h(c)||c.colorSpace!=="lch"||!i(c,["l","c","h"]))return null;let{l:o,c:l,h:r,alpha:t=1}=c;return !f(o)||!f(l)||!f(r)||!f(t)?null:x(w({l:g(o),c:g(l),h:g(r),alpha:g(t)}))},y=new RegExp(`^lch\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<c>${k})(?<cp>%?)\\s+(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${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$1=l(o.l),r=o.cp?l(o.c)*1.5:l(o.c),t=o.hu?.toLowerCase()??"deg",n=l(o.h)*(d[t]??1),h=o.al===void 0?1:l(o.al)/(o.alp?100:1);return x(w({l: l$1,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$1=b(n,r);return {l:b(t,r),c:b$1,h:n<.0015?0: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;export{_ as default};//# sourceMappingURL=lch.mjs.map | ||
| //# sourceMappingURL=lch.mjs.map |
@@ -1,2 +0,2 @@ | ||
| import { q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ interface MinifyOptions { |
@@ -1,2 +0,2 @@ | ||
| import { q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ interface MinifyOptions { |
@@ -1,2 +0,2 @@ | ||
| 'use strict';var chunkTRRLWCL6_cjs=require('../chunk-TRRLWCL6.cjs');require('../chunk-INDSIUQQ.cjs'),require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var b=n=>{n.prototype.mix=function(r,e=.5){let t=new n(r).toRgb(),l=this._rawRgb(),o=chunkYISEJCI6_cjs.a(e,0,1);return new n({r:chunkYISEJCI6_cjs.b(l.r*(1-o)+t.r*o),g:chunkYISEJCI6_cjs.b(l.g*(1-o)+t.g*o),b:chunkYISEJCI6_cjs.b(l.b*(1-o)+t.b*o),alpha:chunkYISEJCI6_cjs.b(l.alpha*(1-o)+t.alpha*o,3)})},n.prototype.mixOklab=function(r,e=.5){let t=chunkTRRLWCL6_cjs.b(this._rawRgb()),l=chunkTRRLWCL6_cjs.b(new n(r)._rawRgb()),o=chunkYISEJCI6_cjs.a(e,0,1);return new n(chunkTRRLWCL6_cjs.d({l:t.l*(1-o)+l.l*o,a:t.a*(1-o)+l.a*o,b:t.b*(1-o)+l.b*o,alpha:chunkYISEJCI6_cjs.b(t.alpha*(1-o)+l.alpha*o,3)}))};let p=(r,e,t)=>e<=0?[]:e===1?[r]:Array.from({length:e},(l,o)=>r.mix(t,o/(e-1)));n.prototype.tints=function(r=5){return p(this,r,"#ffffff")},n.prototype.shades=function(r=5){return p(this,r,"#000000")},n.prototype.tones=function(r=5){return p(this,r,"#808080")},n.prototype.palette=function(r,e="#ffffff"){return p(this,r,e)};},m=b;module.exports=m;//# sourceMappingURL=mix.cjs.map | ||
| 'use strict';var chunkZNT33DPT_cjs=require('../chunk-ZNT33DPT.cjs');require('../chunk-VSMEJU4Z.cjs'),require('../chunk-2KB6V6KD.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var b=n=>{n.prototype.mix=function(r,e=.5){let t=new n(r).toRgb(),l=this._rawRgb(),o=chunkYISEJCI6_cjs.a(e,0,1);return new n({r:chunkYISEJCI6_cjs.b(l.r*(1-o)+t.r*o),g:chunkYISEJCI6_cjs.b(l.g*(1-o)+t.g*o),b:chunkYISEJCI6_cjs.b(l.b*(1-o)+t.b*o),alpha:chunkYISEJCI6_cjs.b(l.alpha*(1-o)+t.alpha*o,3)})},n.prototype.mixOklab=function(r,e=.5){let t=chunkZNT33DPT_cjs.b(this._rawRgb()),l=chunkZNT33DPT_cjs.b(new n(r)._rawRgb()),o=chunkYISEJCI6_cjs.a(e,0,1);return new n(chunkZNT33DPT_cjs.d({l:t.l*(1-o)+l.l*o,a:t.a*(1-o)+l.a*o,b:t.b*(1-o)+l.b*o,alpha:chunkYISEJCI6_cjs.b(t.alpha*(1-o)+l.alpha*o,3)}))};let p=(r,e,t)=>e<=0?[]:e===1?[r]:Array.from({length:e},(l,o)=>r.mix(t,o/(e-1)));n.prototype.tints=function(r=5){return p(this,r,"#ffffff")},n.prototype.shades=function(r=5){return p(this,r,"#000000")},n.prototype.tones=function(r=5){return p(this,r,"#808080")},n.prototype.palette=function(r,e="#ffffff"){return p(this,r,e)};},m=b;module.exports=m;//# sourceMappingURL=mix.cjs.map | ||
| //# sourceMappingURL=mix.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {b as b$2,d}from'../chunk-OX5CMKKI.mjs';import'../chunk-YLJRINFM.mjs';import'../chunk-Q3O3QQ4H.mjs';import {a,b as b$1}from'../chunk-IOXRZECH.mjs';var b=n=>{n.prototype.mix=function(r,e=.5){let t=new n(r).toRgb(),l=this._rawRgb(),o=a(e,0,1);return new n({r:b$1(l.r*(1-o)+t.r*o),g:b$1(l.g*(1-o)+t.g*o),b:b$1(l.b*(1-o)+t.b*o),alpha:b$1(l.alpha*(1-o)+t.alpha*o,3)})},n.prototype.mixOklab=function(r,e=.5){let t=b$2(this._rawRgb()),l=b$2(new n(r)._rawRgb()),o=a(e,0,1);return new n(d({l:t.l*(1-o)+l.l*o,a:t.a*(1-o)+l.a*o,b:t.b*(1-o)+l.b*o,alpha:b$1(t.alpha*(1-o)+l.alpha*o,3)}))};let p=(r,e,t)=>e<=0?[]:e===1?[r]:Array.from({length:e},(l,o)=>r.mix(t,o/(e-1)));n.prototype.tints=function(r=5){return p(this,r,"#ffffff")},n.prototype.shades=function(r=5){return p(this,r,"#000000")},n.prototype.tones=function(r=5){return p(this,r,"#808080")},n.prototype.palette=function(r,e="#ffffff"){return p(this,r,e)};},m=b;export{m as default};//# sourceMappingURL=mix.mjs.map | ||
| import {b as b$2,d}from'../chunk-2FEDFNW7.mjs';import'../chunk-WGY6QKPW.mjs';import'../chunk-GLKEY6D3.mjs';import {a,b as b$1}from'../chunk-IOXRZECH.mjs';var b=n=>{n.prototype.mix=function(r,e=.5){let t=new n(r).toRgb(),l=this._rawRgb(),o=a(e,0,1);return new n({r:b$1(l.r*(1-o)+t.r*o),g:b$1(l.g*(1-o)+t.g*o),b:b$1(l.b*(1-o)+t.b*o),alpha:b$1(l.alpha*(1-o)+t.alpha*o,3)})},n.prototype.mixOklab=function(r,e=.5){let t=b$2(this._rawRgb()),l=b$2(new n(r)._rawRgb()),o=a(e,0,1);return new n(d({l:t.l*(1-o)+l.l*o,a:t.a*(1-o)+l.a*o,b:t.b*(1-o)+l.b*o,alpha:b$1(t.alpha*(1-o)+l.alpha*o,3)}))};let p=(r,e,t)=>e<=0?[]:e===1?[r]:Array.from({length:e},(l,o)=>r.mix(t,o/(e-1)));n.prototype.tints=function(r=5){return p(this,r,"#ffffff")},n.prototype.shades=function(r=5){return p(this,r,"#000000")},n.prototype.tones=function(r=5){return p(this,r,"#808080")},n.prototype.palette=function(r,e="#ffffff"){return p(this,r,e)};},m=b;export{m as default};//# sourceMappingURL=mix.mjs.map | ||
| //# sourceMappingURL=mix.mjs.map |
@@ -1,2 +0,2 @@ | ||
| import { q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkYXTI4MTI_cjs=require('../chunk-YXTI4MTI.cjs'),chunkTRRLWCL6_cjs=require('../chunk-TRRLWCL6.cjs');require('../chunk-PI5KJ3ZM.cjs');var chunkINDSIUQQ_cjs=require('../chunk-INDSIUQQ.cjs');require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var $=(r,o,e)=>chunkTRRLWCL6_cjs.a(...chunkYXTI4MTI_cjs.c(r,o,e)),A=(r,o,e)=>{let[n,t,m]=chunkYXTI4MTI_cjs.b(r,o,e);return [chunkINDSIUQQ_cjs.b(n),chunkINDSIUQQ_cjs.b(t),chunkINDSIUQQ_cjs.b(m)]},S=(r,o,e,n)=>{chunkYXTI4MTI_cjs.a(r,o,e,n),r[0]=chunkINDSIUQQ_cjs.b(r[0]),r[1]=chunkINDSIUQQ_cjs.b(r[1]),r[2]=chunkINDSIUQQ_cjs.b(r[2]);},E=(r,o,e)=>A(...chunkYXTI4MTI_cjs.s(r,o,e)),q=(r,o,e,n)=>{chunkYXTI4MTI_cjs.t(r,o,e,n),S(r,r[0],r[1],r[2]);},I=Math.PI/180,R=(r,o,e)=>A(...chunkYXTI4MTI_cjs.A(r,o,e)),M=(r,o,e,n)=>{chunkYXTI4MTI_cjs.B(r,o,e,n),S(r,r[0],r[1],r[2]);},z=(r,o,e)=>{let n=e*I;return R(r,o*Math.cos(n),o*Math.sin(n))},H=(r,o,e,n)=>{let t=n*I;M(r,o,e*Math.cos(t),e*Math.sin(t));},J=r=>chunkYXTI4MTI_cjs.q(r,chunkYXTI4MTI_cjs.g),v=(r,o,e)=>{r.toGamutP3=n=>{let t=chunkYXTI4MTI_cjs.r(n,chunkYXTI4MTI_cjs.g,$);if(t===null)return new r(n);let[m,a,u]=t.linear,[k,F,G]=chunkYXTI4MTI_cjs.c(m,a,u);return r._makeFromLinearSrgb(k,F,G,t.alpha)},r.prototype.toP3=function(n=4){let{r:t,g:m,b:a,alpha:u}=chunkYXTI4MTI_cjs.d(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(t,n),g:chunkYISEJCI6_cjs.b(m,n),b:chunkYISEJCI6_cjs.b(a,n),alpha:u,colorSpace:"display-p3"}},r.prototype.toP3String=function(n=4){let{r:t,g:m,b:a,alpha:u}=this.toP3(n);return u<1?`color(display-p3 ${t} ${m} ${a} / ${u})`:`color(display-p3 ${t} ${m} ${a})`},o.push(chunkYXTI4MTI_cjs.f,chunkYXTI4MTI_cjs.e),e.push([chunkYXTI4MTI_cjs.f,"p3"],[chunkYXTI4MTI_cjs.e,"p3"]);},K=v;exports.default=K;exports.inGamutP3=J;exports.labToP3Channels=R;exports.labToP3ChannelsInto=M;exports.lchToP3Channels=z;exports.lchToP3ChannelsInto=H;exports.linearToP3Channels=A;exports.linearToP3ChannelsInto=S;exports.oklchToP3Channels=E;exports.oklchToP3ChannelsInto=q;//# sourceMappingURL=p3.cjs.map | ||
| 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkDCLFNJD3_cjs=require('../chunk-DCLFNJD3.cjs'),chunkZNT33DPT_cjs=require('../chunk-ZNT33DPT.cjs');require('../chunk-6FI7U3TH.cjs');var chunkVSMEJU4Z_cjs=require('../chunk-VSMEJU4Z.cjs');require('../chunk-2KB6V6KD.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var $=(r,o,e)=>chunkZNT33DPT_cjs.a(...chunkDCLFNJD3_cjs.j(r,o,e)),A=(r,o,e)=>{let[n,t,m]=chunkDCLFNJD3_cjs.i(r,o,e);return [chunkVSMEJU4Z_cjs.b(n),chunkVSMEJU4Z_cjs.b(t),chunkVSMEJU4Z_cjs.b(m)]},S=(r,o,e,n)=>{chunkDCLFNJD3_cjs.h(r,o,e,n),r[0]=chunkVSMEJU4Z_cjs.b(r[0]),r[1]=chunkVSMEJU4Z_cjs.b(r[1]),r[2]=chunkVSMEJU4Z_cjs.b(r[2]);},E=(r,o,e)=>A(...chunkDCLFNJD3_cjs.G(r,o,e)),q=(r,o,e,n)=>{chunkDCLFNJD3_cjs.H(r,o,e,n),S(r,r[0],r[1],r[2]);},I=Math.PI/180,R=(r,o,e)=>A(...chunkDCLFNJD3_cjs.O(r,o,e)),M=(r,o,e,n)=>{chunkDCLFNJD3_cjs.P(r,o,e,n),S(r,r[0],r[1],r[2]);},z=(r,o,e)=>{let n=e*I;return R(r,o*Math.cos(n),o*Math.sin(n))},H=(r,o,e,n)=>{let t=n*I;M(r,o,e*Math.cos(t),e*Math.sin(t));},J=r=>chunkDCLFNJD3_cjs.E(r,chunkDCLFNJD3_cjs.n),v=(r,o,e)=>{r.toGamutP3=n=>{let t=chunkDCLFNJD3_cjs.F(n,chunkDCLFNJD3_cjs.n,$);if(t===null)return new r(n);let[m,a,u]=t.linear,[k,F,G]=chunkDCLFNJD3_cjs.j(m,a,u);return r._makeFromLinearSrgb(k,F,G,t.alpha)},r.prototype.toP3=function(n=4){let{r:t,g:m,b:a,alpha:u}=chunkDCLFNJD3_cjs.k(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(t,n),g:chunkYISEJCI6_cjs.b(m,n),b:chunkYISEJCI6_cjs.b(a,n),alpha:u,colorSpace:"display-p3"}},r.prototype.toP3String=function(n=4){let{r:t,g:m,b:a,alpha:u}=this.toP3(n);return u<1?`color(display-p3 ${t} ${m} ${a} / ${u})`:`color(display-p3 ${t} ${m} ${a})`},o.push(chunkDCLFNJD3_cjs.m,chunkDCLFNJD3_cjs.l),e.push([chunkDCLFNJD3_cjs.m,"p3"],[chunkDCLFNJD3_cjs.l,"p3"]);},K=v;exports.default=K;exports.inGamutP3=J;exports.labToP3Channels=R;exports.labToP3ChannelsInto=M;exports.lchToP3Channels=z;exports.lchToP3ChannelsInto=H;exports.linearToP3Channels=A;exports.linearToP3ChannelsInto=S;exports.oklchToP3Channels=E;exports.oklchToP3ChannelsInto=q;//# sourceMappingURL=p3.cjs.map | ||
| //# sourceMappingURL=p3.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { P as P3Color, A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { P as P3Color, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { P as P3Color, A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { P as P3Color, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {b,a,s,t,A as A$1,B,q as q$1,g,r,c,d,f,e}from'../chunk-3LS3HCHH.mjs';import {a as a$1}from'../chunk-OX5CMKKI.mjs';import'../chunk-F4W4HJCD.mjs';import {b as b$1}from'../chunk-YLJRINFM.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b as b$2}from'../chunk-IOXRZECH.mjs';var $=(r,o,e)=>a$1(...c(r,o,e)),A=(r,o,e)=>{let[n,t,m]=b(r,o,e);return [b$1(n),b$1(t),b$1(m)]},S=(r,o,e,n)=>{a(r,o,e,n),r[0]=b$1(r[0]),r[1]=b$1(r[1]),r[2]=b$1(r[2]);},E=(r,o,e)=>A(...s(r,o,e)),q=(r,o,e,n)=>{t(r,o,e,n),S(r,r[0],r[1],r[2]);},I=Math.PI/180,R=(r,o,e)=>A(...A$1(r,o,e)),M=(r,o,e,n)=>{B(r,o,e,n),S(r,r[0],r[1],r[2]);},z=(r,o,e)=>{let n=e*I;return R(r,o*Math.cos(n),o*Math.sin(n))},H=(r,o,e,n)=>{let t=n*I;M(r,o,e*Math.cos(t),e*Math.sin(t));},J=r=>q$1(r,g),v=(r$1,o,e$1)=>{r$1.toGamutP3=n=>{let t=r(n,g,$);if(t===null)return new r$1(n);let[m,a,u]=t.linear,[k,F,G]=c(m,a,u);return r$1._makeFromLinearSrgb(k,F,G,t.alpha)},r$1.prototype.toP3=function(n=4){let{r:t,g:m,b:a,alpha:u}=d(this._rawRgb());return {r:b$2(t,n),g:b$2(m,n),b:b$2(a,n),alpha:u,colorSpace:"display-p3"}},r$1.prototype.toP3String=function(n=4){let{r:t,g:m,b:a,alpha:u}=this.toP3(n);return u<1?`color(display-p3 ${t} ${m} ${a} / ${u})`:`color(display-p3 ${t} ${m} ${a})`},o.push(f,e),e$1.push([f,"p3"],[e,"p3"]);},K=v;export{K as default,J as inGamutP3,R as labToP3Channels,M as labToP3ChannelsInto,z as lchToP3Channels,H as lchToP3ChannelsInto,A as linearToP3Channels,S as linearToP3ChannelsInto,E as oklchToP3Channels,q as oklchToP3ChannelsInto};//# sourceMappingURL=p3.mjs.map | ||
| import {i,h,G,H as H$1,O,P,E as E$1,n,F,j,k,m,l}from'../chunk-JT2PPQ6V.mjs';import {a}from'../chunk-2FEDFNW7.mjs';import'../chunk-YQKSXMBN.mjs';import {b}from'../chunk-WGY6QKPW.mjs';import'../chunk-GLKEY6D3.mjs';import {b as b$1}from'../chunk-IOXRZECH.mjs';var $=(r,o,e)=>a(...j(r,o,e)),A=(r,o,e)=>{let[n,t,m]=i(r,o,e);return [b(n),b(t),b(m)]},S=(r,o,e,n)=>{h(r,o,e,n),r[0]=b(r[0]),r[1]=b(r[1]),r[2]=b(r[2]);},E=(r,o,e)=>A(...G(r,o,e)),q=(r,o,e,n)=>{H$1(r,o,e,n),S(r,r[0],r[1],r[2]);},I=Math.PI/180,R=(r,o,e)=>A(...O(r,o,e)),M=(r,o,e,n)=>{P(r,o,e,n),S(r,r[0],r[1],r[2]);},z=(r,o,e)=>{let n=e*I;return R(r,o*Math.cos(n),o*Math.sin(n))},H=(r,o,e,n)=>{let t=n*I;M(r,o,e*Math.cos(t),e*Math.sin(t));},J=r=>E$1(r,n),v=(r,o,e)=>{r.toGamutP3=n$1=>{let t=F(n$1,n,$);if(t===null)return new r(n$1);let[m,a,u]=t.linear,[k,F$1,G]=j(m,a,u);return r._makeFromLinearSrgb(k,F$1,G,t.alpha)},r.prototype.toP3=function(n=4){let{r:t,g:m,b:a,alpha:u}=k(this._rawRgb());return {r:b$1(t,n),g:b$1(m,n),b:b$1(a,n),alpha:u,colorSpace:"display-p3"}},r.prototype.toP3String=function(n=4){let{r:t,g:m,b:a,alpha:u}=this.toP3(n);return u<1?`color(display-p3 ${t} ${m} ${a} / ${u})`:`color(display-p3 ${t} ${m} ${a})`},o.push(m,l),e.push([m,"p3"],[l,"p3"]);},K=v;export{K as default,J as inGamutP3,R as labToP3Channels,M as labToP3ChannelsInto,z as lchToP3Channels,H as lchToP3ChannelsInto,A as linearToP3Channels,S as linearToP3ChannelsInto,E as oklchToP3Channels,q as oklchToP3ChannelsInto};//# sourceMappingURL=p3.mjs.map | ||
| //# sourceMappingURL=p3.mjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../../src/plugins/p3.ts"],"names":["p3FromLinear","g","b","linearSrgbToOklab","linearP3ToSrgb","linearToP3Channels","lr","lg","lb","r","srgbLinearToP3Linear","srgbFromLinear","linearToP3ChannelsInto","out","srgbLinearToP3LinearInto","oklchToP3Channels","l","c","h","oklchToLinear","oklchToP3ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToP3Channels","a","labToLinearSrgb","labToP3ChannelsInto","labToLinearSrgbInto","lchToP3Channels","hRad","lchToP3ChannelsInto","inGamutP3","input","inGamutCustom","oklabToLinearP3","p3","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lpR","lpG","lpB","precision","alpha","rgbToP3Raw","round","parseP3String","parseP3Object","p3_default"],"mappings":"+QAiBA,IAAMA,EAAe,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GAC1CC,GAAAA,CAAkB,GAAGC,CAAAA,CAAe,CAAA,CAAGH,EAAGC,CAAC,CAAC,EAmBjCG,CAAAA,CAAqB,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CAClG,GAAM,CAACC,EAAGR,CAAAA,CAAGC,CAAC,EAAIQ,CAAAA,CAAqBJ,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACjD,OAAO,CAACG,GAAAA,CAAeF,CAAC,CAAA,CAAGE,GAAAA,CAAeV,CAAC,CAAA,CAAGU,GAAAA,CAAeT,CAAC,CAAC,CACjE,EAGaU,CAAAA,CAAyB,CAACC,EAA8BP,CAAAA,CAAYC,CAAAA,CAAYC,IAAqB,CAChHM,CAAAA,CAAyBD,EAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACxCK,CAAAA,CAAI,CAAC,CAAA,CAAIF,GAAAA,CAAeE,EAAI,CAAC,CAAE,EAC/BA,CAAAA,CAAI,CAAC,EAAIF,GAAAA,CAAeE,CAAAA,CAAI,CAAC,CAAE,CAAA,CAC/BA,EAAI,CAAC,CAAA,CAAIF,IAAeE,CAAAA,CAAI,CAAC,CAAE,EACjC,CAAA,CAQaE,EAAoB,CAACC,CAAAA,CAAWC,EAAWC,CAAAA,GACtDb,CAAAA,CAAmB,GAAGc,CAAAA,CAAcH,CAAAA,CAAGC,EAAGC,CAAC,CAAC,EAGjCE,CAAAA,CAAwB,CAACP,EAA8BG,CAAAA,CAAWC,CAAAA,CAAWC,IAAoB,CAC5GG,CAAAA,CAAkBR,EAAKG,CAAAA,CAAGC,CAAAA,CAAGC,CAAC,CAAA,CAC9BN,CAAAA,CAAuBC,EAAKA,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AC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAIC,CAAC,GACpG,CAAA,CACAmC,CAAAA,CAAQ,KAAKW,CAAAA,CAAeC,CAAa,EACzCX,GAAAA,CAAc,IAAA,CAAK,CAACU,CAAAA,CAAe,IAAI,EAAG,CAACC,CAAAA,CAAe,IAAI,CAAC,EACjE,EAEOC,CAAAA,CAAQf","file":"p3.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearP3ToSrgb,\n oklabToLinearP3,\n parseP3Object,\n parseP3String,\n rgbToP3Raw,\n srgbLinearToP3Linear,\n srgbLinearToP3LinearInto,\n} from '../colorModels/p3.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { srgbFromLinear } from '../transfer.js';\nimport type { AnyColor, P3Color } from '../types.js';\n\nconst p3FromLinear = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearP3ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toP3(precision?: number): P3Color;\n toP3String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutP3(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Display-P3 channels.\n * This is the cheap step — only a matrix multiply + gamma encoding, no cbrt.\n * Pair with oklchToLinear to convert one OKLCH color to multiple spaces without\n * repeating the expensive OKLab pipeline.\n */\nexport const linearToP3Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToP3Linear(lr, lg, lb);\n return [srgbFromLinear(r), srgbFromLinear(g), srgbFromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToP3Channels — writes [pr, pg, pb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToP3ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToP3LinearInto(out, lr, lg, lb);\n out[0] = srgbFromLinear(out[0]!);\n out[1] = srgbFromLinear(out[1]!);\n out[2] = srgbFromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the sRGB transfer function (P3 does not use DCI-P3 gamma 2.6).\n */\nexport const oklchToP3Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToP3Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const oklchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear P3 → gamma P3.\n */\nexport const labToP3Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToP3Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const labToP3ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma P3. Out-of-gamut channels may exceed [0, 1].\n */\nexport const lchToP3Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToP3Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const lchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToP3ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Display-P3 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ P3).\n */\nexport const inGamutP3 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearP3);\n\nconst p3: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutP3 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearP3, p3FromLinear);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-P3 → linear-sRGB (wide-gamut when the P3 color is outside sRGB),\n // then gamma-encode for storage. No round-trip through OKLab.\n const [lpR, lpG, lpB] = mapped.linear;\n const [lr, lg, lb] = linearP3ToSrgb(lpR, lpG, lpB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toP3 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToP3Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'display-p3' as const,\n };\n };\n ColordxClass.prototype.toP3String = function (precision = 4) {\n const { r, g, b, alpha } = this.toP3(precision);\n return alpha < 1 ? `color(display-p3 ${r} ${g} ${b} / ${alpha})` : `color(display-p3 ${r} ${g} ${b})`;\n };\n parsers.push(parseP3String, parseP3Object);\n formatParsers.push([parseP3String, 'p3'], [parseP3Object, 'p3']);\n};\n\nexport default p3;\n"]} | ||
| {"version":3,"sources":["../../src/plugins/p3.ts"],"names":["p3FromLinear","g","b","linearSrgbToOklab","linearP3ToSrgb","linearToP3Channels","lr","lg","lb","r","srgbLinearToP3Linear","srgbFromLinear","linearToP3ChannelsInto","out","srgbLinearToP3LinearInto","oklchToP3Channels","l","c","h","oklchToLinear","oklchToP3ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToP3Channels","a","labToLinearSrgb","labToP3ChannelsInto","labToLinearSrgbInto","lchToP3Channels","hRad","lchToP3ChannelsInto","inGamutP3","input","inGamutCustom","oklabToLinearP3","p3","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lpR","lpG","lpB","precision","alpha","rgbToP3Raw","round","parseP3String","parseP3Object","p3_default"],"mappings":"iQAiBA,IAAMA,EAAe,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GAC1CC,CAAAA,CAAkB,GAAGC,CAAAA,CAAe,CAAA,CAAGH,EAAGC,CAAC,CAAC,EAmBjCG,CAAAA,CAAqB,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CAClG,GAAM,CAACC,EAAGR,CAAAA,CAAGC,CAAC,EAAIQ,CAAAA,CAAqBJ,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACjD,OAAO,CAACG,CAAAA,CAAeF,CAAC,CAAA,CAAGE,CAAAA,CAAeV,CAAC,CAAA,CAAGU,CAAAA,CAAeT,CAAC,CAAC,CACjE,EAGaU,CAAAA,CAAyB,CAACC,EAA8BP,CAAAA,CAAYC,CAAAA,CAAYC,IAAqB,CAChHM,CAAAA,CAAyBD,EAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACxCK,CAAAA,CAAI,CAAC,CAAA,CAAIF,CAAAA,CAAeE,EAAI,CAAC,CAAE,EAC/BA,CAAAA,CAAI,CAAC,EAAIF,CAAAA,CAAeE,CAAAA,CAAI,CAAC,CAAE,CAAA,CAC/BA,EAAI,CAAC,CAAA,CAAIF,EAAeE,CAAAA,CAAI,CAAC,CAAE,EACjC,CAAA,CAQaE,EAAoB,CAACC,CAAAA,CAAWC,EAAWC,CAAAA,GACtDb,CAAAA,CAAmB,GAAGc,CAAAA,CAAcH,CAAAA,CAAGC,EA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I,IAAA,CAAK,KAAKD,CAAS,CAAA,CAC9C,OAAOC,CAAAA,CAAQ,CAAA,CAAI,oBAAoBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAIC,CAAC,MAAM2C,CAAK,CAAA,CAAA,CAAA,CAAM,oBAAoBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAIC,CAAC,GACpG,CAAA,CACAmC,CAAAA,CAAQ,KAAKW,CAAAA,CAAeC,CAAa,EACzCX,CAAAA,CAAc,IAAA,CAAK,CAACU,CAAAA,CAAe,IAAI,EAAG,CAACC,CAAAA,CAAe,IAAI,CAAC,EACjE,EAEOC,CAAAA,CAAQf","file":"p3.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearP3ToSrgb,\n oklabToLinearP3,\n parseP3Object,\n parseP3String,\n rgbToP3Raw,\n srgbLinearToP3Linear,\n srgbLinearToP3LinearInto,\n} from '../colorModels/p3.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { srgbFromLinear } from '../transfer.js';\nimport type { AnyColor, P3Color } from '../types.js';\n\nconst p3FromLinear = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearP3ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toP3(precision?: number): P3Color;\n toP3String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutP3(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Display-P3 channels.\n * This is the cheap step — only a matrix multiply + gamma encoding, no cbrt.\n * Pair with oklchToLinear to convert one OKLCH color to multiple spaces without\n * repeating the expensive OKLab pipeline.\n */\nexport const linearToP3Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToP3Linear(lr, lg, lb);\n return [srgbFromLinear(r), srgbFromLinear(g), srgbFromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToP3Channels — writes [pr, pg, pb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToP3ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToP3LinearInto(out, lr, lg, lb);\n out[0] = srgbFromLinear(out[0]!);\n out[1] = srgbFromLinear(out[1]!);\n out[2] = srgbFromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the sRGB transfer function (P3 does not use DCI-P3 gamma 2.6).\n */\nexport const oklchToP3Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToP3Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const oklchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear P3 → gamma P3.\n */\nexport const labToP3Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToP3Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const labToP3ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma P3. Out-of-gamut channels may exceed [0, 1].\n */\nexport const lchToP3Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToP3Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const lchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToP3ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Display-P3 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ P3).\n */\nexport const inGamutP3 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearP3);\n\nconst p3: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutP3 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearP3, p3FromLinear);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-P3 → linear-sRGB (wide-gamut when the P3 color is outside sRGB),\n // then gamma-encode for storage. No round-trip through OKLab.\n const [lpR, lpG, lpB] = mapped.linear;\n const [lr, lg, lb] = linearP3ToSrgb(lpR, lpG, lpB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toP3 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToP3Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'display-p3' as const,\n };\n };\n ColordxClass.prototype.toP3String = function (precision = 4) {\n const { r, g, b, alpha } = this.toP3(precision);\n return alpha < 1 ? `color(display-p3 ${r} ${g} ${b} / ${alpha})` : `color(display-p3 ${r} ${g} ${b})`;\n };\n parsers.push(parseP3String, parseP3Object);\n formatParsers.push([parseP3String, 'p3'], [parseP3Object, 'p3']);\n};\n\nexport default p3;\n"]} |
@@ -1,2 +0,2 @@ | ||
| 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkYXTI4MTI_cjs=require('../chunk-YXTI4MTI.cjs'),chunkTRRLWCL6_cjs=require('../chunk-TRRLWCL6.cjs');require('../chunk-PI5KJ3ZM.cjs');var chunkINDSIUQQ_cjs=require('../chunk-INDSIUQQ.cjs');require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var $=(r,n,o)=>chunkTRRLWCL6_cjs.a(...chunkYXTI4MTI_cjs.j(r,n,o)),A=(r,n,o)=>{let[e,t,m]=chunkYXTI4MTI_cjs.i(r,n,o);return [chunkINDSIUQQ_cjs.d(e),chunkINDSIUQQ_cjs.d(t),chunkINDSIUQQ_cjs.d(m)]},S=(r,n,o,e)=>{chunkYXTI4MTI_cjs.h(r,n,o,e),r[0]=chunkINDSIUQQ_cjs.d(r[0]),r[1]=chunkINDSIUQQ_cjs.d(r[1]),r[2]=chunkINDSIUQQ_cjs.d(r[2]);},E=(r,n,o)=>A(...chunkYXTI4MTI_cjs.s(r,n,o)),q=(r,n,o,e)=>{chunkYXTI4MTI_cjs.t(r,n,o,e),S(r,r[0],r[1],r[2]);},I=Math.PI/180,v=(r,n,o)=>A(...chunkYXTI4MTI_cjs.A(r,n,o)),M=(r,n,o,e)=>{chunkYXTI4MTI_cjs.B(r,n,o,e),S(r,r[0],r[1],r[2]);},z=(r,n,o)=>{let e=o*I;return v(r,n*Math.cos(e),n*Math.sin(e))},H=(r,n,o,e)=>{let t=e*I;M(r,n,o*Math.cos(t),o*Math.sin(t));},J=r=>chunkYXTI4MTI_cjs.q(r,chunkYXTI4MTI_cjs.n),_=(r,n,o)=>{r.toGamutRec2020=e=>{let t=chunkYXTI4MTI_cjs.r(e,chunkYXTI4MTI_cjs.n,$);if(t===null)return new r(e);let[m,b,a]=t.linear,[k,F,G]=chunkYXTI4MTI_cjs.j(m,b,a);return r._makeFromLinearSrgb(k,F,G,t.alpha)},r.prototype.toRec2020=function(e=4){let{r:t,g:m,b,alpha:a}=chunkYXTI4MTI_cjs.k(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(t,e),g:chunkYISEJCI6_cjs.b(m,e),b:chunkYISEJCI6_cjs.b(b,e),alpha:a,colorSpace:"rec2020"}},r.prototype.toRec2020String=function(e=4){let{r:t,g:m,b,alpha:a}=this.toRec2020(e);return a<1?`color(rec2020 ${t} ${m} ${b} / ${a})`:`color(rec2020 ${t} ${m} ${b})`},n.push(chunkYXTI4MTI_cjs.m,chunkYXTI4MTI_cjs.l),o.push([chunkYXTI4MTI_cjs.m,"rec2020"],[chunkYXTI4MTI_cjs.l,"rec2020"]);},K=_;exports.default=K;exports.inGamutRec2020=J;exports.labToRec2020Channels=v;exports.labToRec2020ChannelsInto=M;exports.lchToRec2020Channels=z;exports.lchToRec2020ChannelsInto=H;exports.linearToRec2020Channels=A;exports.linearToRec2020ChannelsInto=S;exports.oklchToRec2020Channels=E;exports.oklchToRec2020ChannelsInto=q;//# sourceMappingURL=rec2020.cjs.map | ||
| 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkDCLFNJD3_cjs=require('../chunk-DCLFNJD3.cjs'),chunkZNT33DPT_cjs=require('../chunk-ZNT33DPT.cjs');require('../chunk-6FI7U3TH.cjs');var chunkVSMEJU4Z_cjs=require('../chunk-VSMEJU4Z.cjs');require('../chunk-2KB6V6KD.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var $=(r,n,o)=>chunkZNT33DPT_cjs.a(...chunkDCLFNJD3_cjs.x(r,n,o)),A=(r,n,o)=>{let[e,t,m]=chunkDCLFNJD3_cjs.w(r,n,o);return [chunkVSMEJU4Z_cjs.d(e),chunkVSMEJU4Z_cjs.d(t),chunkVSMEJU4Z_cjs.d(m)]},S=(r,n,o,e)=>{chunkDCLFNJD3_cjs.v(r,n,o,e),r[0]=chunkVSMEJU4Z_cjs.d(r[0]),r[1]=chunkVSMEJU4Z_cjs.d(r[1]),r[2]=chunkVSMEJU4Z_cjs.d(r[2]);},E=(r,n,o)=>A(...chunkDCLFNJD3_cjs.G(r,n,o)),q=(r,n,o,e)=>{chunkDCLFNJD3_cjs.H(r,n,o,e),S(r,r[0],r[1],r[2]);},I=Math.PI/180,v=(r,n,o)=>A(...chunkDCLFNJD3_cjs.O(r,n,o)),M=(r,n,o,e)=>{chunkDCLFNJD3_cjs.P(r,n,o,e),S(r,r[0],r[1],r[2]);},z=(r,n,o)=>{let e=o*I;return v(r,n*Math.cos(e),n*Math.sin(e))},H=(r,n,o,e)=>{let t=e*I;M(r,n,o*Math.cos(t),o*Math.sin(t));},J=r=>chunkDCLFNJD3_cjs.E(r,chunkDCLFNJD3_cjs.B),_=(r,n,o)=>{r.toGamutRec2020=e=>{let t=chunkDCLFNJD3_cjs.F(e,chunkDCLFNJD3_cjs.B,$);if(t===null)return new r(e);let[m,b,a]=t.linear,[k,F,G]=chunkDCLFNJD3_cjs.x(m,b,a);return r._makeFromLinearSrgb(k,F,G,t.alpha)},r.prototype.toRec2020=function(e=4){let{r:t,g:m,b,alpha:a}=chunkDCLFNJD3_cjs.y(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(t,e),g:chunkYISEJCI6_cjs.b(m,e),b:chunkYISEJCI6_cjs.b(b,e),alpha:a,colorSpace:"rec2020"}},r.prototype.toRec2020String=function(e=4){let{r:t,g:m,b,alpha:a}=this.toRec2020(e);return a<1?`color(rec2020 ${t} ${m} ${b} / ${a})`:`color(rec2020 ${t} ${m} ${b})`},n.push(chunkDCLFNJD3_cjs.A,chunkDCLFNJD3_cjs.z),o.push([chunkDCLFNJD3_cjs.A,"rec2020"],[chunkDCLFNJD3_cjs.z,"rec2020"]);},K=_;exports.default=K;exports.inGamutRec2020=J;exports.labToRec2020Channels=v;exports.labToRec2020ChannelsInto=M;exports.lchToRec2020Channels=z;exports.lchToRec2020ChannelsInto=H;exports.linearToRec2020Channels=A;exports.linearToRec2020ChannelsInto=S;exports.oklchToRec2020Channels=E;exports.oklchToRec2020ChannelsInto=q;//# sourceMappingURL=rec2020.cjs.map | ||
| //# sourceMappingURL=rec2020.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { R as Rec2020Color, A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.cjs'; | ||
| import { R as Rec2020Color, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { R as Rec2020Color, A as AnyColor, q as Plugin } from '../colordx-dFaFF5rN.js'; | ||
| import { R as Rec2020Color, A as AnyColor, s as Plugin } from '../colordx-DmR1sN5A.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {i,h,s,t,A as A$1,B,q as q$1,n,r,j,k,m,l}from'../chunk-3LS3HCHH.mjs';import {a}from'../chunk-OX5CMKKI.mjs';import'../chunk-F4W4HJCD.mjs';import {d}from'../chunk-YLJRINFM.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b}from'../chunk-IOXRZECH.mjs';var $=(r,n,o)=>a(...j(r,n,o)),A=(r,n,o)=>{let[e,t,m]=i(r,n,o);return [d(e),d(t),d(m)]},S=(r,n,o,e)=>{h(r,n,o,e),r[0]=d(r[0]),r[1]=d(r[1]),r[2]=d(r[2]);},E=(r,n,o)=>A(...s(r,n,o)),q=(r,n,o,e)=>{t(r,n,o,e),S(r,r[0],r[1],r[2]);},I=Math.PI/180,v=(r,n,o)=>A(...A$1(r,n,o)),M=(r,n,o,e)=>{B(r,n,o,e),S(r,r[0],r[1],r[2]);},z=(r,n,o)=>{let e=o*I;return v(r,n*Math.cos(e),n*Math.sin(e))},H=(r,n,o,e)=>{let t=e*I;M(r,n,o*Math.cos(t),o*Math.sin(t));},J=r=>q$1(r,n),_=(r$1,n$1,o)=>{r$1.toGamutRec2020=e=>{let t=r(e,n,$);if(t===null)return new r$1(e);let[m,b,a]=t.linear,[k,F,G]=j(m,b,a);return r$1._makeFromLinearSrgb(k,F,G,t.alpha)},r$1.prototype.toRec2020=function(e=4){let{r:t,g:m,b: b$1,alpha:a}=k(this._rawRgb());return {r:b(t,e),g:b(m,e),b:b(b$1,e),alpha:a,colorSpace:"rec2020"}},r$1.prototype.toRec2020String=function(e=4){let{r:t,g:m,b,alpha:a}=this.toRec2020(e);return a<1?`color(rec2020 ${t} ${m} ${b} / ${a})`:`color(rec2020 ${t} ${m} ${b})`},n$1.push(m,l),o.push([m,"rec2020"],[l,"rec2020"]);},K=_;export{K as default,J as inGamutRec2020,v as labToRec2020Channels,M as labToRec2020ChannelsInto,z as lchToRec2020Channels,H as lchToRec2020ChannelsInto,A as linearToRec2020Channels,S as linearToRec2020ChannelsInto,E as oklchToRec2020Channels,q as oklchToRec2020ChannelsInto};//# sourceMappingURL=rec2020.mjs.map | ||
| import {w,v as v$1,G,H as H$1,O,P,E as E$1,B,F,x,y,A as A$1,z as z$1}from'../chunk-JT2PPQ6V.mjs';import {a}from'../chunk-2FEDFNW7.mjs';import'../chunk-YQKSXMBN.mjs';import {d}from'../chunk-WGY6QKPW.mjs';import'../chunk-GLKEY6D3.mjs';import {b}from'../chunk-IOXRZECH.mjs';var $=(r,n,o)=>a(...x(r,n,o)),A=(r,n,o)=>{let[e,t,m]=w(r,n,o);return [d(e),d(t),d(m)]},S=(r,n,o,e)=>{v$1(r,n,o,e),r[0]=d(r[0]),r[1]=d(r[1]),r[2]=d(r[2]);},E=(r,n,o)=>A(...G(r,n,o)),q=(r,n,o,e)=>{H$1(r,n,o,e),S(r,r[0],r[1],r[2]);},I=Math.PI/180,v=(r,n,o)=>A(...O(r,n,o)),M=(r,n,o,e)=>{P(r,n,o,e),S(r,r[0],r[1],r[2]);},z=(r,n,o)=>{let e=o*I;return v(r,n*Math.cos(e),n*Math.sin(e))},H=(r,n,o,e)=>{let t=e*I;M(r,n,o*Math.cos(t),o*Math.sin(t));},J=r=>E$1(r,B),_=(r,n,o)=>{r.toGamutRec2020=e=>{let t=F(e,B,$);if(t===null)return new r(e);let[m,b,a]=t.linear,[k,F$1,G]=x(m,b,a);return r._makeFromLinearSrgb(k,F$1,G,t.alpha)},r.prototype.toRec2020=function(e=4){let{r:t,g:m,b: b$1,alpha:a}=y(this._rawRgb());return {r:b(t,e),g:b(m,e),b:b(b$1,e),alpha:a,colorSpace:"rec2020"}},r.prototype.toRec2020String=function(e=4){let{r:t,g:m,b,alpha:a}=this.toRec2020(e);return a<1?`color(rec2020 ${t} ${m} ${b} / ${a})`:`color(rec2020 ${t} ${m} ${b})`},n.push(A$1,z$1),o.push([A$1,"rec2020"],[z$1,"rec2020"]);},K=_;export{K as default,J as inGamutRec2020,v as labToRec2020Channels,M as labToRec2020ChannelsInto,z as lchToRec2020Channels,H as lchToRec2020ChannelsInto,A as linearToRec2020Channels,S as linearToRec2020ChannelsInto,E as oklchToRec2020Channels,q as oklchToRec2020ChannelsInto};//# sourceMappingURL=rec2020.mjs.map | ||
| //# sourceMappingURL=rec2020.mjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../../src/plugins/rec2020.ts"],"names":["rec2020FromLinearConverter","g","b","linearSrgbToOklab","linearRec2020ToSrgb","linearToRec2020Channels","lr","lg","lb","r","srgbLinearToRec2020Linear","rec2020FromLinear","linearToRec2020ChannelsInto","out","srgbLinearToRec2020LinearInto","oklchToRec2020Channels","l","c","h","oklchToLinear","oklchToRec2020ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToRec2020Channels","a","labToLinearSrgb","labToRec2020ChannelsInto","labToLinearSrgbInto","lchToRec2020Channels","hRad","lchToRec2020ChannelsInto","inGamutRec2020","input","inGamutCustom","oklabToLinearRec2020","rec2020","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lrR","lrG","lrB","precision","alpha","rgbToRec2020Raw","round","parseRec2020String","parseRec2020Object","rec2020_default"],"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,CAAoBC,CAAkB,EACnDX,CAAAA,CAAc,IAAA,CAAK,CAACU,CAAAA,CAAoB,SAAS,EAAG,CAACC,CAAAA,CAAoB,SAAS,CAAC,EACrF,EAEOC,CAAAA,CAAQf","file":"rec2020.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearRec2020ToSrgb,\n oklabToLinearRec2020,\n parseRec2020Object,\n parseRec2020String,\n rgbToRec2020Raw,\n srgbLinearToRec2020Linear,\n srgbLinearToRec2020LinearInto,\n} from '../colorModels/rec2020.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { rec2020FromLinear } from '../transfer.js';\nimport type { AnyColor, Rec2020Color } from '../types.js';\n\nconst rec2020FromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearRec2020ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toRec2020(precision?: number): Rec2020Color;\n toRec2020String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutRec2020(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Rec.2020 channels.\n * This is the cheap step — only a matrix multiply + BT.2020 gamma, no cbrt.\n */\nexport const linearToRec2020Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToRec2020Linear(lr, lg, lb);\n return [rec2020FromLinear(r), rec2020FromLinear(g), rec2020FromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToRec2020Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToRec2020ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToRec2020LinearInto(out, lr, lg, lb);\n out[0] = rec2020FromLinear(out[0]!);\n out[1] = rec2020FromLinear(out[1]!);\n out[2] = rec2020FromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the BT.2020 transfer function (exponent 0.45, distinct from sRGB 1/2.4).\n */\nexport const oklchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToRec2020Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const oklchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear Rec.2020 → BT.2020 gamma.\n */\nexport const labToRec2020Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToRec2020Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const labToRec2020ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma Rec.2020.\n */\nexport const lchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToRec2020Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const lchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToRec2020ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Rec.2020 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ Rec.2020).\n */\nexport const inGamutRec2020 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearRec2020);\n\nconst rec2020: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutRec2020 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearRec2020, rec2020FromLinearConverter);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-Rec.2020 → linear-sRGB (wide-gamut when the Rec.2020 color is outside\n // sRGB), then gamma-encode for storage. No round-trip through OKLab.\n const [lrR, lrG, lrB] = mapped.linear;\n const [lr, lg, lb] = linearRec2020ToSrgb(lrR, lrG, lrB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toRec2020 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToRec2020Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'rec2020' as const,\n };\n };\n ColordxClass.prototype.toRec2020String = function (precision = 4) {\n const { r, g, b, alpha } = this.toRec2020(precision);\n return alpha < 1 ? `color(rec2020 ${r} ${g} ${b} / ${alpha})` : `color(rec2020 ${r} ${g} ${b})`;\n };\n parsers.push(parseRec2020String, parseRec2020Object);\n formatParsers.push([parseRec2020String, 'rec2020'], [parseRec2020Object, 'rec2020']);\n};\n\nexport default rec2020;\n"]} | ||
| {"version":3,"sources":["../../src/plugins/rec2020.ts"],"names":["rec2020FromLinearConverter","g","b","linearSrgbToOklab","linearRec2020ToSrgb","linearToRec2020Channels","lr","lg","lb","r","srgbLinearToRec2020Linear","rec2020FromLinear","linearToRec2020ChannelsInto","out","srgbLinearToRec2020LinearInto","oklchToRec2020Channels","l","c","h","oklchToLinear","oklchToRec2020ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToRec2020Channels","a","labToLinearSrgb","labToRec2020ChannelsInto","labToLinearSrgbInto","lchToRec2020Channels","hRad","lchToRec2020ChannelsInto","inGamutRec2020","input","inGamutCustom","oklabToLinearRec2020","rec2020","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lrR","lrG","lrB","precision","alpha","rgbToRec2020Raw","round","parseRec2020String","parseRec2020Object","rec2020_default"],"mappings":"+QAiBA,IAAMA,EAA6B,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GACxDC,CAAAA,CAAkB,GAAGC,CAAAA,CAAoB,CAAA,CAAGH,EAAGC,CAAC,CAAC,EAiBtCG,CAAAA,CAA0B,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CACvG,GAAM,CAACC,EAAGR,CAAAA,CAAGC,CAAC,EAAIQ,CAAAA,CAA0BJ,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACtD,OAAO,CAACG,CAAAA,CAAkBF,CAAC,CAAA,CAAGE,CAAAA,CAAkBV,CAAC,CAAA,CAAGU,CAAAA,CAAkBT,CAAC,CAAC,CAC1E,EAGaU,CAAAA,CAA8B,CAACC,EAA8BP,CAAAA,CAAYC,CAAAA,CAAYC,IAAqB,CACrHM,GAAAA,CAA8BD,EAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CAC7CK,CAAAA,CAAI,CAAC,CAAA,CAAIF,CAAAA,CAAkBE,EAAI,CAAC,CAAE,EAClCA,CAAAA,CAAI,CAAC,EAAIF,CAAAA,CAAkBE,CAAAA,CAAI,CAAC,CAAE,CAAA,CAClCA,EAAI,CAAC,CAAA,CAAIF,EAAkBE,CAAAA,CAAI,CAAC,CAAE,EACpC,CAAA,CAQaE,EAAyB,CAACC,CAAAA,CAAWC,EAAW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M,CAAE,EAAAnC,CAAAA,CAAG,CAAA,CAAAR,EAAG,CAAA,CAAG,KAAA,CAAA4C,CAAM,CAAA,CAAI,IAAA,CAAK,UAAUD,CAAS,CAAA,CACnD,OAAOC,CAAAA,CAAQ,CAAA,CAAI,iBAAiBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,MAAM4C,CAAK,CAAA,CAAA,CAAA,CAAM,iBAAiBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,GAC9F,CAAA,CACAoC,CAAAA,CAAQ,KAAKW,GAAAA,CAAoBC,GAAkB,EACnDX,CAAAA,CAAc,IAAA,CAAK,CAACU,GAAAA,CAAoB,SAAS,EAAG,CAACC,GAAAA,CAAoB,SAAS,CAAC,EACrF,EAEOC,CAAAA,CAAQf","file":"rec2020.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearRec2020ToSrgb,\n oklabToLinearRec2020,\n parseRec2020Object,\n parseRec2020String,\n rgbToRec2020Raw,\n srgbLinearToRec2020Linear,\n srgbLinearToRec2020LinearInto,\n} from '../colorModels/rec2020.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { rec2020FromLinear } from '../transfer.js';\nimport type { AnyColor, Rec2020Color } from '../types.js';\n\nconst rec2020FromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearRec2020ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toRec2020(precision?: number): Rec2020Color;\n toRec2020String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutRec2020(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Rec.2020 channels.\n * This is the cheap step — only a matrix multiply + BT.2020 gamma, no cbrt.\n */\nexport const linearToRec2020Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToRec2020Linear(lr, lg, lb);\n return [rec2020FromLinear(r), rec2020FromLinear(g), rec2020FromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToRec2020Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToRec2020ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToRec2020LinearInto(out, lr, lg, lb);\n out[0] = rec2020FromLinear(out[0]!);\n out[1] = rec2020FromLinear(out[1]!);\n out[2] = rec2020FromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the BT.2020 transfer function (exponent 0.45, distinct from sRGB 1/2.4).\n */\nexport const oklchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToRec2020Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const oklchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear Rec.2020 → BT.2020 gamma.\n */\nexport const labToRec2020Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToRec2020Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const labToRec2020ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma Rec.2020.\n */\nexport const lchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToRec2020Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const lchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToRec2020ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Rec.2020 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ Rec.2020).\n */\nexport const inGamutRec2020 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearRec2020);\n\nconst rec2020: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutRec2020 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearRec2020, rec2020FromLinearConverter);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-Rec.2020 → linear-sRGB (wide-gamut when the Rec.2020 color is outside\n // sRGB), then gamma-encode for storage. No round-trip through OKLab.\n const [lrR, lrG, lrB] = mapped.linear;\n const [lr, lg, lb] = linearRec2020ToSrgb(lrR, lrG, lrB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toRec2020 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToRec2020Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'rec2020' as const,\n };\n };\n ColordxClass.prototype.toRec2020String = function (precision = 4) {\n const { r, g, b, alpha } = this.toRec2020(precision);\n return alpha < 1 ? `color(rec2020 ${r} ${g} ${b} / ${alpha})` : `color(rec2020 ${r} ${g} ${b})`;\n };\n parsers.push(parseRec2020String, parseRec2020Object);\n formatParsers.push([parseRec2020String, 'rec2020'], [parseRec2020Object, 'rec2020']);\n};\n\nexport default rec2020;\n"]} |
+1
-1
| { | ||
| "name": "@colordx/core", | ||
| "version": "5.4.3", | ||
| "version": "5.5.0", | ||
| "description": "A high-performance color library with extended support for modern color spaces including OKLCH, OKLAB, Display-P3, and more", | ||
@@ -5,0 +5,0 @@ "author": "Dmitrii Kriaklin", |
+95
-4
@@ -9,2 +9,3 @@ <p align="center"> | ||
| [](https://github.com/cssnano/cssnano) | ||
| [](https://github.com/evilmartians/oklch-picker) | ||
| [](https://bundlejs.com/?q=@colordx/core) | ||
@@ -17,3 +18,3 @@ [](https://www.npmjs.com/package/@colordx/core) | ||
| A modern color manipulation library built for the CSS Color 4 era, with first-class support for **OKLCH** and **OKLab**. **6 KB gzipped. 0 Dependencies.** | ||
| A modern color manipulation library built for the CSS Color 4 era, with first-class support for **OKLCH** and **OKLab**. **7.6 KB gzipped. 0 Dependencies.** | ||
@@ -86,2 +87,6 @@ ## Performance | ||
| colordx('color(rec2020 0.7919 0.2307 0.0739)'); // Rec.2020 string | ||
| // With a98rgb plugin loaded: | ||
| colordx('color(a98-rgb 0.8586 0 0)'); // A98 (Adobe RGB 1998) string | ||
| // With prophoto plugin loaded: | ||
| colordx('color(prophoto-rgb 0.7022 0.2757 0.1035)'); // ProPhoto string | ||
| // With hwb plugin loaded: | ||
@@ -188,3 +193,3 @@ colordx('hwb(0 0% 0%)'); | ||
| // Plugin-added parsers register their own format: | ||
| // p3 → 'p3', hsv → 'hsv', cmyk → 'cmyk', lch → 'lch', lab → 'lab', xyz → 'xyz', names → 'name', rec2020 → 'rec2020' | ||
| // p3 → 'p3', hsv → 'hsv', cmyk → 'cmyk', lch → 'lch', lab → 'lab', xyz → 'xyz', names → 'name', rec2020 → 'rec2020', a98-rgb → 'a98-rgb', prophoto-rgb → 'prophoto-rgb' | ||
@@ -376,3 +381,3 @@ nearest('#800', ['#f00', '#ff0', '#00f']); // '#f00' — perceptual distance via OKLab | ||
| Gamut containment is hierarchical: sRGB ⊂ Display-P3 ⊂ Rec.2020. All `inGamut*` functions always return `true` for sRGB-bounded inputs (hex, rgb, hsl, hsv, hwb). The `toGamut*` functions use a binary chroma-reduction search following the [CSS Color 4 gamut mapping algorithm](https://www.w3.org/TR/css-color-4/#css-gamut-mapping). | ||
| Gamut containment is largely hierarchical: sRGB ⊂ Display-P3 ⊂ Rec.2020 ⊂ ProPhoto. A98 (Adobe RGB 1998) sits between sRGB and Rec.2020 — wider than sRGB, mostly in the greens — but is not a strict superset of Display-P3. All `inGamut*` functions always return `true` for sRGB-bounded inputs (hex, rgb, hsl, hsv, hwb). The `toGamut*` functions use a binary chroma-reduction search following the [CSS Color 4 gamut mapping algorithm](https://www.w3.org/TR/css-color-4/#css-gamut-mapping). | ||
@@ -424,4 +429,8 @@ Gamut checks and mapping accept wide-gamut inputs in every supported form — `oklab()` / `oklch()`, CIE `lab()` / `lch()` strings, and the corresponding object shapes (including branded `{ colorSpace: 'lab' | 'lch' }` objects): | ||
| // toRec2020(), toRec2020String(), inGamutRec2020(), Colordx.toGamutRec2020(), linearToRec2020Channels(), oklchToRec2020Channels(), parses color(rec2020 ...) strings | ||
| import a98rgb from '@colordx/core/plugins/a98rgb'; | ||
| // toA98(), toA98String(), inGamutA98(), Colordx.toGamutA98(), linearToA98Channels(), oklchToA98Channels(), parses color(a98-rgb ...) strings | ||
| import prophoto from '@colordx/core/plugins/prophoto'; | ||
| // toProphoto(), toProphotoString(), inGamutProphoto(), Colordx.toGamutProphoto(), linearToProphotoChannels(), oklchToProphotoChannels(), parses color(prophoto-rgb ...) strings | ||
| extend([lab, lch, cmyk, names, a11y, harmonies, hwb, hsv, mix, minify, p3, rec2020]); | ||
| extend([lab, lch, cmyk, names, a11y, harmonies, hwb, hsv, mix, minify, p3, rec2020, a98rgb, prophoto]); | ||
| ``` | ||
@@ -713,2 +722,76 @@ | ||
| ### a98rgb plugin | ||
| Adds A98 (Adobe RGB 1998) color space support. A98 shares sRGB's red and blue primaries but a wider green primary, so it extends mainly into the greens/cyans. It is a CSS Color 4 predefined space and a long-standing photography/print working space. | ||
| ```ts | ||
| import a98rgb from '@colordx/core/plugins/a98rgb'; | ||
| extend([a98rgb]); | ||
| colordx('#ff0000').toA98(); // { r: 0.8586, g: 0, b: 0, alpha: 1, colorSpace: 'a98-rgb' } | ||
| colordx('#ff0000').toA98String(); // 'color(a98-rgb 0.8586 0 0)' | ||
| // Parse A98 strings (alpha optional) | ||
| colordx('color(a98-rgb 0.8586 0 0)').toHex(); // '#ff0000' | ||
| colordx('color(a98-rgb 0.8586 0 0 / 0.5)').toHex(); // '#ff000080' | ||
| ``` | ||
| The plugin also exports standalone gamut utilities and low-level channel functions. `inGamutA98` and the channel helpers need no `extend()`. Gamut mapping is available as `Colordx.toGamutA98` after `extend([a98rgb])`: | ||
| ```ts | ||
| import { Colordx, extend } from '@colordx/core'; | ||
| import a98rgb, { inGamutA98, linearToA98Channels, oklchToA98Channels } from '@colordx/core/plugins/a98rgb'; | ||
| extend([a98rgb]); | ||
| inGamutA98('oklch(0.7 0.25 150)'); // true — inside A98 but outside sRGB | ||
| Colordx.toGamutA98('oklch(0.5 0.4 180)'); // → Colordx at the A98 boundary | ||
| oklchToA98Channels(0.5, 0.2, 240); // [r, g, b] gamma-encoded A98 in [0, 1] | ||
| ``` | ||
| Object parsing is also supported using the `colorSpace` discriminant: | ||
| ```ts | ||
| colordx({ r: 0.8586, g: 0, b: 0, alpha: 1, colorSpace: 'a98-rgb' }).toHex(); | ||
| ``` | ||
| ### prophoto plugin | ||
| Adds ProPhoto (ROMM RGB) color space support. ProPhoto has an extremely wide gamut — wider than Rec.2020, covering most of the visible spectrum — and uses a D50 white point with a gamma-1.8 transfer curve. It is the standard working space for high-end RAW photo and print pipelines. | ||
| ```ts | ||
| import prophoto from '@colordx/core/plugins/prophoto'; | ||
| extend([prophoto]); | ||
| colordx('#ff0000').toProphoto(); // { r: 0.7022, g: 0.2757, b: 0.1035, alpha: 1, colorSpace: 'prophoto-rgb' } | ||
| colordx('#ff0000').toProphotoString(); // 'color(prophoto-rgb 0.7022 0.2757 0.1035)' | ||
| // Parse ProPhoto strings (alpha optional) | ||
| colordx('color(prophoto-rgb 0.7022 0.2757 0.1035)').toHex(); // '#ff0000' | ||
| colordx('color(prophoto-rgb 0.7022 0.2757 0.1035 / 0.5)').toHex(); // '#ff000080' | ||
| ``` | ||
| The plugin also exports standalone gamut utilities and low-level channel functions. `inGamutProphoto` and the channel helpers need no `extend()`. Gamut mapping is available as `Colordx.toGamutProphoto` after `extend([prophoto])`: | ||
| ```ts | ||
| import { Colordx, extend } from '@colordx/core'; | ||
| import prophoto, { inGamutProphoto, linearToProphotoChannels, oklchToProphotoChannels } from '@colordx/core/plugins/prophoto'; | ||
| extend([prophoto]); | ||
| inGamutProphoto('oklch(0.5 0.4 180)'); // false — outside even ProPhoto | ||
| Colordx.toGamutProphoto('oklch(0.5 0.4 180)'); // → Colordx at the ProPhoto boundary | ||
| oklchToProphotoChannels(0.5, 0.2, 240); // [r, g, b] gamma-encoded ProPhoto in [0, 1] | ||
| ``` | ||
| Object parsing is also supported using the `colorSpace` discriminant: | ||
| ```ts | ||
| colordx({ r: 0.7022, g: 0.2757, b: 0.1035, alpha: 1, colorSpace: 'prophoto-rgb' }).toHex(); | ||
| ``` | ||
| ## Notes | ||
@@ -780,4 +863,12 @@ | ||
| ## Ecosystem | ||
| - [**@colordx/gpu**](https://github.com/dkryaklin/colordx-gpu) — colordx's color math on the GPU: conversions and gamut tests as generated GLSL, parity-tested against this library. For per-pixel workloads — picker charts, gamut visualizations, gradients — where you convert millions of colors per frame instead of one at a time. | ||
| ## Sponsors | ||
| Supported by [Ruslo.app](https://ruslo.app). | ||
| ## License | ||
| MIT |
| import {f as f$2,e,a as a$2}from'./chunk-OX5CMKKI.mjs';import {j,e as e$1,k,d as d$1,l as l$1,b as b$1}from'./chunk-F4W4HJCD.mjs';import {a,b,d,c}from'./chunk-YLJRINFM.mjs';import {h,i,f as f$1,a as a$1,g,l,k as k$1,d as d$2}from'./chunk-IOXRZECH.mjs';var er=.8224619687,or=.1775380313,br=.0331941989,tr=.9668058011,ar=.0170826307,ur=.0723974407,mr=.9105199286,Fr=1.2249401762805598,vr=-0.22494017628055996,Br=-0.04205695470968816,Er=1.042056954709688,$r=-0.019637554590334432,Dr=-0.07863604555063189,Or=1.0982736001409663,Rn=(e,r,n,o)=>{e[0]=er*r+or*n,e[1]=br*r+tr*n,e[2]=ar*r+ur*n+mr*o;},sr=(e,r,n)=>[er*e+or*r,br*e+tr*r,ar*e+ur*r+mr*n];var z=(e,r,n)=>[Fr*e+vr*r,Br*e+Er*r,$r*e+Dr*r+Or*n],fn=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=sr(a(e/255),a(r/255),a(n/255));return {r:b(b$1),g:b(t),b:b(u),alpha:o,colorSpace:"display-p3"}};var lr=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=z(a(e),a(r),a(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:o}},yn=e=>{if(!h(e)||e.colorSpace!=="display-p3"||!i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !f$1(r)||!f$1(n)||!f$1(o)||!f$1(b)?null:lr({r:g(r),g:g(n),b:g(o),alpha:a$1(g(b),0,1)})},jr=new RegExp(`^color\\(\\s*display-p3\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),Sn=e=>{if(typeof e!="string")return null;let r=jr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),o=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return lr({r:n,g:o,b,alpha:a$1(t,0,1)})},xn=(e,r,n)=>sr(...f$2(e,r,n));var cr=.6274038959,pr=.3292830384,ir=.0433130657,dr=.0690972894,hr=.9195403951,gr=.0113623156,Rr=.0163914389,fr=.0880133079,yr=.8955952532,Xr=1.6604910021084345,Ur=-0.5876411387885495,Kr=-0.07284986331988488,qr=-0.12455047452159074,Hr=1.1328998971259603,Vr=-0.008349422604369477,Yr=-0.018150763354905303,Zr=-0.10057889800800739,Jr=1.1187296613629127,_n=(e,r,n,o)=>{e[0]=cr*r+pr*n+ir*o,e[1]=dr*r+hr*n+gr*o,e[2]=Rr*r+fr*n+yr*o;},Sr=(e,r,n)=>[cr*e+pr*r+ir*n,dr*e+hr*r+gr*n,Rr*e+fr*r+yr*n];var F=(e,r,n)=>[Xr*e+Ur*r+Kr*n,qr*e+Hr*r+Vr*n,Yr*e+Zr*r+Jr*n],kn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=Sr(a(e/255),a(r/255),a(n/255));return {r:d(b),g:d(t),b:d(u),alpha:o,colorSpace:"rec2020"}};var xr=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=F(c(e),c(r),c(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:o}},Mn=e=>{if(!h(e)||e.colorSpace!=="rec2020"||!i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !f$1(r)||!f$1(n)||!f$1(o)||!f$1(b)?null:xr({r:g(r),g:g(n),b:g(o),alpha:a$1(g(b),0,1)})},Qr=new RegExp(`^color\\(\\s*rec2020\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),Pn=e=>{if(typeof e!="string")return null;let r=Qr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),o=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return xr({r:n,g:o,b,alpha:a$1(t,0,1)})},An=(e,r,n)=>Sr(...f$2(e,r,n));var Wr=/^oklch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^oklab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nn=/^lab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,en=/^lch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,on=/^color\(\s*display-p3\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bn=/^color\(\s*rec2020\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tn=/^color\(\s*xyz-d50\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^color\(\s*xyz-d65\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,A=(e,r,n)=>{let{x:o,y:b,z:t}=l$1({l:e,a:r,b:n,alpha:1,colorSpace:"lab"}),[u,s,l]=e$1(o,b,t);return a$2(u,s,l)},Tr=(e,r,n)=>{let[o,b,t]=z(a(e),a(r),a(n));return a$2(o,b,t)},Cr=(e,r,n)=>{let[o,b,t]=F(c(e),c(r),c(n));return a$2(o,b,t)},Lr=(e,r,n)=>{let[o,b,t]=e$1(e,r,n);return a$2(o,b,t)},Nr=(e,r,n)=>{let[o,b,t]=b$1(e,r,n);return a$2(o,b,t)},G=e=>{if(typeof e=="object"&&e!==null){let r=e;if("l"in r&&"a"in r&&"b"in r&&r.colorSpace!=="lab"&&!("c"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.a=="number"&&typeof n.b=="number"&&typeof n.alpha=="number")return {l:n.l,a:n.a,b:n.b,alpha:n.alpha}}if("l"in r&&"c"in r&&"h"in r&&r.colorSpace!=="lch"&&!("a"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.c=="number"&&typeof n.h=="number"){let o=n.h*Math.PI/180;return {l:n.l,a:n.c*Math.cos(o),b:n.c*Math.sin(o),alpha:n.alpha}}}if(r.colorSpace==="lab"){let n=e;if(typeof n.l!="number"||typeof n.a!="number"||typeof n.b!="number")return null;let[o,b,t]=A(n.l,n.a,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="lch"){let n=e;if(typeof n.l!="number"||typeof n.c!="number"||typeof n.h!="number")return null;let o=n.h*Math.PI/180,[b,t,u]=A(n.l,n.c*Math.cos(o),n.c*Math.sin(o));return {l:b,a:t,b:u,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="display-p3"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Tr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="rec2020"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Cr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="xyz-d65"){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Nr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if("x"in r&&"y"in r&&"z"in r){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Lr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}return null}if(typeof e=="string"){let r=Wr.exec(e);if(r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(d$2[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o*Math.cos(u),b:o*Math.sin(u),alpha:s}}if(r=rn.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?Number(r[5])*.004:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o,b,alpha:t}}if(r=nn.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.25:Number(r[3]),b=r[6]?Number(r[5])*1.25:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=A(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=en.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.5:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(d$2[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[l,x,T]=A(n,o*Math.cos(u),o*Math.sin(u));return {l,a:x,b:T,alpha:s}}if(r=on.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Tr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=bn.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Cr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=tn.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Lr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=an.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Nr(n,o,b);return {l:u,a:s,b:l,alpha:t}}return null}return null},S=5e-4,Pr=(e,r,n)=>e>=-S&&e<=1+S&&r>=-S&&r<=1+S&&n>=-S&&n<=1+S,_r=(e,r,n)=>e>=0&&e<=1&&r>=0&&r<=1&&n>=0&&n<=1,$n=e=>{let r=G(e);if(r===null)return true;let[n,o,b]=f$2(r.l,r.a,r.b);return Pr(n,o,b)},kr=.02,un=1e-4,Mr=(e,r)=>{let n=e[0]-r[0],o=e[1]-r[1],b=e[2]-r[2];return Math.sqrt(n*n+o*o+b*b)},Ar=(e,r,n,o,b)=>{if(e>=1)return [1,1,1];if(e<=0)return [0,0,0];let[t,u,s]=o(e,r,n);if(_r(t,u,s))return [t,u,s];let l=a$1(t,0,1),x=a$1(u,0,1),T=a$1(s,0,1);if(Mr(b(l,x,T),[e,r,n])<=kr)return [l,x,T];let E=Math.atan2(n,r),wr=Math.sqrt(r*r+n*n),N=0,I=wr,$=true,D=l,O=x,j=T;for(;I-N>un;){let C=(N+I)/2,X=C*Math.cos(E),U=C*Math.sin(E),[K,q,H]=o(e,X,U);if($&&_r(K,q,H)){N=C;continue}let V=a$1(K,0,1),Y=a$1(q,0,1),Z=a$1(H,0,1);D=V,O=Y,j=Z,Mr(b(V,Y,Z),[e,X,U])<=kr?(N=C,$=false):I=C;}return [D,O,j]},Dn=e=>{let r=G(e);return r===null?null:{linear:Ar(r.l,r.a,r.b,f$2,a$2),alpha:r.alpha}},On=(e,r)=>{let n=G(e);if(n===null)return true;let[o,b,t]=r(n.l,n.a,n.b);return Pr(o,b,t)},jn=(e,r,n)=>{let o=G(e);return o===null?null:{linear:Ar(o.l,o.a,o.b,r,n),alpha:o.alpha}};var f=Math.PI/180,Gr=(e,r,n)=>{let o=n*f;return f$2(e,r*Math.cos(o),r*Math.sin(o))},Ir=(e$1,r,n,o)=>{let b=o*f;e(e$1,r,n*Math.cos(b),n*Math.sin(b));},Vn=(e,r,n)=>{let[o,b$1,t]=Gr(e,r,n);return [b(o),b(b$1),b(t)]},Yn=(e,r,n,o)=>{Ir(e,r,n,o),e[0]=b(e[0]),e[1]=b(e[1]),e[2]=b(e[2]);},Zn=(e,r,n)=>{let[o,b$1,t]=Gr(e,r,n);return [[o,b$1,t],[b(o),b(b$1),b(t)]]},Jn=(e,r,n,o,b$1)=>{Ir(e,n,o,b$1),r[0]=b(e[0]),r[1]=b(e[1]),r[2]=b(e[2]);},Qn=(e,r,n)=>[a(e),a(r),a(n)],Wn=(e,r,n,o)=>{e[0]=a(r),e[1]=a(n),e[2]=a(o);},v=(e,r,n)=>{let[o,b,t]=j(e,r,n);return e$1(o,b,t)},B=(e,r,n,o)=>{k(e,r,n,o),d$1(e,e[0],e[1],e[2]);},re=(e,r,n)=>{let o=n*f;return v(e,r*Math.cos(o),r*Math.sin(o))},ne=(e,r,n,o)=>{let b=o*f;B(e,r,n*Math.cos(b),n*Math.sin(b));},mn=(e,r,n)=>{let[o,b$1,t]=v(e,r,n);return [b(o),b(b$1),b(t)]},sn=(e,r,n,o)=>{B(e,r,n,o),e[0]=b(e[0]),e[1]=b(e[1]),e[2]=b(e[2]);},ee=(e,r,n)=>{let o=n*f;return mn(e,r*Math.cos(o),r*Math.sin(o))},oe=(e,r,n,o)=>{let b=o*f;sn(e,r,n*Math.cos(b),n*Math.sin(b));},ln=(e,r,n)=>{let[o,b$1,t]=v(e,r,n);return [[o,b$1,t],[b(o),b(b$1),b(t)]]},cn=(e,r,n,o,b$1)=>{B(e,n,o,b$1),r[0]=b(e[0]),r[1]=b(e[1]),r[2]=b(e[2]);},be=(e,r,n)=>{let o=n*f;return ln(e,r*Math.cos(o),r*Math.sin(o))},te=(e,r,n,o,b)=>{let t=b*f;cn(e,r,n,o*Math.cos(t),o*Math.sin(t));};export{v as A,B,re as C,ne as D,mn as E,sn as F,ee as G,oe as H,ln as I,cn as J,be as K,te as L,Rn as a,sr as b,z as c,fn as d,yn as e,Sn as f,xn as g,_n as h,Sr as i,F as j,kn as k,Mn as l,Pn as m,An as n,$n as o,Dn as p,On as q,jn as r,Gr as s,Ir as t,Vn as u,Yn as v,Zn as w,Jn as x,Qn as y,Wn as z};//# sourceMappingURL=chunk-3LS3HCHH.mjs.map | ||
| //# sourceMappingURL=chunk-3LS3HCHH.mjs.map |
Sorry, the diff of this file is too big to display
| 'use strict';var chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var $=s=>({r:chunkYISEJCI6_cjs.a(s.r,0,255),g:chunkYISEJCI6_cjs.a(s.g,0,255),b:chunkYISEJCI6_cjs.a(s.b,0,255),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(s.alpha,3),0,1)}),x=s=>{if(!chunkYISEJCI6_cjs.h(s))return null;let n=s.colorSpace;if(n==="display-p3"||n==="rec2020"||!chunkYISEJCI6_cjs.i(s,["r","g","b"]))return null;let{r:e,g:t,b:c,alpha:l=1}=s;return !chunkYISEJCI6_cjs.f(e)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(c)||!chunkYISEJCI6_cjs.f(l)?null:$({r:chunkYISEJCI6_cjs.g(e),g:chunkYISEJCI6_cjs.g(t),b:chunkYISEJCI6_cjs.g(c),alpha:chunkYISEJCI6_cjs.g(l)})},y=new RegExp(`^rgba?\\(\\s*(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s*(?:,\\s*(?<g_c>${chunkYISEJCI6_cjs.k})(?<gp_c>%?)\\s*,\\s*(?<b_c>${chunkYISEJCI6_cjs.k})(?<bp_c>%?)(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.k})(?<alp_c>%?))?\\s*|\\s+(?<g_s>${chunkYISEJCI6_cjs.k})(?<gp_s>%?)\\s+(?<b_s>${chunkYISEJCI6_cjs.k})(?<bp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?))?\\s*)\\)$`,"i"),N=s=>{if(typeof s!="string")return null;let n=y.exec(s.trim())?.groups;if(!n)return null;let e=n.g_c!==void 0,t=n.g_c??n.g_s,c=n.b_c??n.b_s,l=!!n.rp,_=!!(n.gp_c??n.gp_s),b=!!(n.bp_c??n.bp_s),m=l?chunkYISEJCI6_cjs.l(n.r)/100*255:chunkYISEJCI6_cjs.l(n.r),w=_?chunkYISEJCI6_cjs.l(t)/100*255:chunkYISEJCI6_cjs.l(t),d=b?chunkYISEJCI6_cjs.l(c)/100*255:chunkYISEJCI6_cjs.l(c);if(e&&(l!==_||_!==b||/^none$/i.test(n.r)||/^none$/i.test(t)||/^none$/i.test(c)))return null;let g=n.al_c??n.al_s,h=!!(n.alp_c??n.alp_s);if(e&&g!==void 0&&/^none$/i.test(g))return null;let k=g===void 0?1:chunkYISEJCI6_cjs.l(g)/(h?100:1);return $({r:m,g:w,b:d,alpha:k})};exports.a=$;exports.b=x;exports.c=N;//# sourceMappingURL=chunk-3V4MONNR.cjs.map | ||
| //# sourceMappingURL=chunk-3V4MONNR.cjs.map |
| {"version":3,"sources":["../src/colorModels/rgb.ts"],"names":["clampRgb","rgb","clamp","round","parseRgbObject","input","isObject","cs","hasKeys","r","g","b","alpha","isAnyNumber","sanitize","RGB_RE","NUM_OR_NONE","parseRgbString","isComma","gRaw","bRaw","rPct","gPct","bPct","parseNum","gc","rawA","aPct"],"mappings":"mEAGO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,oBAAMD,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,CAAA,CAAGC,mBAAAA,CAAMD,CAAAA,CAAI,EAAG,CAAA,CAAG,GAAG,CAAA,CACtB,CAAA,CAAGC,mBAAAA,CAAMD,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,KAAA,CAAOC,mBAAAA,CAAMC,mBAAAA,CAAMF,EAAI,KAAA,CAAO,CAAC,CAAA,CAAG,CAAA,CAAG,CAAC,CACxC,CAAA,CAAA,CAEaG,CAAAA,CAAkBC,CAAAA,EAAoC,CACjE,GAAI,CAACC,mBAAAA,CAASD,CAAK,CAAA,CAAG,OAAO,IAAA,CAC7B,IAAME,CAAAA,CAAMF,CAAAA,CAAmC,UAAA,CAE/C,GADIE,IAAO,YAAA,EAAgBA,CAAAA,GAAO,SAAA,EAC9B,CAACC,mBAAAA,CAAQH,CAAAA,CAAO,CAAC,GAAA,CAAK,IAAK,GAAG,CAAC,CAAA,CAAG,OAAO,KAC7C,GAAM,CAAE,CAAA,CAAAI,CAAAA,CAAG,EAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAAA,CAAQ,CAAE,CAAA,CAAIP,CAAAA,CAC/B,OAAI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} from '../helpers.js';\nimport type { RgbColor } from '../types.js';\n\nexport const clampRgb = (rgb: RgbColor): RgbColor => ({\n r: clamp(rgb.r, 0, 255),\n g: clamp(rgb.g, 0, 255),\n b: clamp(rgb.b, 0, 255),\n alpha: clamp(round(rgb.alpha, 3), 0, 1),\n});\n\nexport const parseRgbObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n const cs = (input as { colorSpace?: unknown }).colorSpace;\n if (cs === 'display-p3' || cs === 'rec2020') return null;\n if (!hasKeys(input, ['r', 'g', 'b'])) return null;\n const { r, g, b, alpha = 1 } = input as { r: unknown; g: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(r) || !isAnyNumber(g) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n return clampRgb({ r: sanitize(r), g: sanitize(g), b: sanitize(b), alpha: sanitize(alpha) });\n};\n\n// Matches both legacy comma syntax: rgb(255, 0, 0) / rgba(255, 0, 0, 0.5)\n// and modern space syntax: rgb(255 0 0) / rgb(255 0 0 / 0.5).\n// Supports percentage-based channels and the CSS Color 4 `none` keyword.\n// Named groups are suffixed `_c` (comma/legacy branch) or `_s` (space/modern branch)\n// because ES2022 regex requires distinct names across alternation branches.\nconst RGB_RE = new RegExp(\n `^rgba?\\\\(\\\\s*(?<r>${NUM_OR_NONE})(?<rp>%?)\\\\s*(?:` +\n `,\\\\s*(?<g_c>${NUM_OR_NONE})(?<gp_c>%?)\\\\s*,\\\\s*(?<b_c>${NUM_OR_NONE})(?<bp_c>%?)` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM_OR_NONE})(?<alp_c>%?))?\\\\s*` +\n `|` +\n `\\\\s+(?<g_s>${NUM_OR_NONE})(?<gp_s>%?)\\\\s+(?<b_s>${NUM_OR_NONE})(?<bp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?))?\\\\s*` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseRgbString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = RGB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n\n const isComma = g.g_c !== undefined;\n const gRaw = g.g_c ?? g.g_s!;\n const bRaw = g.b_c ?? g.b_s!;\n const rPct = !!g.rp;\n const gPct = !!(g.gp_c ?? g.gp_s);\n const bPct = !!(g.bp_c ?? g.bp_s);\n\n const r = rPct ? (parseNum(g.r!) / 100) * 255 : parseNum(g.r!);\n const gc = gPct ? (parseNum(gRaw) / 100) * 255 : parseNum(gRaw);\n const b = bPct ? (parseNum(bRaw) / 100) * 255 : parseNum(bRaw);\n\n // Legacy: channels must match type, no `none`. Modern: mixing + `none` allowed.\n if (isComma) {\n if (rPct !== gPct || gPct !== bPct) return null;\n if (/^none$/i.test(g.r!) || /^none$/i.test(gRaw) || /^none$/i.test(bRaw)) return null;\n }\n\n const rawA = g.al_c ?? g.al_s;\n const aPct = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (aPct ? 100 : 1);\n\n return clampRgb({ r, g: gc, b, alpha });\n};\n"]} |
| import {a as a$1}from'./chunk-Q3O3QQ4H.mjs';import {a,b,l,d,h,i,f,g as g$1,k,j as j$1,c}from'./chunk-IOXRZECH.mjs';var N=r=>({h:c(r.h),s:a(r.s,0,100),v:a(r.v,0,100),alpha:a(b(r.alpha,3),0,1)}),g={h:0,s:0,v:0,alpha:0},T=({r,g:n,b:u,alpha:h})=>{let t=r/255,o=n/255,c=u/255,e=Math.max(t,o,c),a$1=Math.min(t,o,c),l=e-a$1,i=e===0?0:l/e,f=0;if(e!==a$1)switch(e){case t:f=((o-c)/l+(o<c?6:0))/6;break;case o:f=((c-t)/l+2)/6;break;case c:f=((t-o)/l+4)/6;break}let k=f*360;return g.h=k>=0&&k<360?k:(k%360+360)%360,g.s=a(i*100,0,100),g.v=a(e*100,0,100),g.alpha=a(b(h,3),0,1),g};var s=[0,0,0],M=({h:r,s:n,v:u,alpha:h})=>{let t=n/100,o=u/100,c=Math.floor(r/60%6),e=r/60-Math.floor(r/60),a=o*(1-t),l=o*(1-e*t),i=o*(1-(1-e)*t);switch(c){case 0:s[0]=o,s[1]=i,s[2]=a;break;case 1:s[0]=l,s[1]=o,s[2]=a;break;case 2:s[0]=a,s[1]=o,s[2]=i;break;case 3:s[0]=a,s[1]=l,s[2]=o;break;case 4:s[0]=i,s[1]=a,s[2]=o;break;default:s[0]=o,s[1]=a,s[2]=l;break}return a$1({r:s[0]*255,g:s[1]*255,b:s[2]*255,alpha:h})},y=new RegExp(`^hsva?\\(\\s*(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${j$1})%\\s*,\\s*(?<v_c>${j$1})%(?:\\s*,\\s*(?<al_c>${j$1})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${k})(?<sp_s>%?)\\s+(?<v_s>${k})(?<vp_s>%?)(?:\\s*/\\s*(?<al_s>${k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),j=r=>{if(typeof r!="string")return null;let n=y.exec(r.trim())?.groups;if(!n)return null;let u=n.s_c!==void 0;if(u&&/^none$/i.test(n.h))return null;let h=n.hu?.toLowerCase()??"deg",t=l(n.h)*(d[h]??1),o=l(n.s_c??n.s_s),c=l(n.v_c??n.v_s),e=n.al_c??n.al_s;if(u&&e!==void 0&&/^none$/i.test(e))return null;let a=!!(n.alp_c??n.alp_s),l$1=e===void 0?1:l(e)/(a?100:1);return M(N({h:t,s:o,v:c,alpha:l$1}))},A=r=>{if(!h(r)||!i(r,["h","s","v"]))return null;let{h:n,s:u,v:h$1,alpha:t=1}=r;return !f(n)||!f(u)||!f(h$1)||!f(t)?null:M(N({h:g$1(n),s:g$1(u),v:g$1(h$1),alpha:g$1(t)}))};export{T as a,M as b,j as c,A as d};//# sourceMappingURL=chunk-6JXMCEQE.mjs.map | ||
| //# sourceMappingURL=chunk-6JXMCEQE.mjs.map |
| {"version":3,"sources":["../src/colorModels/hsv.ts"],"names":["clampHsv","hsv","normalizeHue","clamp","round","_hsvBuf","rgbToHsvRaw","g","b","alpha","rn","gn","bn","max","min","d","s","h","hDeg","_RGB","hsvToRgb","v","sn","vn","i","f","p","q","t","clampRgb","HSV_RE","NUM_OR_NONE","NUM","parseHsvString","input","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","parseHsvObject","isObject","hasKeys","isAnyNumber","sanitize"],"mappings":"mHAgBA,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CAC7C,CAAA,CAAGC,CAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,CAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CAAGE,CAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,KAAA,CAAOE,CAAAA,CAAMC,CAAAA,CAAMH,CAAAA,CAAI,KAAA,CAAO,CAAC,CAAA,CAAG,EAAG,CAAC,CACxC,CAAA,CAAA,CAGMI,CAAAA,CAAoB,CAAE,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAE1CC,CAAAA,CAAc,CAAC,CAAE,CAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAA,GAA0B,CACrE,IAAMC,CAAAA,CAAK,CAAA,CAAI,GAAA,CACbC,CAAAA,CAAKJ,CAAAA,CAAI,GAAA,CACTK,CAAAA,CAAKJ,EAAI,GAAA,CACLK,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAIH,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CAC7BE,GAAAA,CAAM,IAAA,CAAK,GAAA,CAAIJ,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,C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K,CAAC2B,CAAAA,CAAY5B,CAAC,CAAA,EAAK,CAAC4B,CAAAA,CAAYvB,GAAC,CAAA,EAAK,CAACuB,CAAAA,CAAYnC,CAAK,CAAA,CAAU,IAAA,CAClFW,CAAAA,CAASpB,CAAAA,CAAS,CAAE,CAAA,CAAG6C,GAAAA,CAAS5B,CAAC,CAAA,CAAG,CAAA,CAAG4B,GAAAA,CAAS7B,CAAC,CAAA,CAAG,EAAG6B,GAAAA,CAASxB,GAAC,CAAA,CAAG,KAAA,CAAOwB,GAAAA,CAASpC,CAAK,CAAE,CAAC,CAAC,CACtG","file":"chunk-6JXMCEQE.mjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HsvColor, RgbColor } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\nconst clampHsv = (hsv: HsvColor): HsvColor => ({\n h: normalizeHue(hsv.h),\n s: clamp(hsv.s, 0, 100),\n v: clamp(hsv.v, 0, 100),\n alpha: clamp(round(hsv.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHsvRaw — callers must destructure immediately, never store the reference.\nconst _hsvBuf: HsvColor = { h: 0, s: 0, v: 0, alpha: 0 };\n\nexport const rgbToHsvRaw = ({ r, g, b, alpha }: RgbColor): HsvColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const d = max - min;\n const s = max === 0 ? 0 : d / max;\n let h = 0;\n\n if (max !== min) {\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hsvBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hsvBuf.s = clamp(s * 100, 0, 100);\n _hsvBuf.v = clamp(max * 100, 0, 100);\n _hsvBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hsvBuf;\n};\n\nexport const rgbToHsv = (rgb: RgbColor): HsvColor => {\n const { h, s, v, alpha } = rgbToHsvRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), v: round(v, 2), alpha };\n};\n\nconst _RGB = [0, 0, 0] as [number, number, number];\n\nexport const hsvToRgb = ({ h, s, v, alpha }: HsvColor): RgbColor => {\n const sn = s / 100,\n vn = v / 100;\n const i = Math.floor((h / 60) % 6);\n const f = h / 60 - Math.floor(h / 60);\n const p = vn * (1 - sn);\n const q = vn * (1 - f * sn);\n const t = vn * (1 - (1 - f) * sn);\n\n switch (i) {\n case 0:\n _RGB[0] = vn;\n _RGB[1] = t;\n _RGB[2] = p;\n break;\n case 1:\n _RGB[0] = q;\n _RGB[1] = vn;\n _RGB[2] = p;\n break;\n case 2:\n _RGB[0] = p;\n _RGB[1] = vn;\n _RGB[2] = t;\n break;\n case 3:\n _RGB[0] = p;\n _RGB[1] = q;\n _RGB[2] = vn;\n break;\n case 4:\n _RGB[0] = t;\n _RGB[1] = p;\n _RGB[2] = vn;\n break;\n default: // case 5 — not an error handler; i is always 0–5 for h in [0, 360)\n _RGB[0] = vn;\n _RGB[1] = p;\n _RGB[2] = q;\n break;\n }\n\n return clampRgb({ r: _RGB[0] * 255, g: _RGB[1] * 255, b: _RGB[2] * 255, alpha });\n};\n\n// HSV/HSVA is a non-standard, library-defined syntax (not part of any CSS spec).\n// Format mirrors HSL for consistency. Legacy comma form kept for back-compat input;\n// modern space form supports optional `%` and the CSS Color 4 `none` keyword.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSV_RE = new RegExp(\n `^hsva?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<v_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<v_s>${NUM_OR_NONE})(?<vp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHsvString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSV_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null;\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const v = parseNum((g.v_c ?? g.v_s)!);\n const rawA = g.al_c ?? g.al_s;\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hsvToRgb(clampHsv({ h, s, v, alpha }));\n};\n\nexport const parseHsvObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'v'])) return null;\n const { h, s, v, alpha = 1 } = input as { h: unknown; s: unknown; v: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(v) || !isAnyNumber(alpha)) return null;\n return hsvToRgb(clampHsv({ h: sanitize(h), s: sanitize(s), v: sanitize(v), alpha: sanitize(alpha) }));\n};\n"]} |
| 'use strict';var chunk3V4MONNR_cjs=require('./chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var N=r=>({h:chunkYISEJCI6_cjs.c(r.h),s:chunkYISEJCI6_cjs.a(r.s,0,100),v:chunkYISEJCI6_cjs.a(r.v,0,100),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r.alpha,3),0,1)}),g={h:0,s:0,v:0,alpha:0},T=({r,g:n,b:u,alpha:h})=>{let t=r/255,o=n/255,c=u/255,e=Math.max(t,o,c),a=Math.min(t,o,c),l=e-a,i=e===0?0:l/e,f=0;if(e!==a)switch(e){case t:f=((o-c)/l+(o<c?6:0))/6;break;case o:f=((c-t)/l+2)/6;break;case c:f=((t-o)/l+4)/6;break}let k=f*360;return g.h=k>=0&&k<360?k:(k%360+360)%360,g.s=chunkYISEJCI6_cjs.a(i*100,0,100),g.v=chunkYISEJCI6_cjs.a(e*100,0,100),g.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(h,3),0,1),g};var s=[0,0,0],M=({h:r,s:n,v:u,alpha:h})=>{let t=n/100,o=u/100,c=Math.floor(r/60%6),e=r/60-Math.floor(r/60),a=o*(1-t),l=o*(1-e*t),i=o*(1-(1-e)*t);switch(c){case 0:s[0]=o,s[1]=i,s[2]=a;break;case 1:s[0]=l,s[1]=o,s[2]=a;break;case 2:s[0]=a,s[1]=o,s[2]=i;break;case 3:s[0]=a,s[1]=l,s[2]=o;break;case 4:s[0]=i,s[1]=a,s[2]=o;break;default:s[0]=o,s[1]=a,s[2]=l;break}return chunk3V4MONNR_cjs.a({r:s[0]*255,g:s[1]*255,b:s[2]*255,alpha:h})},y=new RegExp(`^hsva?\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${chunkYISEJCI6_cjs.j})%\\s*,\\s*(?<v_c>${chunkYISEJCI6_cjs.j})%(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${chunkYISEJCI6_cjs.k})(?<sp_s>%?)\\s+(?<v_s>${chunkYISEJCI6_cjs.k})(?<vp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),j=r=>{if(typeof r!="string")return null;let n=y.exec(r.trim())?.groups;if(!n)return null;let u=n.s_c!==void 0;if(u&&/^none$/i.test(n.h))return null;let h=n.hu?.toLowerCase()??"deg",t=chunkYISEJCI6_cjs.l(n.h)*(chunkYISEJCI6_cjs.d[h]??1),o=chunkYISEJCI6_cjs.l(n.s_c??n.s_s),c=chunkYISEJCI6_cjs.l(n.v_c??n.v_s),e=n.al_c??n.al_s;if(u&&e!==void 0&&/^none$/i.test(e))return null;let a=!!(n.alp_c??n.alp_s),l=e===void 0?1:chunkYISEJCI6_cjs.l(e)/(a?100:1);return M(N({h:t,s:o,v:c,alpha:l}))},A=r=>{if(!chunkYISEJCI6_cjs.h(r)||!chunkYISEJCI6_cjs.i(r,["h","s","v"]))return null;let{h:n,s:u,v:h,alpha:t=1}=r;return !chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(u)||!chunkYISEJCI6_cjs.f(h)||!chunkYISEJCI6_cjs.f(t)?null:M(N({h:chunkYISEJCI6_cjs.g(n),s:chunkYISEJCI6_cjs.g(u),v:chunkYISEJCI6_cjs.g(h),alpha:chunkYISEJCI6_cjs.g(t)}))};exports.a=T;exports.b=M;exports.c=j;exports.d=A;//# sourceMappingURL=chunk-BLKDDW2U.cjs.map | ||
| //# sourceMappingURL=chunk-BLKDDW2U.cjs.map |
| {"version":3,"sources":["../src/colorModels/hsv.ts"],"names":["clampHsv","hsv","normalizeHue","clamp","round","_hsvBuf","rgbToHsvRaw","g","b","alpha","rn","gn","bn","max","min","d","s","h","hDeg","_RGB","hsvToRgb","v","sn","vn","i","f","p","q","t","clampRgb","HSV_RE","NUM_OR_NONE","NUM","parseHsvString","input","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","parseHsvObject","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AA,CAAG4B,mBAAAA,CAAS7B,CAAC,CAAA,CAAG,EAAG6B,mBAAAA,CAASxB,CAAC,CAAA,CAAG,KAAA,CAAOwB,mBAAAA,CAASpC,CAAK,CAAE,CAAC,CAAC,CACtG","file":"chunk-BLKDDW2U.cjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HsvColor, RgbColor } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\nconst clampHsv = (hsv: HsvColor): HsvColor => ({\n h: normalizeHue(hsv.h),\n s: clamp(hsv.s, 0, 100),\n v: clamp(hsv.v, 0, 100),\n alpha: clamp(round(hsv.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHsvRaw — callers must destructure immediately, never store the reference.\nconst _hsvBuf: HsvColor = { h: 0, s: 0, v: 0, alpha: 0 };\n\nexport const rgbToHsvRaw = ({ r, g, b, alpha }: RgbColor): HsvColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const d = max - min;\n const s = max === 0 ? 0 : d / max;\n let h = 0;\n\n if (max !== min) {\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hsvBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hsvBuf.s = clamp(s * 100, 0, 100);\n _hsvBuf.v = clamp(max * 100, 0, 100);\n _hsvBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hsvBuf;\n};\n\nexport const rgbToHsv = (rgb: RgbColor): HsvColor => {\n const { h, s, v, alpha } = rgbToHsvRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), v: round(v, 2), alpha };\n};\n\nconst _RGB = [0, 0, 0] as [number, number, number];\n\nexport const hsvToRgb = ({ h, s, v, alpha }: HsvColor): RgbColor => {\n const sn = s / 100,\n vn = v / 100;\n const i = Math.floor((h / 60) % 6);\n const f = h / 60 - Math.floor(h / 60);\n const p = vn * (1 - sn);\n const q = vn * (1 - f * sn);\n const t = vn * (1 - (1 - f) * sn);\n\n switch (i) {\n case 0:\n _RGB[0] = vn;\n _RGB[1] = t;\n _RGB[2] = p;\n break;\n case 1:\n _RGB[0] = q;\n _RGB[1] = vn;\n _RGB[2] = p;\n break;\n case 2:\n _RGB[0] = p;\n _RGB[1] = vn;\n _RGB[2] = t;\n break;\n case 3:\n _RGB[0] = p;\n _RGB[1] = q;\n _RGB[2] = vn;\n break;\n case 4:\n _RGB[0] = t;\n _RGB[1] = p;\n _RGB[2] = vn;\n break;\n default: // case 5 — not an error handler; i is always 0–5 for h in [0, 360)\n _RGB[0] = vn;\n _RGB[1] = p;\n _RGB[2] = q;\n break;\n }\n\n return clampRgb({ r: _RGB[0] * 255, g: _RGB[1] * 255, b: _RGB[2] * 255, alpha });\n};\n\n// HSV/HSVA is a non-standard, library-defined syntax (not part of any CSS spec).\n// Format mirrors HSL for consistency. Legacy comma form kept for back-compat input;\n// modern space form supports optional `%` and the CSS Color 4 `none` keyword.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSV_RE = new RegExp(\n `^hsva?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<v_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<v_s>${NUM_OR_NONE})(?<vp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHsvString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSV_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null;\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const v = parseNum((g.v_c ?? g.v_s)!);\n const rawA = g.al_c ?? g.al_s;\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hsvToRgb(clampHsv({ h, s, v, alpha }));\n};\n\nexport const parseHsvObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'v'])) return null;\n const { h, s, v, alpha = 1 } = input as { h: unknown; s: unknown; v: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(v) || !isAnyNumber(alpha)) return null;\n return hsvToRgb(clampHsv({ h: sanitize(h), s: sanitize(s), v: sanitize(v), alpha: sanitize(alpha) }));\n};\n"]} |
| import {a,b as b$1}from'./chunk-YLJRINFM.mjs';import {a as a$2}from'./chunk-Q3O3QQ4H.mjs';import {a as a$1,b,h,i,e,f,g,l,k}from'./chunk-IOXRZECH.mjs';var L=96.4295675298354,O=100,w=82.51046025104603,lo=.4123907992659595,ao=.35758433938387796,co=.1804807884018343,eo=.21263900587151036,bo=.7151686787677559,po=.07219231536073371,uo=.01933081871559185,_o=.11919477979462599,yo=.9505321522496606,A=.032409699419045215,B=-0.015373831775700935,G=-0.004986107602930032,I=-0.009692436362808799,P=.018759675015077207,U=.0004155505740717561,F=.000556300796969936,H=-0.002039769588889766,K=.010569715142428786,Wo=1.0479297925449969,Eo=.022946870601609652,qo=-0.05019226628920524,jo=.02962780877005599,Ao=.9904344267538799,Bo=-0.017073799063418826,Go=-0.009243040646204504,Io=.015055191490298152,Po=.7518742814281371,xo=.955473421488075,go=-0.02309845494876471,mo=.06325924320057072,Do=-0.0283697093338637,zo=1.0099953980813041,io=.021041441191917323,Xo=.012314014864481998,ho=-0.020507649298898964,Co=1.330365926242124,sn=({r:n,g:o,b:t,alpha:s})=>{let r=a(n/255),l=a(o/255),a$2=a(t/255);return {x:100*(lo*r+ao*l+co*a$2),y:100*(eo*r+bo*l+po*a$2),z:100*(uo*r+_o*l+yo*a$2),alpha:a$1(b(s,3),0,1),colorSpace:"xyz-d65"}},Uo=(n,o,t)=>[A*n+B*o+G*t,I*n+P*o+U*t,F*n+H*o+K*t],fo=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=Uo(n,o,t);return {r:b$1(r)*255,g:b$1(l)*255,b:b$1(a)*255,alpha:s}},To=({r:n,g:o,b:t,alpha:s})=>{let r=a(n/255),l=a(o/255),a$2=a(t/255),u=100*(lo*r+ao*l+co*a$2),e=100*(eo*r+bo*l+po*a$2),x=100*(uo*r+_o*l+yo*a$2);return {x:Wo*u+Eo*e+qo*x,y:jo*u+Ao*e+Bo*x,z:Go*u+Io*e+Po*x,alpha:a$1(b(s,3),0,1)}},ln=(n,o,t,s)=>{let r=xo*o+go*t+mo*s,l=Do*o+zo*t+io*s,a=Xo*o+ho*t+Co*s;n[0]=A*r+B*l+G*a,n[1]=I*r+P*l+U*a,n[2]=F*r+H*l+K*a;},M=(n,o,t)=>{let s=xo*n+go*o+mo*t,r=Do*n+zo*o+io*t,l=Xo*n+ho*o+Co*t;return [A*s+B*r+G*l,I*s+P*r+U*l,F*s+H*r+K*l]},Ro=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=M(n,o,t);return a$2({r:b$1(r)*255,g:b$1(l)*255,b:b$1(a)*255,alpha:s})},So=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=M(n,o,t);return {r:b$1(r)*255,g:b$1(l)*255,b:b$1(a)*255,alpha:s}},an=n=>{if(!h(n)||n.colorSpace==="xyz-d65"||!i(n,["x","y","z"]))return null;let{x:o,y:t,z:s,alpha:r=1}=n;return !e(o)||!e(t)||!e(s)||!e(r)?null:So({x:o,y:t,z:s,alpha:a$1(r,0,1)})},cn=n=>{if(!h(n)||n.colorSpace!=="xyz-d65"||!i(n,["x","y","z"]))return null;let{x:o,y:t,z:s,alpha:r=1}=n;return !f(o)||!f(t)||!f(s)||!f(r)?null:fo({x:g(o),y:g(t),z:g(s),alpha:a$1(g(r),0,1)})},Fo=new RegExp(`^color\\(\\s*xyz-d65\\s+(?<x>${k})(?<xp>%?)\\s+(?<y>${k})(?<yp>%?)\\s+(?<z>${k})(?<zp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),Ho=new RegExp(`^color\\(\\s*xyz-d50\\s+(?<x>${k})(?<xp>%?)\\s+(?<y>${k})(?<yp>%?)\\s+(?<z>${k})(?<zp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),en=n=>{if(typeof n!="string")return null;let o=Fo.exec(n.trim())?.groups;if(!o)return null;let t=l(o.x),s=l(o.y),r=l(o.z),l$1=o.al===void 0?1:l(o.al)/(o.alp?100:1);return fo({x:t,y:s,z:r,alpha:a$1(l$1,0,1)})},bn=n=>{if(typeof n!="string")return null;let o=Ho.exec(n.trim())?.groups;if(!o)return null;let t=l(o.x),s=l(o.y),r=l(o.z),l$1=o.al===void 0?1:l(o.al)/(o.alp?100:1);return So({x:t,y:s,z:r,alpha:a$1(l$1,0,1)})};var Ko=.3127/.329*100,vo=100,Vo=(1-.3127-.329)/.329*100,S=216/24389,z=24389/27,C=n=>n>S?Math.cbrt(n):(z*n+16)/116,Jo=({x:n,y:o,z:t,alpha:s})=>{let r=C(o/O);return {l:116*r-16,a:500*(C(n/L)-r)||0,b:200*(r-C(t/w))||0,alpha:b(s,3),colorSpace:"lab"}},Lo=(n,o,t)=>{let s=(n+16)/116,r=o/500+s,l=s-t/200;return [(r**3>S?r**3:(116*r-16)/z)*L,(n>8?s**3:n/z)*O,(l**3>S?l**3:(116*l-16)/z)*w]},xn=(n,o,t,s)=>{let r=(o+16)/116,l=t/500+r,a=r-s/200;n[0]=(l**3>S?l**3:(116*l-16)/z)*L,n[1]=(o>8?r**3:o/z)*O,n[2]=(a**3>S?a**3:(116*a-16)/z)*w;},Qo=({l:n,a:o,b:t,alpha:s})=>{let[r,l,a]=Lo(n,o,t);return {x:r,y:l,z:a,alpha:s}},gn=n=>Jo(To(n)),mn=({r:n,g:o,b:t,alpha:s})=>{let r=a(n/255),l=a(o/255),a$1=a(t/255),u=100*(.4123907992659595*r+.35758433938387796*l+.1804807884018343*a$1),e=100*(.21263900587151036*r+.7151686787677559*l+.07219231536073371*a$1),x=100*(.01933081871559185*r+.11919477979462599*l+.9505321522496606*a$1),f=C(e/vo);return {l:116*f-16,a:500*(C(u/Ko)-f)||0,b:200*(f-C(x/Vo))||0,alpha:b(s,3),colorSpace:"lab"}},Dn=(n,o)=>{let{l:t,a:s,b:r}=n,{l,a,b:u}=o,e=Math.PI/180,x=180/Math.PI,f=Math.sqrt(s**2+r**2),wo=Math.sqrt(a**2+u**2),v=((f+wo)/2)**7,V=.5*(1-Math.sqrt(v/(v+25**7))),Y=s*(1+V),Z=a*(1+V),k=Math.sqrt(Y**2+r**2),$=Math.sqrt(Z**2+u**2),N=(k+$)/2,W=Y===0&&r===0?0:Math.atan2(r,Y)*x,E=Z===0&&u===0?0:Math.atan2(u,Z)*x,i=W<0?W+360:W,X=E<0?E+360:E,q=X-i,j=Math.abs(X-i);j>180&&X<=i?q+=360:j>180&&X>i&&(q-=360);let J=(t+l)/2,D=i+X;j<=180?D/=2:D=(i+X<360?D+360:D-360)/2;let Mo=1-.17*Math.cos(e*(D-30))+.24*Math.cos(2*e*D)+.32*Math.cos(e*(3*D+6))-.2*Math.cos(e*(4*D-63)),Yo=l-t,Q=$-k,oo=2*Math.sin(e*q/2)*Math.sqrt(k*$),Zo=1+.015*(J-50)**2/Math.sqrt(20+(J-50)**2),no=1+.045*N,ro=1+.015*N*Mo,to=N**7,ko=2*Math.sqrt(to/(to+25**7)),$o=30*Math.exp(-(((D-275)/25)**2)),No=-ko*Math.sin(2*e*$o);return Math.sqrt((Yo/Zo)**2+(Q/no)**2+(oo/ro)**2+No*(Q/no)*(oo/ro))},zn=n=>Ro(Qo(n)),Oo=({l:n,a:o,b:t,alpha:s})=>{let[r,l,a]=Lo(n,o,t),[u,e,x]=M(r,l,a);return {r:b$1(u)*255,g:b$1(e)*255,b:b$1(x)*255,alpha:s}},on=new RegExp(`^lab\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<a>${k})(?<ap>%?)\\s+(?<b>${k})(?<bp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),Xn=n=>{if(typeof n!="string")return null;let o=on.exec(n.trim())?.groups;if(!o)return null;let t=l(o.l),s=o.ap?l(o.a)*1.25:l(o.a),r=o.bp?l(o.b)*1.25:l(o.b),l$1=o.al===void 0?1:l(o.al)/(o.alp?100:1);return Oo({l:a$1(t,0,100),a:s,b:r,alpha:a$1(l$1,0,1)})},hn=n=>{if(!h(n)||n.colorSpace!=="lab"||!i(n,["l","a","b"]))return null;let{l:o,a:t,b:s,alpha:r=1}=n;return !f(o)||!f(t)||!f(s)||!f(r)?null:Oo({l:a$1(g(o),0,100),a:g(t),b:g(s),alpha:a$1(g(r),0,1)})};export{sn as a,Uo as b,To as c,ln as d,M as e,an as f,cn as g,en as h,bn as i,Lo as j,xn as k,Qo as l,gn as m,mn as n,Dn as o,zn as p,Oo as q,Xn as r,hn as s};//# sourceMappingURL=chunk-F4W4HJCD.mjs.map | ||
| //# sourceMappingURL=chunk-F4W4HJCD.mjs.map |
| {"version":3,"sources":["../src/colorModels/xyz.ts","../src/colorModels/lab.ts"],"names":["D50_WX","D50_WY","D50_WZ","S_XR","S_XG","S_XB","S_YR","S_YG","S_YB","S_ZR","S_ZG","S_ZB","X_RX","X_RY","X_RZ","X_GX","X_GY","X_GZ","X_BX","X_BY","X_BZ","D65_TO_D50_XX","D65_TO_D50_XY","D65_TO_D50_XZ","D65_TO_D50_YX","D65_TO_D50_YY","D65_TO_D50_YZ","D65_TO_D50_ZX","D65_TO_D50_ZY","D65_TO_D50_ZZ","D50_TO_D65_XX","D50_TO_D65_XY","D50_TO_D65_XZ","D50_TO_D65_YX","D50_TO_D65_YY","D50_TO_D65_YZ","D50_TO_D65_ZX","D50_TO_D65_ZY","D50_TO_D65_ZZ","rgbToXyzD65","r","g","b","alpha","lr","srgbToLinear","lg","lb","clamp","round","xyzD65ToLinearSrgb","x","y","z","xyzD65ToRgbUnclamped","srgbFromLinear","rgbToXyz","xd65","yd65","zd65","xyzD50ToLinearSrgbInto","out","xyzD50ToLinearSrgb","xyzToRgb","clampRgb","xyzToRgbUnclamped","parseXyzObject","input","isObject","hasKeys","isNumber","parseXyzD65Object","isAnyNumber","sanitize","XYZ_D65_RE","NUM_OR_NONE","XYZ_D50_RE","parseXyzD65String","parseNum","parseXyzD50String","D65_WX","D65_WY","D65_WZ","EPSILON","KAPPA","f","t","xyzToLab","fy","labToXyzValues","l","a","fx","fz","labToXyzValuesInto","labToXyz","rgbToLab","rgb","rgbToLabD65","deltaE2000","lab1","lab2","L1","a1","b1","L2","a2","b2","rad","deg","C1","C2","Cab","G","a1p","a2p","C1p","C2p","Cp","h1p","h2p","h1","h2","dhp","absDh","Lm","Hm","T","dLp","dCp","dHp","SL","SC","SH","RC7","RC","dTheta","RT","labToRgb","lab","labToRgbUnclamped","LAB_RE","parseLabString","parseLabObject"],"mappings":"sJAMO,IAAMA,CAAAA,CAAS,iBACTC,CAAAA,CAAS,GA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B,CAAAA,CAASkB,CAAC,CAAA,CACb,CAAA,CAAGlB,CAAAA,CAAS/B,CAAC,EACb,KAAA,CAAOM,GAAAA,CAAMyB,CAAAA,CAAS9B,CAAK,CAAA,CAAG,CAAA,CAAG,CAAC,CAEpC,CAAC,CACH","file":"chunk-F4W4HJCD.mjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { RgbColor, XyzColor, XyzD65Color } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\n// D50 white point (CSS Color 4: xy = 0.3457/0.3585)\nexport const D50_WX = 96.42956752983539;\nexport const D50_WY = 100;\nexport const D50_WZ = 82.51046025104603;\n\n// ── CSS Color 4 exact rational matrices ─────────────────────────────────────\n// sRGB linear → XYZ D65 (xyz in 0–1; callers scale to 0–100 by multiplying).\nconst S_XR = 0.41239079926595951,\n S_XG = 0.35758433938387796,\n S_XB = 0.18048078840183429;\nconst S_YR = 0.21263900587151036,\n S_YG = 0.71516867876775592,\n S_YB = 0.072192315360733714;\nconst S_ZR = 0.019330818715591849,\n S_ZG = 0.11919477979462599,\n S_ZB = 0.95053215224966059;\n\n// XYZ D65 (0–100 scale) → sRGB linear (0–1). Equals the CSS inverse matrix ÷100.\nconst X_RX = 0.032409699419045213,\n X_RY = -0.015373831775700935,\n X_RZ = -0.0049861076029300327;\nconst X_GX = -0.0096924363628087984,\n X_GY = 0.018759675015077206,\n X_GZ = 0.00041555057407175612;\nconst X_BX = 0.00055630079696993608,\n X_BY = -0.0020397695888897657,\n X_BZ = 0.010569715142428786;\n\n// Bradford D65 → D50 (CSS Color 4)\nconst D65_TO_D50_XX = 1.0479297925449969,\n D65_TO_D50_XY = 0.022946870601609652,\n D65_TO_D50_XZ = -0.05019226628920524;\nconst D65_TO_D50_YX = 0.02962780877005599,\n D65_TO_D50_YY = 0.9904344267538799,\n D65_TO_D50_YZ = -0.017073799063418826;\nconst D65_TO_D50_ZX = -0.009243040646204504,\n D65_TO_D50_ZY = 0.015055191490298152,\n D65_TO_D50_ZZ = 0.7518742814281371;\n\n// Bradford D50 → D65 (CSS Color 4, inverse of above)\nconst D50_TO_D65_XX = 0.955473421488075,\n D50_TO_D65_XY = -0.02309845494876471,\n D50_TO_D65_XZ = 0.06325924320057072;\nconst D50_TO_D65_YX = -0.0283697093338637,\n D50_TO_D65_YY = 1.0099953980813041,\n D50_TO_D65_YZ = 0.021041441191917323;\nconst D50_TO_D65_ZX = 0.012314014864481998,\n D50_TO_D65_ZY = -0.020507649298898964,\n D50_TO_D65_ZZ = 1.330365926242124;\n\n// ── RGB ↔ XYZ D65 ───────────────────────────────────────────────────────────\n\n/** sRGB (0–255) → XYZ D65 (0–100, screen-native, no Bradford adaptation). */\nexport const rgbToXyzD65 = ({ r, g, b, alpha }: RgbColor): XyzD65Color => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n return {\n x: 100 * (S_XR * lr + S_XG * lg + S_XB * lb),\n y: 100 * (S_YR * lr + S_YG * lg + S_YB * lb),\n z: 100 * (S_ZR * lr + S_ZG * lg + S_ZB * lb),\n alpha: clamp(round(alpha, 3), 0, 1),\n colorSpace: 'xyz-d65' as const,\n };\n};\n\n/** XYZ D65 (0–100) → linear sRGB (0–1, unclamped). */\nexport const xyzD65ToLinearSrgb = (x: number, y: number, z: number): [number, number, number] => [\n X_RX * x + X_RY * y + X_RZ * z,\n X_GX * x + X_GY * y + X_GZ * z,\n X_BX * x + X_BY * y + X_BZ * z,\n];\n\nconst xyzD65ToRgbUnclamped = ({ x, y, z, alpha }: XyzD65Color): RgbColor => {\n const [lr, lg, lb] = xyzD65ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// ── RGB ↔ XYZ D50 ───────────────────────────────────────────────────────────\n\nexport const rgbToXyz = ({ r, g, b, alpha }: RgbColor): XyzColor => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n const xd65 = 100 * (S_XR * lr + S_XG * lg + S_XB * lb);\n const yd65 = 100 * (S_YR * lr + S_YG * lg + S_YB * lb);\n const zd65 = 100 * (S_ZR * lr + S_ZG * lg + S_ZB * lb);\n return {\n x: D65_TO_D50_XX * xd65 + D65_TO_D50_XY * yd65 + D65_TO_D50_XZ * zd65,\n y: D65_TO_D50_YX * xd65 + D65_TO_D50_YY * yd65 + D65_TO_D50_YZ * zd65,\n z: D65_TO_D50_ZX * xd65 + D65_TO_D50_ZY * yd65 + D65_TO_D50_ZZ * zd65,\n alpha: clamp(round(alpha, 3), 0, 1),\n };\n};\n\n/** Zero-allocation sibling of xyzD50ToLinearSrgb — writes [lr, lg, lb] into `out`. */\nexport const xyzD50ToLinearSrgbInto = (out: Float64Array | number[], x: number, y: number, z: number): void => {\n const xd65 = D50_TO_D65_XX * x + D50_TO_D65_XY * y + D50_TO_D65_XZ * z;\n const yd65 = D50_TO_D65_YX * x + D50_TO_D65_YY * y + D50_TO_D65_YZ * z;\n const zd65 = D50_TO_D65_ZX * x + D50_TO_D65_ZY * y + D50_TO_D65_ZZ * z;\n out[0] = X_RX * xd65 + X_RY * yd65 + X_RZ * zd65;\n out[1] = X_GX * xd65 + X_GY * yd65 + X_GZ * zd65;\n out[2] = X_BX * xd65 + X_BY * yd65 + X_BZ * zd65;\n};\n\n/** XYZ D50 → linear sRGB (no gamma, no clamping). x/y/z are in 0–100 scale. */\nexport const xyzD50ToLinearSrgb = (x: number, y: number, z: number): [number, number, number] => {\n const xd65 = D50_TO_D65_XX * x + D50_TO_D65_XY * y + D50_TO_D65_XZ * z;\n const yd65 = D50_TO_D65_YX * x + D50_TO_D65_YY * y + D50_TO_D65_YZ * z;\n const zd65 = D50_TO_D65_ZX * x + D50_TO_D65_ZY * y + D50_TO_D65_ZZ * z;\n return [\n X_RX * xd65 + X_RY * yd65 + X_RZ * zd65,\n X_GX * xd65 + X_GY * yd65 + X_GZ * zd65,\n X_BX * xd65 + X_BY * yd65 + X_BZ * zd65,\n ];\n};\n\nexport const xyzToRgb = ({ x, y, z, alpha }: XyzColor): RgbColor => {\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return clampRgb({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n};\n\n/** Unclamped XYZ D50 → gamma-encoded sRGB. Channels may exceed [0, 255] for out-of-sRGB-gamut colors. */\nconst xyzToRgbUnclamped = ({ x, y, z, alpha }: XyzColor): RgbColor => {\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// ── Parsers ─────────────────────────────────────────────────────────────────\n\nexport const parseXyzObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Reject D65-discriminated objects — parseXyzD65Object owns those.\n if ((input as { colorSpace?: unknown }).colorSpace === 'xyz-d65') return null;\n if (!hasKeys(input, ['x', 'y', 'z'])) return null;\n const { x, y, z, alpha = 1 } = input as { x: unknown; y: unknown; z: unknown; alpha?: unknown };\n if (!isNumber(x) || !isNumber(y) || !isNumber(z) || !isNumber(alpha)) return null;\n return xyzToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n });\n};\n\nexport const parseXyzD65Object = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if ((input as { colorSpace?: unknown }).colorSpace !== 'xyz-d65') return null;\n if (!hasKeys(input, ['x', 'y', 'z'])) return null;\n const { x, y, z, alpha = 1 } = input as { x: unknown; y: unknown; z: unknown; alpha?: unknown };\n if (!isAnyNumber(x) || !isAnyNumber(y) || !isAnyNumber(z) || !isAnyNumber(alpha)) return null;\n return xyzD65ToRgbUnclamped({\n x: sanitize(x),\n y: sanitize(y),\n z: sanitize(z),\n alpha: clamp(sanitize(alpha), 0, 1),\n colorSpace: 'xyz-d65',\n });\n};\n\n// CSS Color 4: color(xyz-d65 x y z / alpha). Channels accept number|percentage|none.\n// The library uses a 0–100 XYZ scale (to match the existing XyzColor convention); percent is\n// treated as the same scale for symmetry with the emitted string (100% = 100).\nconst XYZ_D65_RE = new RegExp(\n `^color\\\\(\\\\s*xyz-d65\\\\s+(?<x>${NUM_OR_NONE})(?<xp>%?)\\\\s+(?<y>${NUM_OR_NONE})(?<yp>%?)` +\n `\\\\s+(?<z>${NUM_OR_NONE})(?<zp>%?)\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nconst XYZ_D50_RE = new RegExp(\n `^color\\\\(\\\\s*xyz-d50\\\\s+(?<x>${NUM_OR_NONE})(?<xp>%?)\\\\s+(?<y>${NUM_OR_NONE})(?<yp>%?)` +\n `\\\\s+(?<z>${NUM_OR_NONE})(?<zp>%?)\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseXyzD65String = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = XYZ_D65_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const x = parseNum(g.x!);\n const y = parseNum(g.y!);\n const z = parseNum(g.z!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return xyzD65ToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n colorSpace: 'xyz-d65',\n });\n};\n\nexport const parseXyzD50String = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = XYZ_D50_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const x = parseNum(g.x!);\n const y = parseNum(g.y!);\n const z = parseNum(g.z!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return xyzToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { LabColor, RgbColor, XyzColor } from '../types.js';\nimport { D50_WX as WX, D50_WY as WY, D50_WZ as WZ, rgbToXyz, xyzD50ToLinearSrgb, xyzToRgb } from './xyz.js';\n\n// D65 white point derived from CIE chromaticity (x=0.3127, y=0.329)\nconst D65_WX = (0.3127 / 0.329) * 100;\nconst D65_WY = 100;\nconst D65_WZ = ((1 - 0.3127 - 0.329) / 0.329) * 100;\n\nconst EPSILON = 216 / 24389;\nconst KAPPA = 24389 / 27;\n\nconst f = (t: number) => (t > EPSILON ? Math.cbrt(t) : (KAPPA * t + 16) / 116);\n\nexport const xyzToLab = ({ x, y, z, alpha }: XyzColor): LabColor => {\n const fy = f(y / WY);\n return {\n l: 116 * fy - 16,\n a: 500 * (f(x / WX) - fy) || 0, // || 0 suppresses −0; NaN is impossible since WX/WZ are non-zero constants\n b: 200 * (fy - f(z / WZ)) || 0,\n alpha: round(alpha, 3),\n colorSpace: 'lab' as const,\n };\n};\n\n/** Primitives-only Lab → XYZ D50. x/y/z in 0–100 scale. Shared with channels.ts hot paths. */\nexport const labToXyzValues = (l: number, a: number, b: number): [number, number, number] => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n return [\n (fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA) * WX,\n (l > 8 ? fy ** 3 : l / KAPPA) * WY,\n (fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA) * WZ,\n ];\n};\n\n/** Zero-allocation sibling of labToXyzValues — writes [x, y, z] into `out`. */\nexport const labToXyzValuesInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n out[0] = (fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA) * WX;\n out[1] = (l > 8 ? fy ** 3 : l / KAPPA) * WY;\n out[2] = (fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA) * WZ;\n};\n\nexport const labToXyz = ({ l, a, b, alpha }: LabColor): XyzColor => {\n const [x, y, z] = labToXyzValues(l, a, b);\n return { x, y, z, alpha };\n};\n\nexport const rgbToLab = (rgb: RgbColor): LabColor => xyzToLab(rgbToXyz(rgb));\n\n/** RGB → CIE Lab using D65 white point (screen-native; used for perceptual difference). */\nexport const rgbToLabD65 = ({ r, g, b, alpha }: RgbColor): LabColor => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n const x = 100 * (0.41239079926595951 * lr + 0.35758433938387796 * lg + 0.18048078840183429 * lb);\n const y = 100 * (0.21263900587151036 * lr + 0.71516867876775592 * lg + 0.072192315360733714 * lb);\n const z = 100 * (0.019330818715591849 * lr + 0.11919477979462599 * lg + 0.95053215224966059 * lb);\n const fy = f(y / D65_WY);\n return {\n l: 116 * fy - 16,\n a: 500 * (f(x / D65_WX) - fy) || 0,\n b: 200 * (fy - f(z / D65_WZ)) || 0,\n alpha: round(alpha, 3),\n colorSpace: 'lab' as const,\n };\n};\n\nexport const deltaE2000 = (lab1: LabColor, lab2: LabColor): number => {\n const { l: L1, a: a1, b: b1 } = lab1;\n const { l: L2, a: a2, b: b2 } = lab2;\n const rad = Math.PI / 180;\n const deg = 180 / Math.PI;\n\n const C1 = Math.sqrt(a1 ** 2 + b1 ** 2);\n const C2 = Math.sqrt(a2 ** 2 + b2 ** 2);\n const Cab = ((C1 + C2) / 2) ** 7;\n const G = 0.5 * (1 - Math.sqrt(Cab / (Cab + 25 ** 7)));\n const a1p = a1 * (1 + G);\n const a2p = a2 * (1 + G);\n const C1p = Math.sqrt(a1p ** 2 + b1 ** 2);\n const C2p = Math.sqrt(a2p ** 2 + b2 ** 2);\n const Cp = (C1p + C2p) / 2;\n\n const h1p = a1p === 0 && b1 === 0 ? 0 : Math.atan2(b1, a1p) * deg;\n const h2p = a2p === 0 && b2 === 0 ? 0 : Math.atan2(b2, a2p) * deg;\n const h1 = h1p < 0 ? h1p + 360 : h1p;\n const h2 = h2p < 0 ? h2p + 360 : h2p;\n\n let dhp = h2 - h1;\n const absDh = Math.abs(h2 - h1);\n if (absDh > 180 && h2 <= h1) dhp += 360;\n else if (absDh > 180 && h2 > h1) dhp -= 360;\n\n const Lm = (L1 + L2) / 2;\n let Hm = h1 + h2;\n if (absDh <= 180) Hm /= 2;\n else Hm = (h1 + h2 < 360 ? Hm + 360 : Hm - 360) / 2;\n\n const T =\n 1 -\n 0.17 * Math.cos(rad * (Hm - 30)) +\n 0.24 * Math.cos(2 * rad * Hm) +\n 0.32 * Math.cos(rad * (3 * Hm + 6)) -\n 0.2 * Math.cos(rad * (4 * Hm - 63));\n\n const dLp = L2 - L1;\n const dCp = C2p - C1p;\n const dHp = 2 * Math.sin((rad * dhp) / 2) * Math.sqrt(C1p * C2p);\n\n const SL = 1 + (0.015 * (Lm - 50) ** 2) / Math.sqrt(20 + (Lm - 50) ** 2);\n const SC = 1 + 0.045 * Cp;\n const SH = 1 + 0.015 * Cp * T;\n\n const RC7 = Cp ** 7;\n const RC = 2 * Math.sqrt(RC7 / (RC7 + 25 ** 7));\n const dTheta = 30 * Math.exp(-(((Hm - 275) / 25) ** 2));\n const RT = -RC * Math.sin(2 * rad * dTheta);\n\n return Math.sqrt((dLp / SL) ** 2 + (dCp / SC) ** 2 + (dHp / SH) ** 2 + RT * (dCp / SC) * (dHp / SH));\n};\n\nexport const labToRgb = (lab: LabColor): RgbColor => xyzToRgb(labToXyz(lab));\n\n/**\n * Unclamped Lab (D50) → gamma-encoded sRGB (0–255). Channels may exceed [0, 255] or go\n * negative for colors outside the sRGB gamut. Preserves out-of-gamut information so callers\n * (mapSrgb, inGamut*) can detect and map the color; sRGB output methods clamp at the edge.\n */\nexport const labToRgbUnclamped = ({ l, a, b, alpha }: LabColor): RgbColor => {\n const [x, y, z] = labToXyzValues(l, a, b);\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// CSS Color 4: lab(L a b / alpha). L: number|percentage|none (100% = 100).\n// a/b: number|percentage|none (100% = 125).\nconst LAB_RE = new RegExp(\n `^lab\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<a>${NUM_OR_NONE})(?<ap>%?)\\\\s+(?<b>${NUM_OR_NONE})(?<bp>%?)` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseLabString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = LAB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const l = parseNum(g.l!); // 100% = 100, so value is unchanged whether `%` present\n const a = g.ap ? parseNum(g.a!) * 1.25 : parseNum(g.a!);\n const b = g.bp ? parseNum(g.b!) * 1.25 : parseNum(g.b!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return labToRgbUnclamped({\n l: clamp(l, 0, 100),\n a,\n b,\n alpha: clamp(alpha, 0, 1),\n colorSpace: 'lab',\n });\n};\n\nexport const parseLabObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if ((input as { colorSpace?: unknown }).colorSpace !== 'lab') return null;\n if (!hasKeys(input, ['l', 'a', 'b'])) return null;\n const { l, a, b, alpha = 1 } = input as { l: unknown; a: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(a) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n return labToRgbUnclamped({\n l: clamp(sanitize(l), 0, 100),\n a: sanitize(a),\n b: sanitize(b),\n alpha: clamp(sanitize(alpha), 0, 1),\n colorSpace: 'lab',\n });\n};\n"]} |
| 'use strict';var s=r=>{let n=Math.abs(r),e=n<=.04045?n/12.92:((n+.055)/1.055)**2.4;return r<0?-e:e},a=r=>{let n=Math.abs(r),e=n<=.0031308?12.92*n:1.055*n**(1/2.4)-.055;return r<0?-e:e},t=1.09929682680944,o=.018053968510807,b=r=>{let n=Math.abs(r),e=n<o*4.5?n/4.5:((n+t-1)/t)**(1/.45);return r<0?-e:e},c=r=>{let n=Math.abs(r),e=n<o?4.5*n:t*n**.45-(t-1);return r<0?-e:e};exports.a=s;exports.b=a;exports.c=b;exports.d=c;//# sourceMappingURL=chunk-INDSIUQQ.cjs.map | ||
| //# sourceMappingURL=chunk-INDSIUQQ.cjs.map |
| {"version":3,"sources":["../src/transfer.ts"],"names":["srgbToLinear","c","abs","linear","srgbFromLinear","n","encoded","REC2020_ALPHA","REC2020_BETA","rec2020ToLinear","rec2020FromLinear"],"mappings":"aAMO,IAAMA,CAAAA,CAAgBC,GAAsB,CACjD,IAAMC,EAAM,IAAA,CAAK,GAAA,CAAID,CAAC,CAAA,CAChBE,CAAAA,CAASD,CAAAA,EAAO,OAAUA,CAAAA,CAAM,KAAA,CAAA,CAAA,CAAUA,CAAAA,CAAM,IAAA,EAAS,KAAA,GAAU,GAAA,CACzE,OAAOD,CAAAA,CAAI,CAAA,CAAI,CAACE,CAAAA,CAASA,CAC3B,CAAA,CAQaC,EAAkBC,CAAAA,EAAsB,CACnD,IAAMH,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAIG,CAAC,CAAA,CAChBC,CAAAA,CAAUJ,CAAAA,EAAO,QAAA,CAAY,KAAA,CAAQA,CAAAA,CAAM,MAAQA,CAAAA,GAAQ,CAAA,CAAI,GAAA,CAAA,CAAO,IAAA,CAC5E,OAAOG,CAAAA,CAAI,EAAI,CAACC,CAAAA,CAAUA,CAC5B,CAAA,CAGMC,CAAAA,CAAgB,gBAAA,CAChBC,EAAe,gBAAA,CAGRC,CAAAA,CAAmBR,CAAAA,EAAsB,CACpD,IAAMC,CAAAA,CAAM,KAAK,GAAA,CAAID,CAAC,CAAA,CAChBE,CAAAA,CAASD,CAAAA,CAAMM,CAAAA,CAAe,IAAMN,CAAAA,CAAM,GAAA,CAAA,CAAA,CAAQA,CAAAA,CAAMK,CAAAA,CAAgB,CAAA,EAAKA,CAAAA,IAAmB,EAAI,GAAA,CAAA,CAC1G,OAAON,CAAAA,CAAI,CAAA,CAAI,CAACE,CAAAA,CAASA,CAC3B,CAAA,CAGaO,CAAAA,CAAqBL,CAAAA,EAAsB,CACtD,IAAMH,CAAAA,CAAM,KAAK,GAAA,CAAIG,CAAC,CAAA,CAChBC,CAAAA,CAAUJ,CAAAA,CAAMM,CAAAA,CAAe,IAAMN,CAAAA,CAAMK,CAAAA,CAAgBL,CAAAA,EAAO,GAAA,EAAQK,CAAAA,CAAgB,CAAA,CAAA,CAChG,OAAOF,CAAAA,CAAI,CAAA,CAAI,CAACC,CAAAA,CAAUA,CAC5B","file":"chunk-INDSIUQQ.cjs","sourcesContent":["/**\n * sRGB / Display-P3 transfer function (IEC 61966-2-1), extended to the full real line.\n * For in-gamut values [0, 1] this is the standard curve.\n * Extended to negative values using the mirror of the power curve (not the linear piece),\n * matching the CSS Color 4 spec for out-of-gamut channels.\n */\nexport const srgbToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs <= 0.04045 ? abs / 12.92 : ((abs + 0.055) / 1.055) ** 2.4;\n return c < 0 ? -linear : linear;\n};\n\n/**\n * Linear → gamma-encoded sRGB (extended piecewise, per CSS Color 4).\n * For in-gamut values [0, 1] this is the standard IEC 61966-2-1 curve.\n * Extended to negative values using the mirror of the power curve (not the linear piece),\n * matching the CSS Color 4 spec and display-p3 behaviour for out-of-gamut channels.\n */\nexport const srgbFromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs <= 0.0031308 ? 12.92 * abs : 1.055 * abs ** (1 / 2.4) - 0.055;\n return n < 0 ? -encoded : encoded;\n};\n\n/** BT.2020 transfer function constants. */\nconst REC2020_ALPHA = 1.09929682680944;\nconst REC2020_BETA = 0.018053968510807;\n\n/** BT.2020 gamma-encoded → linear. Extended to the full real line (sign-preserving). */\nexport const rec2020ToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs < REC2020_BETA * 4.5 ? abs / 4.5 : ((abs + REC2020_ALPHA - 1) / REC2020_ALPHA) ** (1 / 0.45);\n return c < 0 ? -linear : linear;\n};\n\n/** BT.2020 linear → gamma-encoded. Extended to the full real line (sign-preserving). */\nexport const rec2020FromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs < REC2020_BETA ? 4.5 * abs : REC2020_ALPHA * abs ** 0.45 - (REC2020_ALPHA - 1);\n return n < 0 ? -encoded : encoded;\n};\n"]} |
| import {a,b}from'./chunk-YLJRINFM.mjs';import {a as a$2}from'./chunk-Q3O3QQ4H.mjs';import {a as a$1,h as h$1,i,f,g,l,k}from'./chunk-IOXRZECH.mjs';var U=.4122214708,z=.5363325363,q=.0514459929,D=.2119034982,H=.6806995451,J=.1073969566,P=.0883024619,Q=.2817188376,V=.6299787005,W=.2104542553,X=.793617785,Y=-0.0040720468,Z=1.9779984951,nn=-2.428592205,on=.4505937099,rn=.0259040371,tn=.7827717662,sn=-0.808675766,I=.3963377774,S=.2158037573,O=-0.1055613458,B=-0.0638541728,h=-0.0894841775,x=-1.291485548,A=4.0767416613,C=-3.3077115904,w=.2309699287,T=-1.2684380041,y=2.6097574007,G=-0.3413193963,d=-0.0041960865,N=-0.7034186145,$=1.7076147009;var cn=(o,n,r)=>{let t=Math.cbrt(U*o+z*n+q*r),s=Math.cbrt(D*o+H*n+J*r),c=Math.cbrt(P*o+Q*n+V*r);return [W*t+X*s+Y*c,Z*t+nn*s+on*c,rn*t+tn*s+sn*c]},Mn=({r:o,g:n,b:r,alpha:t})=>{let[s,c,e]=cn(a(o/255),a(n/255),a(r/255));return {l:s,a:c,b:e,alpha:t}},j=({l:o,a:n,b:r,alpha:t})=>{let[s,c,e]=en(o,n,r);return {r:b(s)*255,g:b(c)*255,b:b(e)*255,alpha:t}},un=({l:o,a:n,b:r,alpha:t})=>{if(n===0&&r===0){let K=o**3,k=b(a$1(K,0,1))*255;return a$2({r:k,g:k,b:k,alpha:t})}let s=o+.3963377774*n+.2158037573*r,c=o-.1055613458*n-.0638541728*r,e=o-.0894841775*n-1.291485548*r,_=s**3,l=c**3,b$1=e**3,p=4.0767416613*_-3.3077115904*l+.2309699287*b$1,E=-1.2684380041*_+2.6097574007*l-.3413193963*b$1,F=-0.0041960865*_-.7034186145*l+1.7076147009*b$1;return a$2({r:b(a$1(p,0,1))*255,g:b(a$1(E,0,1))*255,b:b(a$1(F,0,1))*255,alpha:t})},mn=(o,n,r,t)=>{if(r===0&&t===0){let p=n**3;o[0]=p,o[1]=p,o[2]=p;return}let s=n+I*r+S*t,c=n+O*r+B*t,e=n+h*r+x*t,_=s**3,l=c**3,b=e**3;o[0]=A*_+C*l+w*b,o[1]=T*_+y*l+G*b,o[2]=d*_+N*l+$*b;},en=(o,n,r)=>{if(n===0&&r===0){let b=o**3;return [b,b,b]}let t=o+I*n+S*r,s=o+O*n+B*r,c=o+h*n+x*r,e=t**3,_=s**3,l=c**3;return [A*e+C*_+w*l,T*e+y*_+G*l,d*e+N*_+$*l]},pn=o=>{if(!h$1(o)||o.colorSpace==="lab"||!i(o,["l","a","b"])||"r"in o||"x"in o||"c"in o||"h"in o)return null;let{l:n,a:r,b:t,alpha:s=1}=o;return !f(n)||!f(r)||!f(t)||!f(s)||g(n)>1?null:j({l:g(n),a:g(r),b:g(t),alpha:a$1(g(s),0,1)})},_n=new RegExp(`^oklab\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<a>${k})(?<ap>%?)\\s+(?<b>${k})(?<bp>%?)\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),vn=o=>{if(typeof o!="string")return null;let n=_n.exec(o.trim())?.groups;if(!n)return null;let r=n.lp?l(n.l)/100:l(n.l),t=n.ap?l(n.a)*.004:l(n.a),s=n.bp?l(n.b)*.004:l(n.b),c=n.al===void 0?1:l(n.al)/(n.alp?100:1);return j({l:r,a:t,b:s,alpha:a$1(c,0,1)})};export{cn as a,Mn as b,j as c,un as d,mn as e,en as f,pn as g,vn as h};//# sourceMappingURL=chunk-OX5CMKKI.mjs.map | ||
| //# sourceMappingURL=chunk-OX5CMKKI.mjs.map |
| {"version":3,"sources":["../src/colorModels/oklab.ts"],"names":["M1_LR","M1_LG","M1_LB","M1_MR","M1_MG","M1_MB","M1_SR","M1_SG","M1_SB","M2_L_L","M2_M_L","M2_S_L","M2_L_A","M2_M_A","M2_S_A","M2_L_B","M2_M_B","M2_S_B","M2I_A_L","M2I_B_L","M2I_A_M","M2I_B_M","M2I_A_S","M2I_B_S","M1I_L_R","M1I_M_R","M1I_S_R","M1I_L_G","M1I_M_G","M1I_S_G","M1I_L_B","M1I_M_B","M1I_S_B","linearSrgbToOklab","lr","lg","lb","lv","mv","sv","rgbToOklab","r","g","b","alpha","l","a","bv","srgbToLinear","oklabToRgbUnclamped","oklabToLinear","srgbFromLinear","oklabToRgb","v","srgb","clamp","clampRgb","l_","m_","s_","oklabToLinearInto","out","parseOklabObject","input","isObject","hasKeys","isAnyNumber","sanitize","OKLAB_RE","NUM_OR_NONE","parseOklabString","L","parseNum"],"mappings":"kJAQA,IAAMA,EAAQ,WAAA,CACZC,CAAAA,CAAQ,WAAA,CACRC,CAAAA,CAAQ,YACJC,CAAAA,CAAQ,WAAA,CACZC,CAAAA,CAAQ,WAAA,CACRC,EAAQ,WAAA,CACJC,CAAAA,CAAQ,YACZC,CAAAA,CAAQ,WAAA,CACRC,EAAQ,WAAA,CAEJC,CAAAA,CAAS,WAAA,CACbC,CAAAA,CAAS,WACTC,CAAAA,CAAS,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A,EAAsBA,CAAW,CAAA,4BAAA,EAC3EA,CAAW,wBAClC,GACF,CAAA,CAEaC,GAAoBP,CAAAA,EAAoC,CACnE,GAAI,OAAOA,GAAU,QAAA,CAAU,OAAO,KACtC,IAAMrB,CAAAA,CAAI0B,GAAS,IAAA,CAAKL,CAAAA,CAAM,IAAA,EAAM,GAAG,MAAA,CACvC,GAAI,CAACrB,CAAAA,CAAG,OAAO,KACf,IAAM6B,CAAAA,CAAI7B,CAAAA,CAAE,EAAA,CAAK8B,EAAS9B,CAAAA,CAAE,CAAE,EAAI,GAAA,CAAM8B,CAAAA,CAAS9B,EAAE,CAAE,CAAA,CAC/CI,CAAAA,CAAIJ,CAAAA,CAAE,GAAK8B,CAAAA,CAAS9B,CAAAA,CAAE,CAAE,CAAA,CAAI,IAAA,CAAQ8B,EAAS9B,CAAAA,CAAE,CAAE,CAAA,CACjDC,CAAAA,CAAID,EAAE,EAAA,CAAK8B,CAAAA,CAAS9B,EAAE,CAAE,CAAA,CAAI,KAAQ8B,CAAAA,CAAS9B,CAAAA,CAAE,CAAE,CAAA,CACjDE,EAAQF,CAAAA,CAAE,EAAA,GAAO,OAAY,CAAA,CAAI8B,CAAAA,CAAS9B,EAAE,EAAE,CAAA,EAAKA,CAAAA,CAAE,GAAA,CAAM,IAAM,CAAA,CAAA,CACvE,OAAOO,EAAoB,CAAE,CAAA,CAAGsB,EAAG,CAAA,CAAAzB,CAAAA,CAAG,CAAA,CAAAH,CAAAA,CAAG,MAAOY,GAAAA,CAAMX,CAAAA,CAAO,EAAG,CAAC,CAAE,CAAC,CACtE","file":"chunk-OX5CMKKI.mjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { OklabColor, RgbColor } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\n// Björn Ottosson's OKLab matrix coefficients. Referenced by both the allocating\n// and zero-alloc (*Into) variants so the math lives in one place.\n// sRGB linear → LMS (cubed roots taken at M1 stage)\nconst M1_LR = 0.4122214708,\n M1_LG = 0.5363325363,\n M1_LB = 0.0514459929;\nconst M1_MR = 0.2119034982,\n M1_MG = 0.6806995451,\n M1_MB = 0.1073969566;\nconst M1_SR = 0.0883024619,\n M1_SG = 0.2817188376,\n M1_SB = 0.6299787005;\n// LMS' → OKLab\nconst M2_L_L = 0.2104542553,\n M2_M_L = 0.793617785,\n M2_S_L = -0.0040720468;\nconst M2_L_A = 1.9779984951,\n M2_M_A = -2.428592205,\n M2_S_A = 0.4505937099;\nconst M2_L_B = 0.0259040371,\n M2_M_B = 0.7827717662,\n M2_S_B = -0.808675766;\n// OKLab → LMS' (inverse of M2)\nconst M2I_A_L = 0.3963377774,\n M2I_B_L = 0.2158037573;\nconst M2I_A_M = -0.1055613458,\n M2I_B_M = -0.0638541728;\nconst M2I_A_S = -0.0894841775,\n M2I_B_S = -1.291485548;\n// LMS → linear sRGB (inverse of M1)\nconst M1I_L_R = 4.0767416613,\n M1I_M_R = -3.3077115904,\n M1I_S_R = 0.2309699287;\nconst M1I_L_G = -1.2684380041,\n M1I_M_G = 2.6097574007,\n M1I_S_G = -0.3413193963;\nconst M1I_L_B = -0.0041960865,\n M1I_M_B = -0.7034186145,\n M1I_S_B = 1.7076147009;\n\n/** Zero-allocation sibling of linearSrgbToOklab — writes [l, a, b] into `out`. */\nexport const linearSrgbToOklabInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n const lv = Math.cbrt(M1_LR * lr + M1_LG * lg + M1_LB * lb);\n const mv = Math.cbrt(M1_MR * lr + M1_MG * lg + M1_MB * lb);\n const sv = Math.cbrt(M1_SR * lr + M1_SG * lg + M1_SB * lb);\n out[0] = M2_L_L * lv + M2_M_L * mv + M2_S_L * sv;\n out[1] = M2_L_A * lv + M2_M_A * mv + M2_S_A * sv;\n out[2] = M2_L_B * lv + M2_M_B * mv + M2_S_B * sv;\n};\n\n/** Convert linear sRGB channels to OKLab (Björn Ottosson). No gamma, no clamping. */\nexport const linearSrgbToOklab = (lr: number, lg: number, lb: number): [number, number, number] => {\n const lv = Math.cbrt(M1_LR * lr + M1_LG * lg + M1_LB * lb);\n const mv = Math.cbrt(M1_MR * lr + M1_MG * lg + M1_MB * lb);\n const sv = Math.cbrt(M1_SR * lr + M1_SG * lg + M1_SB * lb);\n return [\n M2_L_L * lv + M2_M_L * mv + M2_S_L * sv,\n M2_L_A * lv + M2_M_A * mv + M2_S_A * sv,\n M2_L_B * lv + M2_M_B * mv + M2_S_B * sv,\n ];\n};\n\nexport const rgbToOklab = ({ r, g, b, alpha }: RgbColor): OklabColor => {\n const [l, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n return { l, a, b: bv, alpha };\n};\n\n/** Unclamped OKLab → gamma-encoded sRGB. Channels may exceed [0, 255] for out-of-sRGB-gamut colors. */\nexport const oklabToRgbUnclamped = ({ l, a, b, alpha }: OklabColor): RgbColor => {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\nexport const oklabToRgb = ({ l, a, b, alpha }: OklabColor): RgbColor => {\n if (a === 0 && b === 0) {\n const v = l ** 3;\n const srgb = srgbFromLinear(clamp(v, 0, 1)) * 255;\n return clampRgb({ r: srgb, g: srgb, b: srgb, alpha });\n }\n\n const l_ = l + 0.3963377774 * a + 0.2158037573 * b;\n const m_ = l - 0.1055613458 * a - 0.0638541728 * b;\n const s_ = l - 0.0894841775 * a - 1.291485548 * b;\n\n const lv = l_ ** 3;\n const mv = m_ ** 3;\n const sv = s_ ** 3;\n\n const r = 4.0767416613 * lv - 3.3077115904 * mv + 0.2309699287 * sv;\n const g = -1.2684380041 * lv + 2.6097574007 * mv - 0.3413193963 * sv;\n const bv = -0.0041960865 * lv - 0.7034186145 * mv + 1.7076147009 * sv;\n\n return clampRgb({\n r: srgbFromLinear(clamp(r, 0, 1)) * 255,\n g: srgbFromLinear(clamp(g, 0, 1)) * 255,\n b: srgbFromLinear(clamp(bv, 0, 1)) * 255,\n alpha,\n });\n};\n\n/** Zero-allocation sibling of oklabToLinear — writes [lr, lg, lb] into `out`. */\nexport const oklabToLinearInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n // Achromatic short-circuit: M1⁻¹ rows sum to 1 mathematically, but floating-point\n // rounding leaves lr/lg/lb ~1 ULP apart, which gets amplified into a phantom hue\n // downstream in rgbToHslRaw. Explicitly return lv for all channels.\n if (a === 0 && b === 0) {\n const v = l ** 3;\n out[0] = v;\n out[1] = v;\n out[2] = v;\n return;\n }\n const l_ = l + M2I_A_L * a + M2I_B_L * b;\n const m_ = l + M2I_A_M * a + M2I_B_M * b;\n const s_ = l + M2I_A_S * a + M2I_B_S * b;\n const lv = l_ ** 3,\n mv = m_ ** 3,\n sv = s_ ** 3;\n out[0] = M1I_L_R * lv + M1I_M_R * mv + M1I_S_R * sv;\n out[1] = M1I_L_G * lv + M1I_M_G * mv + M1I_S_G * sv;\n out[2] = M1I_L_B * lv + M1I_M_B * mv + M1I_S_B * sv;\n};\n\n/** Unclamped linear sRGB channels from OKLab values. Channels may exceed [0, 1] for out-of-gamut colors. */\nexport const oklabToLinear = (l: number, a: number, b: number): [number, number, number] => {\n if (a === 0 && b === 0) {\n const v = l ** 3;\n return [v, v, v];\n }\n const l_ = l + M2I_A_L * a + M2I_B_L * b;\n const m_ = l + M2I_A_M * a + M2I_B_M * b;\n const s_ = l + M2I_A_S * a + M2I_B_S * b;\n const lv = l_ ** 3,\n mv = m_ ** 3,\n sv = s_ ** 3;\n return [\n M1I_L_R * lv + M1I_M_R * mv + M1I_S_R * sv,\n M1I_L_G * lv + M1I_M_G * mv + M1I_S_G * sv,\n M1I_L_B * lv + M1I_M_B * mv + M1I_S_B * sv,\n ];\n};\n\nexport const parseOklabObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lab' are CIE Lab, not OKLab — let parseLabObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lab') return null;\n if (!hasKeys(input, ['l', 'a', 'b'])) return null;\n if ('r' in input || 'x' in input || 'c' in input || 'h' in input) return null;\n const { l, a, b, alpha = 1 } = input as { l: unknown; a: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(a) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLab L is always [0, 1]; reject CIE Lab values passed without colorSpace branding\n return oklabToRgbUnclamped({\n l: sanitize(l),\n a: sanitize(a),\n b: sanitize(b),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLAB_RE = new RegExp(\n `^oklab\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<a>${NUM_OR_NONE})(?<ap>%?)\\\\s+(?<b>${NUM_OR_NONE})(?<bp>%?)` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklabString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLAB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const a = g.ap ? parseNum(g.a!) * 0.004 : parseNum(g.a!); // 100% = 0.4\n const b = g.bp ? parseNum(g.b!) * 0.004 : parseNum(g.b!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklabToRgbUnclamped({ l: L, a, b, alpha: clamp(alpha, 0, 1) });\n};\n"]} |
| 'use strict';var chunkINDSIUQQ_cjs=require('./chunk-INDSIUQQ.cjs'),chunk3V4MONNR_cjs=require('./chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var L=96.4295675298354,O=100,w=82.51046025104603,lo=.4123907992659595,ao=.35758433938387796,co=.1804807884018343,eo=.21263900587151036,bo=.7151686787677559,po=.07219231536073371,uo=.01933081871559185,_o=.11919477979462599,yo=.9505321522496606,A=.032409699419045215,B=-0.015373831775700935,G=-0.004986107602930032,I=-0.009692436362808799,P=.018759675015077207,U=.0004155505740717561,F=.000556300796969936,H=-0.002039769588889766,K=.010569715142428786,Wo=1.0479297925449969,Eo=.022946870601609652,qo=-0.05019226628920524,jo=.02962780877005599,Ao=.9904344267538799,Bo=-0.017073799063418826,Go=-0.009243040646204504,Io=.015055191490298152,Po=.7518742814281371,xo=.955473421488075,go=-0.02309845494876471,mo=.06325924320057072,Do=-0.0283697093338637,zo=1.0099953980813041,io=.021041441191917323,Xo=.012314014864481998,ho=-0.020507649298898964,Co=1.330365926242124,sn=({r:n,g:o,b:t,alpha:s})=>{let r=chunkINDSIUQQ_cjs.a(n/255),l=chunkINDSIUQQ_cjs.a(o/255),a=chunkINDSIUQQ_cjs.a(t/255);return {x:100*(lo*r+ao*l+co*a),y:100*(eo*r+bo*l+po*a),z:100*(uo*r+_o*l+yo*a),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(s,3),0,1),colorSpace:"xyz-d65"}},Uo=(n,o,t)=>[A*n+B*o+G*t,I*n+P*o+U*t,F*n+H*o+K*t],fo=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=Uo(n,o,t);return {r:chunkINDSIUQQ_cjs.b(r)*255,g:chunkINDSIUQQ_cjs.b(l)*255,b:chunkINDSIUQQ_cjs.b(a)*255,alpha:s}},To=({r:n,g:o,b:t,alpha:s})=>{let r=chunkINDSIUQQ_cjs.a(n/255),l=chunkINDSIUQQ_cjs.a(o/255),a=chunkINDSIUQQ_cjs.a(t/255),u=100*(lo*r+ao*l+co*a),e=100*(eo*r+bo*l+po*a),x=100*(uo*r+_o*l+yo*a);return {x:Wo*u+Eo*e+qo*x,y:jo*u+Ao*e+Bo*x,z:Go*u+Io*e+Po*x,alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(s,3),0,1)}},ln=(n,o,t,s)=>{let r=xo*o+go*t+mo*s,l=Do*o+zo*t+io*s,a=Xo*o+ho*t+Co*s;n[0]=A*r+B*l+G*a,n[1]=I*r+P*l+U*a,n[2]=F*r+H*l+K*a;},M=(n,o,t)=>{let s=xo*n+go*o+mo*t,r=Do*n+zo*o+io*t,l=Xo*n+ho*o+Co*t;return [A*s+B*r+G*l,I*s+P*r+U*l,F*s+H*r+K*l]},Ro=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=M(n,o,t);return chunk3V4MONNR_cjs.a({r:chunkINDSIUQQ_cjs.b(r)*255,g:chunkINDSIUQQ_cjs.b(l)*255,b:chunkINDSIUQQ_cjs.b(a)*255,alpha:s})},So=({x:n,y:o,z:t,alpha:s})=>{let[r,l,a]=M(n,o,t);return {r:chunkINDSIUQQ_cjs.b(r)*255,g:chunkINDSIUQQ_cjs.b(l)*255,b:chunkINDSIUQQ_cjs.b(a)*255,alpha:s}},an=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace==="xyz-d65"||!chunkYISEJCI6_cjs.i(n,["x","y","z"]))return null;let{x:o,y:t,z:s,alpha:r=1}=n;return !chunkYISEJCI6_cjs.e(o)||!chunkYISEJCI6_cjs.e(t)||!chunkYISEJCI6_cjs.e(s)||!chunkYISEJCI6_cjs.e(r)?null:So({x:o,y:t,z:s,alpha:chunkYISEJCI6_cjs.a(r,0,1)})},cn=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace!=="xyz-d65"||!chunkYISEJCI6_cjs.i(n,["x","y","z"]))return null;let{x:o,y:t,z:s,alpha:r=1}=n;return !chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(s)||!chunkYISEJCI6_cjs.f(r)?null:fo({x:chunkYISEJCI6_cjs.g(o),y:chunkYISEJCI6_cjs.g(t),z:chunkYISEJCI6_cjs.g(s),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(r),0,1)})},Fo=new RegExp(`^color\\(\\s*xyz-d65\\s+(?<x>${chunkYISEJCI6_cjs.k})(?<xp>%?)\\s+(?<y>${chunkYISEJCI6_cjs.k})(?<yp>%?)\\s+(?<z>${chunkYISEJCI6_cjs.k})(?<zp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Ho=new RegExp(`^color\\(\\s*xyz-d50\\s+(?<x>${chunkYISEJCI6_cjs.k})(?<xp>%?)\\s+(?<y>${chunkYISEJCI6_cjs.k})(?<yp>%?)\\s+(?<z>${chunkYISEJCI6_cjs.k})(?<zp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),en=n=>{if(typeof n!="string")return null;let o=Fo.exec(n.trim())?.groups;if(!o)return null;let t=chunkYISEJCI6_cjs.l(o.x),s=chunkYISEJCI6_cjs.l(o.y),r=chunkYISEJCI6_cjs.l(o.z),l=o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1);return fo({x:t,y:s,z:r,alpha:chunkYISEJCI6_cjs.a(l,0,1)})},bn=n=>{if(typeof n!="string")return null;let o=Ho.exec(n.trim())?.groups;if(!o)return null;let t=chunkYISEJCI6_cjs.l(o.x),s=chunkYISEJCI6_cjs.l(o.y),r=chunkYISEJCI6_cjs.l(o.z),l=o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1);return So({x:t,y:s,z:r,alpha:chunkYISEJCI6_cjs.a(l,0,1)})};var Ko=.3127/.329*100,vo=100,Vo=(1-.3127-.329)/.329*100,S=216/24389,z=24389/27,C=n=>n>S?Math.cbrt(n):(z*n+16)/116,Jo=({x:n,y:o,z:t,alpha:s})=>{let r=C(o/O);return {l:116*r-16,a:500*(C(n/L)-r)||0,b:200*(r-C(t/w))||0,alpha:chunkYISEJCI6_cjs.b(s,3),colorSpace:"lab"}},Lo=(n,o,t)=>{let s=(n+16)/116,r=o/500+s,l=s-t/200;return [(r**3>S?r**3:(116*r-16)/z)*L,(n>8?s**3:n/z)*O,(l**3>S?l**3:(116*l-16)/z)*w]},xn=(n,o,t,s)=>{let r=(o+16)/116,l=t/500+r,a=r-s/200;n[0]=(l**3>S?l**3:(116*l-16)/z)*L,n[1]=(o>8?r**3:o/z)*O,n[2]=(a**3>S?a**3:(116*a-16)/z)*w;},Qo=({l:n,a:o,b:t,alpha:s})=>{let[r,l,a]=Lo(n,o,t);return {x:r,y:l,z:a,alpha:s}},gn=n=>Jo(To(n)),mn=({r:n,g:o,b:t,alpha:s})=>{let r=chunkINDSIUQQ_cjs.a(n/255),l=chunkINDSIUQQ_cjs.a(o/255),a=chunkINDSIUQQ_cjs.a(t/255),u=100*(.4123907992659595*r+.35758433938387796*l+.1804807884018343*a),e=100*(.21263900587151036*r+.7151686787677559*l+.07219231536073371*a),x=100*(.01933081871559185*r+.11919477979462599*l+.9505321522496606*a),f=C(e/vo);return {l:116*f-16,a:500*(C(u/Ko)-f)||0,b:200*(f-C(x/Vo))||0,alpha:chunkYISEJCI6_cjs.b(s,3),colorSpace:"lab"}},Dn=(n,o)=>{let{l:t,a:s,b:r}=n,{l,a,b:u}=o,e=Math.PI/180,x=180/Math.PI,f=Math.sqrt(s**2+r**2),wo=Math.sqrt(a**2+u**2),v=((f+wo)/2)**7,V=.5*(1-Math.sqrt(v/(v+25**7))),Y=s*(1+V),Z=a*(1+V),k=Math.sqrt(Y**2+r**2),$=Math.sqrt(Z**2+u**2),N=(k+$)/2,W=Y===0&&r===0?0:Math.atan2(r,Y)*x,E=Z===0&&u===0?0:Math.atan2(u,Z)*x,i=W<0?W+360:W,X=E<0?E+360:E,q=X-i,j=Math.abs(X-i);j>180&&X<=i?q+=360:j>180&&X>i&&(q-=360);let J=(t+l)/2,D=i+X;j<=180?D/=2:D=(i+X<360?D+360:D-360)/2;let Mo=1-.17*Math.cos(e*(D-30))+.24*Math.cos(2*e*D)+.32*Math.cos(e*(3*D+6))-.2*Math.cos(e*(4*D-63)),Yo=l-t,Q=$-k,oo=2*Math.sin(e*q/2)*Math.sqrt(k*$),Zo=1+.015*(J-50)**2/Math.sqrt(20+(J-50)**2),no=1+.045*N,ro=1+.015*N*Mo,to=N**7,ko=2*Math.sqrt(to/(to+25**7)),$o=30*Math.exp(-(((D-275)/25)**2)),No=-ko*Math.sin(2*e*$o);return Math.sqrt((Yo/Zo)**2+(Q/no)**2+(oo/ro)**2+No*(Q/no)*(oo/ro))},zn=n=>Ro(Qo(n)),Oo=({l:n,a:o,b:t,alpha:s})=>{let[r,l,a]=Lo(n,o,t),[u,e,x]=M(r,l,a);return {r:chunkINDSIUQQ_cjs.b(u)*255,g:chunkINDSIUQQ_cjs.b(e)*255,b:chunkINDSIUQQ_cjs.b(x)*255,alpha:s}},on=new RegExp(`^lab\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<a>${chunkYISEJCI6_cjs.k})(?<ap>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Xn=n=>{if(typeof n!="string")return null;let o=on.exec(n.trim())?.groups;if(!o)return null;let t=chunkYISEJCI6_cjs.l(o.l),s=o.ap?chunkYISEJCI6_cjs.l(o.a)*1.25:chunkYISEJCI6_cjs.l(o.a),r=o.bp?chunkYISEJCI6_cjs.l(o.b)*1.25:chunkYISEJCI6_cjs.l(o.b),l=o.al===void 0?1:chunkYISEJCI6_cjs.l(o.al)/(o.alp?100:1);return Oo({l:chunkYISEJCI6_cjs.a(t,0,100),a:s,b:r,alpha:chunkYISEJCI6_cjs.a(l,0,1)})},hn=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace!=="lab"||!chunkYISEJCI6_cjs.i(n,["l","a","b"]))return null;let{l:o,a:t,b:s,alpha:r=1}=n;return !chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(s)||!chunkYISEJCI6_cjs.f(r)?null:Oo({l:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(o),0,100),a:chunkYISEJCI6_cjs.g(t),b:chunkYISEJCI6_cjs.g(s),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(r),0,1)})};exports.a=sn;exports.b=Uo;exports.c=To;exports.d=ln;exports.e=M;exports.f=an;exports.g=cn;exports.h=en;exports.i=bn;exports.j=Lo;exports.k=xn;exports.l=Qo;exports.m=gn;exports.n=mn;exports.o=Dn;exports.p=zn;exports.q=Oo;exports.r=Xn;exports.s=hn;//# sourceMappingURL=chunk-PI5KJ3ZM.cjs.map | ||
| //# sourceMappingURL=chunk-PI5KJ3ZM.cjs.map |
| {"version":3,"sources":["../src/colorModels/xyz.ts","../src/colorModels/lab.ts"],"names":["D50_WX","D50_WY","D50_WZ","S_XR","S_XG","S_XB","S_YR","S_YG","S_YB","S_ZR","S_ZG","S_ZB","X_RX","X_RY","X_RZ","X_GX","X_GY","X_GZ","X_BX","X_BY","X_BZ","D65_TO_D50_XX","D65_TO_D50_XY","D65_TO_D50_XZ","D65_TO_D50_YX","D65_TO_D50_YY","D65_TO_D50_YZ","D65_TO_D50_ZX","D65_TO_D50_ZY","D65_TO_D50_ZZ","D50_TO_D65_XX","D50_TO_D65_XY","D50_TO_D65_XZ","D50_TO_D65_YX","D50_TO_D65_YY","D50_TO_D65_YZ","D50_TO_D65_ZX","D50_TO_D65_ZY","D50_TO_D65_ZZ","rgbToXyzD65","r","g","b","alpha","lr","srgbToLinear","lg","lb","clamp","round","xyzD65ToLinearSrgb","x","y","z","xyzD65ToRgbUnclamped","srgbFromLinear","rgbToXyz","xd65","yd65","zd65","xyzD50ToLinearSrgbInto","out","xyzD50ToLinearSrgb","xyzToRgb","clampRgb","xyzToRgbUnclamped","parseXyzObject","input","isObject","hasKeys","isNumber","parseXyzD65Object","isAnyNumber","sanitize","XYZ_D65_RE","NUM_OR_NONE","XYZ_D50_RE","parseXyzD65String","parseNum","parseXyzD50String","D65_WX","D65_WY","D65_WZ","EPSILON","KAPPA","f","t","xyzToLab","fy","labToXyzValues","l","a","fx","fz","labToXyzValuesInto","labToXyz","rgbToLab","rgb","rgbToLabD65","deltaE2000","lab1","lab2","L1","a1","b1","L2","a2","b2","rad","deg","C1","C2","Cab","G","a1p","a2p","C1p","C2p","Cp","h1p","h2p","h1","h2","dhp","absDh","Lm","Hm","T","dLp","dCp","dHp","SL","SC","SH","RC7","RC","dTheta","RT","labToRgb","lab","labToRgbUnclamped","LAB_RE","parseLabString","parseLabObject"],"mappings":"uKAMO,IAAMA,CAAAA,CAAS,iBACTC,CAAAA,CAAS,GAAA,CACTC,EAAS,iBAAA,CAIhBC,EAAAA,CAAO,iBAAA,CACXC,EAAAA,CAAO,kBAAA,CACPC,EAAAA,CAAO,kBACHC,EAAAA,CAAO,kBAAA,CACXC,GAAO,iBAAA,CACPC,EAAAA,CAAO,mBACHC,EAAAA,CAAO,kBAAA,CACXC,EAAAA,CAAO,kBAAA,CACPC,EAAAA,CAAO,iBAAA,CAGHC,EAAO,mBAAA,CACXC,CAAAA,CAAO,sBACPC,CAAAA,CAAO,qBAAA,CACHC,EAAO,qBAAA,CACXC,CAAAA,CAAO,mBAAA,CACPC,CAAAA,CAAO,oBAAA,CACHC,CAAAA,CAAO,oBACXC,CAAAA,CAAO,qBAAA,CACPC,EAAO,mBAAA,CAGHC,EAAAA,CAAgB,mBACpBC,EAAAA,CAAgB,mBAAA,CAChBC,EAAAA,CAAgB,oBAAA,CACZC,EAAAA,CAAgB,kBAAA,CACpBC,GAAgB,iBAAA,CAChBC,EAAAA,CAAgB,sBACZC,EAAAA,CAAgB,qBAAA,CACpBC,GAAgB,mBAAA,CAChBC,EAAAA,CAAgB,iBAAA,CAGZC,EAAAA,CAAgB,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AAkB5E,CAAAA,EAAoC,CAGjE,GAFI,CAACC,mBAAAA,CAASD,CAAK,GACdA,CAAAA,CAAmC,UAAA,GAAe,OACnD,CAACE,mBAAAA,CAAQF,CAAAA,CAAO,CAAC,GAAA,CAAK,GAAA,CAAK,GAAG,CAAC,CAAA,CAAG,OAAO,IAAA,CAC7C,GAAM,CAAE,EAAAuB,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAjD,CAAAA,CAAG,KAAA,CAAAC,EAAQ,CAAE,CAAA,CAAIwB,EAC/B,OAAI,CAACK,oBAAYkB,CAAC,CAAA,EAAK,CAAClB,mBAAAA,CAAYmB,CAAC,CAAA,EAAK,CAACnB,mBAAAA,CAAY9B,CAAC,GAAK,CAAC8B,mBAAAA,CAAY7B,CAAK,CAAA,CAAU,IAAA,CAClFiG,EAAAA,CAAkB,CACvB,CAAA,CAAG5F,mBAAAA,CAAMyB,oBAASiB,CAAC,CAAA,CAAG,EAAG,GAAG,CAAA,CAC5B,EAAGjB,mBAAAA,CAASkB,CAAC,CAAA,CACb,CAAA,CAAGlB,mBAAAA,CAAS/B,CAAC,EACb,KAAA,CAAOM,mBAAAA,CAAMyB,mBAAAA,CAAS9B,CAAK,CAAA,CAAG,CAAA,CAAG,CAAC,CAEpC,CAAC,CACH","file":"chunk-PI5KJ3ZM.cjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { RgbColor, XyzColor, XyzD65Color } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\n// D50 white point (CSS Color 4: xy = 0.3457/0.3585)\nexport const D50_WX = 96.42956752983539;\nexport const D50_WY = 100;\nexport const D50_WZ = 82.51046025104603;\n\n// ── CSS Color 4 exact rational matrices ─────────────────────────────────────\n// sRGB linear → XYZ D65 (xyz in 0–1; callers scale to 0–100 by multiplying).\nconst S_XR = 0.41239079926595951,\n S_XG = 0.35758433938387796,\n S_XB = 0.18048078840183429;\nconst S_YR = 0.21263900587151036,\n S_YG = 0.71516867876775592,\n S_YB = 0.072192315360733714;\nconst S_ZR = 0.019330818715591849,\n S_ZG = 0.11919477979462599,\n S_ZB = 0.95053215224966059;\n\n// XYZ D65 (0–100 scale) → sRGB linear (0–1). Equals the CSS inverse matrix ÷100.\nconst X_RX = 0.032409699419045213,\n X_RY = -0.015373831775700935,\n X_RZ = -0.0049861076029300327;\nconst X_GX = -0.0096924363628087984,\n X_GY = 0.018759675015077206,\n X_GZ = 0.00041555057407175612;\nconst X_BX = 0.00055630079696993608,\n X_BY = -0.0020397695888897657,\n X_BZ = 0.010569715142428786;\n\n// Bradford D65 → D50 (CSS Color 4)\nconst D65_TO_D50_XX = 1.0479297925449969,\n D65_TO_D50_XY = 0.022946870601609652,\n D65_TO_D50_XZ = -0.05019226628920524;\nconst D65_TO_D50_YX = 0.02962780877005599,\n D65_TO_D50_YY = 0.9904344267538799,\n D65_TO_D50_YZ = -0.017073799063418826;\nconst D65_TO_D50_ZX = -0.009243040646204504,\n D65_TO_D50_ZY = 0.015055191490298152,\n D65_TO_D50_ZZ = 0.7518742814281371;\n\n// Bradford D50 → D65 (CSS Color 4, inverse of above)\nconst D50_TO_D65_XX = 0.955473421488075,\n D50_TO_D65_XY = -0.02309845494876471,\n D50_TO_D65_XZ = 0.06325924320057072;\nconst D50_TO_D65_YX = -0.0283697093338637,\n D50_TO_D65_YY = 1.0099953980813041,\n D50_TO_D65_YZ = 0.021041441191917323;\nconst D50_TO_D65_ZX = 0.012314014864481998,\n D50_TO_D65_ZY = -0.020507649298898964,\n D50_TO_D65_ZZ = 1.330365926242124;\n\n// ── RGB ↔ XYZ D65 ───────────────────────────────────────────────────────────\n\n/** sRGB (0–255) → XYZ D65 (0–100, screen-native, no Bradford adaptation). */\nexport const rgbToXyzD65 = ({ r, g, b, alpha }: RgbColor): XyzD65Color => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n return {\n x: 100 * (S_XR * lr + S_XG * lg + S_XB * lb),\n y: 100 * (S_YR * lr + S_YG * lg + S_YB * lb),\n z: 100 * (S_ZR * lr + S_ZG * lg + S_ZB * lb),\n alpha: clamp(round(alpha, 3), 0, 1),\n colorSpace: 'xyz-d65' as const,\n };\n};\n\n/** XYZ D65 (0–100) → linear sRGB (0–1, unclamped). */\nexport const xyzD65ToLinearSrgb = (x: number, y: number, z: number): [number, number, number] => [\n X_RX * x + X_RY * y + X_RZ * z,\n X_GX * x + X_GY * y + X_GZ * z,\n X_BX * x + X_BY * y + X_BZ * z,\n];\n\nconst xyzD65ToRgbUnclamped = ({ x, y, z, alpha }: XyzD65Color): RgbColor => {\n const [lr, lg, lb] = xyzD65ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// ── RGB ↔ XYZ D50 ───────────────────────────────────────────────────────────\n\nexport const rgbToXyz = ({ r, g, b, alpha }: RgbColor): XyzColor => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n const xd65 = 100 * (S_XR * lr + S_XG * lg + S_XB * lb);\n const yd65 = 100 * (S_YR * lr + S_YG * lg + S_YB * lb);\n const zd65 = 100 * (S_ZR * lr + S_ZG * lg + S_ZB * lb);\n return {\n x: D65_TO_D50_XX * xd65 + D65_TO_D50_XY * yd65 + D65_TO_D50_XZ * zd65,\n y: D65_TO_D50_YX * xd65 + D65_TO_D50_YY * yd65 + D65_TO_D50_YZ * zd65,\n z: D65_TO_D50_ZX * xd65 + D65_TO_D50_ZY * yd65 + D65_TO_D50_ZZ * zd65,\n alpha: clamp(round(alpha, 3), 0, 1),\n };\n};\n\n/** Zero-allocation sibling of xyzD50ToLinearSrgb — writes [lr, lg, lb] into `out`. */\nexport const xyzD50ToLinearSrgbInto = (out: Float64Array | number[], x: number, y: number, z: number): void => {\n const xd65 = D50_TO_D65_XX * x + D50_TO_D65_XY * y + D50_TO_D65_XZ * z;\n const yd65 = D50_TO_D65_YX * x + D50_TO_D65_YY * y + D50_TO_D65_YZ * z;\n const zd65 = D50_TO_D65_ZX * x + D50_TO_D65_ZY * y + D50_TO_D65_ZZ * z;\n out[0] = X_RX * xd65 + X_RY * yd65 + X_RZ * zd65;\n out[1] = X_GX * xd65 + X_GY * yd65 + X_GZ * zd65;\n out[2] = X_BX * xd65 + X_BY * yd65 + X_BZ * zd65;\n};\n\n/** XYZ D50 → linear sRGB (no gamma, no clamping). x/y/z are in 0–100 scale. */\nexport const xyzD50ToLinearSrgb = (x: number, y: number, z: number): [number, number, number] => {\n const xd65 = D50_TO_D65_XX * x + D50_TO_D65_XY * y + D50_TO_D65_XZ * z;\n const yd65 = D50_TO_D65_YX * x + D50_TO_D65_YY * y + D50_TO_D65_YZ * z;\n const zd65 = D50_TO_D65_ZX * x + D50_TO_D65_ZY * y + D50_TO_D65_ZZ * z;\n return [\n X_RX * xd65 + X_RY * yd65 + X_RZ * zd65,\n X_GX * xd65 + X_GY * yd65 + X_GZ * zd65,\n X_BX * xd65 + X_BY * yd65 + X_BZ * zd65,\n ];\n};\n\nexport const xyzToRgb = ({ x, y, z, alpha }: XyzColor): RgbColor => {\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return clampRgb({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n};\n\n/** Unclamped XYZ D50 → gamma-encoded sRGB. Channels may exceed [0, 255] for out-of-sRGB-gamut colors. */\nconst xyzToRgbUnclamped = ({ x, y, z, alpha }: XyzColor): RgbColor => {\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// ── Parsers ─────────────────────────────────────────────────────────────────\n\nexport const parseXyzObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Reject D65-discriminated objects — parseXyzD65Object owns those.\n if ((input as { colorSpace?: unknown }).colorSpace === 'xyz-d65') return null;\n if (!hasKeys(input, ['x', 'y', 'z'])) return null;\n const { x, y, z, alpha = 1 } = input as { x: unknown; y: unknown; z: unknown; alpha?: unknown };\n if (!isNumber(x) || !isNumber(y) || !isNumber(z) || !isNumber(alpha)) return null;\n return xyzToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n });\n};\n\nexport const parseXyzD65Object = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if ((input as { colorSpace?: unknown }).colorSpace !== 'xyz-d65') return null;\n if (!hasKeys(input, ['x', 'y', 'z'])) return null;\n const { x, y, z, alpha = 1 } = input as { x: unknown; y: unknown; z: unknown; alpha?: unknown };\n if (!isAnyNumber(x) || !isAnyNumber(y) || !isAnyNumber(z) || !isAnyNumber(alpha)) return null;\n return xyzD65ToRgbUnclamped({\n x: sanitize(x),\n y: sanitize(y),\n z: sanitize(z),\n alpha: clamp(sanitize(alpha), 0, 1),\n colorSpace: 'xyz-d65',\n });\n};\n\n// CSS Color 4: color(xyz-d65 x y z / alpha). Channels accept number|percentage|none.\n// The library uses a 0–100 XYZ scale (to match the existing XyzColor convention); percent is\n// treated as the same scale for symmetry with the emitted string (100% = 100).\nconst XYZ_D65_RE = new RegExp(\n `^color\\\\(\\\\s*xyz-d65\\\\s+(?<x>${NUM_OR_NONE})(?<xp>%?)\\\\s+(?<y>${NUM_OR_NONE})(?<yp>%?)` +\n `\\\\s+(?<z>${NUM_OR_NONE})(?<zp>%?)\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nconst XYZ_D50_RE = new RegExp(\n `^color\\\\(\\\\s*xyz-d50\\\\s+(?<x>${NUM_OR_NONE})(?<xp>%?)\\\\s+(?<y>${NUM_OR_NONE})(?<yp>%?)` +\n `\\\\s+(?<z>${NUM_OR_NONE})(?<zp>%?)\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseXyzD65String = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = XYZ_D65_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const x = parseNum(g.x!);\n const y = parseNum(g.y!);\n const z = parseNum(g.z!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return xyzD65ToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n colorSpace: 'xyz-d65',\n });\n};\n\nexport const parseXyzD50String = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = XYZ_D50_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const x = parseNum(g.x!);\n const y = parseNum(g.y!);\n const z = parseNum(g.z!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return xyzToRgbUnclamped({\n x,\n y,\n z,\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { LabColor, RgbColor, XyzColor } from '../types.js';\nimport { D50_WX as WX, D50_WY as WY, D50_WZ as WZ, rgbToXyz, xyzD50ToLinearSrgb, xyzToRgb } from './xyz.js';\n\n// D65 white point derived from CIE chromaticity (x=0.3127, y=0.329)\nconst D65_WX = (0.3127 / 0.329) * 100;\nconst D65_WY = 100;\nconst D65_WZ = ((1 - 0.3127 - 0.329) / 0.329) * 100;\n\nconst EPSILON = 216 / 24389;\nconst KAPPA = 24389 / 27;\n\nconst f = (t: number) => (t > EPSILON ? Math.cbrt(t) : (KAPPA * t + 16) / 116);\n\nexport const xyzToLab = ({ x, y, z, alpha }: XyzColor): LabColor => {\n const fy = f(y / WY);\n return {\n l: 116 * fy - 16,\n a: 500 * (f(x / WX) - fy) || 0, // || 0 suppresses −0; NaN is impossible since WX/WZ are non-zero constants\n b: 200 * (fy - f(z / WZ)) || 0,\n alpha: round(alpha, 3),\n colorSpace: 'lab' as const,\n };\n};\n\n/** Primitives-only Lab → XYZ D50. x/y/z in 0–100 scale. Shared with channels.ts hot paths. */\nexport const labToXyzValues = (l: number, a: number, b: number): [number, number, number] => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n return [\n (fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA) * WX,\n (l > 8 ? fy ** 3 : l / KAPPA) * WY,\n (fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA) * WZ,\n ];\n};\n\n/** Zero-allocation sibling of labToXyzValues — writes [x, y, z] into `out`. */\nexport const labToXyzValuesInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n out[0] = (fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA) * WX;\n out[1] = (l > 8 ? fy ** 3 : l / KAPPA) * WY;\n out[2] = (fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA) * WZ;\n};\n\nexport const labToXyz = ({ l, a, b, alpha }: LabColor): XyzColor => {\n const [x, y, z] = labToXyzValues(l, a, b);\n return { x, y, z, alpha };\n};\n\nexport const rgbToLab = (rgb: RgbColor): LabColor => xyzToLab(rgbToXyz(rgb));\n\n/** RGB → CIE Lab using D65 white point (screen-native; used for perceptual difference). */\nexport const rgbToLabD65 = ({ r, g, b, alpha }: RgbColor): LabColor => {\n const lr = srgbToLinear(r / 255),\n lg = srgbToLinear(g / 255),\n lb = srgbToLinear(b / 255);\n const x = 100 * (0.41239079926595951 * lr + 0.35758433938387796 * lg + 0.18048078840183429 * lb);\n const y = 100 * (0.21263900587151036 * lr + 0.71516867876775592 * lg + 0.072192315360733714 * lb);\n const z = 100 * (0.019330818715591849 * lr + 0.11919477979462599 * lg + 0.95053215224966059 * lb);\n const fy = f(y / D65_WY);\n return {\n l: 116 * fy - 16,\n a: 500 * (f(x / D65_WX) - fy) || 0,\n b: 200 * (fy - f(z / D65_WZ)) || 0,\n alpha: round(alpha, 3),\n colorSpace: 'lab' as const,\n };\n};\n\nexport const deltaE2000 = (lab1: LabColor, lab2: LabColor): number => {\n const { l: L1, a: a1, b: b1 } = lab1;\n const { l: L2, a: a2, b: b2 } = lab2;\n const rad = Math.PI / 180;\n const deg = 180 / Math.PI;\n\n const C1 = Math.sqrt(a1 ** 2 + b1 ** 2);\n const C2 = Math.sqrt(a2 ** 2 + b2 ** 2);\n const Cab = ((C1 + C2) / 2) ** 7;\n const G = 0.5 * (1 - Math.sqrt(Cab / (Cab + 25 ** 7)));\n const a1p = a1 * (1 + G);\n const a2p = a2 * (1 + G);\n const C1p = Math.sqrt(a1p ** 2 + b1 ** 2);\n const C2p = Math.sqrt(a2p ** 2 + b2 ** 2);\n const Cp = (C1p + C2p) / 2;\n\n const h1p = a1p === 0 && b1 === 0 ? 0 : Math.atan2(b1, a1p) * deg;\n const h2p = a2p === 0 && b2 === 0 ? 0 : Math.atan2(b2, a2p) * deg;\n const h1 = h1p < 0 ? h1p + 360 : h1p;\n const h2 = h2p < 0 ? h2p + 360 : h2p;\n\n let dhp = h2 - h1;\n const absDh = Math.abs(h2 - h1);\n if (absDh > 180 && h2 <= h1) dhp += 360;\n else if (absDh > 180 && h2 > h1) dhp -= 360;\n\n const Lm = (L1 + L2) / 2;\n let Hm = h1 + h2;\n if (absDh <= 180) Hm /= 2;\n else Hm = (h1 + h2 < 360 ? Hm + 360 : Hm - 360) / 2;\n\n const T =\n 1 -\n 0.17 * Math.cos(rad * (Hm - 30)) +\n 0.24 * Math.cos(2 * rad * Hm) +\n 0.32 * Math.cos(rad * (3 * Hm + 6)) -\n 0.2 * Math.cos(rad * (4 * Hm - 63));\n\n const dLp = L2 - L1;\n const dCp = C2p - C1p;\n const dHp = 2 * Math.sin((rad * dhp) / 2) * Math.sqrt(C1p * C2p);\n\n const SL = 1 + (0.015 * (Lm - 50) ** 2) / Math.sqrt(20 + (Lm - 50) ** 2);\n const SC = 1 + 0.045 * Cp;\n const SH = 1 + 0.015 * Cp * T;\n\n const RC7 = Cp ** 7;\n const RC = 2 * Math.sqrt(RC7 / (RC7 + 25 ** 7));\n const dTheta = 30 * Math.exp(-(((Hm - 275) / 25) ** 2));\n const RT = -RC * Math.sin(2 * rad * dTheta);\n\n return Math.sqrt((dLp / SL) ** 2 + (dCp / SC) ** 2 + (dHp / SH) ** 2 + RT * (dCp / SC) * (dHp / SH));\n};\n\nexport const labToRgb = (lab: LabColor): RgbColor => xyzToRgb(labToXyz(lab));\n\n/**\n * Unclamped Lab (D50) → gamma-encoded sRGB (0–255). Channels may exceed [0, 255] or go\n * negative for colors outside the sRGB gamut. Preserves out-of-gamut information so callers\n * (mapSrgb, inGamut*) can detect and map the color; sRGB output methods clamp at the edge.\n */\nexport const labToRgbUnclamped = ({ l, a, b, alpha }: LabColor): RgbColor => {\n const [x, y, z] = labToXyzValues(l, a, b);\n const [lr, lg, lb] = xyzD50ToLinearSrgb(x, y, z);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\n// CSS Color 4: lab(L a b / alpha). L: number|percentage|none (100% = 100).\n// a/b: number|percentage|none (100% = 125).\nconst LAB_RE = new RegExp(\n `^lab\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<a>${NUM_OR_NONE})(?<ap>%?)\\\\s+(?<b>${NUM_OR_NONE})(?<bp>%?)` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseLabString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = LAB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const l = parseNum(g.l!); // 100% = 100, so value is unchanged whether `%` present\n const a = g.ap ? parseNum(g.a!) * 1.25 : parseNum(g.a!);\n const b = g.bp ? parseNum(g.b!) * 1.25 : parseNum(g.b!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return labToRgbUnclamped({\n l: clamp(l, 0, 100),\n a,\n b,\n alpha: clamp(alpha, 0, 1),\n colorSpace: 'lab',\n });\n};\n\nexport const parseLabObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if ((input as { colorSpace?: unknown }).colorSpace !== 'lab') return null;\n if (!hasKeys(input, ['l', 'a', 'b'])) return null;\n const { l, a, b, alpha = 1 } = input as { l: unknown; a: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(a) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n return labToRgbUnclamped({\n l: clamp(sanitize(l), 0, 100),\n a: sanitize(a),\n b: sanitize(b),\n alpha: clamp(sanitize(alpha), 0, 1),\n colorSpace: 'lab',\n });\n};\n"]} |
| import {a,b,h,i,f,g,l,k}from'./chunk-IOXRZECH.mjs';var $=s=>({r:a(s.r,0,255),g:a(s.g,0,255),b:a(s.b,0,255),alpha:a(b(s.alpha,3),0,1)}),x=s=>{if(!h(s))return null;let n=s.colorSpace;if(n==="display-p3"||n==="rec2020"||!i(s,["r","g","b"]))return null;let{r:e,g:t,b:c,alpha:l=1}=s;return !f(e)||!f(t)||!f(c)||!f(l)?null:$({r:g(e),g:g(t),b:g(c),alpha:g(l)})},y=new RegExp(`^rgba?\\(\\s*(?<r>${k})(?<rp>%?)\\s*(?:,\\s*(?<g_c>${k})(?<gp_c>%?)\\s*,\\s*(?<b_c>${k})(?<bp_c>%?)(?:\\s*,\\s*(?<al_c>${k})(?<alp_c>%?))?\\s*|\\s+(?<g_s>${k})(?<gp_s>%?)\\s+(?<b_s>${k})(?<bp_s>%?)(?:\\s*/\\s*(?<al_s>${k})(?<alp_s>%?))?\\s*)\\)$`,"i"),N=s=>{if(typeof s!="string")return null;let n=y.exec(s.trim())?.groups;if(!n)return null;let e=n.g_c!==void 0,t=n.g_c??n.g_s,c=n.b_c??n.b_s,l$1=!!n.rp,_=!!(n.gp_c??n.gp_s),b=!!(n.bp_c??n.bp_s),m=l$1?l(n.r)/100*255:l(n.r),w=_?l(t)/100*255:l(t),d=b?l(c)/100*255:l(c);if(e&&(l$1!==_||_!==b||/^none$/i.test(n.r)||/^none$/i.test(t)||/^none$/i.test(c)))return null;let g=n.al_c??n.al_s,h=!!(n.alp_c??n.alp_s);if(e&&g!==void 0&&/^none$/i.test(g))return null;let k=g===void 0?1:l(g)/(h?100:1);return $({r:m,g:w,b:d,alpha:k})};export{$ as a,x as b,N as c};//# sourceMappingURL=chunk-Q3O3QQ4H.mjs.map | ||
| //# sourceMappingURL=chunk-Q3O3QQ4H.mjs.map |
| {"version":3,"sources":["../src/colorModels/rgb.ts"],"names":["clampRgb","rgb","clamp","round","parseRgbObject","input","isObject","cs","hasKeys","r","g","b","alpha","isAnyNumber","sanitize","RGB_RE","NUM_OR_NONE","parseRgbString","isComma","gRaw","bRaw","rPct","gPct","bPct","parseNum","gc","rawA","aPct"],"mappings":"mDAGO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,EAAMD,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,CAAA,CAAGC,CAAAA,CAAMD,CAAAA,CAAI,EAAG,CAAA,CAAG,GAAG,CAAA,CACtB,CAAA,CAAGC,CAAAA,CAAMD,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,KAAA,CAAOC,CAAAA,CAAMC,CAAAA,CAAMF,EAAI,KAAA,CAAO,CAAC,CAAA,CAAG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A,CAAA,CAC7B,GAAIQ,CAAAA,EAAWQ,CAAAA,GAAS,QAAa,SAAA,CAAU,IAAA,CAAKA,CAAI,CAAA,CAAG,OAAO,IAAA,CAClE,IAAMd,CAAAA,CAAQc,CAAAA,GAAS,OAAY,CAAA,CAAIF,CAAAA,CAASE,CAAI,CAAA,EAAKC,CAAAA,CAAO,GAAA,CAAM,CAAA,CAAA,CAEtE,OAAO3B,EAAS,CAAE,CAAA,CAAAS,CAAAA,CAAG,CAAA,CAAGgB,EAAI,CAAA,CAAAd,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAC,CACxC","file":"chunk-Q3O3QQ4H.mjs","sourcesContent":["import { NUM_OR_NONE, clamp, hasKeys, isAnyNumber, isObject, parseNum, round, sanitize } from '../helpers.js';\nimport type { RgbColor } from '../types.js';\n\nexport const clampRgb = (rgb: RgbColor): RgbColor => ({\n r: clamp(rgb.r, 0, 255),\n g: clamp(rgb.g, 0, 255),\n b: clamp(rgb.b, 0, 255),\n alpha: clamp(round(rgb.alpha, 3), 0, 1),\n});\n\nexport const parseRgbObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n const cs = (input as { colorSpace?: unknown }).colorSpace;\n if (cs === 'display-p3' || cs === 'rec2020') return null;\n if (!hasKeys(input, ['r', 'g', 'b'])) return null;\n const { r, g, b, alpha = 1 } = input as { r: unknown; g: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(r) || !isAnyNumber(g) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n return clampRgb({ r: sanitize(r), g: sanitize(g), b: sanitize(b), alpha: sanitize(alpha) });\n};\n\n// Matches both legacy comma syntax: rgb(255, 0, 0) / rgba(255, 0, 0, 0.5)\n// and modern space syntax: rgb(255 0 0) / rgb(255 0 0 / 0.5).\n// Supports percentage-based channels and the CSS Color 4 `none` keyword.\n// Named groups are suffixed `_c` (comma/legacy branch) or `_s` (space/modern branch)\n// because ES2022 regex requires distinct names across alternation branches.\nconst RGB_RE = new RegExp(\n `^rgba?\\\\(\\\\s*(?<r>${NUM_OR_NONE})(?<rp>%?)\\\\s*(?:` +\n `,\\\\s*(?<g_c>${NUM_OR_NONE})(?<gp_c>%?)\\\\s*,\\\\s*(?<b_c>${NUM_OR_NONE})(?<bp_c>%?)` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM_OR_NONE})(?<alp_c>%?))?\\\\s*` +\n `|` +\n `\\\\s+(?<g_s>${NUM_OR_NONE})(?<gp_s>%?)\\\\s+(?<b_s>${NUM_OR_NONE})(?<bp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?))?\\\\s*` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseRgbString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = RGB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n\n const isComma = g.g_c !== undefined;\n const gRaw = g.g_c ?? g.g_s!;\n const bRaw = g.b_c ?? g.b_s!;\n const rPct = !!g.rp;\n const gPct = !!(g.gp_c ?? g.gp_s);\n const bPct = !!(g.bp_c ?? g.bp_s);\n\n const r = rPct ? (parseNum(g.r!) / 100) * 255 : parseNum(g.r!);\n const gc = gPct ? (parseNum(gRaw) / 100) * 255 : parseNum(gRaw);\n const b = bPct ? (parseNum(bRaw) / 100) * 255 : parseNum(bRaw);\n\n // Legacy: channels must match type, no `none`. Modern: mixing + `none` allowed.\n if (isComma) {\n if (rPct !== gPct || gPct !== bPct) return null;\n if (/^none$/i.test(g.r!) || /^none$/i.test(gRaw) || /^none$/i.test(bRaw)) return null;\n }\n\n const rawA = g.al_c ?? g.al_s;\n const aPct = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (aPct ? 100 : 1);\n\n return clampRgb({ r, g: gc, b, alpha });\n};\n"]} |
| 'use strict';var chunkINDSIUQQ_cjs=require('./chunk-INDSIUQQ.cjs'),chunk3V4MONNR_cjs=require('./chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var U=.4122214708,z=.5363325363,q=.0514459929,D=.2119034982,H=.6806995451,J=.1073969566,P=.0883024619,Q=.2817188376,V=.6299787005,W=.2104542553,X=.793617785,Y=-0.0040720468,Z=1.9779984951,nn=-2.428592205,on=.4505937099,rn=.0259040371,tn=.7827717662,sn=-0.808675766,I=.3963377774,S=.2158037573,O=-0.1055613458,B=-0.0638541728,h=-0.0894841775,x=-1.291485548,A=4.0767416613,C=-3.3077115904,w=.2309699287,T=-1.2684380041,y=2.6097574007,G=-0.3413193963,d=-0.0041960865,N=-0.7034186145,$=1.7076147009;var cn=(o,n,r)=>{let t=Math.cbrt(U*o+z*n+q*r),s=Math.cbrt(D*o+H*n+J*r),c=Math.cbrt(P*o+Q*n+V*r);return [W*t+X*s+Y*c,Z*t+nn*s+on*c,rn*t+tn*s+sn*c]},Mn=({r:o,g:n,b:r,alpha:t})=>{let[s,c,e]=cn(chunkINDSIUQQ_cjs.a(o/255),chunkINDSIUQQ_cjs.a(n/255),chunkINDSIUQQ_cjs.a(r/255));return {l:s,a:c,b:e,alpha:t}},j=({l:o,a:n,b:r,alpha:t})=>{let[s,c,e]=en(o,n,r);return {r:chunkINDSIUQQ_cjs.b(s)*255,g:chunkINDSIUQQ_cjs.b(c)*255,b:chunkINDSIUQQ_cjs.b(e)*255,alpha:t}},un=({l:o,a:n,b:r,alpha:t})=>{if(n===0&&r===0){let K=o**3,k=chunkINDSIUQQ_cjs.b(chunkYISEJCI6_cjs.a(K,0,1))*255;return chunk3V4MONNR_cjs.a({r:k,g:k,b:k,alpha:t})}let s=o+.3963377774*n+.2158037573*r,c=o-.1055613458*n-.0638541728*r,e=o-.0894841775*n-1.291485548*r,_=s**3,l=c**3,b=e**3,p=4.0767416613*_-3.3077115904*l+.2309699287*b,E=-1.2684380041*_+2.6097574007*l-.3413193963*b,F=-0.0041960865*_-.7034186145*l+1.7076147009*b;return chunk3V4MONNR_cjs.a({r:chunkINDSIUQQ_cjs.b(chunkYISEJCI6_cjs.a(p,0,1))*255,g:chunkINDSIUQQ_cjs.b(chunkYISEJCI6_cjs.a(E,0,1))*255,b:chunkINDSIUQQ_cjs.b(chunkYISEJCI6_cjs.a(F,0,1))*255,alpha:t})},mn=(o,n,r,t)=>{if(r===0&&t===0){let p=n**3;o[0]=p,o[1]=p,o[2]=p;return}let s=n+I*r+S*t,c=n+O*r+B*t,e=n+h*r+x*t,_=s**3,l=c**3,b=e**3;o[0]=A*_+C*l+w*b,o[1]=T*_+y*l+G*b,o[2]=d*_+N*l+$*b;},en=(o,n,r)=>{if(n===0&&r===0){let b=o**3;return [b,b,b]}let t=o+I*n+S*r,s=o+O*n+B*r,c=o+h*n+x*r,e=t**3,_=s**3,l=c**3;return [A*e+C*_+w*l,T*e+y*_+G*l,d*e+N*_+$*l]},pn=o=>{if(!chunkYISEJCI6_cjs.h(o)||o.colorSpace==="lab"||!chunkYISEJCI6_cjs.i(o,["l","a","b"])||"r"in o||"x"in o||"c"in o||"h"in o)return null;let{l:n,a:r,b:t,alpha:s=1}=o;return !chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(s)||chunkYISEJCI6_cjs.g(n)>1?null:j({l:chunkYISEJCI6_cjs.g(n),a:chunkYISEJCI6_cjs.g(r),b:chunkYISEJCI6_cjs.g(t),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(s),0,1)})},_n=new RegExp(`^oklab\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<a>${chunkYISEJCI6_cjs.k})(?<ap>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),vn=o=>{if(typeof o!="string")return null;let n=_n.exec(o.trim())?.groups;if(!n)return null;let r=n.lp?chunkYISEJCI6_cjs.l(n.l)/100:chunkYISEJCI6_cjs.l(n.l),t=n.ap?chunkYISEJCI6_cjs.l(n.a)*.004:chunkYISEJCI6_cjs.l(n.a),s=n.bp?chunkYISEJCI6_cjs.l(n.b)*.004:chunkYISEJCI6_cjs.l(n.b),c=n.al===void 0?1:chunkYISEJCI6_cjs.l(n.al)/(n.alp?100:1);return j({l:r,a:t,b:s,alpha:chunkYISEJCI6_cjs.a(c,0,1)})};exports.a=cn;exports.b=Mn;exports.c=j;exports.d=un;exports.e=mn;exports.f=en;exports.g=pn;exports.h=vn;//# sourceMappingURL=chunk-TRRLWCL6.cjs.map | ||
| //# sourceMappingURL=chunk-TRRLWCL6.cjs.map |
| {"version":3,"sources":["../src/colorModels/oklab.ts"],"names":["M1_LR","M1_LG","M1_LB","M1_MR","M1_MG","M1_MB","M1_SR","M1_SG","M1_SB","M2_L_L","M2_M_L","M2_S_L","M2_L_A","M2_M_A","M2_S_A","M2_L_B","M2_M_B","M2_S_B","M2I_A_L","M2I_B_L","M2I_A_M","M2I_B_M","M2I_A_S","M2I_B_S","M1I_L_R","M1I_M_R","M1I_S_R","M1I_L_G","M1I_M_G","M1I_S_G","M1I_L_B","M1I_M_B","M1I_S_B","linearSrgbToOklab","lr","lg","lb","lv","mv","sv","rgbToOklab","r","g","b","alpha","l","a","bv","srgbToLinear","oklabToRgbUnclamped","oklabToLinear","srgbFromLinear","oklabToRgb","v","srgb","clamp","clampRgb","l_","m_","s_","oklabToLinearInto","out","parseOklabObject","input","isObject","hasKeys","isAnyNumber","sanitize","OKLAB_RE","NUM_OR_NONE","parseOklabString","L","parseNum"],"mappings":"uKAQA,IAAMA,EAAQ,WAAA,CACZC,CAAAA,CAAQ,WAAA,CACRC,CAAAA,CAAQ,YACJC,CAAAA,CAAQ,WAAA,CACZC,CAAAA,CAAQ,WAAA,CACRC,EAAQ,WAAA,CACJC,CAAAA,CAAQ,Y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helpers.js';\nimport { srgbFromLinear, srgbToLinear } from '../transfer.js';\nimport type { OklabColor, RgbColor } from '../types.js';\nimport { clampRgb } from './rgb.js';\n\n// Björn Ottosson's OKLab matrix coefficients. Referenced by both the allocating\n// and zero-alloc (*Into) variants so the math lives in one place.\n// sRGB linear → LMS (cubed roots taken at M1 stage)\nconst M1_LR = 0.4122214708,\n M1_LG = 0.5363325363,\n M1_LB = 0.0514459929;\nconst M1_MR = 0.2119034982,\n M1_MG = 0.6806995451,\n M1_MB = 0.1073969566;\nconst M1_SR = 0.0883024619,\n M1_SG = 0.2817188376,\n M1_SB = 0.6299787005;\n// LMS' → OKLab\nconst M2_L_L = 0.2104542553,\n M2_M_L = 0.793617785,\n M2_S_L = -0.0040720468;\nconst M2_L_A = 1.9779984951,\n M2_M_A = -2.428592205,\n M2_S_A = 0.4505937099;\nconst M2_L_B = 0.0259040371,\n M2_M_B = 0.7827717662,\n M2_S_B = -0.808675766;\n// OKLab → LMS' (inverse of M2)\nconst M2I_A_L = 0.3963377774,\n M2I_B_L = 0.2158037573;\nconst M2I_A_M = -0.1055613458,\n M2I_B_M = -0.0638541728;\nconst M2I_A_S = -0.0894841775,\n M2I_B_S = -1.291485548;\n// LMS → linear sRGB (inverse of M1)\nconst M1I_L_R = 4.0767416613,\n M1I_M_R = -3.3077115904,\n M1I_S_R = 0.2309699287;\nconst M1I_L_G = -1.2684380041,\n M1I_M_G = 2.6097574007,\n M1I_S_G = -0.3413193963;\nconst M1I_L_B = -0.0041960865,\n M1I_M_B = -0.7034186145,\n M1I_S_B = 1.7076147009;\n\n/** Zero-allocation sibling of linearSrgbToOklab — writes [l, a, b] into `out`. */\nexport const linearSrgbToOklabInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n const lv = Math.cbrt(M1_LR * lr + M1_LG * lg + M1_LB * lb);\n const mv = Math.cbrt(M1_MR * lr + M1_MG * lg + M1_MB * lb);\n const sv = Math.cbrt(M1_SR * lr + M1_SG * lg + M1_SB * lb);\n out[0] = M2_L_L * lv + M2_M_L * mv + M2_S_L * sv;\n out[1] = M2_L_A * lv + M2_M_A * mv + M2_S_A * sv;\n out[2] = M2_L_B * lv + M2_M_B * mv + M2_S_B * sv;\n};\n\n/** Convert linear sRGB channels to OKLab (Björn Ottosson). No gamma, no clamping. */\nexport const linearSrgbToOklab = (lr: number, lg: number, lb: number): [number, number, number] => {\n const lv = Math.cbrt(M1_LR * lr + M1_LG * lg + M1_LB * lb);\n const mv = Math.cbrt(M1_MR * lr + M1_MG * lg + M1_MB * lb);\n const sv = Math.cbrt(M1_SR * lr + M1_SG * lg + M1_SB * lb);\n return [\n M2_L_L * lv + M2_M_L * mv + M2_S_L * sv,\n M2_L_A * lv + M2_M_A * mv + M2_S_A * sv,\n M2_L_B * lv + M2_M_B * mv + M2_S_B * sv,\n ];\n};\n\nexport const rgbToOklab = ({ r, g, b, alpha }: RgbColor): OklabColor => {\n const [l, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n return { l, a, b: bv, alpha };\n};\n\n/** Unclamped OKLab → gamma-encoded sRGB. Channels may exceed [0, 255] for out-of-sRGB-gamut colors. */\nexport const oklabToRgbUnclamped = ({ l, a, b, alpha }: OklabColor): RgbColor => {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return {\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n };\n};\n\nexport const oklabToRgb = ({ l, a, b, alpha }: OklabColor): RgbColor => {\n if (a === 0 && b === 0) {\n const v = l ** 3;\n const srgb = srgbFromLinear(clamp(v, 0, 1)) * 255;\n return clampRgb({ r: srgb, g: srgb, b: srgb, alpha });\n }\n\n const l_ = l + 0.3963377774 * a + 0.2158037573 * b;\n const m_ = l - 0.1055613458 * a - 0.0638541728 * b;\n const s_ = l - 0.0894841775 * a - 1.291485548 * b;\n\n const lv = l_ ** 3;\n const mv = m_ ** 3;\n const sv = s_ ** 3;\n\n const r = 4.0767416613 * lv - 3.3077115904 * mv + 0.2309699287 * sv;\n const g = -1.2684380041 * lv + 2.6097574007 * mv - 0.3413193963 * sv;\n const bv = -0.0041960865 * lv - 0.7034186145 * mv + 1.7076147009 * sv;\n\n return clampRgb({\n r: srgbFromLinear(clamp(r, 0, 1)) * 255,\n g: srgbFromLinear(clamp(g, 0, 1)) * 255,\n b: srgbFromLinear(clamp(bv, 0, 1)) * 255,\n alpha,\n });\n};\n\n/** Zero-allocation sibling of oklabToLinear — writes [lr, lg, lb] into `out`. */\nexport const oklabToLinearInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n // Achromatic short-circuit: M1⁻¹ rows sum to 1 mathematically, but floating-point\n // rounding leaves lr/lg/lb ~1 ULP apart, which gets amplified into a phantom hue\n // downstream in rgbToHslRaw. Explicitly return lv for all channels.\n if (a === 0 && b === 0) {\n const v = l ** 3;\n out[0] = v;\n out[1] = v;\n out[2] = v;\n return;\n }\n const l_ = l + M2I_A_L * a + M2I_B_L * b;\n const m_ = l + M2I_A_M * a + M2I_B_M * b;\n const s_ = l + M2I_A_S * a + M2I_B_S * b;\n const lv = l_ ** 3,\n mv = m_ ** 3,\n sv = s_ ** 3;\n out[0] = M1I_L_R * lv + M1I_M_R * mv + M1I_S_R * sv;\n out[1] = M1I_L_G * lv + M1I_M_G * mv + M1I_S_G * sv;\n out[2] = M1I_L_B * lv + M1I_M_B * mv + M1I_S_B * sv;\n};\n\n/** Unclamped linear sRGB channels from OKLab values. Channels may exceed [0, 1] for out-of-gamut colors. */\nexport const oklabToLinear = (l: number, a: number, b: number): [number, number, number] => {\n if (a === 0 && b === 0) {\n const v = l ** 3;\n return [v, v, v];\n }\n const l_ = l + M2I_A_L * a + M2I_B_L * b;\n const m_ = l + M2I_A_M * a + M2I_B_M * b;\n const s_ = l + M2I_A_S * a + M2I_B_S * b;\n const lv = l_ ** 3,\n mv = m_ ** 3,\n sv = s_ ** 3;\n return [\n M1I_L_R * lv + M1I_M_R * mv + M1I_S_R * sv,\n M1I_L_G * lv + M1I_M_G * mv + M1I_S_G * sv,\n M1I_L_B * lv + M1I_M_B * mv + M1I_S_B * sv,\n ];\n};\n\nexport const parseOklabObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lab' are CIE Lab, not OKLab — let parseLabObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lab') return null;\n if (!hasKeys(input, ['l', 'a', 'b'])) return null;\n if ('r' in input || 'x' in input || 'c' in input || 'h' in input) return null;\n const { l, a, b, alpha = 1 } = input as { l: unknown; a: unknown; b: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(a) || !isAnyNumber(b) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLab L is always [0, 1]; reject CIE Lab values passed without colorSpace branding\n return oklabToRgbUnclamped({\n l: sanitize(l),\n a: sanitize(a),\n b: sanitize(b),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLAB_RE = new RegExp(\n `^oklab\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<a>${NUM_OR_NONE})(?<ap>%?)\\\\s+(?<b>${NUM_OR_NONE})(?<bp>%?)` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklabString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLAB_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const a = g.ap ? parseNum(g.a!) * 0.004 : parseNum(g.a!); // 100% = 0.4\n const b = g.bp ? parseNum(g.b!) * 0.004 : parseNum(g.b!);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklabToRgbUnclamped({ l: L, a, b, alpha: clamp(alpha, 0, 1) });\n};\n"]} |
| var s=r=>{let n=Math.abs(r),e=n<=.04045?n/12.92:((n+.055)/1.055)**2.4;return r<0?-e:e},a=r=>{let n=Math.abs(r),e=n<=.0031308?12.92*n:1.055*n**(1/2.4)-.055;return r<0?-e:e},t=1.09929682680944,o=.018053968510807,b=r=>{let n=Math.abs(r),e=n<o*4.5?n/4.5:((n+t-1)/t)**(1/.45);return r<0?-e:e},c=r=>{let n=Math.abs(r),e=n<o?4.5*n:t*n**.45-(t-1);return r<0?-e:e};export{s as a,a as b,b as c,c as d};//# sourceMappingURL=chunk-YLJRINFM.mjs.map | ||
| //# sourceMappingURL=chunk-YLJRINFM.mjs.map |
| {"version":3,"sources":["../src/transfer.ts"],"names":["srgbToLinear","c","abs","linear","srgbFromLinear","n","encoded","REC2020_ALPHA","REC2020_BETA","rec2020ToLinear","rec2020FromLinear"],"mappings":"AAMO,IAAMA,CAAAA,CAAgBC,GAAsB,CACjD,IAAMC,EAAM,IAAA,CAAK,GAAA,CAAID,CAAC,CAAA,CAChBE,CAAAA,CAASD,CAAAA,EAAO,OAAUA,CAAAA,CAAM,KAAA,CAAA,CAAA,CAAUA,CAAAA,CAAM,IAAA,EAAS,KAAA,GAAU,GAAA,CACzE,OAAOD,CAAAA,CAAI,CAAA,CAAI,CAACE,CAAAA,CAASA,CAC3B,CAAA,CAQaC,EAAkBC,CAAAA,EAAsB,CACnD,IAAMH,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAIG,CAAC,CAAA,CAChBC,CAAAA,CAAUJ,CAAAA,EAAO,QAAA,CAAY,KAAA,CAAQA,CAAAA,CAAM,MAAQA,CAAAA,GAAQ,CAAA,CAAI,GAAA,CAAA,CAAO,IAAA,CAC5E,OAAOG,CAAAA,CAAI,EAAI,CAACC,CAAAA,CAAUA,CAC5B,CAAA,CAGMC,CAAAA,CAAgB,gBAAA,CAChBC,EAAe,gBAAA,CAGRC,CAAAA,CAAmBR,CAAAA,EAAsB,CACpD,IAAMC,CAAAA,CAAM,KAAK,GAAA,CAAID,CAAC,CAAA,CAChBE,CAAAA,CAASD,CAAAA,CAAMM,CAAAA,CAAe,IAAMN,CAAAA,CAAM,GAAA,CAAA,CAAA,CAAQA,CAAAA,CAAMK,CAAAA,CAAgB,CAAA,EAAKA,CAAAA,IAAmB,EAAI,GAAA,CAAA,CAC1G,OAAON,CAAAA,CAAI,CAAA,CAAI,CAACE,CAAAA,CAASA,CAC3B,CAAA,CAGaO,CAAAA,CAAqBL,CAAAA,EAAsB,CACtD,IAAMH,CAAAA,CAAM,KAAK,GAAA,CAAIG,CAAC,CAAA,CAChBC,CAAAA,CAAUJ,CAAAA,CAAMM,CAAAA,CAAe,IAAMN,CAAAA,CAAMK,CAAAA,CAAgBL,CAAAA,EAAO,GAAA,EAAQK,CAAAA,CAAgB,CAAA,CAAA,CAChG,OAAOF,CAAAA,CAAI,CAAA,CAAI,CAACC,CAAAA,CAAUA,CAC5B","file":"chunk-YLJRINFM.mjs","sourcesContent":["/**\n * sRGB / Display-P3 transfer function (IEC 61966-2-1), extended to the full real line.\n * For in-gamut values [0, 1] this is the standard curve.\n * Extended to negative values using the mirror of the power curve (not the linear piece),\n * matching the CSS Color 4 spec for out-of-gamut channels.\n */\nexport const srgbToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs <= 0.04045 ? abs / 12.92 : ((abs + 0.055) / 1.055) ** 2.4;\n return c < 0 ? -linear : linear;\n};\n\n/**\n * Linear → gamma-encoded sRGB (extended piecewise, per CSS Color 4).\n * For in-gamut values [0, 1] this is the standard IEC 61966-2-1 curve.\n * Extended to negative values using the mirror of the power curve (not the linear piece),\n * matching the CSS Color 4 spec and display-p3 behaviour for out-of-gamut channels.\n */\nexport const srgbFromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs <= 0.0031308 ? 12.92 * abs : 1.055 * abs ** (1 / 2.4) - 0.055;\n return n < 0 ? -encoded : encoded;\n};\n\n/** BT.2020 transfer function constants. */\nconst REC2020_ALPHA = 1.09929682680944;\nconst REC2020_BETA = 0.018053968510807;\n\n/** BT.2020 gamma-encoded → linear. Extended to the full real line (sign-preserving). */\nexport const rec2020ToLinear = (c: number): number => {\n const abs = Math.abs(c);\n const linear = abs < REC2020_BETA * 4.5 ? abs / 4.5 : ((abs + REC2020_ALPHA - 1) / REC2020_ALPHA) ** (1 / 0.45);\n return c < 0 ? -linear : linear;\n};\n\n/** BT.2020 linear → gamma-encoded. Extended to the full real line (sign-preserving). */\nexport const rec2020FromLinear = (n: number): number => {\n const abs = Math.abs(n);\n const encoded = abs < REC2020_BETA ? 4.5 * abs : REC2020_ALPHA * abs ** 0.45 - (REC2020_ALPHA - 1);\n return n < 0 ? -encoded : encoded;\n};\n"]} |
| 'use strict';var chunkTRRLWCL6_cjs=require('./chunk-TRRLWCL6.cjs'),chunkPI5KJ3ZM_cjs=require('./chunk-PI5KJ3ZM.cjs'),chunkINDSIUQQ_cjs=require('./chunk-INDSIUQQ.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var er=.8224619687,or=.1775380313,br=.0331941989,tr=.9668058011,ar=.0170826307,ur=.0723974407,mr=.9105199286,Fr=1.2249401762805598,vr=-0.22494017628055996,Br=-0.04205695470968816,Er=1.042056954709688,$r=-0.019637554590334432,Dr=-0.07863604555063189,Or=1.0982736001409663,Rn=(e,r,n,o)=>{e[0]=er*r+or*n,e[1]=br*r+tr*n,e[2]=ar*r+ur*n+mr*o;},sr=(e,r,n)=>[er*e+or*r,br*e+tr*r,ar*e+ur*r+mr*n];var z=(e,r,n)=>[Fr*e+vr*r,Br*e+Er*r,$r*e+Dr*r+Or*n],fn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=sr(chunkINDSIUQQ_cjs.a(e/255),chunkINDSIUQQ_cjs.a(r/255),chunkINDSIUQQ_cjs.a(n/255));return {r:chunkINDSIUQQ_cjs.b(b),g:chunkINDSIUQQ_cjs.b(t),b:chunkINDSIUQQ_cjs.b(u),alpha:o,colorSpace:"display-p3"}};var lr=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=z(chunkINDSIUQQ_cjs.a(e),chunkINDSIUQQ_cjs.a(r),chunkINDSIUQQ_cjs.a(n));return {r:chunkINDSIUQQ_cjs.b(b)*255,g:chunkINDSIUQQ_cjs.b(t)*255,b:chunkINDSIUQQ_cjs.b(u)*255,alpha:o}},yn=e=>{if(!chunkYISEJCI6_cjs.h(e)||e.colorSpace!=="display-p3"||!chunkYISEJCI6_cjs.i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(b)?null:lr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(o),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},jr=new RegExp(`^color\\(\\s*display-p3\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Sn=e=>{if(typeof e!="string")return null;let r=jr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),o=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return lr({r:n,g:o,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},xn=(e,r,n)=>sr(...chunkTRRLWCL6_cjs.f(e,r,n));var cr=.6274038959,pr=.3292830384,ir=.0433130657,dr=.0690972894,hr=.9195403951,gr=.0113623156,Rr=.0163914389,fr=.0880133079,yr=.8955952532,Xr=1.6604910021084345,Ur=-0.5876411387885495,Kr=-0.07284986331988488,qr=-0.12455047452159074,Hr=1.1328998971259603,Vr=-0.008349422604369477,Yr=-0.018150763354905303,Zr=-0.10057889800800739,Jr=1.1187296613629127,_n=(e,r,n,o)=>{e[0]=cr*r+pr*n+ir*o,e[1]=dr*r+hr*n+gr*o,e[2]=Rr*r+fr*n+yr*o;},Sr=(e,r,n)=>[cr*e+pr*r+ir*n,dr*e+hr*r+gr*n,Rr*e+fr*r+yr*n];var F=(e,r,n)=>[Xr*e+Ur*r+Kr*n,qr*e+Hr*r+Vr*n,Yr*e+Zr*r+Jr*n],kn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=Sr(chunkINDSIUQQ_cjs.a(e/255),chunkINDSIUQQ_cjs.a(r/255),chunkINDSIUQQ_cjs.a(n/255));return {r:chunkINDSIUQQ_cjs.d(b),g:chunkINDSIUQQ_cjs.d(t),b:chunkINDSIUQQ_cjs.d(u),alpha:o,colorSpace:"rec2020"}};var xr=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=F(chunkINDSIUQQ_cjs.c(e),chunkINDSIUQQ_cjs.c(r),chunkINDSIUQQ_cjs.c(n));return {r:chunkINDSIUQQ_cjs.b(b)*255,g:chunkINDSIUQQ_cjs.b(t)*255,b:chunkINDSIUQQ_cjs.b(u)*255,alpha:o}},Mn=e=>{if(!chunkYISEJCI6_cjs.h(e)||e.colorSpace!=="rec2020"||!chunkYISEJCI6_cjs.i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(b)?null:xr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(o),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},Qr=new RegExp(`^color\\(\\s*rec2020\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Pn=e=>{if(typeof e!="string")return null;let r=Qr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),o=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return xr({r:n,g:o,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},An=(e,r,n)=>Sr(...chunkTRRLWCL6_cjs.f(e,r,n));var Wr=/^oklch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^oklab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nn=/^lab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,en=/^lch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,on=/^color\(\s*display-p3\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bn=/^color\(\s*rec2020\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tn=/^color\(\s*xyz-d50\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^color\(\s*xyz-d65\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,A=(e,r,n)=>{let{x:o,y:b,z:t}=chunkPI5KJ3ZM_cjs.l({l:e,a:r,b:n,alpha:1,colorSpace:"lab"}),[u,s,l]=chunkPI5KJ3ZM_cjs.e(o,b,t);return chunkTRRLWCL6_cjs.a(u,s,l)},Tr=(e,r,n)=>{let[o,b,t]=z(chunkINDSIUQQ_cjs.a(e),chunkINDSIUQQ_cjs.a(r),chunkINDSIUQQ_cjs.a(n));return chunkTRRLWCL6_cjs.a(o,b,t)},Cr=(e,r,n)=>{let[o,b,t]=F(chunkINDSIUQQ_cjs.c(e),chunkINDSIUQQ_cjs.c(r),chunkINDSIUQQ_cjs.c(n));return chunkTRRLWCL6_cjs.a(o,b,t)},Lr=(e,r,n)=>{let[o,b,t]=chunkPI5KJ3ZM_cjs.e(e,r,n);return chunkTRRLWCL6_cjs.a(o,b,t)},Nr=(e,r,n)=>{let[o,b,t]=chunkPI5KJ3ZM_cjs.b(e,r,n);return chunkTRRLWCL6_cjs.a(o,b,t)},G=e=>{if(typeof e=="object"&&e!==null){let r=e;if("l"in r&&"a"in r&&"b"in r&&r.colorSpace!=="lab"&&!("c"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.a=="number"&&typeof n.b=="number"&&typeof n.alpha=="number")return {l:n.l,a:n.a,b:n.b,alpha:n.alpha}}if("l"in r&&"c"in r&&"h"in r&&r.colorSpace!=="lch"&&!("a"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.c=="number"&&typeof n.h=="number"){let o=n.h*Math.PI/180;return {l:n.l,a:n.c*Math.cos(o),b:n.c*Math.sin(o),alpha:n.alpha}}}if(r.colorSpace==="lab"){let n=e;if(typeof n.l!="number"||typeof n.a!="number"||typeof n.b!="number")return null;let[o,b,t]=A(n.l,n.a,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="lch"){let n=e;if(typeof n.l!="number"||typeof n.c!="number"||typeof n.h!="number")return null;let o=n.h*Math.PI/180,[b,t,u]=A(n.l,n.c*Math.cos(o),n.c*Math.sin(o));return {l:b,a:t,b:u,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="display-p3"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Tr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="rec2020"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Cr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="xyz-d65"){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Nr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if("x"in r&&"y"in r&&"z"in r){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Lr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}return null}if(typeof e=="string"){let r=Wr.exec(e);if(r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(chunkYISEJCI6_cjs.d[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o*Math.cos(u),b:o*Math.sin(u),alpha:s}}if(r=rn.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?Number(r[5])*.004:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o,b,alpha:t}}if(r=nn.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.25:Number(r[3]),b=r[6]?Number(r[5])*1.25:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=A(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=en.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.5:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(chunkYISEJCI6_cjs.d[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[l,x,T]=A(n,o*Math.cos(u),o*Math.sin(u));return {l,a:x,b:T,alpha:s}}if(r=on.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Tr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=bn.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Cr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=tn.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Lr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=an.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Nr(n,o,b);return {l:u,a:s,b:l,alpha:t}}return null}return null},S=5e-4,Pr=(e,r,n)=>e>=-S&&e<=1+S&&r>=-S&&r<=1+S&&n>=-S&&n<=1+S,_r=(e,r,n)=>e>=0&&e<=1&&r>=0&&r<=1&&n>=0&&n<=1,$n=e=>{let r=G(e);if(r===null)return true;let[n,o,b]=chunkTRRLWCL6_cjs.f(r.l,r.a,r.b);return Pr(n,o,b)},kr=.02,un=1e-4,Mr=(e,r)=>{let n=e[0]-r[0],o=e[1]-r[1],b=e[2]-r[2];return Math.sqrt(n*n+o*o+b*b)},Ar=(e,r,n,o,b)=>{if(e>=1)return [1,1,1];if(e<=0)return [0,0,0];let[t,u,s]=o(e,r,n);if(_r(t,u,s))return [t,u,s];let l=chunkYISEJCI6_cjs.a(t,0,1),x=chunkYISEJCI6_cjs.a(u,0,1),T=chunkYISEJCI6_cjs.a(s,0,1);if(Mr(b(l,x,T),[e,r,n])<=kr)return [l,x,T];let E=Math.atan2(n,r),wr=Math.sqrt(r*r+n*n),N=0,I=wr,$=true,D=l,O=x,j=T;for(;I-N>un;){let C=(N+I)/2,X=C*Math.cos(E),U=C*Math.sin(E),[K,q,H]=o(e,X,U);if($&&_r(K,q,H)){N=C;continue}let V=chunkYISEJCI6_cjs.a(K,0,1),Y=chunkYISEJCI6_cjs.a(q,0,1),Z=chunkYISEJCI6_cjs.a(H,0,1);D=V,O=Y,j=Z,Mr(b(V,Y,Z),[e,X,U])<=kr?(N=C,$=false):I=C;}return [D,O,j]},Dn=e=>{let r=G(e);return r===null?null:{linear:Ar(r.l,r.a,r.b,chunkTRRLWCL6_cjs.f,chunkTRRLWCL6_cjs.a),alpha:r.alpha}},On=(e,r)=>{let n=G(e);if(n===null)return true;let[o,b,t]=r(n.l,n.a,n.b);return Pr(o,b,t)},jn=(e,r,n)=>{let o=G(e);return o===null?null:{linear:Ar(o.l,o.a,o.b,r,n),alpha:o.alpha}};var f=Math.PI/180,Gr=(e,r,n)=>{let o=n*f;return chunkTRRLWCL6_cjs.f(e,r*Math.cos(o),r*Math.sin(o))},Ir=(e,r,n,o)=>{let b=o*f;chunkTRRLWCL6_cjs.e(e,r,n*Math.cos(b),n*Math.sin(b));},Vn=(e,r,n)=>{let[o,b,t]=Gr(e,r,n);return [chunkINDSIUQQ_cjs.b(o),chunkINDSIUQQ_cjs.b(b),chunkINDSIUQQ_cjs.b(t)]},Yn=(e,r,n,o)=>{Ir(e,r,n,o),e[0]=chunkINDSIUQQ_cjs.b(e[0]),e[1]=chunkINDSIUQQ_cjs.b(e[1]),e[2]=chunkINDSIUQQ_cjs.b(e[2]);},Zn=(e,r,n)=>{let[o,b,t]=Gr(e,r,n);return [[o,b,t],[chunkINDSIUQQ_cjs.b(o),chunkINDSIUQQ_cjs.b(b),chunkINDSIUQQ_cjs.b(t)]]},Jn=(e,r,n,o,b)=>{Ir(e,n,o,b),r[0]=chunkINDSIUQQ_cjs.b(e[0]),r[1]=chunkINDSIUQQ_cjs.b(e[1]),r[2]=chunkINDSIUQQ_cjs.b(e[2]);},Qn=(e,r,n)=>[chunkINDSIUQQ_cjs.a(e),chunkINDSIUQQ_cjs.a(r),chunkINDSIUQQ_cjs.a(n)],Wn=(e,r,n,o)=>{e[0]=chunkINDSIUQQ_cjs.a(r),e[1]=chunkINDSIUQQ_cjs.a(n),e[2]=chunkINDSIUQQ_cjs.a(o);},v=(e,r,n)=>{let[o,b,t]=chunkPI5KJ3ZM_cjs.j(e,r,n);return chunkPI5KJ3ZM_cjs.e(o,b,t)},B=(e,r,n,o)=>{chunkPI5KJ3ZM_cjs.k(e,r,n,o),chunkPI5KJ3ZM_cjs.d(e,e[0],e[1],e[2]);},re=(e,r,n)=>{let o=n*f;return v(e,r*Math.cos(o),r*Math.sin(o))},ne=(e,r,n,o)=>{let b=o*f;B(e,r,n*Math.cos(b),n*Math.sin(b));},mn=(e,r,n)=>{let[o,b,t]=v(e,r,n);return [chunkINDSIUQQ_cjs.b(o),chunkINDSIUQQ_cjs.b(b),chunkINDSIUQQ_cjs.b(t)]},sn=(e,r,n,o)=>{B(e,r,n,o),e[0]=chunkINDSIUQQ_cjs.b(e[0]),e[1]=chunkINDSIUQQ_cjs.b(e[1]),e[2]=chunkINDSIUQQ_cjs.b(e[2]);},ee=(e,r,n)=>{let o=n*f;return mn(e,r*Math.cos(o),r*Math.sin(o))},oe=(e,r,n,o)=>{let b=o*f;sn(e,r,n*Math.cos(b),n*Math.sin(b));},ln=(e,r,n)=>{let[o,b,t]=v(e,r,n);return [[o,b,t],[chunkINDSIUQQ_cjs.b(o),chunkINDSIUQQ_cjs.b(b),chunkINDSIUQQ_cjs.b(t)]]},cn=(e,r,n,o,b)=>{B(e,n,o,b),r[0]=chunkINDSIUQQ_cjs.b(e[0]),r[1]=chunkINDSIUQQ_cjs.b(e[1]),r[2]=chunkINDSIUQQ_cjs.b(e[2]);},be=(e,r,n)=>{let o=n*f;return ln(e,r*Math.cos(o),r*Math.sin(o))},te=(e,r,n,o,b)=>{let t=b*f;cn(e,r,n,o*Math.cos(t),o*Math.sin(t));};exports.A=v;exports.B=B;exports.C=re;exports.D=ne;exports.E=mn;exports.F=sn;exports.G=ee;exports.H=oe;exports.I=ln;exports.J=cn;exports.K=be;exports.L=te;exports.a=Rn;exports.b=sr;exports.c=z;exports.d=fn;exports.e=yn;exports.f=Sn;exports.g=xn;exports.h=_n;exports.i=Sr;exports.j=F;exports.k=kn;exports.l=Mn;exports.m=Pn;exports.n=An;exports.o=$n;exports.p=Dn;exports.q=On;exports.r=jn;exports.s=Gr;exports.t=Ir;exports.u=Vn;exports.v=Yn;exports.w=Zn;exports.x=Jn;exports.y=Qn;exports.z=Wn;//# sourceMappingURL=chunk-YXTI4MTI.cjs.map | ||
| //# sourceMappingURL=chunk-YXTI4MTI.cjs.map |
Sorry, the diff of this file is too big to display
| /** sRGB color. r, g, b in [0, 255]; alpha in [0, 1]. */ | ||
| interface RgbColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `RgbColor` — `alpha` is optional and defaults to 1. */ | ||
| type RgbColorInput = Omit<RgbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HSL color. h in [0, 360); s, l in [0, 100]; alpha in [0, 1]. */ | ||
| interface HslColor { | ||
| h: number; | ||
| s: number; | ||
| l: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HslColor` — `alpha` is optional and defaults to 1. */ | ||
| type HslColorInput = Omit<HslColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HSV color. h in [0, 360); s, v in [0, 100]; alpha in [0, 1]. */ | ||
| interface HsvColor { | ||
| h: number; | ||
| s: number; | ||
| v: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HsvColor` — `alpha` is optional and defaults to 1. */ | ||
| type HsvColorInput = Omit<HsvColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HWB color. h in [0, 360); w, b in [0, 100]; alpha in [0, 1]. */ | ||
| interface HwbColor { | ||
| h: number; | ||
| /** Whiteness [0, 100]. */ | ||
| w: number; | ||
| /** Blackness [0, 100]. */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HwbColor` — `alpha` is optional and defaults to 1. */ | ||
| type HwbColorInput = Omit<HwbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE Lab (D50). L in [0, 100]; a, b roughly in [-128, 128]. */ | ||
| interface LabColor { | ||
| l: number; | ||
| /** Green–red axis. */ | ||
| a: number; | ||
| /** Blue–yellow axis. */ | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lab'; | ||
| } | ||
| /** Input shape of `LabColor` — `alpha` is optional and defaults to 1. */ | ||
| type LabColorInput = Omit<LabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE LCh (D50). L in [0, 100]; C in [0, ~150]; h in degrees. */ | ||
| interface LchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lch'; | ||
| } | ||
| /** Input shape of `LchColor` — `alpha` is optional and defaults to 1. */ | ||
| type LchColorInput = Omit<LchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D50). x, y, z on the library's 0–100 scale. */ | ||
| interface XyzColor { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `XyzColor` — `alpha` is optional and defaults to 1. */ | ||
| type XyzColorInput = Omit<XyzColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D65). x, y, z on the library's 0–100 scale. */ | ||
| interface XyzD65Color { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'xyz-d65'; | ||
| } | ||
| type XyzD65ColorInput = Omit<XyzD65Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CMYK color. c, m, y, k in [0, 100]; alpha in [0, 1]. */ | ||
| interface CmykColor { | ||
| c: number; | ||
| m: number; | ||
| y: number; | ||
| k: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `CmykColor` — `alpha` is optional and defaults to 1. */ | ||
| type CmykColorInput = Omit<CmykColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** OKLab. Perceptually uniform (D65). L in [0, 1]; a, b roughly in [-0.4, 0.4]. */ | ||
| interface OklabColor { | ||
| l: number; | ||
| /** Green–red axis. */ | ||
| a: number; | ||
| /** Blue–yellow axis. */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `OklabColor` — `alpha` is optional and defaults to 1. */ | ||
| type OklabColorInput = Omit<OklabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** OKLCh. Polar form of OKLab. L in [0, 1]; C in [0, ~0.4]; h in degrees. */ | ||
| interface OklchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `OklchColor` — `alpha` is optional and defaults to 1. */ | ||
| type OklchColorInput = Omit<OklchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Display-P3. r, g, b in [0, 1]. */ | ||
| interface P3Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'display-p3'; | ||
| } | ||
| /** Input shape of `P3Color` — `alpha` is optional and defaults to 1. */ | ||
| type P3ColorInput = Omit<P3Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Rec.2020. r, g, b in [0, 1]. */ | ||
| interface Rec2020Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'rec2020'; | ||
| } | ||
| /** Input shape of `Rec2020Color` — `alpha` is optional and defaults to 1. */ | ||
| type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** Any color input accepted by `colordx()` and friends — a CSS string or one of the input objects. */ | ||
| type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | XyzD65ColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput; | ||
| /** A parser registered by a plugin. Returns the sRGB equivalent or `null` if the input doesn't match. */ | ||
| type ColorParser<T = AnyColor> = (input: T) => RgbColor | null; | ||
| /** Format tags returned by `getFormat()`. */ | ||
| type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'xyz-d65' | 'cmyk' | 'p3' | 'rec2020' | 'name'; | ||
| declare const _SENTINEL: unique symbol; | ||
| /** | ||
| * Color value with parse, format, and manipulation methods. | ||
| * Construct via the `colordx()` helper or `new Colordx(input)`. Instances are immutable — | ||
| * mutators return a new `Colordx`. | ||
| */ | ||
| declare class Colordx { | ||
| private readonly _rgb; | ||
| private readonly _valid; | ||
| constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor); | ||
| private static _make; | ||
| /** | ||
| * Construct a Colordx from linear-sRGB channels, gamma-encoding to the internal ×255 storage. | ||
| * Channels may exceed [0, 1] — wide-gamut inputs (toGamutP3 / toGamutRec2020 applied to a | ||
| * color outside sRGB) land here after the target-space → linear-sRGB matrix, and the stored | ||
| * _rgb holds unclamped gamma-encoded ×255 so toP3() / toRec2020() can recover the wide-gamut | ||
| * channels. sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning. | ||
| * | ||
| * Replaces the prior _makeFromOklab: cssGamutMap hands back clipped linear-target channels | ||
| * directly, so callers skip the OKLab → linear round-trip that used to reintroduce 1-ULP | ||
| * asymmetries on gamut-boundary colors. | ||
| * | ||
| * A residual source of asymmetry remains — the clip itself. cssGamutMap's clip puts one | ||
| * channel exactly on 0 or 1 while the others sit where the input's hue landed, so an | ||
| * extreme-dark or extreme-light color ends up with genuinely asymmetric sub-byte channels | ||
| * (e.g. clipped linear (3e-6, 0, 8e-10) from oklch(0.001 0.001 0)). Math.round collapses all | ||
| * three to the same byte, but rgbToHslRaw / rgbToOklab read the raw floats and report | ||
| * phantom hue/saturation. Snap values within half a byte of 0 or 255 to the exact boundary; | ||
| * the band matches Math.round's own behavior so byte output is unchanged, while HSL / OKLab | ||
| * see a consistent pure white / black / primary. Values outside [0, 255] are wide-gamut | ||
| * (P3 / Rec.2020 targets) and pass through untouched. | ||
| */ | ||
| static _makeFromLinearSrgb(lr: number, lg: number, lb: number, alpha: number): Colordx; | ||
| /** True when the input parsed as a recognised color. */ | ||
| isValid(): boolean; | ||
| /** Returns sRGB channels rounded to integers in [0, 255], plus alpha in [0, 1]. */ | ||
| toRgb(): RgbColor; | ||
| /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */ | ||
| _rawRgb(): RgbColor; | ||
| /** | ||
| * Formats as a CSS `rgb()` / `rgba()` string. | ||
| * Default is CSS Color 4 modern syntax — `rgb(255 0 0 / 0.5)`. | ||
| * Pass `{ legacy: true }` for CSS Color 3 comma syntax (switches to `rgba()` when alpha < 1). | ||
| */ | ||
| toRgbString(options?: { | ||
| legacy?: boolean; | ||
| }): string; | ||
| /** Returns `#rrggbb` (or `#rrggbbaa` when alpha < 1). */ | ||
| toHex(): string; | ||
| /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */ | ||
| toHex8(): string; | ||
| /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */ | ||
| toNumber(): number; | ||
| /** Returns HSL channels: h in [0, 360), s/l in [0, 100], rounded to `precision` decimals. */ | ||
| toHsl(precision?: number): HslColor; | ||
| /** Formats as a CSS `hsl()` string. */ | ||
| toHslString(precision?: number): string; | ||
| /** Returns OKLab channels: L in [0, 1], a/b roughly in [-0.4, 0.4]. */ | ||
| toOklab(precision?: number): OklabColor; | ||
| /** Formats as a CSS `oklab()` string. */ | ||
| toOklabString(precision?: number): string; | ||
| /** Returns OKLCh channels: L in [0, 1], C in [0, ~0.4], H in degrees. */ | ||
| toOklch(precision?: number): OklchColor; | ||
| /** Formats as a CSS `oklch()` string. Hue is `none` when chroma is 0. */ | ||
| toOklchString(precision?: number): string; | ||
| /** Perceived brightness in [0, 1] using the ITU-R BT.601 weights. */ | ||
| brightness(): number; | ||
| /** True when `brightness()` is below 0.5. */ | ||
| isDark(): boolean; | ||
| /** True when `brightness()` is at or above 0.5. */ | ||
| isLight(): boolean; | ||
| /** Get or set the alpha channel (clamped to [0, 1]). Setter returns a new `Colordx`. */ | ||
| alpha(): number; | ||
| alpha(value: number): Colordx; | ||
| /** Get or set the HSL hue in degrees. Setter returns a new `Colordx`. */ | ||
| hue(): number; | ||
| hue(value: number): Colordx; | ||
| /** Get or set the OKLCh lightness in [0, 1]. Setter returns a new `Colordx`. */ | ||
| lightness(): number; | ||
| lightness(value: number): Colordx; | ||
| /** Get or set the OKLCh chroma in [0, 0.4]. Setter returns a new `Colordx`. */ | ||
| chroma(): number; | ||
| chroma(value: number): Colordx; | ||
| /** | ||
| * Lightens by `amount` (default 0.1) in HSL. Absolute by default — adds `amount * 100` to L. | ||
| * Pass `{ relative: true }` to multiply L by `1 + amount` instead. | ||
| */ | ||
| lighten(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Inverse of `lighten`. */ | ||
| darken(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** | ||
| * Saturates by `amount` (default 0.1) in HSL. Absolute by default — adds `amount * 100` to S. | ||
| * Pass `{ relative: true }` to multiply S by `1 + amount` instead. | ||
| */ | ||
| saturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Inverse of `saturate`. */ | ||
| desaturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Drops saturation to zero. */ | ||
| grayscale(): Colordx; | ||
| /** Inverts each RGB channel (255 − channel). */ | ||
| invert(): Colordx; | ||
| /** Shifts the HSL hue by `amount` degrees (default 15). */ | ||
| rotate(amount?: number): Colordx; | ||
| /** True when both colors round to the same RGBA tuple. */ | ||
| isEqual(color: AnyColor): boolean; | ||
| /** Returns the hex form (alias for `toHex()`). */ | ||
| toString(): string; | ||
| /** | ||
| * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255]. | ||
| * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`. | ||
| * Hue and lightness may shift noticeably for colors far outside sRGB. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| clampSrgb(): Colordx; | ||
| /** | ||
| * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm | ||
| * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma. | ||
| * Useful when hue stability matters — design tokens, palettes, color pickers. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| mapSrgb(): Colordx; | ||
| /** | ||
| * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm. | ||
| * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through. | ||
| */ | ||
| static toGamutSrgb: (input: AnyColor) => Colordx; | ||
| } | ||
| /** | ||
| * Plugin signature. Receives the `Colordx` class plus the parser arrays so a plugin | ||
| * can register conversions (by adding instance methods) and parsers (by pushing onto the arrays). | ||
| */ | ||
| type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void; | ||
| /** Constructs a `Colordx` from any supported color input. Existing instances pass through. */ | ||
| declare const colordx: (input: AnyColor | Colordx) => Colordx; | ||
| /** Emits an 8-digit `#rrggbbaa` hex for any color input. Shortcut for `colordx(c).toHex8()`. */ | ||
| declare const toHex8: (input: AnyColor | Colordx) => string; | ||
| /** Registers plugins. Each plugin is called once with the `Colordx` class and parser arrays. */ | ||
| declare const extend: (plugins: Plugin[]) => void; | ||
| /** | ||
| * Picks the candidate closest to `color` by Euclidean distance in OKLab. | ||
| * Throws when `candidates` is empty. | ||
| */ | ||
| declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T; | ||
| /** Returns a random opaque sRGB color. */ | ||
| declare const random: () => Colordx; | ||
| export { type AnyColor as A, type XyzD65Color as B, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type CmykColorInput as b, type ColorParser as c, Colordx as d, type HslColorInput as e, type HsvColor as f, type HsvColorInput as g, type HwbColor as h, type HwbColorInput as i, type LabColorInput as j, type LchColor as k, type LchColorInput as l, type OklabColorInput as m, type OklchColor as n, type OklchColorInput as o, type P3ColorInput as p, type Plugin as q, type Rec2020ColorInput as r, type RgbColor as s, type RgbColorInput as t, type XyzColorInput as u, colordx as v, extend as w, nearest as x, random as y, toHex8 as z }; |
| /** sRGB color. r, g, b in [0, 255]; alpha in [0, 1]. */ | ||
| interface RgbColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `RgbColor` — `alpha` is optional and defaults to 1. */ | ||
| type RgbColorInput = Omit<RgbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HSL color. h in [0, 360); s, l in [0, 100]; alpha in [0, 1]. */ | ||
| interface HslColor { | ||
| h: number; | ||
| s: number; | ||
| l: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HslColor` — `alpha` is optional and defaults to 1. */ | ||
| type HslColorInput = Omit<HslColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HSV color. h in [0, 360); s, v in [0, 100]; alpha in [0, 1]. */ | ||
| interface HsvColor { | ||
| h: number; | ||
| s: number; | ||
| v: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HsvColor` — `alpha` is optional and defaults to 1. */ | ||
| type HsvColorInput = Omit<HsvColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** HWB color. h in [0, 360); w, b in [0, 100]; alpha in [0, 1]. */ | ||
| interface HwbColor { | ||
| h: number; | ||
| /** Whiteness [0, 100]. */ | ||
| w: number; | ||
| /** Blackness [0, 100]. */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `HwbColor` — `alpha` is optional and defaults to 1. */ | ||
| type HwbColorInput = Omit<HwbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE Lab (D50). L in [0, 100]; a, b roughly in [-128, 128]. */ | ||
| interface LabColor { | ||
| l: number; | ||
| /** Green–red axis. */ | ||
| a: number; | ||
| /** Blue–yellow axis. */ | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lab'; | ||
| } | ||
| /** Input shape of `LabColor` — `alpha` is optional and defaults to 1. */ | ||
| type LabColorInput = Omit<LabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE LCh (D50). L in [0, 100]; C in [0, ~150]; h in degrees. */ | ||
| interface LchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lch'; | ||
| } | ||
| /** Input shape of `LchColor` — `alpha` is optional and defaults to 1. */ | ||
| type LchColorInput = Omit<LchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D50). x, y, z on the library's 0–100 scale. */ | ||
| interface XyzColor { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `XyzColor` — `alpha` is optional and defaults to 1. */ | ||
| type XyzColorInput = Omit<XyzColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D65). x, y, z on the library's 0–100 scale. */ | ||
| interface XyzD65Color { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'xyz-d65'; | ||
| } | ||
| type XyzD65ColorInput = Omit<XyzD65Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CMYK color. c, m, y, k in [0, 100]; alpha in [0, 1]. */ | ||
| interface CmykColor { | ||
| c: number; | ||
| m: number; | ||
| y: number; | ||
| k: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `CmykColor` — `alpha` is optional and defaults to 1. */ | ||
| type CmykColorInput = Omit<CmykColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** OKLab. Perceptually uniform (D65). L in [0, 1]; a, b roughly in [-0.4, 0.4]. */ | ||
| interface OklabColor { | ||
| l: number; | ||
| /** Green–red axis. */ | ||
| a: number; | ||
| /** Blue–yellow axis. */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `OklabColor` — `alpha` is optional and defaults to 1. */ | ||
| type OklabColorInput = Omit<OklabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** OKLCh. Polar form of OKLab. L in [0, 1]; C in [0, ~0.4]; h in degrees. */ | ||
| interface OklchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| } | ||
| /** Input shape of `OklchColor` — `alpha` is optional and defaults to 1. */ | ||
| type OklchColorInput = Omit<OklchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Display-P3. r, g, b in [0, 1]. */ | ||
| interface P3Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'display-p3'; | ||
| } | ||
| /** Input shape of `P3Color` — `alpha` is optional and defaults to 1. */ | ||
| type P3ColorInput = Omit<P3Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Rec.2020. r, g, b in [0, 1]. */ | ||
| interface Rec2020Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'rec2020'; | ||
| } | ||
| /** Input shape of `Rec2020Color` — `alpha` is optional and defaults to 1. */ | ||
| type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** Any color input accepted by `colordx()` and friends — a CSS string or one of the input objects. */ | ||
| type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | XyzD65ColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput; | ||
| /** A parser registered by a plugin. Returns the sRGB equivalent or `null` if the input doesn't match. */ | ||
| type ColorParser<T = AnyColor> = (input: T) => RgbColor | null; | ||
| /** Format tags returned by `getFormat()`. */ | ||
| type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'xyz-d65' | 'cmyk' | 'p3' | 'rec2020' | 'name'; | ||
| declare const _SENTINEL: unique symbol; | ||
| /** | ||
| * Color value with parse, format, and manipulation methods. | ||
| * Construct via the `colordx()` helper or `new Colordx(input)`. Instances are immutable — | ||
| * mutators return a new `Colordx`. | ||
| */ | ||
| declare class Colordx { | ||
| private readonly _rgb; | ||
| private readonly _valid; | ||
| constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor); | ||
| private static _make; | ||
| /** | ||
| * Construct a Colordx from linear-sRGB channels, gamma-encoding to the internal ×255 storage. | ||
| * Channels may exceed [0, 1] — wide-gamut inputs (toGamutP3 / toGamutRec2020 applied to a | ||
| * color outside sRGB) land here after the target-space → linear-sRGB matrix, and the stored | ||
| * _rgb holds unclamped gamma-encoded ×255 so toP3() / toRec2020() can recover the wide-gamut | ||
| * channels. sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning. | ||
| * | ||
| * Replaces the prior _makeFromOklab: cssGamutMap hands back clipped linear-target channels | ||
| * directly, so callers skip the OKLab → linear round-trip that used to reintroduce 1-ULP | ||
| * asymmetries on gamut-boundary colors. | ||
| * | ||
| * A residual source of asymmetry remains — the clip itself. cssGamutMap's clip puts one | ||
| * channel exactly on 0 or 1 while the others sit where the input's hue landed, so an | ||
| * extreme-dark or extreme-light color ends up with genuinely asymmetric sub-byte channels | ||
| * (e.g. clipped linear (3e-6, 0, 8e-10) from oklch(0.001 0.001 0)). Math.round collapses all | ||
| * three to the same byte, but rgbToHslRaw / rgbToOklab read the raw floats and report | ||
| * phantom hue/saturation. Snap values within half a byte of 0 or 255 to the exact boundary; | ||
| * the band matches Math.round's own behavior so byte output is unchanged, while HSL / OKLab | ||
| * see a consistent pure white / black / primary. Values outside [0, 255] are wide-gamut | ||
| * (P3 / Rec.2020 targets) and pass through untouched. | ||
| */ | ||
| static _makeFromLinearSrgb(lr: number, lg: number, lb: number, alpha: number): Colordx; | ||
| /** True when the input parsed as a recognised color. */ | ||
| isValid(): boolean; | ||
| /** Returns sRGB channels rounded to integers in [0, 255], plus alpha in [0, 1]. */ | ||
| toRgb(): RgbColor; | ||
| /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */ | ||
| _rawRgb(): RgbColor; | ||
| /** | ||
| * Formats as a CSS `rgb()` / `rgba()` string. | ||
| * Default is CSS Color 4 modern syntax — `rgb(255 0 0 / 0.5)`. | ||
| * Pass `{ legacy: true }` for CSS Color 3 comma syntax (switches to `rgba()` when alpha < 1). | ||
| */ | ||
| toRgbString(options?: { | ||
| legacy?: boolean; | ||
| }): string; | ||
| /** Returns `#rrggbb` (or `#rrggbbaa` when alpha < 1). */ | ||
| toHex(): string; | ||
| /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */ | ||
| toHex8(): string; | ||
| /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */ | ||
| toNumber(): number; | ||
| /** Returns HSL channels: h in [0, 360), s/l in [0, 100], rounded to `precision` decimals. */ | ||
| toHsl(precision?: number): HslColor; | ||
| /** Formats as a CSS `hsl()` string. */ | ||
| toHslString(precision?: number): string; | ||
| /** Returns OKLab channels: L in [0, 1], a/b roughly in [-0.4, 0.4]. */ | ||
| toOklab(precision?: number): OklabColor; | ||
| /** Formats as a CSS `oklab()` string. */ | ||
| toOklabString(precision?: number): string; | ||
| /** Returns OKLCh channels: L in [0, 1], C in [0, ~0.4], H in degrees. */ | ||
| toOklch(precision?: number): OklchColor; | ||
| /** Formats as a CSS `oklch()` string. Hue is `none` when chroma is 0. */ | ||
| toOklchString(precision?: number): string; | ||
| /** Perceived brightness in [0, 1] using the ITU-R BT.601 weights. */ | ||
| brightness(): number; | ||
| /** True when `brightness()` is below 0.5. */ | ||
| isDark(): boolean; | ||
| /** True when `brightness()` is at or above 0.5. */ | ||
| isLight(): boolean; | ||
| /** Get or set the alpha channel (clamped to [0, 1]). Setter returns a new `Colordx`. */ | ||
| alpha(): number; | ||
| alpha(value: number): Colordx; | ||
| /** Get or set the HSL hue in degrees. Setter returns a new `Colordx`. */ | ||
| hue(): number; | ||
| hue(value: number): Colordx; | ||
| /** Get or set the OKLCh lightness in [0, 1]. Setter returns a new `Colordx`. */ | ||
| lightness(): number; | ||
| lightness(value: number): Colordx; | ||
| /** Get or set the OKLCh chroma in [0, 0.4]. Setter returns a new `Colordx`. */ | ||
| chroma(): number; | ||
| chroma(value: number): Colordx; | ||
| /** | ||
| * Lightens by `amount` (default 0.1) in HSL. Absolute by default — adds `amount * 100` to L. | ||
| * Pass `{ relative: true }` to multiply L by `1 + amount` instead. | ||
| */ | ||
| lighten(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Inverse of `lighten`. */ | ||
| darken(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** | ||
| * Saturates by `amount` (default 0.1) in HSL. Absolute by default — adds `amount * 100` to S. | ||
| * Pass `{ relative: true }` to multiply S by `1 + amount` instead. | ||
| */ | ||
| saturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Inverse of `saturate`. */ | ||
| desaturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| /** Drops saturation to zero. */ | ||
| grayscale(): Colordx; | ||
| /** Inverts each RGB channel (255 − channel). */ | ||
| invert(): Colordx; | ||
| /** Shifts the HSL hue by `amount` degrees (default 15). */ | ||
| rotate(amount?: number): Colordx; | ||
| /** True when both colors round to the same RGBA tuple. */ | ||
| isEqual(color: AnyColor): boolean; | ||
| /** Returns the hex form (alias for `toHex()`). */ | ||
| toString(): string; | ||
| /** | ||
| * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255]. | ||
| * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`. | ||
| * Hue and lightness may shift noticeably for colors far outside sRGB. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| clampSrgb(): Colordx; | ||
| /** | ||
| * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm | ||
| * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma. | ||
| * Useful when hue stability matters — design tokens, palettes, color pickers. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| mapSrgb(): Colordx; | ||
| /** | ||
| * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm. | ||
| * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through. | ||
| */ | ||
| static toGamutSrgb: (input: AnyColor) => Colordx; | ||
| } | ||
| /** | ||
| * Plugin signature. Receives the `Colordx` class plus the parser arrays so a plugin | ||
| * can register conversions (by adding instance methods) and parsers (by pushing onto the arrays). | ||
| */ | ||
| type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void; | ||
| /** Constructs a `Colordx` from any supported color input. Existing instances pass through. */ | ||
| declare const colordx: (input: AnyColor | Colordx) => Colordx; | ||
| /** Emits an 8-digit `#rrggbbaa` hex for any color input. Shortcut for `colordx(c).toHex8()`. */ | ||
| declare const toHex8: (input: AnyColor | Colordx) => string; | ||
| /** Registers plugins. Each plugin is called once with the `Colordx` class and parser arrays. */ | ||
| declare const extend: (plugins: Plugin[]) => void; | ||
| /** | ||
| * Picks the candidate closest to `color` by Euclidean distance in OKLab. | ||
| * Throws when `candidates` is empty. | ||
| */ | ||
| declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T; | ||
| /** Returns a random opaque sRGB color. */ | ||
| declare const random: () => Colordx; | ||
| export { type AnyColor as A, type XyzD65Color as B, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type CmykColorInput as b, type ColorParser as c, Colordx as d, type HslColorInput as e, type HsvColor as f, type HsvColorInput as g, type HwbColor as h, type HwbColorInput as i, type LabColorInput as j, type LchColor as k, type LchColorInput as l, type OklabColorInput as m, type OklchColor as n, type OklchColorInput as o, type P3ColorInput as p, type Plugin as q, type Rec2020ColorInput as r, type RgbColor as s, type RgbColorInput as t, type XyzColorInput as u, colordx as v, extend as w, nearest as x, random as y, toHex8 as z }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances
911447
17.77%127
10.43%1273
17.44%867
11.73%46
9.52%