import{w as s,L as c,v as u}from"./index-B6uGkrgD.js";import{c as a}from"./contrast-qfZiX0wi-BxADjsFV.js";const f=/^#((\d|[a-f]){8}|(\d|[a-f]){6}|(\d|[a-f]){3,4})$/i;function d(o){return f.test(o)}function g(o){if(o.startsWith("{"))try{const r=JSON.parse(o);if(l(r))return{type:"ColorPair",value:r}}catch{return{type:null,value:null}}return{type:null,value:null}}function i(o){if(o)if(typeof o=="string"){if(d(o))return{type:"string",valid:!0,value:o};{const r=g(o);if(r.value)return{type:r.type,valid:!0,value:r.value}}}else{const r=o;if(l(r))return{type:"ColorPair",valid:!0,value:r}}return{type:null,valid:!1,value:""}}function l(o){return!!(typeof o=="object"&&o&&typeof o.backgroundColor=="string"&&typeof o.foregroundColor=="string")}function p(o){const r=i(o);switch(r.type){case null:return!1;case"string":case"ColorPair":return r.valid}}const b=(o,r,t)=>{s(o,"_color",p,new Set(["rgb in hex","ColorPair"]),r,t)},v=o=>{let r;const t=i(o);switch(t.type){case"string":r=a(t.value);break;case"ColorPair":{const n=t.value;let e="";typeof n.foregroundColor=="string"&&(e=n.foregroundColor),(!e||typeof e!="string")&&(e="#fff"),r=a({background:n.backgroundColor,foreground:e});break}case null:c.warn(`_color was empty or invalid (${JSON.stringify(o)})`),r=a({background:"#000",foreground:"#000"})}return r.contrast<7&&u(`[KolBadge] The contrast of ${r.contrast} (≥7, AAA) is to low, between the color pair ${r.background} and ${r.foreground}.`),{backgroundColor:r.background,foregroundColor:r.foreground}};export{v as h,b as v};
//# sourceMappingURL=color-CUkVwfhq-CFTd88di.js.map
