"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[2075,2697],{12075:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var n=r(86087),l=r(27723),a=r(52697),s=r(45111),o=r(4219),i=r(10790);const c=(0,n.memo)(e=>{const[t,r]=(0,n.useState)([]),c=e.fields?.comparisons||[],u=(0,o.default)(e=>e.getFieldValue("font_size")),p=(0,o.default)(e=>c.reduce((t,r)=>(t[r.foreground_field]=e.getFieldValue(r.foreground_field),t[r.background_field]=e.getFieldValue(r.background_field),t),{})),m={AAA:(0,l.__)("AAA: Meets enhanced WCAG 2.1 contrast requirements (≥7:1).","complianz-gdpr"),AA:(0,l.__)("AA: Meets minimum WCAG 2.1 contrast requirements (≥4.5:1).","complianz-gdpr"),Fail:(0,l.__)("Fail: Does not meet WCAG 2.1 minimum contrast (below 4.5:1).","complianz-gdpr")},d=(0,n.useCallback)(()=>c.map(e=>{const t=p[e.foreground_field],r=p[e.background_field],n=t&&"object"==typeof t&&e.foreground_key?t[e.foreground_key]:t,l=r&&"object"==typeof r&&e.background_key?r[e.background_key]:l;return{name:`${e.foreground_label} vs ${e.background_label}`,fg:n,bg:l}}),[c,p]);return(0,n.useEffect)(()=>{((e,t=100)=>{let r;return(...n)=>{clearTimeout(r),r=setTimeout(()=>e(...n),t)}})(()=>{const e=d().map(e=>{const{ratio:t,level:r,pass:n}=(0,a.checkContrast)(e.fg,e.bg,u);return{...e,ratio:t,level:r,pass:n}});r(e)},100)()},[c,p,u,d]),t.length?(0,i.jsx)("div",{className:"cmplz-contrast-checker","aria-live":"polite",children:(0,i.jsx)("ul",{children:t.map((e,t)=>(0,i.jsxs)("li",{className:"cmplz-contrast-row",children:[(0,i.jsxs)("p",{className:"cmplz-contrast-value "+("AAA"===e.level?"cmplz-pass-aaa":"AA"===e.level?"cmplz-pass-aa":"cmplz-fail"),children:[(0,i.jsx)(s.default,{name:"contrast",size:16,color:"AAA"===e.level?"green":"AA"===e.level?"orange":"red",tooltip:m[e.level]}),(0,i.jsx)("strong",{children:e.ratio?e.ratio.toFixed(2):"—"}),(0,i.jsx)("span",{children:e.level})]}),(0,i.jsxs)("p",{children:["- ",e.name]})]},t))})}):null})},52697:(e,t,r)=>{function n(e){if(!e||"string"!=typeof e)return null;let t=e.trim().toLowerCase();if(t.startsWith("#")){let e=t.slice(1);return 3===e.length?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16)}:6===e.length?{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}:null}const r=t.match(/^rgba?\(([^)]+)\)$/);if(r){const e=r[1].split(",").map(e=>e.trim());if(e.length>=3){const t=parseFloat(e[0]),r=parseFloat(e[1]),n=parseFloat(e[2]);if(Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n))return{r:t,g:r,b:n}}return null}const n=t.match(/^hsla?\(([^)]+)\)$/);if(n){const e=n[1].split(",").map(e=>e.trim());if(e.length>=3){const t=parseFloat(e[0]),r=parseFloat(e[1])/100,n=parseFloat(e[2])/100;if(Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)){const{r:e,g:l,b:a}=function(e,t,r){const n=(1-Math.abs(2*r-1))*t,l=e%360/60,a=n*(1-Math.abs(l%2-1));let s=0,o=0,i=0;0<=l&&l<1?(s=n,o=a,i=0):1<=l&&l<2?(s=a,o=n,i=0):2<=l&&l<3?(s=0,o=n,i=a):3<=l&&l<4?(s=0,o=a,i=n):4<=l&&l<5?(s=a,o=0,i=n):5<=l&&l<6&&(s=n,o=0,i=a);const c=r-n/2;return{r:255*(s+c),g:255*(o+c),b:255*(i+c)}}(t,r,n);return{r:Math.round(e),g:Math.round(l),b:Math.round(a)}}}return null}return null}function l(e,t,r){const n=[e,t,r].map(e=>{const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)});return.2126*n[0]+.7152*n[1]+.0722*n[2]}function a(e,t){const r="string"==typeof e?n(e):e,a="string"==typeof t?n(t):t;if(!r||!a)return null;const s=l(r.r,r.g,r.b),o=l(a.r,a.g,a.b);return(Math.max(s,o)+.05)/(Math.min(s,o)+.05)}function s(e,t=12){return null==e?"Fail":t>=18?e>=4.5?"AAA":e>=3?"AA":"Fail":e>=7?"AAA":e>=4.5?"AA":"Fail"}function o(e,t,r=12){const n=a(e,t),l=s(n,r);return{ratio:n,level:l,pass:"AA"===l||"AAA"===l}}r.r(t),r.d(t,{checkContrast:()=>o,contrastRatio:()=>a,getComplianceLevel:()=>s,luminance:()=>l,parseColor:()=>n})}}]);