@yuktishaalaa/yuktai 1.0.11 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +26 -1
- package/dist/index.d.cts +33 -4
- package/dist/index.d.ts +33 -4
- package/dist/index.js +26 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1,26 @@
|
|
|
1
|
-
"use strict";"use client";var B=Object.create;var y=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var i in t)y(e,i,{get:t[i],enumerable:!0})},T=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of $(t))!q.call(e,u)&&u!==i&&y(e,u,{get:()=>t[u],enumerable:!(r=N(t,u))||r.enumerable});return e};var A=(e,t,i)=>(i=e!=null?B(O(e)):{},T(t||!e||!e.__esModule?y(i,"default",{value:e,enumerable:!0}):i,e)),z=e=>T(y({},"__esModule",{value:!0}),e);var G={};D(G,{YuktAI:()=>P,YuktAIWrapper:()=>C,default:()=>K});module.exports=z(G);var h=class{plugins=new Map;register(t,i){if(!i||typeof i.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,i)}use(t){return this.plugins.get(t)}async run(t,i){try{let r=this.use(t);if(!r)throw new Error(`Plugin not found: ${t}`);return await r.execute(i)}catch(r){throw console.error(`[YuktAI Runtime Error in ${t}]:`,r),r}}getPlugins(){return Array.from(this.plugins.keys())}};var k={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var E={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var S=A(require("tesseract.js"),1),g=null,I=null;function W(e){let t=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(t)?"tel":/[\u0900-\u097F]/.test(t)?"hin":/[\u0B80-\u0BFF]/.test(t)?"tam":/[\u4E00-\u9FFF]/.test(t)?"chi_sim":/[\u3040-\u30FF]/.test(t)?"jpn":/[\u0600-\u06FF]/.test(t)?"ara":/[\u0400-\u04FF]/.test(t)?"rus":"eng"}async function H(e){return g&&I===e||(g&&(await g.terminate(),g=null),g=await S.default.createWorker({langPath:"/tessdata",logger:()=>{}}),await g.loadLanguage(e),await g.initialize(e),I=e),g}var R={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let t=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),i=e.lang||W(await t.arrayBuffer())||"eng",r=await H(i),{data:u}=await r.recognize(t),s=u.text?.trim();return s?{language:i,confidence:Math.round(u.confidence??0),text:s}:"\u26A0\uFE0F No text detected"}catch(t){return console.error("[ocrSmartPlugin]",t),"\u274C OCR failed"}}};var w={name:"ui.a11y.pro",version:"1.0.1",observer:null,async execute(e){if(!e?.enabled)return this.stopObserver(),"yuktai-a11y: disabled";try{let t=this.applyFixes(e);if(e.autoFix&&this.startObserver(e),this.ensureLiveRegion(),this.announce(`Accessibility active. ${t.fixed} fixes applied.`),e.validate){let i=this.validatePage();return{...t,validation:i}}return t}catch(t){return console.error("WCAG Plugin execution error:",t),{fixed:0,scanned:0,errors:[t.message]}}},applyFixes(e){let t={fixed:0,scanned:0,errors:[]};if(typeof document>"u")return t;let i=e.root||document,r=e.skipFixes||[];try{let u=i.querySelectorAll("a,button,input,select,textarea,img,table,[onclick],[tabindex],h1,h2,h3,h4,h5,h6,iframe,video,audio,[role],[aria-label],[aria-labelledby]");t.scanned=u.length;let s=0;if(u.forEach(o=>{try{let n=o,a=n.tagName.toLowerCase();if(!r.includes("headings")&&/^h[1-6]$/.test(a)){let c=parseInt(a[1]);c>s+1&&s!==0&&(n.setAttribute("aria-level",String(s+1)),t.fixed++),s=c}if(!r.includes("buttons")&&(a==="a"||a==="button")&&!n.innerText.trim()&&!n.getAttribute("aria-label")){let c=n.getAttribute("title")||n.getAttribute("aria-label")||"Interactive element";n.setAttribute("aria-label",c),t.fixed++}if(r.includes("clickables")||(n.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(n).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(a)&&(n.getAttribute("role")||(n.setAttribute("role","button"),t.fixed++),n.tabIndex<0&&(n.tabIndex=0,t.fixed++),n._yuktKeyBound||(n.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),n.click())}),n._yuktKeyBound=!0)),!r.includes("forms")&&["input","select","textarea"].includes(a)){if(!n.getAttribute("aria-label")&&!n.getAttribute("aria-labelledby")){let c=n.getAttribute("placeholder")||n.getAttribute("name")||n.getAttribute("title")||a;n.setAttribute("aria-label",c),t.fixed++}n.hasAttribute("required")&&!n.getAttribute("aria-required")&&(n.setAttribute("aria-required","true"),t.fixed++)}!r.includes("images")&&a==="img"&&!n.hasAttribute("alt")&&(n.setAttribute("alt",""),n.setAttribute("aria-hidden","true"),t.fixed++),!r.includes("tables")&&a==="table"&&!o.querySelector("th")&&(n.getAttribute("role")||(n.setAttribute("role","grid"),t.fixed++)),!r.includes("media")&&["video","audio"].includes(a)&&(n.hasAttribute("controls")||(n.setAttribute("controls","true"),t.fixed++)),!r.includes("iframes")&&a==="iframe"&&!n.getAttribute("title")&&(n.setAttribute("title","Embedded content"),t.fixed++)}catch(n){t.errors.push(`Error fixing element ${o.tagName}: ${n.message}`)}}),e.highContrast&&(document.documentElement.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(document.documentElement.style.scrollBehavior="auto",!document.getElementById("yukt-reduce-motion"))){let o=document.createElement("style");o.id="yukt-reduce-motion",o.textContent="*, *::before, *::after { transition: none !important; animation: none !important; }",document.head.appendChild(o)}}catch(u){t.errors.push(`General error in applyFixes: ${u.message}`)}return t},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(t=>{clearTimeout(this._mutationTimer),this._mutationTimer=setTimeout(()=>{t.forEach(i=>{i.addedNodes.forEach(r=>{r instanceof HTMLElement&&this.applyFixes({...e,root:r})})})},100)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this._mutationTimer&&clearTimeout(this._mutationTimer)},cleanup(){this.stopObserver(),this.removeLiveRegion();let e=document.getElementById("yukt-reduce-motion");e&&e.remove(),typeof document<"u"&&(document.documentElement.style.filter="",document.documentElement.style.scrollBehavior="")},ensureLiveRegion(){if(typeof document>"u"||document.getElementById("yukt-sr-announcer"))return;let e=document.createElement("div");e.id="yukt-sr-announcer",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e)},removeLiveRegion(){if(typeof document>"u")return;let e=document.getElementById("yukt-sr-announcer");e&&e.remove()},announce(e){if(typeof document>"u")return;let t=document.getElementById("yukt-sr-announcer");t&&(t.textContent="",setTimeout(()=>{t.textContent=e},50))},checkContrast(e,t,i=4.5){try{return(u=>{let s=document.createElement("div");s.style.color=u,s.style.backgroundColor=t,document.body.appendChild(s);let o=window.getComputedStyle(s).color,n=window.getComputedStyle(s).backgroundColor;s.remove();let a=o.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/),c=n.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!a||!c)return 1;let d=this.rgbToLuminance(parseInt(a[1]),parseInt(a[2]),parseInt(a[3])),m=this.rgbToLuminance(parseInt(c[1]),parseInt(c[2]),parseInt(c[3])),b=Math.max(d,m),v=Math.min(d,m);return(b+.05)/(v+.05)})(e)>=i}catch(r){return console.warn("Contrast check failed:",r),!0}},validatePage(){let e=[],t=[];if(typeof document>"u")return{score:0,issues:["Server-side rendering detected"],recommendations:[]};document.documentElement.getAttribute("lang")||(e.push("Missing lang attribute on html element"),t.push('Add lang attribute to <html> element (e.g., <html lang="en">)')),document.title||(e.push("Missing page title"),t.push("Add a descriptive <title> element")),document.querySelectorAll('a,button,input,select,textarea,[tabindex]:not([tabindex="-1"])').length===0&&(e.push("No keyboard-focusable elements found"),t.push("Ensure interactive elements are keyboard accessible"));let r=document.querySelectorAll("img:not([alt])");r.length>0&&(e.push(`${r.length} images missing alt text`),t.push("Add descriptive alt text to all images"));let u=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")),s=0;return u.forEach((n,a)=>{let c=parseInt(n.tagName[1]);a>0&&c>s+1&&(e.push(`Skipped heading level: ${n.tagName} after h${s}`),t.push("Ensure heading hierarchy is sequential")),s=c}),{score:Math.max(0,100-e.length*10),issues:e,recommendations:t}}};var p=A(require("react"),1),_=A(require("react-dom/client"),1),M=require("react/jsx-runtime");function x(e,t=!0,i={fixes:0,nodes:0,renderTime:0}){let r=i.nodes===0,u=r?performance.now():0;if(!p.default.isValidElement(e))return e;i.nodes++;let s=e,o={...s.props},n=s.type,a=!1;t&&(["input","textarea","select"].includes(n)&&!o["aria-label"]&&(o["aria-label"]=o.placeholder||o.name||`${n} field`,a=!0),n==="img"&&(o.alt===void 0||o.alt===null)&&(o.alt="",o["aria-hidden"]="true",a=!0),(n==="div"||n==="span")&&o.onClick&&(o.role||(o.role="button",a=!0),o.tabIndex===void 0&&(o.tabIndex=0,a=!0)),a&&i.fixes++);let c=p.default.Children.map(o.children,m=>p.default.isValidElement(m)?x(m,t,i):m),d=p.default.cloneElement(s,o,c);return r&&(i.renderTime=parseFloat((performance.now()-u).toFixed(2))),d}function F(e,t,i=!0){let r=document.querySelector(t);if(!r)return;let s=x(e,i,{fixes:0,nodes:0,renderTime:0});_.default.createRoot(r).render((0,M.jsx)(p.default.StrictMode,{children:s}))}var f=require("react");var l=require("react/jsx-runtime");function C({children:e}){let[t,i]=(0,f.useState)(!1),[r,u]=(0,f.useState)(!1),[s,o]=(0,f.useState)(!1),[n,a]=(0,f.useState)({fixes:0,nodes:0,renderTime:0}),c=(0,f.useRef)(null);(0,f.useEffect)(()=>{i(!0)},[]);let d={fixes:0,nodes:0,renderTime:0},m=(0,f.useMemo)(()=>x(e,r,d),[e,r]);return(0,f.useEffect)(()=>{t&&(n.fixes!==d.fixes||n.nodes!==d.nodes)&&a({...d})},[m,r,t]),(0,f.useEffect)(()=>{if(!s)return;let b=v=>{c.current&&!c.current.contains(v.target)&&o(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]),t?(0,l.jsxs)(l.Fragment,{children:[m,(0,l.jsx)("button",{onClick:()=>o(!0),style:{position:"fixed",bottom:25,right:25,width:60,height:60,borderRadius:"50%",background:"#1a202c",color:"white",border:"none",cursor:"pointer",zIndex:9999,boxShadow:"0 4px 20px rgba(0,0,0,0.25)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"28px"},children:"\u267F"}),s&&(0,l.jsxs)("div",{ref:c,style:{position:"fixed",bottom:95,right:25,width:340,background:"#ffffff",borderRadius:"20px",padding:"24px",boxShadow:"0 10px 40px rgba(0,0,0,0.15)",zIndex:1e4,border:"1px solid #f0f0f0",fontFamily:"system-ui, sans-serif"},children:[(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"20px"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,l.jsx)("span",{style:{fontSize:"22px"},children:"\u267F"}),(0,l.jsx)("strong",{style:{fontSize:"18px"},children:"ADA accessibility"})]}),(0,l.jsx)("button",{onClick:()=>o(!1),style:{background:"none",border:"none",cursor:"pointer",fontSize:"20px"},children:"\xD7"})]}),(0,l.jsx)("button",{onClick:()=>u(!r),style:{width:"100%",padding:"16px",borderRadius:"12px",border:"none",cursor:"pointer",fontWeight:"700",background:r?"#dcfce7":"#eff6ff",color:r?"#065f46":"#2563eb",marginBottom:"20px"},children:r?"Disable ADA Engine":"Enable ADA Engine"}),(0,l.jsx)("div",{style:{borderTop:"1px solid #edf2f7",paddingTop:"16px",fontSize:"12px",color:"#718096"},children:r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{style:{color:"#2d3748",fontWeight:"600",marginBottom:"4px"},children:["yuktai-a11y: ",n.fixes," fixes applied."]}),(0,l.jsxs)("div",{children:["Nodes scanned: ",n.nodes]}),(0,l.jsxs)("div",{style:{marginTop:"4px",color:"#a0aec0"},children:["Render time: ",n.renderTime,"ms"]})]}):(0,l.jsx)("div",{style:{fontStyle:"italic"},children:"ADA Engine is offline."})})]})]}):(0,l.jsx)(l.Fragment,{children:e})}function Y(){if(!globalThis.__yuktai_runtime__){let e=new h;e.register(k.name,k),e.register(E.name,E),e.register(R.name,R),e.register(w.name,w),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var L=Y(),P={render:F,list(){return L.getPlugins()},use(e){return L.use(e)}},K=P;0&&(module.exports={YuktAI,YuktAIWrapper});
|
|
1
|
+
"use strict";"use client";var q=Object.create;var S=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var U=(e,n)=>{for(var s in n)S(e,s,{get:n[s],enumerable:!0})},_=(e,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Y(n))!K.call(e,t)&&t!==s&&S(e,t,{get:()=>n[t],enumerable:!(a=V(n,t))||a.enumerable});return e};var B=(e,n,s)=>(s=e!=null?q(G(e)):{},_(n||!e||!e.__esModule?S(s,"default",{value:e,enumerable:!0}):s,e)),Z=e=>_(S({},"__esModule",{value:!0}),e);var ne={};U(ne,{YuktAI:()=>N,YuktAIWrapper:()=>z,default:()=>te});module.exports=Z(ne);var k=class{plugins=new Map;register(n,s){if(!s||typeof s.execute!="function")throw new Error(`Invalid plugin: ${n}`);this.plugins.set(n,s)}use(n){return this.plugins.get(n)}async run(n,s){try{let a=this.use(n);if(!a)throw new Error(`Plugin not found: ${n}`);return await a.execute(s)}catch(a){throw console.error(`[YuktAI Runtime Error in ${n}]:`,a),a}}getPlugins(){return Array.from(this.plugins.keys())}};var E={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var F={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var W=B(require("tesseract.js"),1),p=null,P=null;function J(e){let n=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(n)?"tel":/[\u0900-\u097F]/.test(n)?"hin":/[\u0B80-\u0BFF]/.test(n)?"tam":/[\u4E00-\u9FFF]/.test(n)?"chi_sim":/[\u3040-\u30FF]/.test(n)?"jpn":/[\u0600-\u06FF]/.test(n)?"ara":/[\u0400-\u04FF]/.test(n)?"rus":"eng"}async function Q(e){return p&&P===e||(p&&(await p.terminate(),p=null),p=await W.default.createWorker({langPath:"/tessdata",logger:()=>{}}),await p.loadLanguage(e),await p.initialize(e),P=e),p}var L={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let n=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),s=e.lang||J(await n.arrayBuffer())||"eng",a=await Q(s),{data:t}=await a.recognize(n),r=t.text?.trim();return r?{language:s,confidence:Math.round(t.confidence??0),text:r}:"\u26A0\uFE0F No text detected"}catch(n){return console.error("[ocrSmartPlugin]",n),"\u274C OCR failed"}}};var y=null,w=null,A={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"},u={name:"yuktai-a11y",version:"1.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai-a11y: disabled.";let n=this.applyFixes(e);return e.autoFix&&this.startObserver(e),`yuktai-a11y: ${n.fixed} fixes applied across ${n.scanned} nodes.`},applyFixes(e){let n={fixed:0,scanned:0,details:[]};if(typeof document>"u")return n;let s=document.querySelectorAll("*");if(n.scanned=s.length,s.forEach(a=>{let t=a,r=t.tagName.toLowerCase();if((r==="a"||r==="button")&&!t.innerText?.trim()&&!t.getAttribute("aria-label")){let l=t.getAttribute("title")||"Interactive element";t.setAttribute("aria-label",l),n.details.push({tag:r,fix:`aria-label="${l}"`,element:t.outerHTML.slice(0,60)}),n.fixed++}if(r==="img"&&!t.hasAttribute("alt")&&(t.setAttribute("alt",""),t.setAttribute("aria-hidden","true"),n.details.push({tag:r,fix:'alt="" aria-hidden="true"',element:t.outerHTML.slice(0,60)}),n.fixed++),(t.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(t).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(r)&&(t.getAttribute("role")||(t.setAttribute("role","button"),n.details.push({tag:r,fix:'role="button"',element:t.outerHTML.slice(0,60)}),n.fixed++),t.tabIndex<0&&(t.tabIndex=0,n.fixed++),t.onkeydown||(t.onkeydown=l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t.click())})),["input","select","textarea"].includes(r)){if(!t.getAttribute("aria-label")&&!t.getAttribute("aria-labelledby")){let f=t.getAttribute("placeholder")||t.getAttribute("name")||r;t.setAttribute("aria-label",f),n.details.push({tag:r,fix:`aria-label="${f}"`,element:t.outerHTML.slice(0,60)}),n.fixed++}t.hasAttribute("required")&&!t.getAttribute("aria-required")&&(t.setAttribute("aria-required","true"),n.fixed++);let l=t;r==="input"&&!l.autocomplete&&(l.name?.includes("email")?l.autocomplete="email":l.name?.includes("tel")&&(l.autocomplete="tel"))}if(r==="table"&&!a.querySelector("th")&&(t.getAttribute("role")||(t.setAttribute("role","grid"),n.details.push({tag:r,fix:'role="grid"',element:t.outerHTML.slice(0,60)}),n.fixed++)),r==="a"){let l=t;if(l.target==="_blank"){l.rel?.includes("noopener")||(l.rel="noopener noreferrer",n.fixed++);let f=l.getAttribute("aria-label")||(l.innerText?.trim()?l.innerText.trim():"link");f.includes("opens in new window")||(l.setAttribute("aria-label",`${f} (opens in new window)`),n.fixed++)}}let g={nav:"navigation",header:"banner",footer:"contentinfo",main:"main"};if(g[r]&&!t.getAttribute("role")&&(t.setAttribute("role",g[r]),n.fixed++),e.highContrast&&(t.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(t.style.transition="none",t.style.animation="none"),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1){let l=parseFloat(window.getComputedStyle(t).fontSize);t.style.fontSize=`${l*e.fontSizeMultiplier}px`}if(e.colorBlindMode&&e.colorBlindMode!=="none"){let l=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${A[e.colorBlindMode]})`;t.style.filter=(t.style.filter?t.style.filter+" ":"")+l}e.keyboardHints&&(t.tabIndex>=0||["button","a","input","select","textarea"].includes(r))&&(t.style.outline="2px solid #007acc",t.style.outlineOffset="2px")}),e.colorBlindMode&&e.colorBlindMode!=="none"&&!w){let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("aria-hidden","true"),a.style.display="none",a.innerHTML=`
|
|
2
|
+
<defs>
|
|
3
|
+
<filter id="${A.deuteranopia}">
|
|
4
|
+
<feColorMatrix type="matrix" values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
|
|
5
|
+
</filter>
|
|
6
|
+
<filter id="${A.protanopia}">
|
|
7
|
+
<feColorMatrix type="matrix" values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
|
|
8
|
+
</filter>
|
|
9
|
+
<filter id="${A.tritanopia}">
|
|
10
|
+
<feColorMatrix type="matrix" values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
|
|
11
|
+
</filter>
|
|
12
|
+
</defs>
|
|
13
|
+
`,document.body.appendChild(a),w=a}return this.ensureLiveRegion(),n},removeColorBlindSvg(){w?.remove(),w=null},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0}))},stopObserver(){this.observer?.disconnect(),this.observer=null},ensureLiveRegion(){if(typeof document>"u"||y)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e),y=e},removeLiveRegion(){y?.remove(),y=null},announce(e){y&&(y.textContent=e)}};var d=B(require("react"),1);var o=require("react/jsx-runtime"),C=null,m=null,H={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100},x=[80,90,100,110,120,130,140,150],$=[{id:"highContrast",label:"High contrast",description:"Boosts contrast and brightness on all elements",icon:"\u25D1"},{id:"reduceMotion",label:"Reduce motion",description:"Disables transitions and animations site-wide",icon:"\u23F8"},{id:"autoFix",label:"Auto-fix ARIA",description:"Re-runs fixes automatically on new DOM nodes",icon:"\u267F"},{id:"dyslexiaFont",label:"Dyslexia-friendly font",description:"Wider letter & word spacing for readability",icon:"Aa"}];function X({checked:e,onChange:n,label:s}){return(0,o.jsxs)("label",{"aria-label":s,style:{position:"relative",display:"inline-flex",width:40,height:24,cursor:"pointer",flexShrink:0},children:[(0,o.jsx)("input",{type:"checkbox",checked:e,onChange:a=>n(a.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,o.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:99,background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,o.jsx)("span",{style:{position:"absolute",top:3,left:e?19:3,width:18,height:18,background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function z({children:e}){let[n,s]=(0,d.useState)(!1),[a,t]=(0,d.useState)(!1),[r,M]=(0,d.useState)(H),[g,l]=(0,d.useState)(null),[f,I]=(0,d.useState)(!1),R=(0,d.useRef)(null),h=(0,d.useRef)(null);(0,d.useEffect)(()=>s(!0),[]),(0,d.useEffect)(()=>{if(C)return;let i=document.createElement("style");return i.innerHTML=`
|
|
14
|
+
*:focus-visible {
|
|
15
|
+
outline: 3px solid #0d9488 !important;
|
|
16
|
+
outline-offset: 2px !important;
|
|
17
|
+
box-shadow: 0 0 0 5px rgba(13,148,136,0.25) !important;
|
|
18
|
+
}
|
|
19
|
+
`,document.head.appendChild(i),C=i,()=>{C?.remove(),C=null}},[]),(0,d.useEffect)(()=>()=>{u.stopObserver(),u.removeLiveRegion(),u.removeColorBlindSvg()},[]),(0,d.useEffect)(()=>{if(!a)return;let i=c=>{R.current&&!R.current.contains(c.target)&&h.current&&!h.current.contains(c.target)&&t(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]),(0,d.useEffect)(()=>{let i=c=>{c.key==="Escape"&&a&&(t(!1),h.current?.focus())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[a]);let v=(i,c)=>M(b=>({...b,[i]:c})),D=(0,d.useCallback)(async()=>{let i={enabled:!0,highContrast:r.highContrast,reduceMotion:r.reduceMotion,autoFix:r.autoFix},c=await u.execute(i);console.log("[yuktai-a11y]",c);let b=u.applyFixes(i);if(l(b),document.documentElement.style.fontSize=`${r.fontScale}%`,r.dyslexiaFont){if(!m){let T=document.createElement("style");T.textContent=`
|
|
20
|
+
body, body * {
|
|
21
|
+
font-family: 'Georgia', serif !important;
|
|
22
|
+
letter-spacing: 0.06em !important;
|
|
23
|
+
word-spacing: 0.12em !important;
|
|
24
|
+
line-height: 1.9 !important;
|
|
25
|
+
}
|
|
26
|
+
`,document.head.appendChild(T),m=T}}else m?.remove(),m=null;I(!0),t(!1),u.announce(`yuktai-a11y active. ${b.fixed} fixes applied. `+[r.highContrast&&"High contrast on.",r.reduceMotion&&"Motion reduced.",r.dyslexiaFont&&"Dyslexia font on.",r.fontScale!==100&&`Text at ${r.fontScale}%.`].filter(Boolean).join(" "))},[r]),j=(0,d.useCallback)(async()=>{await u.execute({enabled:!1}),document.documentElement.style.fontSize="",m?.remove(),m=null,document.querySelectorAll("*").forEach(i=>{i.style.filter="",i.style.transition="",i.style.animation=""}),M(H),l(null),I(!1),u.announce("yuktai-a11y disabled. All settings reset to defaults.")},[]);return n?(0,o.jsxs)(o.Fragment,{children:[e,(0,o.jsxs)("button",{ref:h,onClick:()=>t(i=>!i),"aria-label":"Open yuktai-a11y accessibility options","aria-expanded":a,"aria-haspopup":"dialog",style:{position:"fixed",bottom:24,right:24,width:52,height:52,borderRadius:"50%",background:f?"#0f766e":"#0d9488",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 14px rgba(0,0,0,0.18)",zIndex:9999,transition:"background 0.2s, transform 0.15s",outline:"none"},onMouseEnter:i=>i.currentTarget.style.transform="scale(1.08)",onMouseLeave:i=>i.currentTarget.style.transform="scale(1)",onFocus:i=>i.currentTarget.style.boxShadow="0 0 0 4px rgba(13,148,136,0.45)",onBlur:i=>i.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.18)",children:[(0,o.jsx)("svg",{viewBox:"0 0 24 24",style:{width:26,height:26,fill:"#fff"},"aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4zm9 4.5l-5-.5-2-.2V5l-4 .5-4-.5v.8L4 6.5 3 7l1 3 4-.5v2.3L6 17h2l2-4.5L12 14l2 2.5L16 17h2l-2-4.2V9.5l4 .5 1-3z"})}),f&&(0,o.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:4,right:4,width:10,height:10,borderRadius:"50%",background:"#5eead4",border:"2px solid #fff"}})]}),a&&(0,o.jsxs)("div",{ref:R,role:"dialog","aria-modal":"true","aria-label":"yuktai-a11y accessibility options",style:{position:"fixed",bottom:88,right:24,width:312,background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:16,boxShadow:"0 8px 32px rgba(0,0,0,0.12)",zIndex:9998,overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif"},children:[(0,o.jsxs)("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:5},children:[(0,o.jsxs)("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:["yuktai-a11y v",u.version]}),f&&(0,o.jsx)("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),(0,o.jsx)("p",{style:{margin:"0 0 2px",fontSize:15,fontWeight:600,color:"#0f172a"},children:"Accessibility"}),(0,o.jsx)("p",{style:{margin:0,fontSize:12,color:"#64748b"},children:"Zero-config WCAG fixes for your page"})]}),(0,o.jsx)("button",{onClick:()=>t(!1),"aria-label":"Close panel",style:{background:"none",border:"none",cursor:"pointer",padding:4,color:"#94a3b8",fontSize:18,lineHeight:1,borderRadius:6},children:"\xD7"})]}),(0,o.jsx)("div",{style:{padding:"6px 0"},children:$.map((i,c)=>(0,o.jsxs)(d.default.Fragment,{children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:12},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1},children:[(0,o.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:"#f0fdfa",color:"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,flexShrink:0,fontWeight:700},children:i.icon}),(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:i.label}),(0,o.jsx)("p",{style:{margin:0,fontSize:11,color:"#94a3b8"},children:i.description})]})]}),(0,o.jsx)(X,{checked:r[i.id],onChange:b=>v(i.id,b),label:`Toggle ${i.label}`})]}),c<$.length-1&&(0,o.jsx)("div",{style:{height:1,background:"#f8fafc",margin:"0 18px"}})]},i.id))}),(0,o.jsxs)("div",{style:{padding:"10px 18px 14px",borderTop:"1px solid #f1f5f9"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[(0,o.jsx)("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:"Text size"}),(0,o.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:99},children:[r.fontScale,"%"]})]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,o.jsx)("button",{onClick:()=>{let i=x.indexOf(r.fontScale);i>0&&v("fontScale",x[i-1])},disabled:r.fontScale<=80,"aria-label":"Decrease text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:r.fontScale<=80?"not-allowed":"pointer",fontSize:16,color:r.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),(0,o.jsx)("div",{style:{flex:1,display:"flex",gap:3},children:x.map(i=>(0,o.jsx)("button",{onClick:()=>v("fontScale",i),"aria-label":`Set text size to ${i}%`,style:{flex:1,height:6,borderRadius:99,border:"none",cursor:"pointer",padding:0,background:i<=r.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},i))}),(0,o.jsx)("button",{onClick:()=>{let i=x.indexOf(r.fontScale);i<x.length-1&&v("fontScale",x[i+1])},disabled:r.fontScale>=150,"aria-label":"Increase text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:r.fontScale>=150?"not-allowed":"pointer",fontSize:16,color:r.fontScale>=150?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),g&&(0,o.jsxs)("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:8,fontSize:12,color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:["\u2713 yuktai-a11y: ",g.fixed," fixes across ",g.scanned," nodes"]}),(0,o.jsxs)("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[(0,o.jsx)("button",{onClick:j,style:{flex:1,padding:"8px 0",fontSize:13,fontWeight:500,borderRadius:9,border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),(0,o.jsx)("button",{onClick:D,style:{flex:2,padding:"8px 0",fontSize:13,fontWeight:600,borderRadius:9,border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})]}):(0,o.jsx)(o.Fragment,{children:e})}function ee(){if(!globalThis.__yuktai_runtime__){let e=new k;e.register(E.name,E),e.register(F.name,F),e.register(L.name,L),e.register(u.name,u),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var O=ee(),N={wcagPlugin:u,list(){return O.getPlugins()},use(e){return O.use(e)}},te=N;0&&(module.exports={YuktAI,YuktAIWrapper});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface Plugin {
|
|
5
5
|
name: string;
|
|
@@ -20,17 +20,46 @@ declare class Runtime {
|
|
|
20
20
|
getPlugins(): string[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
interface A11yConfig {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
highContrast?: boolean;
|
|
26
|
+
reduceMotion?: boolean;
|
|
27
|
+
autoFix?: boolean;
|
|
28
|
+
fontSizeMultiplier?: number;
|
|
29
|
+
colorBlindMode?: "none" | "deuteranopia" | "protanopia" | "tritanopia" | "achromatopsia";
|
|
30
|
+
keyboardHints?: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface A11yReport {
|
|
33
|
+
fixed: number;
|
|
34
|
+
scanned: number;
|
|
35
|
+
details: {
|
|
36
|
+
tag: string;
|
|
37
|
+
fix: string;
|
|
38
|
+
element: string;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
24
41
|
|
|
25
42
|
declare function YuktAIWrapper({ children }: {
|
|
26
|
-
children?:
|
|
43
|
+
children?: ReactNode;
|
|
27
44
|
}): react_jsx_runtime.JSX.Element;
|
|
28
45
|
|
|
29
46
|
declare global {
|
|
30
47
|
var __yuktai_runtime__: Runtime | undefined;
|
|
31
48
|
}
|
|
32
49
|
declare const YuktAI: {
|
|
33
|
-
|
|
50
|
+
wcagPlugin: {
|
|
51
|
+
name: string;
|
|
52
|
+
version: string;
|
|
53
|
+
observer: MutationObserver | null;
|
|
54
|
+
execute(config: A11yConfig): Promise<string>;
|
|
55
|
+
applyFixes(config: A11yConfig): A11yReport;
|
|
56
|
+
removeColorBlindSvg(): void;
|
|
57
|
+
startObserver(config: A11yConfig): void;
|
|
58
|
+
stopObserver(): void;
|
|
59
|
+
ensureLiveRegion(): void;
|
|
60
|
+
removeLiveRegion(): void;
|
|
61
|
+
announce(msg: string): void;
|
|
62
|
+
};
|
|
34
63
|
list(): string[];
|
|
35
64
|
use(name: string): Plugin | undefined;
|
|
36
65
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
interface Plugin {
|
|
5
5
|
name: string;
|
|
@@ -20,17 +20,46 @@ declare class Runtime {
|
|
|
20
20
|
getPlugins(): string[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
interface A11yConfig {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
highContrast?: boolean;
|
|
26
|
+
reduceMotion?: boolean;
|
|
27
|
+
autoFix?: boolean;
|
|
28
|
+
fontSizeMultiplier?: number;
|
|
29
|
+
colorBlindMode?: "none" | "deuteranopia" | "protanopia" | "tritanopia" | "achromatopsia";
|
|
30
|
+
keyboardHints?: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface A11yReport {
|
|
33
|
+
fixed: number;
|
|
34
|
+
scanned: number;
|
|
35
|
+
details: {
|
|
36
|
+
tag: string;
|
|
37
|
+
fix: string;
|
|
38
|
+
element: string;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
24
41
|
|
|
25
42
|
declare function YuktAIWrapper({ children }: {
|
|
26
|
-
children?:
|
|
43
|
+
children?: ReactNode;
|
|
27
44
|
}): react_jsx_runtime.JSX.Element;
|
|
28
45
|
|
|
29
46
|
declare global {
|
|
30
47
|
var __yuktai_runtime__: Runtime | undefined;
|
|
31
48
|
}
|
|
32
49
|
declare const YuktAI: {
|
|
33
|
-
|
|
50
|
+
wcagPlugin: {
|
|
51
|
+
name: string;
|
|
52
|
+
version: string;
|
|
53
|
+
observer: MutationObserver | null;
|
|
54
|
+
execute(config: A11yConfig): Promise<string>;
|
|
55
|
+
applyFixes(config: A11yConfig): A11yReport;
|
|
56
|
+
removeColorBlindSvg(): void;
|
|
57
|
+
startObserver(config: A11yConfig): void;
|
|
58
|
+
stopObserver(): void;
|
|
59
|
+
ensureLiveRegion(): void;
|
|
60
|
+
removeLiveRegion(): void;
|
|
61
|
+
announce(msg: string): void;
|
|
62
|
+
};
|
|
34
63
|
list(): string[];
|
|
35
64
|
use(name: string): Plugin | undefined;
|
|
36
65
|
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1,26 @@
|
|
|
1
|
-
"use client";var y=class{plugins=new Map;register(t,s){if(!s||typeof s.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,s)}use(t){return this.plugins.get(t)}async run(t,s){try{let r=this.use(t);if(!r)throw new Error(`Plugin not found: ${t}`);return await r.execute(s)}catch(r){throw console.error(`[YuktAI Runtime Error in ${t}]:`,r),r}}getPlugins(){return Array.from(this.plugins.keys())}};var A={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var k={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};import F from"tesseract.js";var f=null,T=null;function M(e){let t=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(t)?"tel":/[\u0900-\u097F]/.test(t)?"hin":/[\u0B80-\u0BFF]/.test(t)?"tam":/[\u4E00-\u9FFF]/.test(t)?"chi_sim":/[\u3040-\u30FF]/.test(t)?"jpn":/[\u0600-\u06FF]/.test(t)?"ara":/[\u0400-\u04FF]/.test(t)?"rus":"eng"}async function L(e){return f&&T===e||(f&&(await f.terminate(),f=null),f=await F.createWorker({langPath:"/tessdata",logger:()=>{}}),await f.loadLanguage(e),await f.initialize(e),T=e),f}var E={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let t=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),s=e.lang||M(await t.arrayBuffer())||"eng",r=await L(s),{data:l}=await r.recognize(t),o=l.text?.trim();return o?{language:s,confidence:Math.round(l.confidence??0),text:o}:"\u26A0\uFE0F No text detected"}catch(t){return console.error("[ocrSmartPlugin]",t),"\u274C OCR failed"}}};var R={name:"ui.a11y.pro",version:"1.0.1",observer:null,async execute(e){if(!e?.enabled)return this.stopObserver(),"yuktai-a11y: disabled";try{let t=this.applyFixes(e);if(e.autoFix&&this.startObserver(e),this.ensureLiveRegion(),this.announce(`Accessibility active. ${t.fixed} fixes applied.`),e.validate){let s=this.validatePage();return{...t,validation:s}}return t}catch(t){return console.error("WCAG Plugin execution error:",t),{fixed:0,scanned:0,errors:[t.message]}}},applyFixes(e){let t={fixed:0,scanned:0,errors:[]};if(typeof document>"u")return t;let s=e.root||document,r=e.skipFixes||[];try{let l=s.querySelectorAll("a,button,input,select,textarea,img,table,[onclick],[tabindex],h1,h2,h3,h4,h5,h6,iframe,video,audio,[role],[aria-label],[aria-labelledby]");t.scanned=l.length;let o=0;if(l.forEach(i=>{try{let n=i,a=n.tagName.toLowerCase();if(!r.includes("headings")&&/^h[1-6]$/.test(a)){let u=parseInt(a[1]);u>o+1&&o!==0&&(n.setAttribute("aria-level",String(o+1)),t.fixed++),o=u}if(!r.includes("buttons")&&(a==="a"||a==="button")&&!n.innerText.trim()&&!n.getAttribute("aria-label")){let u=n.getAttribute("title")||n.getAttribute("aria-label")||"Interactive element";n.setAttribute("aria-label",u),t.fixed++}if(r.includes("clickables")||(n.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(n).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(a)&&(n.getAttribute("role")||(n.setAttribute("role","button"),t.fixed++),n.tabIndex<0&&(n.tabIndex=0,t.fixed++),n._yuktKeyBound||(n.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),n.click())}),n._yuktKeyBound=!0)),!r.includes("forms")&&["input","select","textarea"].includes(a)){if(!n.getAttribute("aria-label")&&!n.getAttribute("aria-labelledby")){let u=n.getAttribute("placeholder")||n.getAttribute("name")||n.getAttribute("title")||a;n.setAttribute("aria-label",u),t.fixed++}n.hasAttribute("required")&&!n.getAttribute("aria-required")&&(n.setAttribute("aria-required","true"),t.fixed++)}!r.includes("images")&&a==="img"&&!n.hasAttribute("alt")&&(n.setAttribute("alt",""),n.setAttribute("aria-hidden","true"),t.fixed++),!r.includes("tables")&&a==="table"&&!i.querySelector("th")&&(n.getAttribute("role")||(n.setAttribute("role","grid"),t.fixed++)),!r.includes("media")&&["video","audio"].includes(a)&&(n.hasAttribute("controls")||(n.setAttribute("controls","true"),t.fixed++)),!r.includes("iframes")&&a==="iframe"&&!n.getAttribute("title")&&(n.setAttribute("title","Embedded content"),t.fixed++)}catch(n){t.errors.push(`Error fixing element ${i.tagName}: ${n.message}`)}}),e.highContrast&&(document.documentElement.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(document.documentElement.style.scrollBehavior="auto",!document.getElementById("yukt-reduce-motion"))){let i=document.createElement("style");i.id="yukt-reduce-motion",i.textContent="*, *::before, *::after { transition: none !important; animation: none !important; }",document.head.appendChild(i)}}catch(l){t.errors.push(`General error in applyFixes: ${l.message}`)}return t},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(t=>{clearTimeout(this._mutationTimer),this._mutationTimer=setTimeout(()=>{t.forEach(s=>{s.addedNodes.forEach(r=>{r instanceof HTMLElement&&this.applyFixes({...e,root:r})})})},100)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this._mutationTimer&&clearTimeout(this._mutationTimer)},cleanup(){this.stopObserver(),this.removeLiveRegion();let e=document.getElementById("yukt-reduce-motion");e&&e.remove(),typeof document<"u"&&(document.documentElement.style.filter="",document.documentElement.style.scrollBehavior="")},ensureLiveRegion(){if(typeof document>"u"||document.getElementById("yukt-sr-announcer"))return;let e=document.createElement("div");e.id="yukt-sr-announcer",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e)},removeLiveRegion(){if(typeof document>"u")return;let e=document.getElementById("yukt-sr-announcer");e&&e.remove()},announce(e){if(typeof document>"u")return;let t=document.getElementById("yukt-sr-announcer");t&&(t.textContent="",setTimeout(()=>{t.textContent=e},50))},checkContrast(e,t,s=4.5){try{return(l=>{let o=document.createElement("div");o.style.color=l,o.style.backgroundColor=t,document.body.appendChild(o);let i=window.getComputedStyle(o).color,n=window.getComputedStyle(o).backgroundColor;o.remove();let a=i.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/),u=n.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!a||!u)return 1;let c=this.rgbToLuminance(parseInt(a[1]),parseInt(a[2]),parseInt(a[3])),d=this.rgbToLuminance(parseInt(u[1]),parseInt(u[2]),parseInt(u[3])),b=Math.max(c,d),v=Math.min(c,d);return(b+.05)/(v+.05)})(e)>=s}catch(r){return console.warn("Contrast check failed:",r),!0}},validatePage(){let e=[],t=[];if(typeof document>"u")return{score:0,issues:["Server-side rendering detected"],recommendations:[]};document.documentElement.getAttribute("lang")||(e.push("Missing lang attribute on html element"),t.push('Add lang attribute to <html> element (e.g., <html lang="en">)')),document.title||(e.push("Missing page title"),t.push("Add a descriptive <title> element")),document.querySelectorAll('a,button,input,select,textarea,[tabindex]:not([tabindex="-1"])').length===0&&(e.push("No keyboard-focusable elements found"),t.push("Ensure interactive elements are keyboard accessible"));let r=document.querySelectorAll("img:not([alt])");r.length>0&&(e.push(`${r.length} images missing alt text`),t.push("Add descriptive alt text to all images"));let l=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")),o=0;return l.forEach((n,a)=>{let u=parseInt(n.tagName[1]);a>0&&u>o+1&&(e.push(`Skipped heading level: ${n.tagName} after h${o}`),t.push("Ensure heading hierarchy is sequential")),o=u}),{score:Math.max(0,100-e.length*10),issues:e,recommendations:t}}};import p from"react";import P from"react-dom/client";import{jsx as B}from"react/jsx-runtime";function h(e,t=!0,s={fixes:0,nodes:0,renderTime:0}){let r=s.nodes===0,l=r?performance.now():0;if(!p.isValidElement(e))return e;s.nodes++;let o=e,i={...o.props},n=o.type,a=!1;t&&(["input","textarea","select"].includes(n)&&!i["aria-label"]&&(i["aria-label"]=i.placeholder||i.name||`${n} field`,a=!0),n==="img"&&(i.alt===void 0||i.alt===null)&&(i.alt="",i["aria-hidden"]="true",a=!0),(n==="div"||n==="span")&&i.onClick&&(i.role||(i.role="button",a=!0),i.tabIndex===void 0&&(i.tabIndex=0,a=!0)),a&&s.fixes++);let u=p.Children.map(i.children,d=>p.isValidElement(d)?h(d,t,s):d),c=p.cloneElement(o,i,u);return r&&(s.renderTime=parseFloat((performance.now()-l).toFixed(2))),c}function I(e,t,s=!0){let r=document.querySelector(t);if(!r)return;let o=h(e,s,{fixes:0,nodes:0,renderTime:0});P.createRoot(r).render(B(p.StrictMode,{children:o}))}import{useState as x,useEffect as w,useRef as N,useMemo as $}from"react";import{Fragment as C,jsx as m,jsxs as g}from"react/jsx-runtime";function S({children:e}){let[t,s]=x(!1),[r,l]=x(!1),[o,i]=x(!1),[n,a]=x({fixes:0,nodes:0,renderTime:0}),u=N(null);w(()=>{s(!0)},[]);let c={fixes:0,nodes:0,renderTime:0},d=$(()=>h(e,r,c),[e,r]);return w(()=>{t&&(n.fixes!==c.fixes||n.nodes!==c.nodes)&&a({...c})},[d,r,t]),w(()=>{if(!o)return;let b=v=>{u.current&&!u.current.contains(v.target)&&i(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[o]),t?g(C,{children:[d,m("button",{onClick:()=>i(!0),style:{position:"fixed",bottom:25,right:25,width:60,height:60,borderRadius:"50%",background:"#1a202c",color:"white",border:"none",cursor:"pointer",zIndex:9999,boxShadow:"0 4px 20px rgba(0,0,0,0.25)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"28px"},children:"\u267F"}),o&&g("div",{ref:u,style:{position:"fixed",bottom:95,right:25,width:340,background:"#ffffff",borderRadius:"20px",padding:"24px",boxShadow:"0 10px 40px rgba(0,0,0,0.15)",zIndex:1e4,border:"1px solid #f0f0f0",fontFamily:"system-ui, sans-serif"},children:[g("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"20px"},children:[g("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[m("span",{style:{fontSize:"22px"},children:"\u267F"}),m("strong",{style:{fontSize:"18px"},children:"ADA accessibility"})]}),m("button",{onClick:()=>i(!1),style:{background:"none",border:"none",cursor:"pointer",fontSize:"20px"},children:"\xD7"})]}),m("button",{onClick:()=>l(!r),style:{width:"100%",padding:"16px",borderRadius:"12px",border:"none",cursor:"pointer",fontWeight:"700",background:r?"#dcfce7":"#eff6ff",color:r?"#065f46":"#2563eb",marginBottom:"20px"},children:r?"Disable ADA Engine":"Enable ADA Engine"}),m("div",{style:{borderTop:"1px solid #edf2f7",paddingTop:"16px",fontSize:"12px",color:"#718096"},children:r?g(C,{children:[g("div",{style:{color:"#2d3748",fontWeight:"600",marginBottom:"4px"},children:["yuktai-a11y: ",n.fixes," fixes applied."]}),g("div",{children:["Nodes scanned: ",n.nodes]}),g("div",{style:{marginTop:"4px",color:"#a0aec0"},children:["Render time: ",n.renderTime,"ms"]})]}):m("div",{style:{fontStyle:"italic"},children:"ADA Engine is offline."})})]})]}):m(C,{children:e})}function O(){if(!globalThis.__yuktai_runtime__){let e=new y;e.register(A.name,A),e.register(k.name,k),e.register(E.name,E),e.register(R.name,R),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var _=O(),q={render:I,list(){return _.getPlugins()},use(e){return _.use(e)}},le=q;export{q as YuktAI,S as YuktAIWrapper,le as default};
|
|
1
|
+
"use client";var w=class{plugins=new Map;register(n,d){if(!d||typeof d.execute!="function")throw new Error(`Invalid plugin: ${n}`);this.plugins.set(n,d)}use(n){return this.plugins.get(n)}async run(n,d){try{let a=this.use(n);if(!a)throw new Error(`Plugin not found: ${n}`);return await a.execute(d)}catch(a){throw console.error(`[YuktAI Runtime Error in ${n}]:`,a),a}}getPlugins(){return Array.from(this.plugins.keys())}};var F={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var L={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};import q from"tesseract.js";var p=null,_=null;function V(e){let n=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(n)?"tel":/[\u0900-\u097F]/.test(n)?"hin":/[\u0B80-\u0BFF]/.test(n)?"tam":/[\u4E00-\u9FFF]/.test(n)?"chi_sim":/[\u3040-\u30FF]/.test(n)?"jpn":/[\u0600-\u06FF]/.test(n)?"ara":/[\u0400-\u04FF]/.test(n)?"rus":"eng"}async function Y(e){return p&&_===e||(p&&(await p.terminate(),p=null),p=await q.createWorker({langPath:"/tessdata",logger:()=>{}}),await p.loadLanguage(e),await p.initialize(e),_=e),p}var z={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let n=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),d=e.lang||V(await n.arrayBuffer())||"eng",a=await Y(d),{data:t}=await a.recognize(n),o=t.text?.trim();return o?{language:d,confidence:Math.round(t.confidence??0),text:o}:"\u26A0\uFE0F No text detected"}catch(n){return console.error("[ocrSmartPlugin]",n),"\u274C OCR failed"}}};var y=null,A=null,C={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"},u={name:"yuktai-a11y",version:"1.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai-a11y: disabled.";let n=this.applyFixes(e);return e.autoFix&&this.startObserver(e),`yuktai-a11y: ${n.fixed} fixes applied across ${n.scanned} nodes.`},applyFixes(e){let n={fixed:0,scanned:0,details:[]};if(typeof document>"u")return n;let d=document.querySelectorAll("*");if(n.scanned=d.length,d.forEach(a=>{let t=a,o=t.tagName.toLowerCase();if((o==="a"||o==="button")&&!t.innerText?.trim()&&!t.getAttribute("aria-label")){let r=t.getAttribute("title")||"Interactive element";t.setAttribute("aria-label",r),n.details.push({tag:o,fix:`aria-label="${r}"`,element:t.outerHTML.slice(0,60)}),n.fixed++}if(o==="img"&&!t.hasAttribute("alt")&&(t.setAttribute("alt",""),t.setAttribute("aria-hidden","true"),n.details.push({tag:o,fix:'alt="" aria-hidden="true"',element:t.outerHTML.slice(0,60)}),n.fixed++),(t.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(t).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(o)&&(t.getAttribute("role")||(t.setAttribute("role","button"),n.details.push({tag:o,fix:'role="button"',element:t.outerHTML.slice(0,60)}),n.fixed++),t.tabIndex<0&&(t.tabIndex=0,n.fixed++),t.onkeydown||(t.onkeydown=r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.click())})),["input","select","textarea"].includes(o)){if(!t.getAttribute("aria-label")&&!t.getAttribute("aria-labelledby")){let f=t.getAttribute("placeholder")||t.getAttribute("name")||o;t.setAttribute("aria-label",f),n.details.push({tag:o,fix:`aria-label="${f}"`,element:t.outerHTML.slice(0,60)}),n.fixed++}t.hasAttribute("required")&&!t.getAttribute("aria-required")&&(t.setAttribute("aria-required","true"),n.fixed++);let r=t;o==="input"&&!r.autocomplete&&(r.name?.includes("email")?r.autocomplete="email":r.name?.includes("tel")&&(r.autocomplete="tel"))}if(o==="table"&&!a.querySelector("th")&&(t.getAttribute("role")||(t.setAttribute("role","grid"),n.details.push({tag:o,fix:'role="grid"',element:t.outerHTML.slice(0,60)}),n.fixed++)),o==="a"){let r=t;if(r.target==="_blank"){r.rel?.includes("noopener")||(r.rel="noopener noreferrer",n.fixed++);let f=r.getAttribute("aria-label")||(r.innerText?.trim()?r.innerText.trim():"link");f.includes("opens in new window")||(r.setAttribute("aria-label",`${f} (opens in new window)`),n.fixed++)}}let g={nav:"navigation",header:"banner",footer:"contentinfo",main:"main"};if(g[o]&&!t.getAttribute("role")&&(t.setAttribute("role",g[o]),n.fixed++),e.highContrast&&(t.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(t.style.transition="none",t.style.animation="none"),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1){let r=parseFloat(window.getComputedStyle(t).fontSize);t.style.fontSize=`${r*e.fontSizeMultiplier}px`}if(e.colorBlindMode&&e.colorBlindMode!=="none"){let r=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${C[e.colorBlindMode]})`;t.style.filter=(t.style.filter?t.style.filter+" ":"")+r}e.keyboardHints&&(t.tabIndex>=0||["button","a","input","select","textarea"].includes(o))&&(t.style.outline="2px solid #007acc",t.style.outlineOffset="2px")}),e.colorBlindMode&&e.colorBlindMode!=="none"&&!A){let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("aria-hidden","true"),a.style.display="none",a.innerHTML=`
|
|
2
|
+
<defs>
|
|
3
|
+
<filter id="${C.deuteranopia}">
|
|
4
|
+
<feColorMatrix type="matrix" values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
|
|
5
|
+
</filter>
|
|
6
|
+
<filter id="${C.protanopia}">
|
|
7
|
+
<feColorMatrix type="matrix" values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
|
|
8
|
+
</filter>
|
|
9
|
+
<filter id="${C.tritanopia}">
|
|
10
|
+
<feColorMatrix type="matrix" values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
|
|
11
|
+
</filter>
|
|
12
|
+
</defs>
|
|
13
|
+
`,document.body.appendChild(a),A=a}return this.ensureLiveRegion(),n},removeColorBlindSvg(){A?.remove(),A=null},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0}))},stopObserver(){this.observer?.disconnect(),this.observer=null},ensureLiveRegion(){if(typeof document>"u"||y)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e),y=e},removeLiveRegion(){y?.remove(),y=null},announce(e){y&&(y.textContent=e)}};import G,{useState as h,useEffect as v,useRef as B,useCallback as P}from"react";import{Fragment as $,jsx as l,jsxs as s}from"react/jsx-runtime";var M=null,m=null,W={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100},x=[80,90,100,110,120,130,140,150],H=[{id:"highContrast",label:"High contrast",description:"Boosts contrast and brightness on all elements",icon:"\u25D1"},{id:"reduceMotion",label:"Reduce motion",description:"Disables transitions and animations site-wide",icon:"\u23F8"},{id:"autoFix",label:"Auto-fix ARIA",description:"Re-runs fixes automatically on new DOM nodes",icon:"\u267F"},{id:"dyslexiaFont",label:"Dyslexia-friendly font",description:"Wider letter & word spacing for readability",icon:"Aa"}];function K({checked:e,onChange:n,label:d}){return s("label",{"aria-label":d,style:{position:"relative",display:"inline-flex",width:40,height:24,cursor:"pointer",flexShrink:0},children:[l("input",{type:"checkbox",checked:e,onChange:a=>n(a.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),l("span",{style:{position:"absolute",inset:0,borderRadius:99,background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),l("span",{style:{position:"absolute",top:3,left:e?19:3,width:18,height:18,background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function O({children:e}){let[n,d]=h(!1),[a,t]=h(!1),[o,R]=h(W),[g,r]=h(null),[f,I]=h(!1),T=B(null),S=B(null);v(()=>d(!0),[]),v(()=>{if(M)return;let i=document.createElement("style");return i.innerHTML=`
|
|
14
|
+
*:focus-visible {
|
|
15
|
+
outline: 3px solid #0d9488 !important;
|
|
16
|
+
outline-offset: 2px !important;
|
|
17
|
+
box-shadow: 0 0 0 5px rgba(13,148,136,0.25) !important;
|
|
18
|
+
}
|
|
19
|
+
`,document.head.appendChild(i),M=i,()=>{M?.remove(),M=null}},[]),v(()=>()=>{u.stopObserver(),u.removeLiveRegion(),u.removeColorBlindSvg()},[]),v(()=>{if(!a)return;let i=c=>{T.current&&!T.current.contains(c.target)&&S.current&&!S.current.contains(c.target)&&t(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]),v(()=>{let i=c=>{c.key==="Escape"&&a&&(t(!1),S.current?.focus())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[a]);let k=(i,c)=>R(b=>({...b,[i]:c})),D=P(async()=>{let i={enabled:!0,highContrast:o.highContrast,reduceMotion:o.reduceMotion,autoFix:o.autoFix},c=await u.execute(i);console.log("[yuktai-a11y]",c);let b=u.applyFixes(i);if(r(b),document.documentElement.style.fontSize=`${o.fontScale}%`,o.dyslexiaFont){if(!m){let E=document.createElement("style");E.textContent=`
|
|
20
|
+
body, body * {
|
|
21
|
+
font-family: 'Georgia', serif !important;
|
|
22
|
+
letter-spacing: 0.06em !important;
|
|
23
|
+
word-spacing: 0.12em !important;
|
|
24
|
+
line-height: 1.9 !important;
|
|
25
|
+
}
|
|
26
|
+
`,document.head.appendChild(E),m=E}}else m?.remove(),m=null;I(!0),t(!1),u.announce(`yuktai-a11y active. ${b.fixed} fixes applied. `+[o.highContrast&&"High contrast on.",o.reduceMotion&&"Motion reduced.",o.dyslexiaFont&&"Dyslexia font on.",o.fontScale!==100&&`Text at ${o.fontScale}%.`].filter(Boolean).join(" "))},[o]),j=P(async()=>{await u.execute({enabled:!1}),document.documentElement.style.fontSize="",m?.remove(),m=null,document.querySelectorAll("*").forEach(i=>{i.style.filter="",i.style.transition="",i.style.animation=""}),R(W),r(null),I(!1),u.announce("yuktai-a11y disabled. All settings reset to defaults.")},[]);return n?s($,{children:[e,s("button",{ref:S,onClick:()=>t(i=>!i),"aria-label":"Open yuktai-a11y accessibility options","aria-expanded":a,"aria-haspopup":"dialog",style:{position:"fixed",bottom:24,right:24,width:52,height:52,borderRadius:"50%",background:f?"#0f766e":"#0d9488",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 14px rgba(0,0,0,0.18)",zIndex:9999,transition:"background 0.2s, transform 0.15s",outline:"none"},onMouseEnter:i=>i.currentTarget.style.transform="scale(1.08)",onMouseLeave:i=>i.currentTarget.style.transform="scale(1)",onFocus:i=>i.currentTarget.style.boxShadow="0 0 0 4px rgba(13,148,136,0.45)",onBlur:i=>i.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.18)",children:[l("svg",{viewBox:"0 0 24 24",style:{width:26,height:26,fill:"#fff"},"aria-hidden":"true",children:l("path",{d:"M12 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4zm9 4.5l-5-.5-2-.2V5l-4 .5-4-.5v.8L4 6.5 3 7l1 3 4-.5v2.3L6 17h2l2-4.5L12 14l2 2.5L16 17h2l-2-4.2V9.5l4 .5 1-3z"})}),f&&l("span",{"aria-hidden":"true",style:{position:"absolute",top:4,right:4,width:10,height:10,borderRadius:"50%",background:"#5eead4",border:"2px solid #fff"}})]}),a&&s("div",{ref:T,role:"dialog","aria-modal":"true","aria-label":"yuktai-a11y accessibility options",style:{position:"fixed",bottom:88,right:24,width:312,background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:16,boxShadow:"0 8px 32px rgba(0,0,0,0.12)",zIndex:9998,overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif"},children:[s("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[s("div",{children:[s("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:5},children:[s("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:["yuktai-a11y v",u.version]}),f&&l("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),l("p",{style:{margin:"0 0 2px",fontSize:15,fontWeight:600,color:"#0f172a"},children:"Accessibility"}),l("p",{style:{margin:0,fontSize:12,color:"#64748b"},children:"Zero-config WCAG fixes for your page"})]}),l("button",{onClick:()=>t(!1),"aria-label":"Close panel",style:{background:"none",border:"none",cursor:"pointer",padding:4,color:"#94a3b8",fontSize:18,lineHeight:1,borderRadius:6},children:"\xD7"})]}),l("div",{style:{padding:"6px 0"},children:H.map((i,c)=>s(G.Fragment,{children:[s("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:12},children:[s("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1},children:[l("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:"#f0fdfa",color:"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,flexShrink:0,fontWeight:700},children:i.icon}),s("div",{children:[l("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:i.label}),l("p",{style:{margin:0,fontSize:11,color:"#94a3b8"},children:i.description})]})]}),l(K,{checked:o[i.id],onChange:b=>k(i.id,b),label:`Toggle ${i.label}`})]}),c<H.length-1&&l("div",{style:{height:1,background:"#f8fafc",margin:"0 18px"}})]},i.id))}),s("div",{style:{padding:"10px 18px 14px",borderTop:"1px solid #f1f5f9"},children:[s("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[l("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:"Text size"}),s("span",{style:{fontSize:12,fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:99},children:[o.fontScale,"%"]})]}),s("div",{style:{display:"flex",alignItems:"center",gap:8},children:[l("button",{onClick:()=>{let i=x.indexOf(o.fontScale);i>0&&k("fontScale",x[i-1])},disabled:o.fontScale<=80,"aria-label":"Decrease text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:o.fontScale<=80?"not-allowed":"pointer",fontSize:16,color:o.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),l("div",{style:{flex:1,display:"flex",gap:3},children:x.map(i=>l("button",{onClick:()=>k("fontScale",i),"aria-label":`Set text size to ${i}%`,style:{flex:1,height:6,borderRadius:99,border:"none",cursor:"pointer",padding:0,background:i<=o.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},i))}),l("button",{onClick:()=>{let i=x.indexOf(o.fontScale);i<x.length-1&&k("fontScale",x[i+1])},disabled:o.fontScale>=150,"aria-label":"Increase text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:o.fontScale>=150?"not-allowed":"pointer",fontSize:16,color:o.fontScale>=150?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),g&&s("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:8,fontSize:12,color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:["\u2713 yuktai-a11y: ",g.fixed," fixes across ",g.scanned," nodes"]}),s("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[l("button",{onClick:j,style:{flex:1,padding:"8px 0",fontSize:13,fontWeight:500,borderRadius:9,border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),l("button",{onClick:D,style:{flex:2,padding:"8px 0",fontSize:13,fontWeight:600,borderRadius:9,border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})]}):l($,{children:e})}function U(){if(!globalThis.__yuktai_runtime__){let e=new w;e.register(F.name,F),e.register(L.name,L),e.register(z.name,z),e.register(u.name,u),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var N=U(),Z={wcagPlugin:u,list(){return N.getPlugins()},use(e){return N.use(e)}},ge=Z;export{Z as YuktAI,O as YuktAIWrapper,ge as default};
|