@yuktishaalaa/yuktai 2.0.18 → 2.0.19

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.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var He=Object.create;var F=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var Ne=(e,t)=>{for(var o in t)F(e,o,{get:t[o],enumerable:!0})},ce=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Fe(t))!Oe.call(e,n)&&n!==o&&F(e,n,{get:()=>t[n],enumerable:!(a=$e(t,n))||a.enumerable});return e};var Be=(e,t,o)=>(o=e!=null?He(We(e)):{},ce(t||!e||!e.__esModule?F(o,"default",{value:e,enumerable:!0}):o,e)),_e=e=>ce(F({},"__esModule",{value:!0}),e);var bt={};Ne(bt,{Runtime:()=>S,YuktAI:()=>mt,YuktAIWrapper:()=>j,aiPlugin:()=>z,default:()=>j,voicePlugin:()=>I,wcag:()=>h,wcagPlugin:()=>h});module.exports=_e(bt);async function Z(){try{return window.ai?.rewriter?(await window.ai.rewriter.capabilities()).available!=="no":!1}catch{return!1}}async function De(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=await window.ai.rewriter.create({tone:"more-casual",format:"plain-text",length:"as-is"}),o=await t.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return t.destroy(),{success:!0,original:e,rewritten:o.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function ue(){if(!await Z())return{fixed:0,error:"Chrome Built-in AI not available on this device. Chrome 127+ required."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),o=0;for(let a of t){let n=a.innerText?.trim();if(!n||n.length<20||a.closest("[data-yuktai-panel]"))continue;let s=await De(n);s.success&&s.rewritten!==n&&(a.dataset.yuktaiOriginal=n,a.innerText=s.rewritten,o++)}return{fixed:o}}function pe(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let o=t.dataset.yuktaiOriginal;o&&(t.innerText=o,delete t.dataset.yuktaiOriginal)}}var fe="yuktai-summary-box";async function Q(){try{return window.ai?.summarizer?(await window.ai.summarizer.capabilities()).available!=="no":!1}catch{return!1}}function qe(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let o of e){if(o.closest("[data-yuktai-panel]"))continue;let a=window.getComputedStyle(o);if(a.display==="none"||a.visibility==="hidden")continue;let n=o.innerText?.trim();n&&n.length>10&&t.push(n)}return t.join(" ").slice(0,5e3)}async function me(){if(!await Q())return{success:!1,summary:"",error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=qe();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let o=await window.ai.summarizer.create({type:"tl;dr",format:"plain-text",length:"short"}),a=await o.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return o.destroy(),Ge(a.trim()),{success:!0,summary:a.trim()}}catch(o){return{success:!1,summary:"",error:o instanceof Error?o.message:"Summary failed"}}}function Ge(e){W();let t=document.createElement("div");t.id=fe,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
1
+ "use strict";var $e=Object.create;var O=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var Be=(e,t)=>{for(var o in t)O(e,o,{get:t[o],enumerable:!0})},ue=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of We(t))!Ne.call(e,a)&&a!==o&&O(e,a,{get:()=>t[a],enumerable:!(n=Fe(t,a))||n.enumerable});return e};var _e=(e,t,o)=>(o=e!=null?$e(Oe(e)):{},ue(t||!e||!e.__esModule?O(o,"default",{value:e,enumerable:!0}):o,e)),De=e=>ue(O({},"__esModule",{value:!0}),e);var gt={};Be(gt,{Runtime:()=>E,YuktAI:()=>bt,YuktAIWrapper:()=>Y,aiPlugin:()=>I,default:()=>Y,voicePlugin:()=>H,wcag:()=>w,wcagPlugin:()=>w});module.exports=De(gt);async function Q(){try{return window.ai?.rewriter?(await window.ai.rewriter.capabilities()).available!=="no":!1}catch{return!1}}async function qe(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=await window.ai.rewriter.create({tone:"more-casual",format:"plain-text",length:"as-is"}),o=await t.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return t.destroy(),{success:!0,original:e,rewritten:o.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function pe(){if(!await Q())return{fixed:0,error:"Chrome Built-in AI not available on this device. Chrome 127+ required."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),o=0;for(let n of t){let a=n.innerText?.trim();if(!a||a.length<20||n.closest("[data-yuktai-panel]"))continue;let s=await qe(a);s.success&&s.rewritten!==a&&(n.dataset.yuktaiOriginal=a,n.innerText=s.rewritten,o++)}return{fixed:o}}function fe(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let o=t.dataset.yuktaiOriginal;o&&(t.innerText=o,delete t.dataset.yuktaiOriginal)}}var me="yuktai-summary-box";async function ee(){try{return window.ai?.summarizer?(await window.ai.summarizer.capabilities()).available!=="no":!1}catch{return!1}}function Ge(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let o of e){if(o.closest("[data-yuktai-panel]"))continue;let n=window.getComputedStyle(o);if(n.display==="none"||n.visibility==="hidden")continue;let a=o.innerText?.trim();a&&a.length>10&&t.push(a)}return t.join(" ").slice(0,5e3)}async function be(){if(!await ee())return{success:!1,summary:"",error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=Ge();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let o=await window.ai.summarizer.create({type:"tl;dr",format:"plain-text",length:"short"}),n=await o.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return o.destroy(),Ve(n.trim()),{success:!0,summary:n.trim()}}catch(o){return{success:!1,summary:"",error:o instanceof Error?o.message:"Summary failed"}}}function Ve(e){N();let t=document.createElement("div");t.id=me,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -15,7 +15,7 @@
15
15
  justify-content: space-between;
16
16
  gap: 12px;
17
17
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
18
- `;let o=document.createElement("p");o.style.cssText="margin: 0; flex: 1;",o.textContent=`\u{1F4CB} Page summary: ${e}`;let a=document.createElement("button");a.textContent="\xD7",a.setAttribute("aria-label","Close page summary"),a.style.cssText=`
18
+ `;let o=document.createElement("p");o.style.cssText="margin: 0; flex: 1;",o.textContent=`\u{1F4CB} Page summary: ${e}`;let n=document.createElement("button");n.textContent="\xD7",n.setAttribute("aria-label","Close page summary"),n.style.cssText=`
19
19
  background: none;
20
20
  border: none;
21
21
  color: #ffffff;
@@ -24,7 +24,7 @@
24
24
  padding: 0 4px;
25
25
  line-height: 1;
26
26
  flex-shrink: 0;
27
- `,a.addEventListener("click",W),t.appendChild(o),t.appendChild(a),document.body.prepend(t)}function W(){let e=document.getElementById(fe);e&&e.remove()}var N=[{code:"en",label:"English"},{code:"hi",label:"Hindi"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"nl",label:"Dutch"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"zh",label:"Chinese"},{code:"ar",label:"Arabic"},{code:"tr",label:"Turkish"},{code:"vi",label:"Vietnamese"},{code:"bn",label:"Bengali"},{code:"id",label:"Indonesian"}],O="en";async function Ve(e){try{return window.translation?await window.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function be(e){if(e===O)return{success:!0,language:e,fixed:0};if(e==="en")return ee(),O="en",{success:!0,language:"en",fixed:0};if(!await Ve(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Chrome 127+ required.`};try{let o=await window.translation.createTranslator({sourceLanguage:"en",targetLanguage:e}),a=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),n=0;for(let s of a){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let i=s.innerText?.trim();if(!i||i.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=i);let d=await o.translate(i);d&&d!==i&&(s.innerText=d,n++)}return o.destroy(),O=e,{success:!0,language:e,fixed:n}}catch(o){return{success:!1,language:e,fixed:0,error:o instanceof Error?o.message:"Translation failed"}}}function ee(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let o=t.dataset.yuktaiTranslationOriginal;o&&(t.innerText=o,delete t.dataset.yuktaiTranslationOriginal)}O="en"}var je=[{phrases:["go to main","skip to main","main content"],action:"focus-main",label:"Jump to main content"},{phrases:["go to navigation","go to nav","open menu"],action:"focus-nav",label:"Jump to navigation"},{phrases:["go to search","search","find"],action:"focus-search",label:"Jump to search"},{phrases:["scroll down","page down","next"],action:"scroll-down",label:"Scroll down"},{phrases:["scroll up","page up","back up"],action:"scroll-up",label:"Scroll up"},{phrases:["go back","previous page"],action:"go-back",label:"Go back"},{phrases:["click","press","select"],action:"click-focused",label:"Click focused element"},{phrases:["next item","tab forward","tab"],action:"tab-forward",label:"Move to next element"},{phrases:["previous item","tab back","shift tab"],action:"tab-back",label:"Move to previous element"},{phrases:["stop listening","stop voice","quiet"],action:"stop-voice",label:"Stop voice control"}],w=null,B=!1,C=null;function te(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function Ke(e){let t=e.toLowerCase().trim();for(let o of je)for(let a of o.phrases)if(t.includes(a))return{action:o.action,label:o.label};return null}function Ye(e){switch(e){case"focus-main":{let t=document.querySelector("main, [role='main'], #main");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-nav":{let t=document.querySelector("nav, [role='navigation']");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-search":{let t=document.querySelector("input[type='search'], input[role='searchbox'], [aria-label*='search' i]");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"scroll-down":{window.scrollBy({top:400,behavior:"smooth"});break}case"scroll-up":{window.scrollBy({top:-400,behavior:"smooth"});break}case"go-back":{window.history.back();break}case"click-focused":{let t=document.activeElement;t&&t!==document.body&&t.click();break}case"tab-forward":{let t=ge(),o=t.indexOf(document.activeElement),a=t[o+1]||t[0];a&&a.focus();break}case"tab-back":{let t=ge(),o=t.indexOf(document.activeElement),a=t[o-1]||t[t.length-1];a&&a.focus();break}case"stop-voice":{oe();break}}}function ge(){return Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>!e.closest("[data-yuktai-panel]"))}function xe(e){if(!te())return!1;if(B)return!0;e&&(C=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return w=new t,w.continuous=!0,w.interimResults=!1,w.lang="en-US",w.onresult=o=>{let a=o.results[o.results.length-1][0].transcript,n=Ke(a);if(n){Ye(n.action);let s={success:!0,command:a,action:n.label};if(C&&C(s),n.action==="stop-voice")return}},w.onend=()=>{B&&w?.start()},w.onerror=o=>{o.error!=="no-speech"&&C&&C({success:!1,command:"",action:"",error:`Voice error: ${o.error}`})},w.start(),B=!0,Ue(),!0}function oe(){B=!1,w&&(w.stop(),w=null),C=null,he()}var ye="yuktai-voice-indicator";function Ue(){he();let e=document.createElement("div");e.id=ye,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
27
+ `,n.addEventListener("click",N),t.appendChild(o),t.appendChild(n),document.body.prepend(t)}function N(){let e=document.getElementById(me);e&&e.remove()}var _=[{code:"en",label:"English"},{code:"hi",label:"Hindi"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"nl",label:"Dutch"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"zh",label:"Chinese"},{code:"ar",label:"Arabic"},{code:"tr",label:"Turkish"},{code:"vi",label:"Vietnamese"},{code:"bn",label:"Bengali"},{code:"id",label:"Indonesian"}],B="en";async function je(e){try{return window.translation?await window.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function ge(e){if(e===B)return{success:!0,language:e,fixed:0};if(e==="en")return te(),B="en",{success:!0,language:"en",fixed:0};if(!await je(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Chrome 127+ required.`};try{let o=await window.translation.createTranslator({sourceLanguage:"en",targetLanguage:e}),n=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),a=0;for(let s of n){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let i=s.innerText?.trim();if(!i||i.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=i);let d=await o.translate(i);d&&d!==i&&(s.innerText=d,a++)}return o.destroy(),B=e,{success:!0,language:e,fixed:a}}catch(o){return{success:!1,language:e,fixed:0,error:o instanceof Error?o.message:"Translation failed"}}}function te(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let o=t.dataset.yuktaiTranslationOriginal;o&&(t.innerText=o,delete t.dataset.yuktaiTranslationOriginal)}B="en"}var Ke=[{phrases:["go to main","skip to main","main content"],action:"focus-main",label:"Jump to main content"},{phrases:["go to navigation","go to nav","open menu"],action:"focus-nav",label:"Jump to navigation"},{phrases:["go to search","search","find"],action:"focus-search",label:"Jump to search"},{phrases:["scroll down","page down","next"],action:"scroll-down",label:"Scroll down"},{phrases:["scroll up","page up","back up"],action:"scroll-up",label:"Scroll up"},{phrases:["go back","previous page"],action:"go-back",label:"Go back"},{phrases:["click","press","select"],action:"click-focused",label:"Click focused element"},{phrases:["next item","tab forward","tab"],action:"tab-forward",label:"Move to next element"},{phrases:["previous item","tab back","shift tab"],action:"tab-back",label:"Move to previous element"},{phrases:["stop listening","stop voice","quiet"],action:"stop-voice",label:"Stop voice control"}],v=null,D=!1,C=null;function oe(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function Ye(e){let t=e.toLowerCase().trim();for(let o of Ke)for(let n of o.phrases)if(t.includes(n))return{action:o.action,label:o.label};return null}function Ue(e){switch(e){case"focus-main":{let t=document.querySelector("main, [role='main'], #main");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-nav":{let t=document.querySelector("nav, [role='navigation']");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-search":{let t=document.querySelector("input[type='search'], input[role='searchbox'], [aria-label*='search' i]");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"scroll-down":{window.scrollBy({top:400,behavior:"smooth"});break}case"scroll-up":{window.scrollBy({top:-400,behavior:"smooth"});break}case"go-back":{window.history.back();break}case"click-focused":{let t=document.activeElement;t&&t!==document.body&&t.click();break}case"tab-forward":{let t=ye(),o=t.indexOf(document.activeElement),n=t[o+1]||t[0];n&&n.focus();break}case"tab-back":{let t=ye(),o=t.indexOf(document.activeElement),n=t[o-1]||t[t.length-1];n&&n.focus();break}case"stop-voice":{ie();break}}}function ye(){return Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>!e.closest("[data-yuktai-panel]"))}function xe(e){if(!oe())return!1;if(D)return!0;e&&(C=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return v=new t,v.continuous=!0,v.interimResults=!1,v.lang="en-US",v.onresult=o=>{let n=o.results[o.results.length-1][0].transcript,a=Ye(n);if(a){Ue(a.action);let s={success:!0,command:n,action:a.label};if(C&&C(s),a.action==="stop-voice")return}},v.onend=()=>{D&&v?.start()},v.onerror=o=>{o.error!=="no-speech"&&C&&C({success:!1,command:"",action:"",error:`Voice error: ${o.error}`})},v.start(),D=!0,Je(),!0}function ie(){D=!1,v&&(v.stop(),v=null),C=null,we()}var he="yuktai-voice-indicator";function Je(){we();let e=document.createElement("div");e.id=he,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
28
28
  position: fixed;
29
29
  bottom: 80px;
30
30
  left: 50%;
@@ -49,12 +49,12 @@
49
49
  background: #ffffff;
50
50
  animation: yuktai-pulse 1.2s infinite;
51
51
  flex-shrink: 0;
52
- `,!document.getElementById("yuktai-pulse-style")){let a=document.createElement("style");a.id="yuktai-pulse-style",a.textContent=`
52
+ `,!document.getElementById("yuktai-pulse-style")){let n=document.createElement("style");n.id="yuktai-pulse-style",n.textContent=`
53
53
  @keyframes yuktai-pulse {
54
54
  0%, 100% { opacity: 1; transform: scale(1); }
55
55
  50% { opacity: 0.4; transform: scale(0.7); }
56
56
  }
57
- `,document.head.appendChild(a)}let o=document.createElement("span");o.textContent="Listening for commands...",e.appendChild(t),e.appendChild(o),document.body.appendChild(e)}function he(){let e=document.getElementById(ye);e&&e.remove()}var Je=["button:not([aria-label]):not([aria-labelledby])","a:not([aria-label]):not([aria-labelledby])","input:not([aria-label]):not([aria-labelledby]):not([id])","select:not([aria-label]):not([aria-labelledby])","textarea:not([aria-label]):not([aria-labelledby])","[role='button']:not([aria-label])","[role='link']:not([aria-label])","[role='checkbox']:not([aria-label])","[role='tab']:not([aria-label])"].join(", ");async function ie(){try{return window.ai?.writer?(await window.ai.writer.capabilities()).available!=="no":!1}catch{return!1}}function Xe(e){let t=[],o=e.innerText?.trim();o&&t.push(`element text: "${o}"`);let a=e.placeholder?.trim();a&&t.push(`placeholder: "${a}"`);let n=e.getAttribute("name")?.trim();n&&t.push(`name: "${n}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let i=e.id;if(i){let p=document.querySelector(`label[for="${i}"]`);p&&t.push(`label: "${p.innerText?.trim()}"`)}let d=e.parentElement?.innerText?.trim().slice(0,60);d&&t.push(`parent context: "${d}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let f=e.getAttribute("role");return f&&t.push(`role: ${f}`),t.join(". ")}async function Ze(e,t){let o=`
57
+ `,document.head.appendChild(n)}let o=document.createElement("span");o.textContent="Listening for commands...",e.appendChild(t),e.appendChild(o),document.body.appendChild(e)}function we(){let e=document.getElementById(he);e&&e.remove()}var Xe=["button:not([aria-label]):not([aria-labelledby])","a:not([aria-label]):not([aria-labelledby])","input:not([aria-label]):not([aria-labelledby]):not([id])","select:not([aria-label]):not([aria-labelledby])","textarea:not([aria-label]):not([aria-labelledby])","[role='button']:not([aria-label])","[role='link']:not([aria-label])","[role='checkbox']:not([aria-label])","[role='tab']:not([aria-label])"].join(", ");async function ae(){try{return window.ai?.writer?(await window.ai.writer.capabilities()).available!=="no":!1}catch{return!1}}function Ze(e){let t=[],o=e.innerText?.trim();o&&t.push(`element text: "${o}"`);let n=e.placeholder?.trim();n&&t.push(`placeholder: "${n}"`);let a=e.getAttribute("name")?.trim();a&&t.push(`name: "${a}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let i=e.id;if(i){let p=document.querySelector(`label[for="${i}"]`);p&&t.push(`label: "${p.innerText?.trim()}"`)}let d=e.parentElement?.innerText?.trim().slice(0,60);d&&t.push(`parent context: "${d}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let f=e.getAttribute("role");return f&&t.push(`role: ${f}`),t.join(". ")}async function Qe(e,t){let o=`
58
58
  Generate a short, clear aria-label for an HTML element.
59
59
  The label must be 2-6 words maximum.
60
60
  The label must describe what the element does or what it is.
@@ -65,7 +65,7 @@
65
65
  ${t}
66
66
 
67
67
  Output only the label. Nothing else.
68
- `.trim();return(await e.write(o)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function we(){if(!await ie())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=document.querySelectorAll(Je);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let o=await window.ai.writer.create({tone:"neutral",format:"plain-text",length:"short"}),a=0,n=[];for(let s of t){if(s.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(s);if(i.display==="none"||i.visibility==="hidden")continue;let d=Xe(s),f=await Ze(o,d);f&&f.length>0&&(s.dataset.yuktaiLabelOriginal=s.getAttribute("aria-label")||"",s.setAttribute("aria-label",f),a++,n.push({tag:s.tagName.toLowerCase(),label:f}))}return o.destroy(),{success:!0,fixed:a,elements:n}}catch(o){return{success:!1,fixed:0,elements:[],error:o instanceof Error?o.message:"Label generation failed"}}}function ve(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let o=t.dataset.yuktaiLabelOriginal;o?t.setAttribute("aria-label",o):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var q=null,ke=null;var Ae=null,ne=null,m=null,L=null,_=null,ae=null,M=null,D={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Se=new Set(["input","select","textarea"]);var re={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function se(e,t="polite"){if(typeof window>"u"||!M?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let o=new SpeechSynthesisUtterance(e);o.rate=1,o.pitch=1,o.volume=1;let a=window.speechSynthesis.getVoices();a.length>0&&(o.voice=a[0]),window.speechSynthesis.speak(o)}function Pe(e,t="info"){if(typeof document>"u")return;let a={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];m||(m=document.createElement("div"),m.setAttribute("role","alert"),m.setAttribute("aria-live","assertive"),m.setAttribute("aria-atomic","true"),m.style.cssText=`
68
+ `.trim();return(await e.write(o)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function ve(){if(!await ae())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=document.querySelectorAll(Xe);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let o=await window.ai.writer.create({tone:"neutral",format:"plain-text",length:"short"}),n=0,a=[];for(let s of t){if(s.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(s);if(i.display==="none"||i.visibility==="hidden")continue;let d=Ze(s),f=await Qe(o,d);f&&f.length>0&&(s.dataset.yuktaiLabelOriginal=s.getAttribute("aria-label")||"",s.setAttribute("aria-label",f),n++,a.push({tag:s.tagName.toLowerCase(),label:f}))}return o.destroy(),{success:!0,fixed:n,elements:a}}catch(o){return{success:!1,fixed:0,elements:[],error:o instanceof Error?o.message:"Label generation failed"}}}function ke(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let o=t.dataset.yuktaiLabelOriginal;o?t.setAttribute("aria-label",o):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var V=null,Ae=null;var Se=null,ne=null,m=null,L=null,q=null,re=null,M=null,G={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Ee=new Set(["input","select","textarea"]);var se={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function le(e,t="polite"){if(typeof window>"u"||!M?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let o=new SpeechSynthesisUtterance(e);o.rate=1,o.pitch=1,o.volume=1;let n=window.speechSynthesis.getVoices();n.length>0&&(o.voice=n[0]),window.speechSynthesis.speak(o)}function ze(e,t="info"){if(typeof document>"u")return;let n={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];m||(m=document.createElement("div"),m.setAttribute("role","alert"),m.setAttribute("aria-live","assertive"),m.setAttribute("aria-atomic","true"),m.style.cssText=`
69
69
  position: fixed;
70
70
  top: 80px;
71
71
  right: 16px;
@@ -84,14 +84,14 @@
84
84
  transition: transform 0.3s, opacity 0.3s;
85
85
  transform: translateX(120%);
86
86
  opacity: 0;
87
- `,document.body.appendChild(m)),m.style.background=a.bg,m.style.border=`1px solid ${a.border}`,m.style.color="#fff",m.innerHTML=`
88
- <span style="font-size:18px;font-weight:700">${a.icon}</span>
87
+ `,document.body.appendChild(m)),m.style.background=n.bg,m.style.border=`1px solid ${n.border}`,m.style.color="#fff",m.innerHTML=`
88
+ <span style="font-size:18px;font-weight:700">${n.icon}</span>
89
89
  <span style="flex:1;line-height:1.4">${e}</span>
90
90
  <button
91
91
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
92
92
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
93
93
  aria-label="Close notification">\xD7</button>
94
- `,window.innerWidth<=480&&(m.style.right="8px",m.style.left="8px",m.style.maxWidth="none",m.style.width="auto"),requestAnimationFrame(()=>{m&&(m.style.transform="translateX(0)",m.style.opacity="1")}),setTimeout(()=>{m&&(m.style.transform="translateX(120%)",m.style.opacity="0")},5e3)}function u(e,t="info",o=!0){q&&(q.textContent=e),Pe(e,t),o&&se(e,t==="error"?"assertive":"polite")}function Qe(){if(typeof document>"u"||Ae)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
94
+ `,window.innerWidth<=480&&(m.style.right="8px",m.style.left="8px",m.style.maxWidth="none",m.style.width="auto"),requestAnimationFrame(()=>{m&&(m.style.transform="translateX(0)",m.style.opacity="1")}),setTimeout(()=>{m&&(m.style.transform="translateX(120%)",m.style.opacity="0")},5e3)}function u(e,t="info",o=!0){V&&(V.textContent=e),ze(e,t),o&&le(e,t==="error"?"assertive":"polite")}function et(){if(typeof document>"u"||Se)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
95
95
  position: fixed;
96
96
  top: 0;
97
97
  left: 0;
@@ -105,7 +105,7 @@
105
105
  transform: translateY(-100%);
106
106
  transition: transform 0.2s ease;
107
107
  font-family: system-ui, sans-serif;
108
- `;let o=!1;if(e.forEach(({label:n,selector:s})=>{let i=document.querySelector(s);if(!i)return;o=!0,i.getAttribute("tabindex")||i.setAttribute("tabindex","-1");let d=document.createElement("a");d.href="#",d.textContent=n,d.style.cssText=`
108
+ `;let o=!1;if(e.forEach(({label:a,selector:s})=>{let i=document.querySelector(s);if(!i)return;o=!0,i.getAttribute("tabindex")||i.setAttribute("tabindex","-1");let d=document.createElement("a");d.href="#",d.textContent=a,d.style.cssText=`
109
109
  color: #fff;
110
110
  background: #1a73e8;
111
111
  padding: 8px 14px;
@@ -116,7 +116,7 @@
116
116
  white-space: nowrap;
117
117
  border: 2px solid transparent;
118
118
  transition: background 0.15s, border-color 0.15s;
119
- `,d.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),d.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),d.addEventListener("click",f=>{f.preventDefault(),i.focus(),i.scrollIntoView({behavior:"smooth",block:"start"}),u(`Jumped to ${n.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(d)}),!o)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Ae=t}function et(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
119
+ `,d.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),d.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),d.addEventListener("click",f=>{f.preventDefault(),i.focus(),i.scrollIntoView({behavior:"smooth",block:"start"}),u(`Jumped to ${a.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(d)}),!o)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Se=t}function tt(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
120
120
 
121
121
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
122
122
  [data-yuktai-a11y] *:focus-visible {
@@ -262,7 +262,7 @@
262
262
  width: auto !important;
263
263
  }
264
264
  }
265
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function tt(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let o=t.getAttribute("role")||"";if(e.key==="Escape"){let a=t.closest("[role='dialog'],[role='alertdialog']");if(a){a.style.display="none",u("Dialog closed","info");return}let n=t.closest("[role='menu'],[role='menubar']");n&&(n.style.display="none",u("Menu closed","info"))}if(o==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let a=t.closest("[role='menu'],[role='menubar']");if(!a)return;let n=Array.from(a.querySelectorAll("[role='menuitem']:not([disabled])")),s=n.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),n[(s+1)%n.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),n[(s-1+n.length)%n.length]?.focus()):e.key==="Home"?(e.preventDefault(),n[0]?.focus()):e.key==="End"&&(e.preventDefault(),n[n.length-1]?.focus())}if(o==="tab"||t.closest("[role='tablist']")){let a=t.closest("[role='tablist']");if(!a)return;let n=Array.from(a.querySelectorAll("[role='tab']:not([disabled])")),s=n.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let i=n[(s+1)%n.length];i?.focus(),i?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let i=n[(s-1+n.length)%n.length];i?.focus(),i?.click()}}if(o==="option"||t.closest("[role='listbox']")){let a=t.closest("[role='listbox']");if(!a)return;let n=Array.from(a.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=n.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),n[(s+1)%n.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),n[(s-1+n.length)%n.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),n.forEach(i=>{i!==t&&i.setAttribute("aria-selected","false")}),u(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),ot()),e.key==="Tab"&&M?.speechEnabled&&setTimeout(()=>{let a=document.activeElement;if(!a)return;let n=a.getAttribute("aria-label")||a.getAttribute("title")||a.textContent?.trim()||a.tagName.toLowerCase(),s=a.getAttribute("role")||a.tagName.toLowerCase();se(`${n}, ${s}`)},100)}))}function G(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let o=t[0],a=t[t.length-1];o.focus(),e.addEventListener("keydown",n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===o&&(n.preventDefault(),a.focus()):document.activeElement===a&&(n.preventDefault(),o.focus()))})}function ot(){if(typeof document>"u")return;if(L){L.remove(),L=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
265
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function ot(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let o=t.getAttribute("role")||"";if(e.key==="Escape"){let n=t.closest("[role='dialog'],[role='alertdialog']");if(n){n.style.display="none",u("Dialog closed","info");return}let a=t.closest("[role='menu'],[role='menubar']");a&&(a.style.display="none",u("Menu closed","info"))}if(o==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let n=t.closest("[role='menu'],[role='menubar']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='menuitem']:not([disabled])")),s=a.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),a[(s+1)%a.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),a[(s-1+a.length)%a.length]?.focus()):e.key==="Home"?(e.preventDefault(),a[0]?.focus()):e.key==="End"&&(e.preventDefault(),a[a.length-1]?.focus())}if(o==="tab"||t.closest("[role='tablist']")){let n=t.closest("[role='tablist']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='tab']:not([disabled])")),s=a.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let i=a[(s+1)%a.length];i?.focus(),i?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let i=a[(s-1+a.length)%a.length];i?.focus(),i?.click()}}if(o==="option"||t.closest("[role='listbox']")){let n=t.closest("[role='listbox']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=a.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),a[(s+1)%a.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),a[(s-1+a.length)%a.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),a.forEach(i=>{i!==t&&i.setAttribute("aria-selected","false")}),u(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),it()),e.key==="Tab"&&M?.speechEnabled&&setTimeout(()=>{let n=document.activeElement;if(!n)return;let a=n.getAttribute("aria-label")||n.getAttribute("title")||n.textContent?.trim()||n.tagName.toLowerCase(),s=n.getAttribute("role")||n.tagName.toLowerCase();le(`${a}, ${s}`)},100)}))}function j(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let o=t[0],n=t[t.length-1];o.focus(),e.addEventListener("keydown",a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===o&&(a.preventDefault(),n.focus()):document.activeElement===n&&(a.preventDefault(),o.focus()))})}function it(){if(typeof document>"u")return;if(L){L.remove(),L=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
266
266
  position: fixed;
267
267
  top: 50%;
268
268
  left: 50%;
@@ -286,13 +286,13 @@
286
286
  style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1"
287
287
  aria-label="Close shortcuts">\xD7</button>
288
288
  </div>
289
- ${t.map(([a,n])=>`
289
+ ${t.map(([n,a])=>`
290
290
  <div style="display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid #2a2a4a">
291
- <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${a}</kbd>
292
- <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${n}</span>
291
+ <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${n}</kbd>
292
+ <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${a}</span>
293
293
  </div>
294
294
  `).join("")}
295
- `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),L=null}),e.addEventListener("keydown",a=>{a.key==="Escape"&&(e.remove(),L=null)}),document.body.appendChild(e),L=e,G(e),u("Keyboard shortcuts opened. Press Escape to close.","info")}function it(e){if(typeof document>"u"||!M?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;ne&&ne.remove();let t=e.score,o=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",a=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",n=document.createElement("button");n.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),n.setAttribute("data-yuktai-badge","true"),n.style.cssText=`
295
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),L=null}),e.addEventListener("keydown",n=>{n.key==="Escape"&&(e.remove(),L=null)}),document.body.appendChild(e),L=e,j(e),u("Keyboard shortcuts opened. Press Escape to close.","info")}function at(e){if(typeof document>"u"||!M?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;ne&&ne.remove();let t=e.score,o=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",n=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",a=document.createElement("button");a.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),a.setAttribute("data-yuktai-badge","true"),a.style.cssText=`
296
296
  position: fixed;
297
297
  bottom: 16px;
298
298
  left: 16px;
@@ -311,7 +311,7 @@
311
311
  align-items: center;
312
312
  gap: 6px;
313
313
  transition: transform 0.15s;
314
- `,n.innerHTML=`${a} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,n.addEventListener("click",()=>nt(e)),document.body.appendChild(n),ne=n}function nt(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let o=document.createElement("div");o.setAttribute("data-yuktai-audit-details","true"),o.setAttribute("role","dialog"),o.setAttribute("aria-label","Accessibility audit details"),o.style.cssText=`
314
+ `,a.innerHTML=`${n} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,a.addEventListener("click",()=>nt(e)),document.body.appendChild(a),ne=a}function nt(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let o=document.createElement("div");o.setAttribute("data-yuktai-audit-details","true"),o.setAttribute("role","dialog"),o.setAttribute("aria-label","Accessibility audit details"),o.style.cssText=`
315
315
  position: fixed;
316
316
  bottom: 56px;
317
317
  left: 16px;
@@ -328,22 +328,22 @@
328
328
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
329
329
  font-family: system-ui, sans-serif;
330
330
  font-size: 12px;
331
- `;let a={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};o.innerHTML=`
331
+ `;let n={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};o.innerHTML=`
332
332
  <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
333
333
  <strong style="font-size:14px;color:#74c0fc">Audit report</strong>
334
334
  <span style="color:#aaa">${e.fixed} fixed \xB7 ${e.renderTime}ms</span>
335
335
  </div>
336
- ${e.details.slice(0,20).map(n=>`
336
+ ${e.details.slice(0,20).map(a=>`
337
337
  <div style="padding:6px 0;border-bottom:1px solid #2a2a4a">
338
338
  <div style="display:flex;gap:6px;align-items:center">
339
- <span style="background:${a[n.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${n.severity}</span>
340
- <code style="color:#74c0fc">&lt;${n.tag}&gt;</code>
339
+ <span style="background:${n[a.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${a.severity}</span>
340
+ <code style="color:#74c0fc">&lt;${a.tag}&gt;</code>
341
341
  </div>
342
- <div style="color:#ccc;margin-top:3px">${n.fix}</div>
342
+ <div style="color:#ccc;margin-top:3px">${a.fix}</div>
343
343
  </div>
344
344
  `).join("")}
345
345
  ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
346
- `,o.addEventListener("keydown",n=>{n.key==="Escape"&&o.remove()}),document.body.appendChild(o),G(o)}function ze(e){typeof document>"u"||(ae&&clearTimeout(ae),ae=setTimeout(()=>{if(_)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
346
+ `,o.addEventListener("keydown",a=>{a.key==="Escape"&&o.remove()}),document.body.appendChild(o),j(o)}function Ie(e){typeof document>"u"||(re&&clearTimeout(re),re=setTimeout(()=>{if(q)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
347
347
  position: fixed;
348
348
  top: 50%;
349
349
  left: 50%;
@@ -372,19 +372,19 @@
372
372
  No, sign out
373
373
  </button>
374
374
  </div>
375
- `;let o=t.querySelector("[data-yuktai-extend]"),a=t.querySelector("[data-yuktai-dismiss]");o?.addEventListener("click",()=>{t.remove(),_=null,u("Session extended. You have more time.","success"),M?.timeoutWarning&&ze(M.timeoutWarning)}),a?.addEventListener("click",()=>{t.remove(),_=null}),document.body.appendChild(t),_=t,G(t),u("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function at(e){if(typeof document>"u")return;let t=document.documentElement;if(t.toggleAttribute("data-yuktai-high-contrast",!!e.highContrast),t.toggleAttribute("data-yuktai-dark",!!e.darkMode),t.toggleAttribute("data-yuktai-reduce-motion",!!e.reduceMotion),t.toggleAttribute("data-yuktai-large-targets",!!e.largeTargets),t.toggleAttribute("data-yuktai-keyboard",!!e.keyboardHints),t.toggleAttribute("data-yuktai-dyslexia",!!e.dyslexiaFont),e.localFont?document.body.style.fontFamily=`"${e.localFont}", system-ui, sans-serif`:e.dyslexiaFont||(document.body.style.fontFamily=""),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1?document.documentElement.style.fontSize=`${e.fontSizeMultiplier*100}%`:document.documentElement.style.fontSize="",e.colorBlindMode&&e.colorBlindMode!=="none"){let o=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${D[e.colorBlindMode]})`;document.body.style.filter=o}else document.body.style.filter=""}function rt(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Ee(e){if(e){if(!await Z()){u("Plain English requires Chrome 127+","warning");return}u("Rewriting page in plain English...","info",!1);let o=await ue();u(o.error?`Plain English failed: ${o.error}`:`${o.fixed} sections rewritten in plain English`,o.error?"error":"success",!1)}else pe(),u("Original text restored","info",!1)}async function Te(e){if(e){if(!await Q()){u("Page summariser requires Chrome 127+","warning");return}u("Generating page summary...","info",!1);let o=await me();u(o.error?`Summary failed: ${o.error}`:"Page summary added at top",o.error?"error":"success",!1)}else W(),u("Page summary removed","info",!1)}async function Ce(e){if(e==="en"){ee(),u("Page restored to English","info",!1);return}u(`Translating page to ${e}...`,"info",!1);let t=await be(e);u(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Le(e){if(e){if(!te()){u("Voice control not supported in this browser","warning");return}xe(t=>{t.success&&u(`Voice: ${t.action}`,"info",!1)}),u("Voice control started. Say a command.","success",!1)}else oe(),u("Voice control stopped","info",!1)}async function Me(e){if(e){if(!await ie()){u("Smart labels requires Chrome 127+","warning");return}u("Generating smart labels...","info",!1);let o=await we();u(o.error?`Smart labels failed: ${o.error}`:`${o.fixed} elements labelled`,o.error?"error":"success",!1)}else ve(),u("Smart labels removed","info",!1)}function st(){if(typeof document>"u"||q)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("aria-relevant","text"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);",document.body.appendChild(e),q=e}function lt(){if(typeof document>"u"||ke)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
375
+ `;let o=t.querySelector("[data-yuktai-extend]"),n=t.querySelector("[data-yuktai-dismiss]");o?.addEventListener("click",()=>{t.remove(),q=null,u("Session extended. You have more time.","success"),M?.timeoutWarning&&Ie(M.timeoutWarning)}),n?.addEventListener("click",()=>{t.remove(),q=null}),document.body.appendChild(t),q=t,j(t),u("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function rt(e){if(typeof document>"u")return;let t=document.documentElement;if(t.toggleAttribute("data-yuktai-high-contrast",!!e.highContrast),t.toggleAttribute("data-yuktai-dark",!!e.darkMode),t.toggleAttribute("data-yuktai-reduce-motion",!!e.reduceMotion),t.toggleAttribute("data-yuktai-large-targets",!!e.largeTargets),t.toggleAttribute("data-yuktai-keyboard",!!e.keyboardHints),t.toggleAttribute("data-yuktai-dyslexia",!!e.dyslexiaFont),e.localFont?document.body.style.fontFamily=`"${e.localFont}", system-ui, sans-serif`:e.dyslexiaFont||(document.body.style.fontFamily=""),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1?document.documentElement.style.fontSize=`${e.fontSizeMultiplier*100}%`:document.documentElement.style.fontSize="",e.colorBlindMode&&e.colorBlindMode!=="none"){let o=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${G[e.colorBlindMode]})`;document.body.style.filter=o}else document.body.style.filter=""}function st(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Te(e){if(e){if(!await Q()){u("Plain English requires Chrome 127+","warning");return}u("Rewriting page in plain English...","info",!1);let o=await pe();u(o.error?`Plain English failed: ${o.error}`:`${o.fixed} sections rewritten in plain English`,o.error?"error":"success",!1)}else fe(),u("Original text restored","info",!1)}async function Ce(e){if(e){if(!await ee()){u("Page summariser requires Chrome 127+","warning");return}u("Generating page summary...","info",!1);let o=await be();u(o.error?`Summary failed: ${o.error}`:"Page summary added at top",o.error?"error":"success",!1)}else N(),u("Page summary removed","info",!1)}async function Le(e){if(e==="en"){te(),u("Page restored to English","info",!1);return}u(`Translating page to ${e}...`,"info",!1);let t=await ge(e);u(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Me(e){if(e){if(!oe()){u("Voice control not supported in this browser","warning");return}xe(t=>{t.success&&u(`Voice: ${t.action}`,"info",!1)}),u("Voice control started. Say a command.","success",!1)}else ie(),u("Voice control stopped","info",!1)}async function Re(e){if(e){if(!await ae()){u("Smart labels requires Chrome 127+","warning");return}u("Generating smart labels...","info",!1);let o=await ve();u(o.error?`Smart labels failed: ${o.error}`:`${o.fixed} elements labelled`,o.error?"error":"success",!1)}else ke(),u("Smart labels removed","info",!1)}function lt(){if(typeof document>"u"||V)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("aria-relevant","text"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);",document.body.appendChild(e),V=e}function dt(){if(typeof document>"u"||Ae)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
376
376
  <defs>
377
- <filter id="${D.deuteranopia}">
377
+ <filter id="${G.deuteranopia}">
378
378
  <feColorMatrix type="matrix"
379
379
  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"/>
380
380
  </filter>
381
- <filter id="${D.protanopia}">
381
+ <filter id="${G.protanopia}">
382
382
  <feColorMatrix type="matrix"
383
383
  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"/>
384
384
  </filter>
385
- <filter id="${D.tritanopia}">
385
+ <filter id="${G.tritanopia}">
386
386
  <feColorMatrix type="matrix"
387
387
  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"/>
388
388
  </filter>
389
389
  </defs>
390
- `,document.body.appendChild(e),ke=e}function Re(e){let t={critical:20,serious:10,moderate:5,minor:2},o=e.details.reduce((a,n)=>a+(t[n.severity]||0),0);return Math.max(0,Math.min(100,100-o))}var h={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";M=e,rt(e),st(),lt(),et(),tt(),e.showSkipLinks!==!1&&Qe(),e.showPreferencePanel,at(e);let t=this.applyFixes(e);t.score=Re(t),e.showAuditBadge&&it(t),e.timeoutWarning&&ze(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Ee(!0),e.summarisePage&&await Te(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Ce(e.translateLanguage),e.voiceControl&&await Le(!0),e.smartLabels&&await Me(!0);let o=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return u(o,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${o} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let o=performance.now(),a=document.querySelectorAll("*");t.scanned=a.length;let n=(s,i,d,f)=>{t.details.push({tag:s,fix:i,severity:d,element:f.outerHTML.slice(0,100)}),t.fixed++};return a.forEach(s=>{let i=s,d=i.tagName.toLowerCase();if(d==="html"&&!i.getAttribute("lang")&&(i.setAttribute("lang","en"),n(d,'lang="en" added',"critical",i)),d==="meta"){let p=i.getAttribute("name"),x=i.getAttribute("content")||"";p==="viewport"&&x.includes("user-scalable=no")&&(i.setAttribute("content",x.replace("user-scalable=no","user-scalable=yes")),n(d,"user-scalable=yes restored","serious",i)),p==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(x)&&(i.setAttribute("content",x.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),n(d,"maximum-scale=5 restored","serious",i))}if(d==="main"&&!i.getAttribute("tabindex")&&(i.setAttribute("tabindex","-1"),i.getAttribute("id")||i.setAttribute("id","main-content")),d==="img"&&(i.hasAttribute("alt")||(i.setAttribute("alt",""),i.setAttribute("aria-hidden","true"),n(d,'alt="" aria-hidden="true"',"serious",i))),d==="svg"&&(!i.getAttribute("aria-hidden")&&!i.getAttribute("aria-label")&&!s.querySelector("title")&&(i.setAttribute("aria-hidden","true"),n(d,'aria-hidden="true" (decorative svg)',"minor",i)),i.getAttribute("focusable")||i.setAttribute("focusable","false")),d==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&(i.setAttribute("title","embedded content"),i.setAttribute("aria-label","embedded content"),n(d,"title + aria-label added","serious",i)),d==="button"){if(!i.innerText?.trim()&&!i.getAttribute("aria-label")){let p=i.getAttribute("title")||"button";i.setAttribute("aria-label",p),n(d,`aria-label="${p}" (empty button)`,"critical",i)}i.hasAttribute("disabled")&&!i.getAttribute("aria-disabled")&&(i.setAttribute("aria-disabled","true"),t.fixed++)}if(d==="a"){let p=i;!i.innerText?.trim()&&!i.getAttribute("aria-label")&&(i.setAttribute("aria-label",i.getAttribute("title")||"link"),n(d,"aria-label added (empty link)","critical",i)),p.target==="_blank"&&!p.rel?.includes("noopener")&&(p.rel="noopener noreferrer",t.fixed++)}if(Se.has(d)){let p=i;if(!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")){let x=i.getAttribute("placeholder")||i.getAttribute("name")||d;i.setAttribute("aria-label",x),n(d,`aria-label="${x}"`,"serious",i)}if(i.hasAttribute("required")&&!i.getAttribute("aria-required")&&(i.setAttribute("aria-required","true"),t.fixed++),d==="input"&&!p.autocomplete){let x=p.name||"";p.type==="email"||x.includes("email")?p.autocomplete="email":p.type==="tel"||x.includes("tel")?p.autocomplete="tel":p.type==="password"&&(p.autocomplete="current-password"),t.fixed++}}d==="th"&&!i.getAttribute("scope")&&(i.setAttribute("scope",i.closest("thead")?"col":"row"),n(d,"scope added to <th>","moderate",i)),re[d]&&!i.getAttribute("role")&&(i.setAttribute("role",re[d]),n(d,`role="${re[d]}"`,"minor",i));let f=i.getAttribute("role")||"";f==="tab"&&!i.getAttribute("aria-selected")&&(i.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(f)&&!i.getAttribute("aria-live")&&(i.setAttribute("aria-live",f==="alert"?"assertive":"polite"),n(d,`aria-live added on role=${f}`,"moderate",i)),f==="combobox"&&!i.getAttribute("aria-expanded")&&(i.setAttribute("aria-expanded","false"),n(d,'aria-expanded="false" on combobox',"serious",i)),(f==="checkbox"||f==="radio")&&!i.getAttribute("aria-checked")&&(i.setAttribute("aria-checked","false"),n(d,`aria-checked="false" on role=${f}`,"serious",i))}),t.renderTime=parseFloat((performance.now()-o).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),o=document.querySelectorAll("*");e.scanned=o.length;let a=(n,s,i,d)=>e.details.push({tag:n,fix:s,severity:i,element:d.outerHTML.slice(0,100)});return o.forEach(n=>{let s=n,i=s.tagName.toLowerCase();(i==="a"||i==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&a(i,"needs aria-label (empty)","critical",s),i==="img"&&!s.hasAttribute("alt")&&a(i,"needs alt text","serious",s),Se.has(i)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&a(i,"needs aria-label","serious",s),i==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&a(i,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=Re(e),e.renderTime=parseFloat((performance.now()-t).toFixed(2)),e},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer?.disconnect(),this.observer=null},announce:u,speak:se,showVisualAlert:Pe,trapFocus:G,handlePlainEnglish:Ee,handleSummarisePage:Te,handleTranslate:Ce,handleVoiceControl:Le,handleSmartLabels:Me,SUPPORTED_LANGUAGES:N};var b=Be(require("react"));var A=require("react");var r=require("react/jsx-runtime"),le={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100,localFont:"",darkMode:!1,largeTargets:!1,speechEnabled:!1,colorBlindMode:"none",showAuditBadge:!1,timeoutWarning:void 0,plainEnglish:!1,summarisePage:!1,translateLanguage:"en",voiceControl:!1,smartLabels:!1},R=[80,90,100,110,120,130],dt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],ct=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function ut(){let[e,t]=(0,A.useState)(typeof window<"u"?window.innerWidth:1024);return(0,A.useEffect)(()=>{let o=()=>t(window.innerWidth);return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function pt({checked:e,onChange:t,label:o,disabled:a=!1}){return(0,r.jsxs)("label",{"aria-label":o,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:a?"not-allowed":"pointer",flexShrink:0,opacity:a?.4:1},children:[(0,r.jsx)("input",{type:"checkbox",checked:e,disabled:a,onChange:n=>t(n.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,r.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,r.jsx)("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function V({label:e,color:t="#64748b",badge:o}){return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",margin:"8px 18px 4px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),o&&(0,r.jsx)("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:o})]})}function k({icon:e,label:t,desc:o,checked:a,onChange:n,disabled:s=!1,disabledReason:i}){return(0,r.jsxs)("div",{title:s?i:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:"30px",height:"30px",borderRadius:"8px",background:s?"#f1f5f9":"#f0fdfa",color:s?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",flexShrink:0,fontWeight:700},children:e}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:s?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:s?i:o})]})]}),(0,r.jsx)(pt,{checked:a,onChange:n,label:`Toggle ${t}`,disabled:s})]})}function y(){return(0,r.jsx)("div",{style:{height:"1px",background:"#f1f5f9",margin:"0"}})}var de=(0,A.forwardRef)(({position:e,settings:t,report:o,isActive:a,aiSupported:n,voiceSupported:s,set:i,onApply:d,onReset:f,onClose:p},x)=>{let{isMobile:g,isTablet:K}=ut(),[H,Y]=(0,A.useState)([]);(0,A.useEffect)(()=>{(async()=>{try{let $=window;if(!$.queryLocalFonts)return;let U=await $.queryLocalFonts(),J=[...new Set(U.map(X=>X.family))].sort();Y(J.slice(0,50))}catch{}})()},[]);let P=g?{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px 16px 0 0",boxShadow:"0 -8px 32px rgba(0,0,0,0.12)",maxHeight:"90vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif",width:"100%"}:{position:"fixed",bottom:"84px",[e]:"24px",zIndex:9999,width:K?"300px":"320px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",maxHeight:"80vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif"};return(0,r.jsxs)("div",{ref:x,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:P,children:[(0,r.jsxs)("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between",position:"sticky",top:0,background:"#fff",zIndex:1},children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"7px",marginBottom:"5px",flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v2.0.18"}),a&&(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),(0,r.jsx)("p",{style:{margin:"0 0 2px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),(0,r.jsx)("p",{style:{margin:0,fontSize:"12px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost"})]}),(0,r.jsx)("button",{onClick:p,"aria-label":"Close accessibility panel",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#94a3b8",fontSize:"20px",lineHeight:1,borderRadius:"6px",flexShrink:0,minWidth:g?"44px":"auto",minHeight:g?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,r.jsx)(V,{label:"Core"}),(0,r.jsx)(k,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:l=>i("autoFix",l)}),(0,r.jsx)(y,{}),(0,r.jsx)(k,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:l=>i("speechEnabled",l)}),(0,r.jsx)(y,{}),(0,r.jsx)(k,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:l=>i("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser"}),(0,r.jsx)(y,{}),(0,r.jsx)(V,{label:"AI features",color:"#7c3aed",badge:"Gemini Nano \xB7 Chrome 127+"}),(0,r.jsx)("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:"#f5f3ff",borderRadius:"8px",border:"0.5px solid #c4b5fd",fontSize:"10px",color:"#7c3aed",lineHeight:1.5},children:n?"Gemini Nano detected \u2014 AI features ready. Runs privately on your device. No data leaves your browser.":"AI features need setup \u2014 see guide below."}),!n&&(0,r.jsxs)("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[(0,r.jsx)("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} How to enable AI features:"}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome and go to"," ",(0,r.jsx)("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["2. Search and set each to ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Enabled:"})]}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:ct.map(l=>(0,r.jsxs)("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",l]},l))}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["3. Click ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Relaunch"})," when Chrome prompts you"]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["4. Go to"," ",(0,r.jsx)("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://components"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px 10px"},children:["\u2192 Find ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Optimization Guide On Device Model"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 6px 10px"},children:["\u2192 Click ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Check for update"})," and wait for download"]}),(0,r.jsx)("p",{style:{margin:"0"},children:"5. Refresh this page \u2014 AI features will unlock automatically"})]}),(0,r.jsx)(k,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:l=>i("plainEnglish",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(y,{}),(0,r.jsx)(k,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:l=>i("summarisePage",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(y,{}),(0,r.jsx)(k,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:l=>i("smartLabels",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(y,{}),(0,r.jsx)(V,{label:"Visual"}),(0,r.jsx)(k,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:l=>i("highContrast",l)}),(0,r.jsx)(y,{}),(0,r.jsx)(k,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:l=>i("darkMode",l)}),(0,r.jsx)(y,{}),(0,r.jsx)(k,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:l=>i("reduceMotion",l)}),(0,r.jsx)(y,{}),(0,r.jsx)(k,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>i("largeTargets",l)}),(0,r.jsx)(y,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:dt.map(l=>(0,r.jsx)("button",{onClick:()=>i("colorBlindMode",l.value),"aria-pressed":t.colorBlindMode===l.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===l.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===l.value?"#f0fdfa":"#fff",color:t.colorBlindMode===l.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:g?"36px":"auto"},children:l.label},l.value))})]}),(0,r.jsx)(y,{}),(0,r.jsx)(V,{label:"Font"}),(0,r.jsx)(k,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:l=>i("dyslexiaFont",l)}),(0,r.jsx)(y,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F524} Local font"}),H.length>0?(0,r.jsxs)("select",{value:t.localFont,onChange:l=>i("localFont",l.target.value),"aria-label":"Choose a font from your device",style:{width:"100%",padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"13px",color:"#0f172a",background:"#fff",cursor:"pointer",height:g?"44px":"36px"},children:[(0,r.jsx)("option",{value:"",children:"System default"}),H.map(l=>(0,r.jsx)("option",{value:l,style:{fontFamily:l},children:l},l))]}):(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Local font access available in Chrome 103+. Allow font access when prompted."})]}),(0,r.jsx)(y,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px 14px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"Text size"}),(0,r.jsxs)("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,r.jsx)("button",{onClick:()=>{let l=R.indexOf(t.fontScale);l>0&&i("fontScale",R[l-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale<=80?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),(0,r.jsx)("div",{style:{flex:1,display:"flex",gap:"3px"},children:R.map(l=>(0,r.jsx)("button",{onClick:()=>i("fontScale",l),"aria-label":`Set text size to ${l}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:l<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},l))}),(0,r.jsx)("button",{onClick:()=>{let l=R.indexOf(t.fontScale);l<R.length-1&&i("fontScale",R[l+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale>=130?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale>=130?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),(0,r.jsx)(y,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsxs)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:["\u{1F310} Translate page"," ",(0,r.jsx)("span",{style:{marginLeft:"6px",fontSize:"9px",fontWeight:500,padding:"1px 6px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd"},children:"Gemini Nano"})]}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:N.slice(0,g?8:18).map(l=>(0,r.jsx)("button",{onClick:()=>i("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!n,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===l.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===l.code?"#f5f3ff":"#fff",color:t.translateLanguage===l.code?"#7c3aed":"#64748b",cursor:n?"pointer":"not-allowed",opacity:n?1:.5,minHeight:g?"36px":"auto"},children:l.code.toUpperCase()},l.code))}),!n&&(0,r.jsx)("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above to unlock translation."})]}),o&&(0,r.jsx)("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:"8px",fontSize:"12px",color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:o.fixed>0?`\u2713 ${o.fixed} fixes \xB7 ${o.scanned} nodes \xB7 ${o.renderTime}ms \xB7 Score: ${o.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${o.scanned} nodes \xB7 ${o.renderTime}ms`}),(0,r.jsxs)("div",{style:{display:"flex",gap:"8px",padding:"12px 14px 14px",position:g?"sticky":"relative",bottom:g?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[(0,r.jsx)("button",{onClick:f,style:{flex:1,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:500,borderRadius:"9px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),(0,r.jsx)("button",{onClick:d,style:{flex:2,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});de.displayName="WidgetPanel";var T=require("react/jsx-runtime");function j({position:e="left",children:t,config:o={}}){let[a,n]=(0,b.useState)(!1),[s,i]=(0,b.useState)(le),[d,f]=(0,b.useState)(null),[p,x]=(0,b.useState)(!1),[g,K]=(0,b.useState)(!1),[H,Y]=(0,b.useState)(!1),P=b.default.useRef(null);(0,b.useEffect)(()=>{if(typeof window>"u")return;let c=!!window.ai;K(c);let v=!!(window.SpeechRecognition||window.webkitSpeechRecognition);Y(v)},[]),(0,b.useEffect)(()=>{if(!(typeof window>"u"))try{let c=localStorage.getItem("yuktai-a11y-prefs");if(c){let v=JSON.parse(c);i(E=>({...E,...v}))}}catch{}},[]);let l=(0,b.useCallback)(async c=>{let v={enabled:!0,highContrast:c.highContrast,darkMode:c.darkMode,reduceMotion:c.reduceMotion,largeTargets:c.largeTargets,speechEnabled:c.speechEnabled,autoFix:c.autoFix,dyslexiaFont:c.dyslexiaFont,localFont:c.localFont,fontSizeMultiplier:c.fontScale/100,colorBlindMode:c.colorBlindMode,showAuditBadge:c.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:c.plainEnglish,summarisePage:c.summarisePage,translateLanguage:c.translateLanguage,voiceControl:c.voiceControl,smartLabels:c.smartLabels,...o};await h.execute(v);let E=h.applyFixes(v);f(E),x(!0)},[o]),$=(0,b.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await l(s),n(!1)},[s,l]),U=(0,b.useCallback)(()=>{i(le);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let c=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(E=>c.removeAttribute(E)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",f(null),x(!1)},[]),J=(0,b.useCallback)((c,v)=>{i(E=>({...E,[c]:v}))},[]);(0,b.useEffect)(()=>{let c=v=>{v.key==="Escape"&&a&&n(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),(0,b.useEffect)(()=>{a&&P.current&&h.trapFocus(P.current)},[a]);let X={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:p?"#0d9488":"#1a73e8",color:"#fff",border:"none",cursor:"pointer",fontSize:"22px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(0,0,0,0.25)",transition:"transform 0.15s, background 0.2s"};return(0,T.jsxs)(T.Fragment,{children:[t,(0,T.jsx)("button",{style:X,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":a,"data-yuktai-pref-toggle":"true",onClick:()=>n(c=>!c),onMouseEnter:c=>{c.currentTarget.style.transform="scale(1.08)"},onMouseLeave:c=>{c.currentTarget.style.transform="scale(1)"},children:"\u267F"}),a&&(0,T.jsx)(de,{ref:P,position:e,settings:s,report:d,isActive:p,aiSupported:g,voiceSupported:H,set:J,onApply:$,onReset:U,onClose:()=>n(!1)})]})}var z={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var I={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var S=class{plugins=new Map;register(t,o){if(!o||typeof o.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,o)}use(t){return this.plugins.get(t)}async run(t,o){try{let a=this.use(t);if(!a)throw new Error(`Plugin not found: ${t}`);return await a.execute(o)}catch(a){throw console.error(`[YuktAI Runtime Error in ${t}]:`,a),a}}getPlugins(){return Array.from(this.plugins.keys())}};function ft(){if(typeof globalThis>"u")return new S;if(!globalThis.__yuktai_runtime__){let e=new S;e.register(h.name,h),e.register(z.name,z),e.register(I.name,I),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var Ie=typeof window<"u"?ft():new S,mt={wcagPlugin:h,list(){return Ie.getPlugins()},use(e){return Ie.use(e)},fix(e){return h.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return h.scan()}};0&&(module.exports={Runtime,YuktAI,YuktAIWrapper,aiPlugin,voicePlugin,wcag,wcagPlugin});
390
+ `,document.body.appendChild(e),Ae=e}function Pe(e){let t={critical:20,serious:10,moderate:5,minor:2},o=e.details.reduce((n,a)=>n+(t[a.severity]||0),0);return Math.max(0,Math.min(100,100-o))}var w={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";M=e,st(e),lt(),dt(),tt(),ot(),e.showSkipLinks!==!1&&et(),e.showPreferencePanel,rt(e);let t=this.applyFixes(e);t.score=Pe(t),e.showAuditBadge&&at(t),e.timeoutWarning&&Ie(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Te(!0),e.summarisePage&&await Ce(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Le(e.translateLanguage),e.voiceControl&&await Me(!0),e.smartLabels&&await Re(!0);let o=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return u(o,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${o} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let o=performance.now(),n=document.querySelectorAll("*");t.scanned=n.length;let a=(s,i,d,f)=>{t.details.push({tag:s,fix:i,severity:d,element:f.outerHTML.slice(0,100)}),t.fixed++};return n.forEach(s=>{let i=s,d=i.tagName.toLowerCase();if(d==="html"&&!i.getAttribute("lang")&&(i.setAttribute("lang","en"),a(d,'lang="en" added',"critical",i)),d==="meta"){let p=i.getAttribute("name"),y=i.getAttribute("content")||"";p==="viewport"&&y.includes("user-scalable=no")&&(i.setAttribute("content",y.replace("user-scalable=no","user-scalable=yes")),a(d,"user-scalable=yes restored","serious",i)),p==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(y)&&(i.setAttribute("content",y.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(d,"maximum-scale=5 restored","serious",i))}if(d==="main"&&!i.getAttribute("tabindex")&&(i.setAttribute("tabindex","-1"),i.getAttribute("id")||i.setAttribute("id","main-content")),d==="img"&&(i.hasAttribute("alt")||(i.setAttribute("alt",""),i.setAttribute("aria-hidden","true"),a(d,'alt="" aria-hidden="true"',"serious",i))),d==="svg"&&(!i.getAttribute("aria-hidden")&&!i.getAttribute("aria-label")&&!s.querySelector("title")&&(i.setAttribute("aria-hidden","true"),a(d,'aria-hidden="true" (decorative svg)',"minor",i)),i.getAttribute("focusable")||i.setAttribute("focusable","false")),d==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&(i.setAttribute("title","embedded content"),i.setAttribute("aria-label","embedded content"),a(d,"title + aria-label added","serious",i)),d==="button"){if(!i.innerText?.trim()&&!i.getAttribute("aria-label")){let p=i.getAttribute("title")||"button";i.setAttribute("aria-label",p),a(d,`aria-label="${p}" (empty button)`,"critical",i)}i.hasAttribute("disabled")&&!i.getAttribute("aria-disabled")&&(i.setAttribute("aria-disabled","true"),t.fixed++)}if(d==="a"){let p=i;!i.innerText?.trim()&&!i.getAttribute("aria-label")&&(i.setAttribute("aria-label",i.getAttribute("title")||"link"),a(d,"aria-label added (empty link)","critical",i)),p.target==="_blank"&&!p.rel?.includes("noopener")&&(p.rel="noopener noreferrer",t.fixed++)}if(Ee.has(d)){let p=i;if(!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")){let y=i.getAttribute("placeholder")||i.getAttribute("name")||d;i.setAttribute("aria-label",y),a(d,`aria-label="${y}"`,"serious",i)}if(i.hasAttribute("required")&&!i.getAttribute("aria-required")&&(i.setAttribute("aria-required","true"),t.fixed++),d==="input"&&!p.autocomplete){let y=p.name||"";p.type==="email"||y.includes("email")?p.autocomplete="email":p.type==="tel"||y.includes("tel")?p.autocomplete="tel":p.type==="password"&&(p.autocomplete="current-password"),t.fixed++}}d==="th"&&!i.getAttribute("scope")&&(i.setAttribute("scope",i.closest("thead")?"col":"row"),a(d,"scope added to <th>","moderate",i)),se[d]&&!i.getAttribute("role")&&(i.setAttribute("role",se[d]),a(d,`role="${se[d]}"`,"minor",i));let f=i.getAttribute("role")||"";f==="tab"&&!i.getAttribute("aria-selected")&&(i.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(f)&&!i.getAttribute("aria-live")&&(i.setAttribute("aria-live",f==="alert"?"assertive":"polite"),a(d,`aria-live added on role=${f}`,"moderate",i)),f==="combobox"&&!i.getAttribute("aria-expanded")&&(i.setAttribute("aria-expanded","false"),a(d,'aria-expanded="false" on combobox',"serious",i)),(f==="checkbox"||f==="radio")&&!i.getAttribute("aria-checked")&&(i.setAttribute("aria-checked","false"),a(d,`aria-checked="false" on role=${f}`,"serious",i))}),t.renderTime=parseFloat((performance.now()-o).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),o=document.querySelectorAll("*");e.scanned=o.length;let n=(a,s,i,d)=>e.details.push({tag:a,fix:s,severity:i,element:d.outerHTML.slice(0,100)});return o.forEach(a=>{let s=a,i=s.tagName.toLowerCase();(i==="a"||i==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&n(i,"needs aria-label (empty)","critical",s),i==="img"&&!s.hasAttribute("alt")&&n(i,"needs alt text","serious",s),Ee.has(i)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&n(i,"needs aria-label","serious",s),i==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&n(i,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=Pe(e),e.renderTime=parseFloat((performance.now()-t).toFixed(2)),e},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer?.disconnect(),this.observer=null},announce:u,speak:le,showVisualAlert:ze,trapFocus:j,handlePlainEnglish:Te,handleSummarisePage:Ce,handleTranslate:Le,handleVoiceControl:Me,handleSmartLabels:Re,SUPPORTED_LANGUAGES:_};var b=_e(require("react"));var S=require("react");var r=require("react/jsx-runtime"),de={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100,localFont:"",darkMode:!1,largeTargets:!1,speechEnabled:!1,colorBlindMode:"none",showAuditBadge:!1,timeoutWarning:void 0,plainEnglish:!1,summarisePage:!1,translateLanguage:"en",voiceControl:!1,smartLabels:!1},R=[80,90,100,110,120,130],ct=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],ut=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function pt(){let[e,t]=(0,S.useState)(typeof window<"u"?window.innerWidth:1024);return(0,S.useEffect)(()=>{let o=()=>t(window.innerWidth);return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function ft({checked:e,onChange:t,label:o,disabled:n=!1}){return(0,r.jsxs)("label",{"aria-label":o,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:n?"not-allowed":"pointer",flexShrink:0,opacity:n?.4:1},children:[(0,r.jsx)("input",{type:"checkbox",checked:e,disabled:n,onChange:a=>t(a.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,r.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,r.jsx)("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function K({label:e,color:t="#64748b",badge:o}){return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",margin:"8px 18px 4px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),o&&(0,r.jsx)("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:o})]})}function k({icon:e,label:t,desc:o,checked:n,onChange:a,disabled:s=!1,disabledReason:i}){return(0,r.jsxs)("div",{title:s?i:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:"30px",height:"30px",borderRadius:"8px",background:s?"#f1f5f9":"#f0fdfa",color:s?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",flexShrink:0,fontWeight:700},children:e}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:s?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:s?i:o})]})]}),(0,r.jsx)(ft,{checked:n,onChange:a,label:`Toggle ${t}`,disabled:s})]})}function x(){return(0,r.jsx)("div",{style:{height:"1px",background:"#f1f5f9",margin:"0"}})}var ce=(0,S.forwardRef)(({position:e,settings:t,report:o,isActive:n,aiSupported:a,voiceSupported:s,set:i,onApply:d,onReset:f,onClose:p},y)=>{let{isMobile:g,isTablet:P}=pt(),[$,U]=(0,S.useState)([]);(0,S.useEffect)(()=>{(async()=>{try{let F=window;if(!F.queryLocalFonts)return;let J=await F.queryLocalFonts(),X=[...new Set(J.map(Z=>Z.family))].sort();U(X.slice(0,50))}catch{}})()},[]);let z=g?{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px 16px 0 0",boxShadow:"0 -8px 32px rgba(0,0,0,0.12)",maxHeight:"90vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif",width:"100%"}:{position:"fixed",bottom:"84px",[e]:"24px",zIndex:9999,width:P?"300px":"320px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",maxHeight:"80vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif"};return(0,r.jsxs)("div",{ref:y,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:z,children:[(0,r.jsxs)("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between",position:"sticky",top:0,background:"#fff",zIndex:1},children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"7px",marginBottom:"5px",flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v2.0.18"}),n&&(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),(0,r.jsx)("p",{style:{margin:"0 0 2px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),(0,r.jsx)("p",{style:{margin:0,fontSize:"12px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost"})]}),(0,r.jsx)("button",{onClick:p,"aria-label":"Close accessibility panel",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#94a3b8",fontSize:"20px",lineHeight:1,borderRadius:"6px",flexShrink:0,minWidth:g?"44px":"auto",minHeight:g?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,r.jsx)(K,{label:"Core"}),(0,r.jsx)(k,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:l=>i("autoFix",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(k,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:l=>i("speechEnabled",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(k,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:l=>i("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser"}),(0,r.jsx)(x,{}),(0,r.jsx)(K,{label:"AI features",color:"#7c3aed",badge:"Gemini Nano \xB7 Chrome 127+"}),(0,r.jsx)("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:"#f5f3ff",borderRadius:"8px",border:"0.5px solid #c4b5fd",fontSize:"10px",color:"#7c3aed",lineHeight:1.5},children:a?"Gemini Nano detected \u2014 AI features ready. Runs privately on your device. No data leaves your browser.":"AI features need setup \u2014 see guide below."}),!a&&(0,r.jsxs)("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[(0,r.jsx)("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} How to enable AI features:"}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome and go to"," ",(0,r.jsx)("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["2. Search and set each to ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Enabled:"})]}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:ut.map(l=>(0,r.jsxs)("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",l]},l))}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["3. Click ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Relaunch"})," when Chrome prompts you"]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["4. Go to"," ",(0,r.jsx)("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://components"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px 10px"},children:["\u2192 Find ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Optimization Guide On Device Model"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 6px 10px"},children:["\u2192 Click ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Check for update"})," and wait for download"]}),(0,r.jsx)("p",{style:{margin:"0"},children:"5. Refresh this page \u2014 AI features will unlock automatically"})]}),(0,r.jsx)(k,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:l=>i("plainEnglish",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(k,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:l=>i("summarisePage",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(k,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:l=>i("smartLabels",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(K,{label:"Visual"}),(0,r.jsx)(k,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:l=>i("highContrast",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(k,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:l=>i("darkMode",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(k,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:l=>i("reduceMotion",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(k,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>i("largeTargets",l)}),(0,r.jsx)(x,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ct.map(l=>(0,r.jsx)("button",{onClick:()=>i("colorBlindMode",l.value),"aria-pressed":t.colorBlindMode===l.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===l.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===l.value?"#f0fdfa":"#fff",color:t.colorBlindMode===l.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:g?"36px":"auto"},children:l.label},l.value))})]}),(0,r.jsx)(x,{}),(0,r.jsx)(K,{label:"Font"}),(0,r.jsx)(k,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:l=>i("dyslexiaFont",l)}),(0,r.jsx)(x,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F524} Local font"}),$.length>0?(0,r.jsxs)("select",{value:t.localFont,onChange:l=>i("localFont",l.target.value),"aria-label":"Choose a font from your device",style:{width:"100%",padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"13px",color:"#0f172a",background:"#fff",cursor:"pointer",height:g?"44px":"36px"},children:[(0,r.jsx)("option",{value:"",children:"System default"}),$.map(l=>(0,r.jsx)("option",{value:l,style:{fontFamily:l},children:l},l))]}):(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Local font access available in Chrome 103+. Allow font access when prompted."})]}),(0,r.jsx)(x,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px 14px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"Text size"}),(0,r.jsxs)("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,r.jsx)("button",{onClick:()=>{let l=R.indexOf(t.fontScale);l>0&&i("fontScale",R[l-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale<=80?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),(0,r.jsx)("div",{style:{flex:1,display:"flex",gap:"3px"},children:R.map(l=>(0,r.jsx)("button",{onClick:()=>i("fontScale",l),"aria-label":`Set text size to ${l}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:l<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},l))}),(0,r.jsx)("button",{onClick:()=>{let l=R.indexOf(t.fontScale);l<R.length-1&&i("fontScale",R[l+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale>=130?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale>=130?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),(0,r.jsx)(x,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsxs)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:["\u{1F310} Translate page"," ",(0,r.jsx)("span",{style:{marginLeft:"6px",fontSize:"9px",fontWeight:500,padding:"1px 6px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd"},children:"Gemini Nano"})]}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.slice(0,g?8:18).map(l=>(0,r.jsx)("button",{onClick:()=>i("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!a,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===l.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===l.code?"#f5f3ff":"#fff",color:t.translateLanguage===l.code?"#7c3aed":"#64748b",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,minHeight:g?"36px":"auto"},children:l.code.toUpperCase()},l.code))}),!a&&(0,r.jsx)("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above to unlock translation."})]}),o&&(0,r.jsx)("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:"8px",fontSize:"12px",color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:o.fixed>0?`\u2713 ${o.fixed} fixes \xB7 ${o.scanned} nodes \xB7 ${o.renderTime}ms \xB7 Score: ${o.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${o.scanned} nodes \xB7 ${o.renderTime}ms`}),(0,r.jsxs)("div",{style:{display:"flex",gap:"8px",padding:"12px 14px 14px",position:g?"sticky":"relative",bottom:g?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[(0,r.jsx)("button",{onClick:f,style:{flex:1,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:500,borderRadius:"9px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),(0,r.jsx)("button",{onClick:d,style:{flex:2,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});ce.displayName="WidgetPanel";var T=require("react/jsx-runtime");function Y({position:e="left",children:t,config:o={}}){let[n,a]=(0,b.useState)(!1),[s,i]=(0,b.useState)(de),[d,f]=(0,b.useState)(null),[p,y]=(0,b.useState)(!1),[g,P]=(0,b.useState)(!1),[$,U]=(0,b.useState)(!1),z=b.default.useRef(null);(0,b.useEffect)(()=>{if(typeof window>"u")return;(async()=>{let h=window.ai||globalThis.ai;if(h&&h.languageModel)try{let W=await h.languageModel.availability();(W==="readily"||W==="downloadable")&&(P(!0),console.log("yuktai: AI Engine ready."))}catch(W){console.error("yuktai: AI check failed",W),P(!1)}else P(!1);let A=!!(window.SpeechRecognition||window.webkitSpeechRecognition);U(A)})()},[]),(0,b.useEffect)(()=>{if(!(typeof window>"u"))try{let c=localStorage.getItem("yuktai-a11y-prefs");if(c){let h=JSON.parse(c);i(A=>({...A,...h}))}}catch{}},[]);let l=(0,b.useCallback)(async c=>{let h={enabled:!0,highContrast:c.highContrast,darkMode:c.darkMode,reduceMotion:c.reduceMotion,largeTargets:c.largeTargets,speechEnabled:c.speechEnabled,autoFix:c.autoFix,dyslexiaFont:c.dyslexiaFont,localFont:c.localFont,fontSizeMultiplier:c.fontScale/100,colorBlindMode:c.colorBlindMode,showAuditBadge:c.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:c.plainEnglish,summarisePage:c.summarisePage,translateLanguage:c.translateLanguage,voiceControl:c.voiceControl,smartLabels:c.smartLabels,...o};await w.execute(h);let A=w.applyFixes(h);f(A),y(!0)},[o]),F=(0,b.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await l(s),a(!1)},[s,l]),J=(0,b.useCallback)(()=>{i(de);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let c=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(A=>c.removeAttribute(A)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",f(null),y(!1)},[]),X=(0,b.useCallback)((c,h)=>{i(A=>({...A,[c]:h}))},[]);(0,b.useEffect)(()=>{let c=h=>{h.key==="Escape"&&n&&a(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n]),(0,b.useEffect)(()=>{n&&z.current&&w.trapFocus(z.current)},[n]);let Z={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:p?"#0d9488":"#1a73e8",color:"#fff",border:"none",cursor:"pointer",fontSize:"22px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(0,0,0,0.25)",transition:"transform 0.15s, background 0.2s"};return(0,T.jsxs)(T.Fragment,{children:[t,(0,T.jsx)("button",{style:Z,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":n,"data-yuktai-pref-toggle":"true",onClick:()=>a(c=>!c),onMouseEnter:c=>{c.currentTarget.style.transform="scale(1.08)"},onMouseLeave:c=>{c.currentTarget.style.transform="scale(1)"},children:"\u267F"}),n&&(0,T.jsx)(ce,{ref:z,position:e,settings:s,report:d,isActive:p,aiSupported:g,voiceSupported:$,set:X,onApply:F,onReset:J,onClose:()=>a(!1)})]})}var I={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var H={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var E=class{plugins=new Map;register(t,o){if(!o||typeof o.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,o)}use(t){return this.plugins.get(t)}async run(t,o){try{let n=this.use(t);if(!n)throw new Error(`Plugin not found: ${t}`);return await n.execute(o)}catch(n){throw console.error(`[YuktAI Runtime Error in ${t}]:`,n),n}}getPlugins(){return Array.from(this.plugins.keys())}};function mt(){if(typeof globalThis>"u")return new E;if(!globalThis.__yuktai_runtime__){let e=new E;e.register(w.name,w),e.register(I.name,I),e.register(H.name,H),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var He=typeof window<"u"?mt():new E,bt={wcagPlugin:w,list(){return He.getPlugins()},use(e){return He.use(e)},fix(e){return w.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return w.scan()}};0&&(module.exports={Runtime,YuktAI,YuktAIWrapper,aiPlugin,voicePlugin,wcag,wcagPlugin});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capabilities()).available!=="no":!1}catch{return!1}}async function Fe(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=await window.ai.rewriter.create({tone:"more-casual",format:"plain-text",length:"as-is"}),o=await t.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return t.destroy(),{success:!0,original:e,rewritten:o.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function ce(){if(!await X())return{fixed:0,error:"Chrome Built-in AI not available on this device. Chrome 127+ required."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),o=0;for(let a of t){let n=a.innerText?.trim();if(!n||n.length<20||a.closest("[data-yuktai-panel]"))continue;let s=await Fe(n);s.success&&s.rewritten!==n&&(a.dataset.yuktaiOriginal=n,a.innerText=s.rewritten,o++)}return{fixed:o}}function ue(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let o=t.dataset.yuktaiOriginal;o&&(t.innerText=o,delete t.dataset.yuktaiOriginal)}}var pe="yuktai-summary-box";async function Z(){try{return window.ai?.summarizer?(await window.ai.summarizer.capabilities()).available!=="no":!1}catch{return!1}}function We(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let o of e){if(o.closest("[data-yuktai-panel]"))continue;let a=window.getComputedStyle(o);if(a.display==="none"||a.visibility==="hidden")continue;let n=o.innerText?.trim();n&&n.length>10&&t.push(n)}return t.join(" ").slice(0,5e3)}async function fe(){if(!await Z())return{success:!1,summary:"",error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=We();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let o=await window.ai.summarizer.create({type:"tl;dr",format:"plain-text",length:"short"}),a=await o.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return o.destroy(),Oe(a.trim()),{success:!0,summary:a.trim()}}catch(o){return{success:!1,summary:"",error:o instanceof Error?o.message:"Summary failed"}}}function Oe(e){I();let t=document.createElement("div");t.id=pe,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
1
+ async function Z(){try{return window.ai?.rewriter?(await window.ai.rewriter.capabilities()).available!=="no":!1}catch{return!1}}async function We(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=await window.ai.rewriter.create({tone:"more-casual",format:"plain-text",length:"as-is"}),o=await t.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return t.destroy(),{success:!0,original:e,rewritten:o.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function ue(){if(!await Z())return{fixed:0,error:"Chrome Built-in AI not available on this device. Chrome 127+ required."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),o=0;for(let n of t){let a=n.innerText?.trim();if(!a||a.length<20||n.closest("[data-yuktai-panel]"))continue;let s=await We(a);s.success&&s.rewritten!==a&&(n.dataset.yuktaiOriginal=a,n.innerText=s.rewritten,o++)}return{fixed:o}}function pe(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let o=t.dataset.yuktaiOriginal;o&&(t.innerText=o,delete t.dataset.yuktaiOriginal)}}var fe="yuktai-summary-box";async function Q(){try{return window.ai?.summarizer?(await window.ai.summarizer.capabilities()).available!=="no":!1}catch{return!1}}function Oe(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let o of e){if(o.closest("[data-yuktai-panel]"))continue;let n=window.getComputedStyle(o);if(n.display==="none"||n.visibility==="hidden")continue;let a=o.innerText?.trim();a&&a.length>10&&t.push(a)}return t.join(" ").slice(0,5e3)}async function me(){if(!await Q())return{success:!1,summary:"",error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=Oe();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let o=await window.ai.summarizer.create({type:"tl;dr",format:"plain-text",length:"short"}),n=await o.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return o.destroy(),Ne(n.trim()),{success:!0,summary:n.trim()}}catch(o){return{success:!1,summary:"",error:o instanceof Error?o.message:"Summary failed"}}}function Ne(e){$();let t=document.createElement("div");t.id=fe,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -15,7 +15,7 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
15
15
  justify-content: space-between;
16
16
  gap: 12px;
17
17
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
18
- `;let o=document.createElement("p");o.style.cssText="margin: 0; flex: 1;",o.textContent=`\u{1F4CB} Page summary: ${e}`;let a=document.createElement("button");a.textContent="\xD7",a.setAttribute("aria-label","Close page summary"),a.style.cssText=`
18
+ `;let o=document.createElement("p");o.style.cssText="margin: 0; flex: 1;",o.textContent=`\u{1F4CB} Page summary: ${e}`;let n=document.createElement("button");n.textContent="\xD7",n.setAttribute("aria-label","Close page summary"),n.style.cssText=`
19
19
  background: none;
20
20
  border: none;
21
21
  color: #ffffff;
@@ -24,7 +24,7 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
24
24
  padding: 0 4px;
25
25
  line-height: 1;
26
26
  flex-shrink: 0;
27
- `,a.addEventListener("click",I),t.appendChild(o),t.appendChild(a),document.body.prepend(t)}function I(){let e=document.getElementById(pe);e&&e.remove()}var $=[{code:"en",label:"English"},{code:"hi",label:"Hindi"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"nl",label:"Dutch"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"zh",label:"Chinese"},{code:"ar",label:"Arabic"},{code:"tr",label:"Turkish"},{code:"vi",label:"Vietnamese"},{code:"bn",label:"Bengali"},{code:"id",label:"Indonesian"}],H="en";async function Ne(e){try{return window.translation?await window.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function me(e){if(e===H)return{success:!0,language:e,fixed:0};if(e==="en")return Q(),H="en",{success:!0,language:"en",fixed:0};if(!await Ne(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Chrome 127+ required.`};try{let o=await window.translation.createTranslator({sourceLanguage:"en",targetLanguage:e}),a=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),n=0;for(let s of a){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let i=s.innerText?.trim();if(!i||i.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=i);let d=await o.translate(i);d&&d!==i&&(s.innerText=d,n++)}return o.destroy(),H=e,{success:!0,language:e,fixed:n}}catch(o){return{success:!1,language:e,fixed:0,error:o instanceof Error?o.message:"Translation failed"}}}function Q(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let o=t.dataset.yuktaiTranslationOriginal;o&&(t.innerText=o,delete t.dataset.yuktaiTranslationOriginal)}H="en"}var Be=[{phrases:["go to main","skip to main","main content"],action:"focus-main",label:"Jump to main content"},{phrases:["go to navigation","go to nav","open menu"],action:"focus-nav",label:"Jump to navigation"},{phrases:["go to search","search","find"],action:"focus-search",label:"Jump to search"},{phrases:["scroll down","page down","next"],action:"scroll-down",label:"Scroll down"},{phrases:["scroll up","page up","back up"],action:"scroll-up",label:"Scroll up"},{phrases:["go back","previous page"],action:"go-back",label:"Go back"},{phrases:["click","press","select"],action:"click-focused",label:"Click focused element"},{phrases:["next item","tab forward","tab"],action:"tab-forward",label:"Move to next element"},{phrases:["previous item","tab back","shift tab"],action:"tab-back",label:"Move to previous element"},{phrases:["stop listening","stop voice","quiet"],action:"stop-voice",label:"Stop voice control"}],h=null,F=!1,E=null;function ee(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function _e(e){let t=e.toLowerCase().trim();for(let o of Be)for(let a of o.phrases)if(t.includes(a))return{action:o.action,label:o.label};return null}function De(e){switch(e){case"focus-main":{let t=document.querySelector("main, [role='main'], #main");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-nav":{let t=document.querySelector("nav, [role='navigation']");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-search":{let t=document.querySelector("input[type='search'], input[role='searchbox'], [aria-label*='search' i]");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"scroll-down":{window.scrollBy({top:400,behavior:"smooth"});break}case"scroll-up":{window.scrollBy({top:-400,behavior:"smooth"});break}case"go-back":{window.history.back();break}case"click-focused":{let t=document.activeElement;t&&t!==document.body&&t.click();break}case"tab-forward":{let t=be(),o=t.indexOf(document.activeElement),a=t[o+1]||t[0];a&&a.focus();break}case"tab-back":{let t=be(),o=t.indexOf(document.activeElement),a=t[o-1]||t[t.length-1];a&&a.focus();break}case"stop-voice":{te();break}}}function be(){return Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>!e.closest("[data-yuktai-panel]"))}function ge(e){if(!ee())return!1;if(F)return!0;e&&(E=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return h=new t,h.continuous=!0,h.interimResults=!1,h.lang="en-US",h.onresult=o=>{let a=o.results[o.results.length-1][0].transcript,n=_e(a);if(n){De(n.action);let s={success:!0,command:a,action:n.label};if(E&&E(s),n.action==="stop-voice")return}},h.onend=()=>{F&&h?.start()},h.onerror=o=>{o.error!=="no-speech"&&E&&E({success:!1,command:"",action:"",error:`Voice error: ${o.error}`})},h.start(),F=!0,qe(),!0}function te(){F=!1,h&&(h.stop(),h=null),E=null,ye()}var xe="yuktai-voice-indicator";function qe(){ye();let e=document.createElement("div");e.id=xe,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
27
+ `,n.addEventListener("click",$),t.appendChild(o),t.appendChild(n),document.body.prepend(t)}function $(){let e=document.getElementById(fe);e&&e.remove()}var W=[{code:"en",label:"English"},{code:"hi",label:"Hindi"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"nl",label:"Dutch"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"zh",label:"Chinese"},{code:"ar",label:"Arabic"},{code:"tr",label:"Turkish"},{code:"vi",label:"Vietnamese"},{code:"bn",label:"Bengali"},{code:"id",label:"Indonesian"}],F="en";async function Be(e){try{return window.translation?await window.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function be(e){if(e===F)return{success:!0,language:e,fixed:0};if(e==="en")return ee(),F="en",{success:!0,language:"en",fixed:0};if(!await Be(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Chrome 127+ required.`};try{let o=await window.translation.createTranslator({sourceLanguage:"en",targetLanguage:e}),n=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),a=0;for(let s of n){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let i=s.innerText?.trim();if(!i||i.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=i);let d=await o.translate(i);d&&d!==i&&(s.innerText=d,a++)}return o.destroy(),F=e,{success:!0,language:e,fixed:a}}catch(o){return{success:!1,language:e,fixed:0,error:o instanceof Error?o.message:"Translation failed"}}}function ee(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let o=t.dataset.yuktaiTranslationOriginal;o&&(t.innerText=o,delete t.dataset.yuktaiTranslationOriginal)}F="en"}var _e=[{phrases:["go to main","skip to main","main content"],action:"focus-main",label:"Jump to main content"},{phrases:["go to navigation","go to nav","open menu"],action:"focus-nav",label:"Jump to navigation"},{phrases:["go to search","search","find"],action:"focus-search",label:"Jump to search"},{phrases:["scroll down","page down","next"],action:"scroll-down",label:"Scroll down"},{phrases:["scroll up","page up","back up"],action:"scroll-up",label:"Scroll up"},{phrases:["go back","previous page"],action:"go-back",label:"Go back"},{phrases:["click","press","select"],action:"click-focused",label:"Click focused element"},{phrases:["next item","tab forward","tab"],action:"tab-forward",label:"Move to next element"},{phrases:["previous item","tab back","shift tab"],action:"tab-back",label:"Move to previous element"},{phrases:["stop listening","stop voice","quiet"],action:"stop-voice",label:"Stop voice control"}],w=null,O=!1,E=null;function te(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function De(e){let t=e.toLowerCase().trim();for(let o of _e)for(let n of o.phrases)if(t.includes(n))return{action:o.action,label:o.label};return null}function qe(e){switch(e){case"focus-main":{let t=document.querySelector("main, [role='main'], #main");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-nav":{let t=document.querySelector("nav, [role='navigation']");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-search":{let t=document.querySelector("input[type='search'], input[role='searchbox'], [aria-label*='search' i]");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"scroll-down":{window.scrollBy({top:400,behavior:"smooth"});break}case"scroll-up":{window.scrollBy({top:-400,behavior:"smooth"});break}case"go-back":{window.history.back();break}case"click-focused":{let t=document.activeElement;t&&t!==document.body&&t.click();break}case"tab-forward":{let t=ge(),o=t.indexOf(document.activeElement),n=t[o+1]||t[0];n&&n.focus();break}case"tab-back":{let t=ge(),o=t.indexOf(document.activeElement),n=t[o-1]||t[t.length-1];n&&n.focus();break}case"stop-voice":{oe();break}}}function ge(){return Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>!e.closest("[data-yuktai-panel]"))}function ye(e){if(!te())return!1;if(O)return!0;e&&(E=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return w=new t,w.continuous=!0,w.interimResults=!1,w.lang="en-US",w.onresult=o=>{let n=o.results[o.results.length-1][0].transcript,a=De(n);if(a){qe(a.action);let s={success:!0,command:n,action:a.label};if(E&&E(s),a.action==="stop-voice")return}},w.onend=()=>{O&&w?.start()},w.onerror=o=>{o.error!=="no-speech"&&E&&E({success:!1,command:"",action:"",error:`Voice error: ${o.error}`})},w.start(),O=!0,Ge(),!0}function oe(){O=!1,w&&(w.stop(),w=null),E=null,he()}var xe="yuktai-voice-indicator";function Ge(){he();let e=document.createElement("div");e.id=xe,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
28
28
  position: fixed;
29
29
  bottom: 80px;
30
30
  left: 50%;
@@ -49,12 +49,12 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
49
49
  background: #ffffff;
50
50
  animation: yuktai-pulse 1.2s infinite;
51
51
  flex-shrink: 0;
52
- `,!document.getElementById("yuktai-pulse-style")){let a=document.createElement("style");a.id="yuktai-pulse-style",a.textContent=`
52
+ `,!document.getElementById("yuktai-pulse-style")){let n=document.createElement("style");n.id="yuktai-pulse-style",n.textContent=`
53
53
  @keyframes yuktai-pulse {
54
54
  0%, 100% { opacity: 1; transform: scale(1); }
55
55
  50% { opacity: 0.4; transform: scale(0.7); }
56
56
  }
57
- `,document.head.appendChild(a)}let o=document.createElement("span");o.textContent="Listening for commands...",e.appendChild(t),e.appendChild(o),document.body.appendChild(e)}function ye(){let e=document.getElementById(xe);e&&e.remove()}var Ge=["button:not([aria-label]):not([aria-labelledby])","a:not([aria-label]):not([aria-labelledby])","input:not([aria-label]):not([aria-labelledby]):not([id])","select:not([aria-label]):not([aria-labelledby])","textarea:not([aria-label]):not([aria-labelledby])","[role='button']:not([aria-label])","[role='link']:not([aria-label])","[role='checkbox']:not([aria-label])","[role='tab']:not([aria-label])"].join(", ");async function oe(){try{return window.ai?.writer?(await window.ai.writer.capabilities()).available!=="no":!1}catch{return!1}}function Ve(e){let t=[],o=e.innerText?.trim();o&&t.push(`element text: "${o}"`);let a=e.placeholder?.trim();a&&t.push(`placeholder: "${a}"`);let n=e.getAttribute("name")?.trim();n&&t.push(`name: "${n}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let i=e.id;if(i){let f=document.querySelector(`label[for="${i}"]`);f&&t.push(`label: "${f.innerText?.trim()}"`)}let d=e.parentElement?.innerText?.trim().slice(0,60);d&&t.push(`parent context: "${d}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let m=e.getAttribute("role");return m&&t.push(`role: ${m}`),t.join(". ")}async function je(e,t){let o=`
57
+ `,document.head.appendChild(n)}let o=document.createElement("span");o.textContent="Listening for commands...",e.appendChild(t),e.appendChild(o),document.body.appendChild(e)}function he(){let e=document.getElementById(xe);e&&e.remove()}var Ve=["button:not([aria-label]):not([aria-labelledby])","a:not([aria-label]):not([aria-labelledby])","input:not([aria-label]):not([aria-labelledby]):not([id])","select:not([aria-label]):not([aria-labelledby])","textarea:not([aria-label]):not([aria-labelledby])","[role='button']:not([aria-label])","[role='link']:not([aria-label])","[role='checkbox']:not([aria-label])","[role='tab']:not([aria-label])"].join(", ");async function ie(){try{return window.ai?.writer?(await window.ai.writer.capabilities()).available!=="no":!1}catch{return!1}}function je(e){let t=[],o=e.innerText?.trim();o&&t.push(`element text: "${o}"`);let n=e.placeholder?.trim();n&&t.push(`placeholder: "${n}"`);let a=e.getAttribute("name")?.trim();a&&t.push(`name: "${a}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let i=e.id;if(i){let f=document.querySelector(`label[for="${i}"]`);f&&t.push(`label: "${f.innerText?.trim()}"`)}let d=e.parentElement?.innerText?.trim().slice(0,60);d&&t.push(`parent context: "${d}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let m=e.getAttribute("role");return m&&t.push(`role: ${m}`),t.join(". ")}async function Ke(e,t){let o=`
58
58
  Generate a short, clear aria-label for an HTML element.
59
59
  The label must be 2-6 words maximum.
60
60
  The label must describe what the element does or what it is.
@@ -65,7 +65,7 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
65
65
  ${t}
66
66
 
67
67
  Output only the label. Nothing else.
68
- `.trim();return(await e.write(o)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function he(){if(!await oe())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=document.querySelectorAll(Ge);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let o=await window.ai.writer.create({tone:"neutral",format:"plain-text",length:"short"}),a=0,n=[];for(let s of t){if(s.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(s);if(i.display==="none"||i.visibility==="hidden")continue;let d=Ve(s),m=await je(o,d);m&&m.length>0&&(s.dataset.yuktaiLabelOriginal=s.getAttribute("aria-label")||"",s.setAttribute("aria-label",m),a++,n.push({tag:s.tagName.toLowerCase(),label:m}))}return o.destroy(),{success:!0,fixed:a,elements:n}}catch(o){return{success:!1,fixed:0,elements:[],error:o instanceof Error?o.message:"Label generation failed"}}}function we(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let o=t.dataset.yuktaiLabelOriginal;o?t.setAttribute("aria-label",o):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var N=null,ve=null;var ke=null,ie=null,b=null,T=null,W=null,ne=null,C=null,O={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Ae=new Set(["input","select","textarea"]);var ae={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function re(e,t="polite"){if(typeof window>"u"||!C?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let o=new SpeechSynthesisUtterance(e);o.rate=1,o.pitch=1,o.volume=1;let a=window.speechSynthesis.getVoices();a.length>0&&(o.voice=a[0]),window.speechSynthesis.speak(o)}function Re(e,t="info"){if(typeof document>"u")return;let a={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];b||(b=document.createElement("div"),b.setAttribute("role","alert"),b.setAttribute("aria-live","assertive"),b.setAttribute("aria-atomic","true"),b.style.cssText=`
68
+ `.trim();return(await e.write(o)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function we(){if(!await ie())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=document.querySelectorAll(Ve);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let o=await window.ai.writer.create({tone:"neutral",format:"plain-text",length:"short"}),n=0,a=[];for(let s of t){if(s.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(s);if(i.display==="none"||i.visibility==="hidden")continue;let d=je(s),m=await Ke(o,d);m&&m.length>0&&(s.dataset.yuktaiLabelOriginal=s.getAttribute("aria-label")||"",s.setAttribute("aria-label",m),n++,a.push({tag:s.tagName.toLowerCase(),label:m}))}return o.destroy(),{success:!0,fixed:n,elements:a}}catch(o){return{success:!1,fixed:0,elements:[],error:o instanceof Error?o.message:"Label generation failed"}}}function ve(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let o=t.dataset.yuktaiLabelOriginal;o?t.setAttribute("aria-label",o):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var _=null,ke=null;var Ae=null,ae=null,b=null,T=null,N=null,ne=null,C=null,B={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Se=new Set(["input","select","textarea"]);var re={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function se(e,t="polite"){if(typeof window>"u"||!C?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let o=new SpeechSynthesisUtterance(e);o.rate=1,o.pitch=1,o.volume=1;let n=window.speechSynthesis.getVoices();n.length>0&&(o.voice=n[0]),window.speechSynthesis.speak(o)}function Pe(e,t="info"){if(typeof document>"u")return;let n={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];b||(b=document.createElement("div"),b.setAttribute("role","alert"),b.setAttribute("aria-live","assertive"),b.setAttribute("aria-atomic","true"),b.style.cssText=`
69
69
  position: fixed;
70
70
  top: 80px;
71
71
  right: 16px;
@@ -84,14 +84,14 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
84
84
  transition: transform 0.3s, opacity 0.3s;
85
85
  transform: translateX(120%);
86
86
  opacity: 0;
87
- `,document.body.appendChild(b)),b.style.background=a.bg,b.style.border=`1px solid ${a.border}`,b.style.color="#fff",b.innerHTML=`
88
- <span style="font-size:18px;font-weight:700">${a.icon}</span>
87
+ `,document.body.appendChild(b)),b.style.background=n.bg,b.style.border=`1px solid ${n.border}`,b.style.color="#fff",b.innerHTML=`
88
+ <span style="font-size:18px;font-weight:700">${n.icon}</span>
89
89
  <span style="flex:1;line-height:1.4">${e}</span>
90
90
  <button
91
91
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
92
92
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
93
93
  aria-label="Close notification">\xD7</button>
94
- `,window.innerWidth<=480&&(b.style.right="8px",b.style.left="8px",b.style.maxWidth="none",b.style.width="auto"),requestAnimationFrame(()=>{b&&(b.style.transform="translateX(0)",b.style.opacity="1")}),setTimeout(()=>{b&&(b.style.transform="translateX(120%)",b.style.opacity="0")},5e3)}function u(e,t="info",o=!0){N&&(N.textContent=e),Re(e,t),o&&re(e,t==="error"?"assertive":"polite")}function Ke(){if(typeof document>"u"||ke)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
94
+ `,window.innerWidth<=480&&(b.style.right="8px",b.style.left="8px",b.style.maxWidth="none",b.style.width="auto"),requestAnimationFrame(()=>{b&&(b.style.transform="translateX(0)",b.style.opacity="1")}),setTimeout(()=>{b&&(b.style.transform="translateX(120%)",b.style.opacity="0")},5e3)}function u(e,t="info",o=!0){_&&(_.textContent=e),Pe(e,t),o&&se(e,t==="error"?"assertive":"polite")}function Ye(){if(typeof document>"u"||Ae)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
95
95
  position: fixed;
96
96
  top: 0;
97
97
  left: 0;
@@ -105,7 +105,7 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
105
105
  transform: translateY(-100%);
106
106
  transition: transform 0.2s ease;
107
107
  font-family: system-ui, sans-serif;
108
- `;let o=!1;if(e.forEach(({label:n,selector:s})=>{let i=document.querySelector(s);if(!i)return;o=!0,i.getAttribute("tabindex")||i.setAttribute("tabindex","-1");let d=document.createElement("a");d.href="#",d.textContent=n,d.style.cssText=`
108
+ `;let o=!1;if(e.forEach(({label:a,selector:s})=>{let i=document.querySelector(s);if(!i)return;o=!0,i.getAttribute("tabindex")||i.setAttribute("tabindex","-1");let d=document.createElement("a");d.href="#",d.textContent=a,d.style.cssText=`
109
109
  color: #fff;
110
110
  background: #1a73e8;
111
111
  padding: 8px 14px;
@@ -116,7 +116,7 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
116
116
  white-space: nowrap;
117
117
  border: 2px solid transparent;
118
118
  transition: background 0.15s, border-color 0.15s;
119
- `,d.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),d.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),d.addEventListener("click",m=>{m.preventDefault(),i.focus(),i.scrollIntoView({behavior:"smooth",block:"start"}),u(`Jumped to ${n.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(d)}),!o)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),ke=t}function Ye(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
119
+ `,d.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),d.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),d.addEventListener("click",m=>{m.preventDefault(),i.focus(),i.scrollIntoView({behavior:"smooth",block:"start"}),u(`Jumped to ${a.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(d)}),!o)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Ae=t}function Ue(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
120
120
 
121
121
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
122
122
  [data-yuktai-a11y] *:focus-visible {
@@ -262,7 +262,7 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
262
262
  width: auto !important;
263
263
  }
264
264
  }
265
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function Ue(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let o=t.getAttribute("role")||"";if(e.key==="Escape"){let a=t.closest("[role='dialog'],[role='alertdialog']");if(a){a.style.display="none",u("Dialog closed","info");return}let n=t.closest("[role='menu'],[role='menubar']");n&&(n.style.display="none",u("Menu closed","info"))}if(o==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let a=t.closest("[role='menu'],[role='menubar']");if(!a)return;let n=Array.from(a.querySelectorAll("[role='menuitem']:not([disabled])")),s=n.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),n[(s+1)%n.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),n[(s-1+n.length)%n.length]?.focus()):e.key==="Home"?(e.preventDefault(),n[0]?.focus()):e.key==="End"&&(e.preventDefault(),n[n.length-1]?.focus())}if(o==="tab"||t.closest("[role='tablist']")){let a=t.closest("[role='tablist']");if(!a)return;let n=Array.from(a.querySelectorAll("[role='tab']:not([disabled])")),s=n.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let i=n[(s+1)%n.length];i?.focus(),i?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let i=n[(s-1+n.length)%n.length];i?.focus(),i?.click()}}if(o==="option"||t.closest("[role='listbox']")){let a=t.closest("[role='listbox']");if(!a)return;let n=Array.from(a.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=n.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),n[(s+1)%n.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),n[(s-1+n.length)%n.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),n.forEach(i=>{i!==t&&i.setAttribute("aria-selected","false")}),u(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Je()),e.key==="Tab"&&C?.speechEnabled&&setTimeout(()=>{let a=document.activeElement;if(!a)return;let n=a.getAttribute("aria-label")||a.getAttribute("title")||a.textContent?.trim()||a.tagName.toLowerCase(),s=a.getAttribute("role")||a.tagName.toLowerCase();re(`${n}, ${s}`)},100)}))}function B(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let o=t[0],a=t[t.length-1];o.focus(),e.addEventListener("keydown",n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===o&&(n.preventDefault(),a.focus()):document.activeElement===a&&(n.preventDefault(),o.focus()))})}function Je(){if(typeof document>"u")return;if(T){T.remove(),T=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
265
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function Je(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let o=t.getAttribute("role")||"";if(e.key==="Escape"){let n=t.closest("[role='dialog'],[role='alertdialog']");if(n){n.style.display="none",u("Dialog closed","info");return}let a=t.closest("[role='menu'],[role='menubar']");a&&(a.style.display="none",u("Menu closed","info"))}if(o==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let n=t.closest("[role='menu'],[role='menubar']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='menuitem']:not([disabled])")),s=a.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),a[(s+1)%a.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),a[(s-1+a.length)%a.length]?.focus()):e.key==="Home"?(e.preventDefault(),a[0]?.focus()):e.key==="End"&&(e.preventDefault(),a[a.length-1]?.focus())}if(o==="tab"||t.closest("[role='tablist']")){let n=t.closest("[role='tablist']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='tab']:not([disabled])")),s=a.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let i=a[(s+1)%a.length];i?.focus(),i?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let i=a[(s-1+a.length)%a.length];i?.focus(),i?.click()}}if(o==="option"||t.closest("[role='listbox']")){let n=t.closest("[role='listbox']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=a.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),a[(s+1)%a.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),a[(s-1+a.length)%a.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),a.forEach(i=>{i!==t&&i.setAttribute("aria-selected","false")}),u(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Xe()),e.key==="Tab"&&C?.speechEnabled&&setTimeout(()=>{let n=document.activeElement;if(!n)return;let a=n.getAttribute("aria-label")||n.getAttribute("title")||n.textContent?.trim()||n.tagName.toLowerCase(),s=n.getAttribute("role")||n.tagName.toLowerCase();se(`${a}, ${s}`)},100)}))}function D(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let o=t[0],n=t[t.length-1];o.focus(),e.addEventListener("keydown",a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===o&&(a.preventDefault(),n.focus()):document.activeElement===n&&(a.preventDefault(),o.focus()))})}function Xe(){if(typeof document>"u")return;if(T){T.remove(),T=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
266
266
  position: fixed;
267
267
  top: 50%;
268
268
  left: 50%;
@@ -286,13 +286,13 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
286
286
  style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1"
287
287
  aria-label="Close shortcuts">\xD7</button>
288
288
  </div>
289
- ${t.map(([a,n])=>`
289
+ ${t.map(([n,a])=>`
290
290
  <div style="display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid #2a2a4a">
291
- <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${a}</kbd>
292
- <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${n}</span>
291
+ <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${n}</kbd>
292
+ <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${a}</span>
293
293
  </div>
294
294
  `).join("")}
295
- `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),T=null}),e.addEventListener("keydown",a=>{a.key==="Escape"&&(e.remove(),T=null)}),document.body.appendChild(e),T=e,B(e),u("Keyboard shortcuts opened. Press Escape to close.","info")}function Xe(e){if(typeof document>"u"||!C?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;ie&&ie.remove();let t=e.score,o=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",a=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",n=document.createElement("button");n.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),n.setAttribute("data-yuktai-badge","true"),n.style.cssText=`
295
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),T=null}),e.addEventListener("keydown",n=>{n.key==="Escape"&&(e.remove(),T=null)}),document.body.appendChild(e),T=e,D(e),u("Keyboard shortcuts opened. Press Escape to close.","info")}function Ze(e){if(typeof document>"u"||!C?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;ae&&ae.remove();let t=e.score,o=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",n=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",a=document.createElement("button");a.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),a.setAttribute("data-yuktai-badge","true"),a.style.cssText=`
296
296
  position: fixed;
297
297
  bottom: 16px;
298
298
  left: 16px;
@@ -311,7 +311,7 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
311
311
  align-items: center;
312
312
  gap: 6px;
313
313
  transition: transform 0.15s;
314
- `,n.innerHTML=`${a} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,n.addEventListener("click",()=>Ze(e)),document.body.appendChild(n),ie=n}function Ze(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let o=document.createElement("div");o.setAttribute("data-yuktai-audit-details","true"),o.setAttribute("role","dialog"),o.setAttribute("aria-label","Accessibility audit details"),o.style.cssText=`
314
+ `,a.innerHTML=`${n} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,a.addEventListener("click",()=>Qe(e)),document.body.appendChild(a),ae=a}function Qe(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let o=document.createElement("div");o.setAttribute("data-yuktai-audit-details","true"),o.setAttribute("role","dialog"),o.setAttribute("aria-label","Accessibility audit details"),o.style.cssText=`
315
315
  position: fixed;
316
316
  bottom: 56px;
317
317
  left: 16px;
@@ -328,22 +328,22 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
328
328
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
329
329
  font-family: system-ui, sans-serif;
330
330
  font-size: 12px;
331
- `;let a={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};o.innerHTML=`
331
+ `;let n={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};o.innerHTML=`
332
332
  <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
333
333
  <strong style="font-size:14px;color:#74c0fc">Audit report</strong>
334
334
  <span style="color:#aaa">${e.fixed} fixed \xB7 ${e.renderTime}ms</span>
335
335
  </div>
336
- ${e.details.slice(0,20).map(n=>`
336
+ ${e.details.slice(0,20).map(a=>`
337
337
  <div style="padding:6px 0;border-bottom:1px solid #2a2a4a">
338
338
  <div style="display:flex;gap:6px;align-items:center">
339
- <span style="background:${a[n.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${n.severity}</span>
340
- <code style="color:#74c0fc">&lt;${n.tag}&gt;</code>
339
+ <span style="background:${n[a.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${a.severity}</span>
340
+ <code style="color:#74c0fc">&lt;${a.tag}&gt;</code>
341
341
  </div>
342
- <div style="color:#ccc;margin-top:3px">${n.fix}</div>
342
+ <div style="color:#ccc;margin-top:3px">${a.fix}</div>
343
343
  </div>
344
344
  `).join("")}
345
345
  ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
346
- `,o.addEventListener("keydown",n=>{n.key==="Escape"&&o.remove()}),document.body.appendChild(o),B(o)}function Pe(e){typeof document>"u"||(ne&&clearTimeout(ne),ne=setTimeout(()=>{if(W)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
346
+ `,o.addEventListener("keydown",a=>{a.key==="Escape"&&o.remove()}),document.body.appendChild(o),D(o)}function ze(e){typeof document>"u"||(ne&&clearTimeout(ne),ne=setTimeout(()=>{if(N)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
347
347
  position: fixed;
348
348
  top: 50%;
349
349
  left: 50%;
@@ -372,19 +372,19 @@ async function X(){try{return window.ai?.rewriter?(await window.ai.rewriter.capa
372
372
  No, sign out
373
373
  </button>
374
374
  </div>
375
- `;let o=t.querySelector("[data-yuktai-extend]"),a=t.querySelector("[data-yuktai-dismiss]");o?.addEventListener("click",()=>{t.remove(),W=null,u("Session extended. You have more time.","success"),C?.timeoutWarning&&Pe(C.timeoutWarning)}),a?.addEventListener("click",()=>{t.remove(),W=null}),document.body.appendChild(t),W=t,B(t),u("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function Qe(e){if(typeof document>"u")return;let t=document.documentElement;if(t.toggleAttribute("data-yuktai-high-contrast",!!e.highContrast),t.toggleAttribute("data-yuktai-dark",!!e.darkMode),t.toggleAttribute("data-yuktai-reduce-motion",!!e.reduceMotion),t.toggleAttribute("data-yuktai-large-targets",!!e.largeTargets),t.toggleAttribute("data-yuktai-keyboard",!!e.keyboardHints),t.toggleAttribute("data-yuktai-dyslexia",!!e.dyslexiaFont),e.localFont?document.body.style.fontFamily=`"${e.localFont}", system-ui, sans-serif`:e.dyslexiaFont||(document.body.style.fontFamily=""),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1?document.documentElement.style.fontSize=`${e.fontSizeMultiplier*100}%`:document.documentElement.style.fontSize="",e.colorBlindMode&&e.colorBlindMode!=="none"){let o=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${O[e.colorBlindMode]})`;document.body.style.filter=o}else document.body.style.filter=""}function et(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Se(e){if(e){if(!await X()){u("Plain English requires Chrome 127+","warning");return}u("Rewriting page in plain English...","info",!1);let o=await ce();u(o.error?`Plain English failed: ${o.error}`:`${o.fixed} sections rewritten in plain English`,o.error?"error":"success",!1)}else ue(),u("Original text restored","info",!1)}async function Ee(e){if(e){if(!await Z()){u("Page summariser requires Chrome 127+","warning");return}u("Generating page summary...","info",!1);let o=await fe();u(o.error?`Summary failed: ${o.error}`:"Page summary added at top",o.error?"error":"success",!1)}else I(),u("Page summary removed","info",!1)}async function Te(e){if(e==="en"){Q(),u("Page restored to English","info",!1);return}u(`Translating page to ${e}...`,"info",!1);let t=await me(e);u(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Ce(e){if(e){if(!ee()){u("Voice control not supported in this browser","warning");return}ge(t=>{t.success&&u(`Voice: ${t.action}`,"info",!1)}),u("Voice control started. Say a command.","success",!1)}else te(),u("Voice control stopped","info",!1)}async function Le(e){if(e){if(!await oe()){u("Smart labels requires Chrome 127+","warning");return}u("Generating smart labels...","info",!1);let o=await he();u(o.error?`Smart labels failed: ${o.error}`:`${o.fixed} elements labelled`,o.error?"error":"success",!1)}else we(),u("Smart labels removed","info",!1)}function tt(){if(typeof document>"u"||N)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("aria-relevant","text"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);",document.body.appendChild(e),N=e}function ot(){if(typeof document>"u"||ve)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
375
+ `;let o=t.querySelector("[data-yuktai-extend]"),n=t.querySelector("[data-yuktai-dismiss]");o?.addEventListener("click",()=>{t.remove(),N=null,u("Session extended. You have more time.","success"),C?.timeoutWarning&&ze(C.timeoutWarning)}),n?.addEventListener("click",()=>{t.remove(),N=null}),document.body.appendChild(t),N=t,D(t),u("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function et(e){if(typeof document>"u")return;let t=document.documentElement;if(t.toggleAttribute("data-yuktai-high-contrast",!!e.highContrast),t.toggleAttribute("data-yuktai-dark",!!e.darkMode),t.toggleAttribute("data-yuktai-reduce-motion",!!e.reduceMotion),t.toggleAttribute("data-yuktai-large-targets",!!e.largeTargets),t.toggleAttribute("data-yuktai-keyboard",!!e.keyboardHints),t.toggleAttribute("data-yuktai-dyslexia",!!e.dyslexiaFont),e.localFont?document.body.style.fontFamily=`"${e.localFont}", system-ui, sans-serif`:e.dyslexiaFont||(document.body.style.fontFamily=""),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1?document.documentElement.style.fontSize=`${e.fontSizeMultiplier*100}%`:document.documentElement.style.fontSize="",e.colorBlindMode&&e.colorBlindMode!=="none"){let o=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${B[e.colorBlindMode]})`;document.body.style.filter=o}else document.body.style.filter=""}function tt(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Ee(e){if(e){if(!await Z()){u("Plain English requires Chrome 127+","warning");return}u("Rewriting page in plain English...","info",!1);let o=await ue();u(o.error?`Plain English failed: ${o.error}`:`${o.fixed} sections rewritten in plain English`,o.error?"error":"success",!1)}else pe(),u("Original text restored","info",!1)}async function Te(e){if(e){if(!await Q()){u("Page summariser requires Chrome 127+","warning");return}u("Generating page summary...","info",!1);let o=await me();u(o.error?`Summary failed: ${o.error}`:"Page summary added at top",o.error?"error":"success",!1)}else $(),u("Page summary removed","info",!1)}async function Ce(e){if(e==="en"){ee(),u("Page restored to English","info",!1);return}u(`Translating page to ${e}...`,"info",!1);let t=await be(e);u(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Le(e){if(e){if(!te()){u("Voice control not supported in this browser","warning");return}ye(t=>{t.success&&u(`Voice: ${t.action}`,"info",!1)}),u("Voice control started. Say a command.","success",!1)}else oe(),u("Voice control stopped","info",!1)}async function Me(e){if(e){if(!await ie()){u("Smart labels requires Chrome 127+","warning");return}u("Generating smart labels...","info",!1);let o=await we();u(o.error?`Smart labels failed: ${o.error}`:`${o.fixed} elements labelled`,o.error?"error":"success",!1)}else ve(),u("Smart labels removed","info",!1)}function ot(){if(typeof document>"u"||_)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("aria-relevant","text"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);",document.body.appendChild(e),_=e}function it(){if(typeof document>"u"||ke)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
376
376
  <defs>
377
- <filter id="${O.deuteranopia}">
377
+ <filter id="${B.deuteranopia}">
378
378
  <feColorMatrix type="matrix"
379
379
  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"/>
380
380
  </filter>
381
- <filter id="${O.protanopia}">
381
+ <filter id="${B.protanopia}">
382
382
  <feColorMatrix type="matrix"
383
383
  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"/>
384
384
  </filter>
385
- <filter id="${O.tritanopia}">
385
+ <filter id="${B.tritanopia}">
386
386
  <feColorMatrix type="matrix"
387
387
  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"/>
388
388
  </filter>
389
389
  </defs>
390
- `,document.body.appendChild(e),ve=e}function Me(e){let t={critical:20,serious:10,moderate:5,minor:2},o=e.details.reduce((a,n)=>a+(t[n.severity]||0),0);return Math.max(0,Math.min(100,100-o))}var w={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";C=e,et(e),tt(),ot(),Ye(),Ue(),e.showSkipLinks!==!1&&Ke(),e.showPreferencePanel,Qe(e);let t=this.applyFixes(e);t.score=Me(t),e.showAuditBadge&&Xe(t),e.timeoutWarning&&Pe(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Se(!0),e.summarisePage&&await Ee(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Te(e.translateLanguage),e.voiceControl&&await Ce(!0),e.smartLabels&&await Le(!0);let o=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return u(o,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${o} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let o=performance.now(),a=document.querySelectorAll("*");t.scanned=a.length;let n=(s,i,d,m)=>{t.details.push({tag:s,fix:i,severity:d,element:m.outerHTML.slice(0,100)}),t.fixed++};return a.forEach(s=>{let i=s,d=i.tagName.toLowerCase();if(d==="html"&&!i.getAttribute("lang")&&(i.setAttribute("lang","en"),n(d,'lang="en" added',"critical",i)),d==="meta"){let f=i.getAttribute("name"),x=i.getAttribute("content")||"";f==="viewport"&&x.includes("user-scalable=no")&&(i.setAttribute("content",x.replace("user-scalable=no","user-scalable=yes")),n(d,"user-scalable=yes restored","serious",i)),f==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(x)&&(i.setAttribute("content",x.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),n(d,"maximum-scale=5 restored","serious",i))}if(d==="main"&&!i.getAttribute("tabindex")&&(i.setAttribute("tabindex","-1"),i.getAttribute("id")||i.setAttribute("id","main-content")),d==="img"&&(i.hasAttribute("alt")||(i.setAttribute("alt",""),i.setAttribute("aria-hidden","true"),n(d,'alt="" aria-hidden="true"',"serious",i))),d==="svg"&&(!i.getAttribute("aria-hidden")&&!i.getAttribute("aria-label")&&!s.querySelector("title")&&(i.setAttribute("aria-hidden","true"),n(d,'aria-hidden="true" (decorative svg)',"minor",i)),i.getAttribute("focusable")||i.setAttribute("focusable","false")),d==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&(i.setAttribute("title","embedded content"),i.setAttribute("aria-label","embedded content"),n(d,"title + aria-label added","serious",i)),d==="button"){if(!i.innerText?.trim()&&!i.getAttribute("aria-label")){let f=i.getAttribute("title")||"button";i.setAttribute("aria-label",f),n(d,`aria-label="${f}" (empty button)`,"critical",i)}i.hasAttribute("disabled")&&!i.getAttribute("aria-disabled")&&(i.setAttribute("aria-disabled","true"),t.fixed++)}if(d==="a"){let f=i;!i.innerText?.trim()&&!i.getAttribute("aria-label")&&(i.setAttribute("aria-label",i.getAttribute("title")||"link"),n(d,"aria-label added (empty link)","critical",i)),f.target==="_blank"&&!f.rel?.includes("noopener")&&(f.rel="noopener noreferrer",t.fixed++)}if(Ae.has(d)){let f=i;if(!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")){let x=i.getAttribute("placeholder")||i.getAttribute("name")||d;i.setAttribute("aria-label",x),n(d,`aria-label="${x}"`,"serious",i)}if(i.hasAttribute("required")&&!i.getAttribute("aria-required")&&(i.setAttribute("aria-required","true"),t.fixed++),d==="input"&&!f.autocomplete){let x=f.name||"";f.type==="email"||x.includes("email")?f.autocomplete="email":f.type==="tel"||x.includes("tel")?f.autocomplete="tel":f.type==="password"&&(f.autocomplete="current-password"),t.fixed++}}d==="th"&&!i.getAttribute("scope")&&(i.setAttribute("scope",i.closest("thead")?"col":"row"),n(d,"scope added to <th>","moderate",i)),ae[d]&&!i.getAttribute("role")&&(i.setAttribute("role",ae[d]),n(d,`role="${ae[d]}"`,"minor",i));let m=i.getAttribute("role")||"";m==="tab"&&!i.getAttribute("aria-selected")&&(i.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(m)&&!i.getAttribute("aria-live")&&(i.setAttribute("aria-live",m==="alert"?"assertive":"polite"),n(d,`aria-live added on role=${m}`,"moderate",i)),m==="combobox"&&!i.getAttribute("aria-expanded")&&(i.setAttribute("aria-expanded","false"),n(d,'aria-expanded="false" on combobox',"serious",i)),(m==="checkbox"||m==="radio")&&!i.getAttribute("aria-checked")&&(i.setAttribute("aria-checked","false"),n(d,`aria-checked="false" on role=${m}`,"serious",i))}),t.renderTime=parseFloat((performance.now()-o).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),o=document.querySelectorAll("*");e.scanned=o.length;let a=(n,s,i,d)=>e.details.push({tag:n,fix:s,severity:i,element:d.outerHTML.slice(0,100)});return o.forEach(n=>{let s=n,i=s.tagName.toLowerCase();(i==="a"||i==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&a(i,"needs aria-label (empty)","critical",s),i==="img"&&!s.hasAttribute("alt")&&a(i,"needs alt text","serious",s),Ae.has(i)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&a(i,"needs aria-label","serious",s),i==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&a(i,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=Me(e),e.renderTime=parseFloat((performance.now()-t).toFixed(2)),e},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer?.disconnect(),this.observer=null},announce:u,speak:re,showVisualAlert:Re,trapFocus:B,handlePlainEnglish:Se,handleSummarisePage:Ee,handleTranslate:Te,handleVoiceControl:Ce,handleSmartLabels:Le,SUPPORTED_LANGUAGES:$};import lt,{useEffect as D,useState as M,useCallback as q}from"react";import{forwardRef as it,useEffect as ze,useState as Ie}from"react";import{jsx as r,jsxs as p}from"react/jsx-runtime";var se={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100,localFont:"",darkMode:!1,largeTargets:!1,speechEnabled:!1,colorBlindMode:"none",showAuditBadge:!1,timeoutWarning:void 0,plainEnglish:!1,summarisePage:!1,translateLanguage:"en",voiceControl:!1,smartLabels:!1},L=[80,90,100,110,120,130],nt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],at=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function rt(){let[e,t]=Ie(typeof window<"u"?window.innerWidth:1024);return ze(()=>{let o=()=>t(window.innerWidth);return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function st({checked:e,onChange:t,label:o,disabled:a=!1}){return p("label",{"aria-label":o,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:a?"not-allowed":"pointer",flexShrink:0,opacity:a?.4:1},children:[r("input",{type:"checkbox",checked:e,disabled:a,onChange:n=>t(n.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),r("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),r("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function _({label:e,color:t="#64748b",badge:o}){return p("div",{style:{display:"flex",alignItems:"center",gap:"8px",margin:"8px 18px 4px"},children:[r("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),o&&r("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:o})]})}function k({icon:e,label:t,desc:o,checked:a,onChange:n,disabled:s=!1,disabledReason:i}){return p("div",{title:s?i:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[p("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[r("span",{"aria-hidden":"true",style:{width:"30px",height:"30px",borderRadius:"8px",background:s?"#f1f5f9":"#f0fdfa",color:s?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",flexShrink:0,fontWeight:700},children:e}),p("div",{style:{minWidth:0},children:[r("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:s?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),r("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:s?i:o})]})]}),r(st,{checked:a,onChange:n,label:`Toggle ${t}`,disabled:s})]})}function y(){return r("div",{style:{height:"1px",background:"#f1f5f9",margin:"0"}})}var le=it(({position:e,settings:t,report:o,isActive:a,aiSupported:n,voiceSupported:s,set:i,onApply:d,onReset:m,onClose:f},x)=>{let{isMobile:g,isTablet:j}=rt(),[P,K]=Ie([]);ze(()=>{(async()=>{try{let z=window;if(!z.queryLocalFonts)return;let Y=await z.queryLocalFonts(),U=[...new Set(Y.map(J=>J.family))].sort();K(U.slice(0,50))}catch{}})()},[]);let R=g?{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px 16px 0 0",boxShadow:"0 -8px 32px rgba(0,0,0,0.12)",maxHeight:"90vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif",width:"100%"}:{position:"fixed",bottom:"84px",[e]:"24px",zIndex:9999,width:j?"300px":"320px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",maxHeight:"80vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif"};return p("div",{ref:x,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:R,children:[p("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between",position:"sticky",top:0,background:"#fff",zIndex:1},children:[p("div",{children:[p("div",{style:{display:"flex",alignItems:"center",gap:"7px",marginBottom:"5px",flexWrap:"wrap"},children:[r("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v2.0.18"}),a&&r("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),r("p",{style:{margin:"0 0 2px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),r("p",{style:{margin:0,fontSize:"12px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost"})]}),r("button",{onClick:f,"aria-label":"Close accessibility panel",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#94a3b8",fontSize:"20px",lineHeight:1,borderRadius:"6px",flexShrink:0,minWidth:g?"44px":"auto",minHeight:g?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),r(_,{label:"Core"}),r(k,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:l=>i("autoFix",l)}),r(y,{}),r(k,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:l=>i("speechEnabled",l)}),r(y,{}),r(k,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:l=>i("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser"}),r(y,{}),r(_,{label:"AI features",color:"#7c3aed",badge:"Gemini Nano \xB7 Chrome 127+"}),r("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:"#f5f3ff",borderRadius:"8px",border:"0.5px solid #c4b5fd",fontSize:"10px",color:"#7c3aed",lineHeight:1.5},children:n?"Gemini Nano detected \u2014 AI features ready. Runs privately on your device. No data leaves your browser.":"AI features need setup \u2014 see guide below."}),!n&&p("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[r("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} How to enable AI features:"}),p("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome and go to"," ",r("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),p("p",{style:{margin:"0 0 3px"},children:["2. Search and set each to ",r("strong",{style:{color:"#0f172a"},children:"Enabled:"})]}),r("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:at.map(l=>p("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",l]},l))}),p("p",{style:{margin:"0 0 3px"},children:["3. Click ",r("strong",{style:{color:"#0f172a"},children:"Relaunch"})," when Chrome prompts you"]}),p("p",{style:{margin:"0 0 3px"},children:["4. Go to"," ",r("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://components"})]}),p("p",{style:{margin:"0 0 3px 10px"},children:["\u2192 Find ",r("strong",{style:{color:"#0f172a"},children:"Optimization Guide On Device Model"})]}),p("p",{style:{margin:"0 0 6px 10px"},children:["\u2192 Click ",r("strong",{style:{color:"#0f172a"},children:"Check for update"})," and wait for download"]}),r("p",{style:{margin:"0"},children:"5. Refresh this page \u2014 AI features will unlock automatically"})]}),r(k,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:l=>i("plainEnglish",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(y,{}),r(k,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:l=>i("summarisePage",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(y,{}),r(k,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:l=>i("smartLabels",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(y,{}),r(_,{label:"Visual"}),r(k,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:l=>i("highContrast",l)}),r(y,{}),r(k,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:l=>i("darkMode",l)}),r(y,{}),r(k,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:l=>i("reduceMotion",l)}),r(y,{}),r(k,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>i("largeTargets",l)}),r(y,{}),p("div",{style:{padding:"10px 18px"},children:[r("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),r("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:nt.map(l=>r("button",{onClick:()=>i("colorBlindMode",l.value),"aria-pressed":t.colorBlindMode===l.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===l.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===l.value?"#f0fdfa":"#fff",color:t.colorBlindMode===l.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:g?"36px":"auto"},children:l.label},l.value))})]}),r(y,{}),r(_,{label:"Font"}),r(k,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:l=>i("dyslexiaFont",l)}),r(y,{}),p("div",{style:{padding:"10px 18px"},children:[r("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F524} Local font"}),P.length>0?p("select",{value:t.localFont,onChange:l=>i("localFont",l.target.value),"aria-label":"Choose a font from your device",style:{width:"100%",padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"13px",color:"#0f172a",background:"#fff",cursor:"pointer",height:g?"44px":"36px"},children:[r("option",{value:"",children:"System default"}),P.map(l=>r("option",{value:l,style:{fontFamily:l},children:l},l))]}):r("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Local font access available in Chrome 103+. Allow font access when prompted."})]}),r(y,{}),p("div",{style:{padding:"10px 18px 14px"},children:[p("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[r("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"Text size"}),p("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),p("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[r("button",{onClick:()=>{let l=L.indexOf(t.fontScale);l>0&&i("fontScale",L[l-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale<=80?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),r("div",{style:{flex:1,display:"flex",gap:"3px"},children:L.map(l=>r("button",{onClick:()=>i("fontScale",l),"aria-label":`Set text size to ${l}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:l<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},l))}),r("button",{onClick:()=>{let l=L.indexOf(t.fontScale);l<L.length-1&&i("fontScale",L[l+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale>=130?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale>=130?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),r(y,{}),p("div",{style:{padding:"10px 18px"},children:[p("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:["\u{1F310} Translate page"," ",r("span",{style:{marginLeft:"6px",fontSize:"9px",fontWeight:500,padding:"1px 6px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd"},children:"Gemini Nano"})]}),r("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.slice(0,g?8:18).map(l=>r("button",{onClick:()=>i("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!n,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===l.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===l.code?"#f5f3ff":"#fff",color:t.translateLanguage===l.code?"#7c3aed":"#64748b",cursor:n?"pointer":"not-allowed",opacity:n?1:.5,minHeight:g?"36px":"auto"},children:l.code.toUpperCase()},l.code))}),!n&&r("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above to unlock translation."})]}),o&&r("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:"8px",fontSize:"12px",color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:o.fixed>0?`\u2713 ${o.fixed} fixes \xB7 ${o.scanned} nodes \xB7 ${o.renderTime}ms \xB7 Score: ${o.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${o.scanned} nodes \xB7 ${o.renderTime}ms`}),p("div",{style:{display:"flex",gap:"8px",padding:"12px 14px 14px",position:g?"sticky":"relative",bottom:g?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[r("button",{onClick:m,style:{flex:1,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:500,borderRadius:"9px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),r("button",{onClick:d,style:{flex:2,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});le.displayName="WidgetPanel";import{Fragment as dt,jsx as He,jsxs as ct}from"react/jsx-runtime";function de({position:e="left",children:t,config:o={}}){let[a,n]=M(!1),[s,i]=M(se),[d,m]=M(null),[f,x]=M(!1),[g,j]=M(!1),[P,K]=M(!1),R=lt.useRef(null);D(()=>{if(typeof window>"u")return;let c=!!window.ai;j(c);let v=!!(window.SpeechRecognition||window.webkitSpeechRecognition);K(v)},[]),D(()=>{if(!(typeof window>"u"))try{let c=localStorage.getItem("yuktai-a11y-prefs");if(c){let v=JSON.parse(c);i(A=>({...A,...v}))}}catch{}},[]);let l=q(async c=>{let v={enabled:!0,highContrast:c.highContrast,darkMode:c.darkMode,reduceMotion:c.reduceMotion,largeTargets:c.largeTargets,speechEnabled:c.speechEnabled,autoFix:c.autoFix,dyslexiaFont:c.dyslexiaFont,localFont:c.localFont,fontSizeMultiplier:c.fontScale/100,colorBlindMode:c.colorBlindMode,showAuditBadge:c.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:c.plainEnglish,summarisePage:c.summarisePage,translateLanguage:c.translateLanguage,voiceControl:c.voiceControl,smartLabels:c.smartLabels,...o};await w.execute(v);let A=w.applyFixes(v);m(A),x(!0)},[o]),z=q(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await l(s),n(!1)},[s,l]),Y=q(()=>{i(se);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let c=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(A=>c.removeAttribute(A)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",m(null),x(!1)},[]),U=q((c,v)=>{i(A=>({...A,[c]:v}))},[]);D(()=>{let c=v=>{v.key==="Escape"&&a&&n(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),D(()=>{a&&R.current&&w.trapFocus(R.current)},[a]);let J={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:f?"#0d9488":"#1a73e8",color:"#fff",border:"none",cursor:"pointer",fontSize:"22px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(0,0,0,0.25)",transition:"transform 0.15s, background 0.2s"};return ct(dt,{children:[t,He("button",{style:J,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":a,"data-yuktai-pref-toggle":"true",onClick:()=>n(c=>!c),onMouseEnter:c=>{c.currentTarget.style.transform="scale(1.08)"},onMouseLeave:c=>{c.currentTarget.style.transform="scale(1)"},children:"\u267F"}),a&&He(le,{ref:R,position:e,settings:s,report:d,isActive:f,aiSupported:g,voiceSupported:P,set:U,onApply:z,onReset:Y,onClose:()=>n(!1)})]})}var G={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var V={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var S=class{plugins=new Map;register(t,o){if(!o||typeof o.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,o)}use(t){return this.plugins.get(t)}async run(t,o){try{let a=this.use(t);if(!a)throw new Error(`Plugin not found: ${t}`);return await a.execute(o)}catch(a){throw console.error(`[YuktAI Runtime Error in ${t}]:`,a),a}}getPlugins(){return Array.from(this.plugins.keys())}};function ut(){if(typeof globalThis>"u")return new S;if(!globalThis.__yuktai_runtime__){let e=new S;e.register(w.name,w),e.register(G.name,G),e.register(V.name,V),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var $e=typeof window<"u"?ut():new S,Dt={wcagPlugin:w,list(){return $e.getPlugins()},use(e){return $e.use(e)},fix(e){return w.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return w.scan()}};export{S as Runtime,Dt as YuktAI,de as YuktAIWrapper,G as aiPlugin,de as default,V as voicePlugin,w as wcag,w as wcagPlugin};
390
+ `,document.body.appendChild(e),ke=e}function Re(e){let t={critical:20,serious:10,moderate:5,minor:2},o=e.details.reduce((n,a)=>n+(t[a.severity]||0),0);return Math.max(0,Math.min(100,100-o))}var v={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";C=e,tt(e),ot(),it(),Ue(),Je(),e.showSkipLinks!==!1&&Ye(),e.showPreferencePanel,et(e);let t=this.applyFixes(e);t.score=Re(t),e.showAuditBadge&&Ze(t),e.timeoutWarning&&ze(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Ee(!0),e.summarisePage&&await Te(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Ce(e.translateLanguage),e.voiceControl&&await Le(!0),e.smartLabels&&await Me(!0);let o=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return u(o,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${o} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let o=performance.now(),n=document.querySelectorAll("*");t.scanned=n.length;let a=(s,i,d,m)=>{t.details.push({tag:s,fix:i,severity:d,element:m.outerHTML.slice(0,100)}),t.fixed++};return n.forEach(s=>{let i=s,d=i.tagName.toLowerCase();if(d==="html"&&!i.getAttribute("lang")&&(i.setAttribute("lang","en"),a(d,'lang="en" added',"critical",i)),d==="meta"){let f=i.getAttribute("name"),y=i.getAttribute("content")||"";f==="viewport"&&y.includes("user-scalable=no")&&(i.setAttribute("content",y.replace("user-scalable=no","user-scalable=yes")),a(d,"user-scalable=yes restored","serious",i)),f==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(y)&&(i.setAttribute("content",y.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(d,"maximum-scale=5 restored","serious",i))}if(d==="main"&&!i.getAttribute("tabindex")&&(i.setAttribute("tabindex","-1"),i.getAttribute("id")||i.setAttribute("id","main-content")),d==="img"&&(i.hasAttribute("alt")||(i.setAttribute("alt",""),i.setAttribute("aria-hidden","true"),a(d,'alt="" aria-hidden="true"',"serious",i))),d==="svg"&&(!i.getAttribute("aria-hidden")&&!i.getAttribute("aria-label")&&!s.querySelector("title")&&(i.setAttribute("aria-hidden","true"),a(d,'aria-hidden="true" (decorative svg)',"minor",i)),i.getAttribute("focusable")||i.setAttribute("focusable","false")),d==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&(i.setAttribute("title","embedded content"),i.setAttribute("aria-label","embedded content"),a(d,"title + aria-label added","serious",i)),d==="button"){if(!i.innerText?.trim()&&!i.getAttribute("aria-label")){let f=i.getAttribute("title")||"button";i.setAttribute("aria-label",f),a(d,`aria-label="${f}" (empty button)`,"critical",i)}i.hasAttribute("disabled")&&!i.getAttribute("aria-disabled")&&(i.setAttribute("aria-disabled","true"),t.fixed++)}if(d==="a"){let f=i;!i.innerText?.trim()&&!i.getAttribute("aria-label")&&(i.setAttribute("aria-label",i.getAttribute("title")||"link"),a(d,"aria-label added (empty link)","critical",i)),f.target==="_blank"&&!f.rel?.includes("noopener")&&(f.rel="noopener noreferrer",t.fixed++)}if(Se.has(d)){let f=i;if(!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")){let y=i.getAttribute("placeholder")||i.getAttribute("name")||d;i.setAttribute("aria-label",y),a(d,`aria-label="${y}"`,"serious",i)}if(i.hasAttribute("required")&&!i.getAttribute("aria-required")&&(i.setAttribute("aria-required","true"),t.fixed++),d==="input"&&!f.autocomplete){let y=f.name||"";f.type==="email"||y.includes("email")?f.autocomplete="email":f.type==="tel"||y.includes("tel")?f.autocomplete="tel":f.type==="password"&&(f.autocomplete="current-password"),t.fixed++}}d==="th"&&!i.getAttribute("scope")&&(i.setAttribute("scope",i.closest("thead")?"col":"row"),a(d,"scope added to <th>","moderate",i)),re[d]&&!i.getAttribute("role")&&(i.setAttribute("role",re[d]),a(d,`role="${re[d]}"`,"minor",i));let m=i.getAttribute("role")||"";m==="tab"&&!i.getAttribute("aria-selected")&&(i.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(m)&&!i.getAttribute("aria-live")&&(i.setAttribute("aria-live",m==="alert"?"assertive":"polite"),a(d,`aria-live added on role=${m}`,"moderate",i)),m==="combobox"&&!i.getAttribute("aria-expanded")&&(i.setAttribute("aria-expanded","false"),a(d,'aria-expanded="false" on combobox',"serious",i)),(m==="checkbox"||m==="radio")&&!i.getAttribute("aria-checked")&&(i.setAttribute("aria-checked","false"),a(d,`aria-checked="false" on role=${m}`,"serious",i))}),t.renderTime=parseFloat((performance.now()-o).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),o=document.querySelectorAll("*");e.scanned=o.length;let n=(a,s,i,d)=>e.details.push({tag:a,fix:s,severity:i,element:d.outerHTML.slice(0,100)});return o.forEach(a=>{let s=a,i=s.tagName.toLowerCase();(i==="a"||i==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&n(i,"needs aria-label (empty)","critical",s),i==="img"&&!s.hasAttribute("alt")&&n(i,"needs alt text","serious",s),Se.has(i)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&n(i,"needs aria-label","serious",s),i==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&n(i,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=Re(e),e.renderTime=parseFloat((performance.now()-t).toFixed(2)),e},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer?.disconnect(),this.observer=null},announce:u,speak:se,showVisualAlert:Pe,trapFocus:D,handlePlainEnglish:Ee,handleSummarisePage:Te,handleTranslate:Ce,handleVoiceControl:Le,handleSmartLabels:Me,SUPPORTED_LANGUAGES:W};import dt,{useEffect as G,useState as M,useCallback as V}from"react";import{forwardRef as at,useEffect as Ie,useState as He}from"react";import{jsx as r,jsxs as p}from"react/jsx-runtime";var le={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100,localFont:"",darkMode:!1,largeTargets:!1,speechEnabled:!1,colorBlindMode:"none",showAuditBadge:!1,timeoutWarning:void 0,plainEnglish:!1,summarisePage:!1,translateLanguage:"en",voiceControl:!1,smartLabels:!1},L=[80,90,100,110,120,130],nt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],rt=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function st(){let[e,t]=He(typeof window<"u"?window.innerWidth:1024);return Ie(()=>{let o=()=>t(window.innerWidth);return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function lt({checked:e,onChange:t,label:o,disabled:n=!1}){return p("label",{"aria-label":o,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:n?"not-allowed":"pointer",flexShrink:0,opacity:n?.4:1},children:[r("input",{type:"checkbox",checked:e,disabled:n,onChange:a=>t(a.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),r("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),r("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function q({label:e,color:t="#64748b",badge:o}){return p("div",{style:{display:"flex",alignItems:"center",gap:"8px",margin:"8px 18px 4px"},children:[r("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),o&&r("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:o})]})}function k({icon:e,label:t,desc:o,checked:n,onChange:a,disabled:s=!1,disabledReason:i}){return p("div",{title:s?i:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[p("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[r("span",{"aria-hidden":"true",style:{width:"30px",height:"30px",borderRadius:"8px",background:s?"#f1f5f9":"#f0fdfa",color:s?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",flexShrink:0,fontWeight:700},children:e}),p("div",{style:{minWidth:0},children:[r("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:s?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),r("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:s?i:o})]})]}),r(lt,{checked:n,onChange:a,label:`Toggle ${t}`,disabled:s})]})}function x(){return r("div",{style:{height:"1px",background:"#f1f5f9",margin:"0"}})}var de=at(({position:e,settings:t,report:o,isActive:n,aiSupported:a,voiceSupported:s,set:i,onApply:d,onReset:m,onClose:f},y)=>{let{isMobile:g,isTablet:R}=st(),[z,Y]=He([]);Ie(()=>{(async()=>{try{let I=window;if(!I.queryLocalFonts)return;let U=await I.queryLocalFonts(),J=[...new Set(U.map(X=>X.family))].sort();Y(J.slice(0,50))}catch{}})()},[]);let P=g?{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px 16px 0 0",boxShadow:"0 -8px 32px rgba(0,0,0,0.12)",maxHeight:"90vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif",width:"100%"}:{position:"fixed",bottom:"84px",[e]:"24px",zIndex:9999,width:R?"300px":"320px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",maxHeight:"80vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif"};return p("div",{ref:y,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:P,children:[p("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between",position:"sticky",top:0,background:"#fff",zIndex:1},children:[p("div",{children:[p("div",{style:{display:"flex",alignItems:"center",gap:"7px",marginBottom:"5px",flexWrap:"wrap"},children:[r("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v2.0.18"}),n&&r("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),r("p",{style:{margin:"0 0 2px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),r("p",{style:{margin:0,fontSize:"12px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost"})]}),r("button",{onClick:f,"aria-label":"Close accessibility panel",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#94a3b8",fontSize:"20px",lineHeight:1,borderRadius:"6px",flexShrink:0,minWidth:g?"44px":"auto",minHeight:g?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),r(q,{label:"Core"}),r(k,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:l=>i("autoFix",l)}),r(x,{}),r(k,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:l=>i("speechEnabled",l)}),r(x,{}),r(k,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:l=>i("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser"}),r(x,{}),r(q,{label:"AI features",color:"#7c3aed",badge:"Gemini Nano \xB7 Chrome 127+"}),r("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:"#f5f3ff",borderRadius:"8px",border:"0.5px solid #c4b5fd",fontSize:"10px",color:"#7c3aed",lineHeight:1.5},children:a?"Gemini Nano detected \u2014 AI features ready. Runs privately on your device. No data leaves your browser.":"AI features need setup \u2014 see guide below."}),!a&&p("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[r("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} How to enable AI features:"}),p("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome and go to"," ",r("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),p("p",{style:{margin:"0 0 3px"},children:["2. Search and set each to ",r("strong",{style:{color:"#0f172a"},children:"Enabled:"})]}),r("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:rt.map(l=>p("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",l]},l))}),p("p",{style:{margin:"0 0 3px"},children:["3. Click ",r("strong",{style:{color:"#0f172a"},children:"Relaunch"})," when Chrome prompts you"]}),p("p",{style:{margin:"0 0 3px"},children:["4. Go to"," ",r("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://components"})]}),p("p",{style:{margin:"0 0 3px 10px"},children:["\u2192 Find ",r("strong",{style:{color:"#0f172a"},children:"Optimization Guide On Device Model"})]}),p("p",{style:{margin:"0 0 6px 10px"},children:["\u2192 Click ",r("strong",{style:{color:"#0f172a"},children:"Check for update"})," and wait for download"]}),r("p",{style:{margin:"0"},children:"5. Refresh this page \u2014 AI features will unlock automatically"})]}),r(k,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:l=>i("plainEnglish",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(k,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:l=>i("summarisePage",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(k,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:l=>i("smartLabels",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(q,{label:"Visual"}),r(k,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:l=>i("highContrast",l)}),r(x,{}),r(k,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:l=>i("darkMode",l)}),r(x,{}),r(k,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:l=>i("reduceMotion",l)}),r(x,{}),r(k,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>i("largeTargets",l)}),r(x,{}),p("div",{style:{padding:"10px 18px"},children:[r("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),r("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:nt.map(l=>r("button",{onClick:()=>i("colorBlindMode",l.value),"aria-pressed":t.colorBlindMode===l.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===l.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===l.value?"#f0fdfa":"#fff",color:t.colorBlindMode===l.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:g?"36px":"auto"},children:l.label},l.value))})]}),r(x,{}),r(q,{label:"Font"}),r(k,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:l=>i("dyslexiaFont",l)}),r(x,{}),p("div",{style:{padding:"10px 18px"},children:[r("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F524} Local font"}),z.length>0?p("select",{value:t.localFont,onChange:l=>i("localFont",l.target.value),"aria-label":"Choose a font from your device",style:{width:"100%",padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"13px",color:"#0f172a",background:"#fff",cursor:"pointer",height:g?"44px":"36px"},children:[r("option",{value:"",children:"System default"}),z.map(l=>r("option",{value:l,style:{fontFamily:l},children:l},l))]}):r("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Local font access available in Chrome 103+. Allow font access when prompted."})]}),r(x,{}),p("div",{style:{padding:"10px 18px 14px"},children:[p("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[r("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"Text size"}),p("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),p("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[r("button",{onClick:()=>{let l=L.indexOf(t.fontScale);l>0&&i("fontScale",L[l-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale<=80?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),r("div",{style:{flex:1,display:"flex",gap:"3px"},children:L.map(l=>r("button",{onClick:()=>i("fontScale",l),"aria-label":`Set text size to ${l}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:l<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},l))}),r("button",{onClick:()=>{let l=L.indexOf(t.fontScale);l<L.length-1&&i("fontScale",L[l+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale>=130?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale>=130?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),r(x,{}),p("div",{style:{padding:"10px 18px"},children:[p("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:["\u{1F310} Translate page"," ",r("span",{style:{marginLeft:"6px",fontSize:"9px",fontWeight:500,padding:"1px 6px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd"},children:"Gemini Nano"})]}),r("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:W.slice(0,g?8:18).map(l=>r("button",{onClick:()=>i("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!a,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===l.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===l.code?"#f5f3ff":"#fff",color:t.translateLanguage===l.code?"#7c3aed":"#64748b",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,minHeight:g?"36px":"auto"},children:l.code.toUpperCase()},l.code))}),!a&&r("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above to unlock translation."})]}),o&&r("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:"8px",fontSize:"12px",color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:o.fixed>0?`\u2713 ${o.fixed} fixes \xB7 ${o.scanned} nodes \xB7 ${o.renderTime}ms \xB7 Score: ${o.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${o.scanned} nodes \xB7 ${o.renderTime}ms`}),p("div",{style:{display:"flex",gap:"8px",padding:"12px 14px 14px",position:g?"sticky":"relative",bottom:g?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[r("button",{onClick:m,style:{flex:1,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:500,borderRadius:"9px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),r("button",{onClick:d,style:{flex:2,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});de.displayName="WidgetPanel";import{Fragment as ct,jsx as $e,jsxs as ut}from"react/jsx-runtime";function ce({position:e="left",children:t,config:o={}}){let[n,a]=M(!1),[s,i]=M(le),[d,m]=M(null),[f,y]=M(!1),[g,R]=M(!1),[z,Y]=M(!1),P=dt.useRef(null);G(()=>{if(typeof window>"u")return;(async()=>{let h=window.ai||globalThis.ai;if(h&&h.languageModel)try{let H=await h.languageModel.availability();(H==="readily"||H==="downloadable")&&(R(!0),console.log("yuktai: AI Engine ready."))}catch(H){console.error("yuktai: AI check failed",H),R(!1)}else R(!1);let A=!!(window.SpeechRecognition||window.webkitSpeechRecognition);Y(A)})()},[]),G(()=>{if(!(typeof window>"u"))try{let c=localStorage.getItem("yuktai-a11y-prefs");if(c){let h=JSON.parse(c);i(A=>({...A,...h}))}}catch{}},[]);let l=V(async c=>{let h={enabled:!0,highContrast:c.highContrast,darkMode:c.darkMode,reduceMotion:c.reduceMotion,largeTargets:c.largeTargets,speechEnabled:c.speechEnabled,autoFix:c.autoFix,dyslexiaFont:c.dyslexiaFont,localFont:c.localFont,fontSizeMultiplier:c.fontScale/100,colorBlindMode:c.colorBlindMode,showAuditBadge:c.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:c.plainEnglish,summarisePage:c.summarisePage,translateLanguage:c.translateLanguage,voiceControl:c.voiceControl,smartLabels:c.smartLabels,...o};await v.execute(h);let A=v.applyFixes(h);m(A),y(!0)},[o]),I=V(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await l(s),a(!1)},[s,l]),U=V(()=>{i(le);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let c=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(A=>c.removeAttribute(A)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",m(null),y(!1)},[]),J=V((c,h)=>{i(A=>({...A,[c]:h}))},[]);G(()=>{let c=h=>{h.key==="Escape"&&n&&a(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n]),G(()=>{n&&P.current&&v.trapFocus(P.current)},[n]);let X={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:f?"#0d9488":"#1a73e8",color:"#fff",border:"none",cursor:"pointer",fontSize:"22px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(0,0,0,0.25)",transition:"transform 0.15s, background 0.2s"};return ut(ct,{children:[t,$e("button",{style:X,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":n,"data-yuktai-pref-toggle":"true",onClick:()=>a(c=>!c),onMouseEnter:c=>{c.currentTarget.style.transform="scale(1.08)"},onMouseLeave:c=>{c.currentTarget.style.transform="scale(1)"},children:"\u267F"}),n&&$e(de,{ref:P,position:e,settings:s,report:d,isActive:f,aiSupported:g,voiceSupported:z,set:J,onApply:I,onReset:U,onClose:()=>a(!1)})]})}var j={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}`}};var S=class{plugins=new Map;register(t,o){if(!o||typeof o.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,o)}use(t){return this.plugins.get(t)}async run(t,o){try{let n=this.use(t);if(!n)throw new Error(`Plugin not found: ${t}`);return await n.execute(o)}catch(n){throw console.error(`[YuktAI Runtime Error in ${t}]:`,n),n}}getPlugins(){return Array.from(this.plugins.keys())}};function pt(){if(typeof globalThis>"u")return new S;if(!globalThis.__yuktai_runtime__){let e=new S;e.register(v.name,v),e.register(j.name,j),e.register(K.name,K),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var Fe=typeof window<"u"?pt():new S,qt={wcagPlugin:v,list(){return Fe.getPlugins()},use(e){return Fe.use(e)},fix(e){return v.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return v.scan()}};export{S as Runtime,qt as YuktAI,ce as YuktAIWrapper,j as aiPlugin,ce as default,K as voicePlugin,v as wcag,v as wcagPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuktishaalaa/yuktai",
3
- "version": "2.0.18",
3
+ "version": "2.0.19",
4
4
  "description": "Universal runtime accessibility plugin — auto-fixes WCAG 2.2 violations with on-device AI features. Desktop only. Zero API keys. Zero cost.",
5
5
  "author": "Sandeep Miriyala — Yuktishaalaa AI Lab",
6
6
  "license": "ISC",