@yuktishaalaa/yuktai 2.0.22 → 2.0.23

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 Ne=Object.create;var F=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Ge=(e,t)=>{for(var a in t)F(e,a,{get:t[a],enumerable:!0})},ue=(e,t,a,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _e(t))!qe.call(e,i)&&i!==a&&F(e,i,{get:()=>t[i],enumerable:!(n=Oe(t,i))||n.enumerable});return e};var Ve=(e,t,a)=>(a=e!=null?Ne(De(e)):{},ue(t||!e||!e.__esModule?F(a,"default",{value:e,enumerable:!0}):a,e)),je=e=>ue(F({},"__esModule",{value:!0}),e);var vt={};Ge(vt,{Runtime:()=>E,YuktAI:()=>wt,YuktAIWrapper:()=>j,aiPlugin:()=>z,default:()=>j,voicePlugin:()=>I,wcag:()=>w,wcagPlugin:()=>w});module.exports=je(vt);function pe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function Z(){try{let e=pe();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}async function Ke(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=pe();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),n=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:n.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function fe(){if(!await Z())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let n of t){let i=n.innerText?.trim();if(!i||i.length<20||n.closest("[data-yuktai-panel]"))continue;let s=await Ke(i);s.success&&s.rewritten!==i&&(n.dataset.yuktaiOriginal=i,n.innerText=s.rewritten,a++)}return{fixed:a}}function me(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let a=t.dataset.yuktaiOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiOriginal)}}var be="yuktai-summary-box";function ge(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function Q(){try{let e=ge();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function Ye(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let n=window.getComputedStyle(a);if(n.display==="none"||n.visibility==="hidden")continue;let i=a.innerText?.trim();i&&i.length>10&&t.push(i)}return t.join(" ").slice(0,5e3)}async function ye(){if(!await Q())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=Ye();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=ge();if(!a)throw new Error("Summarizer API not available");let n=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),i=await n.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 n.destroy(),Ue(i.trim()),{success:!0,summary:i.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function Ue(e){W();let t=document.createElement("div");t.id=be,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 Ne=Object.create;var F=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty;var Ge=(e,t)=>{for(var a in t)F(e,a,{get:t[a],enumerable:!0})},ue=(e,t,a,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _e(t))!qe.call(e,i)&&i!==a&&F(e,i,{get:()=>t[i],enumerable:!(n=Oe(t,i))||n.enumerable});return e};var Ve=(e,t,a)=>(a=e!=null?Ne(De(e)):{},ue(t||!e||!e.__esModule?F(a,"default",{value:e,enumerable:!0}):a,e)),je=e=>ue(F({},"__esModule",{value:!0}),e);var At={};Ge(At,{Runtime:()=>E,YuktAI:()=>kt,YuktAIWrapper:()=>j,aiPlugin:()=>z,default:()=>j,voicePlugin:()=>I,wcag:()=>w,wcagPlugin:()=>w});module.exports=je(At);function pe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function Z(){try{let e=pe();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}async function Ke(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=pe();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),n=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:n.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function fe(){if(!await Z())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let n of t){let i=n.innerText?.trim();if(!i||i.length<20||n.closest("[data-yuktai-panel]"))continue;let s=await Ke(i);s.success&&s.rewritten!==i&&(n.dataset.yuktaiOriginal=i,n.innerText=s.rewritten,a++)}return{fixed:a}}function me(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let a=t.dataset.yuktaiOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiOriginal)}}var be="yuktai-summary-box";function ge(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function Q(){try{let e=ge();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function Ye(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let n=window.getComputedStyle(a);if(n.display==="none"||n.visibility==="hidden")continue;let i=a.innerText?.trim();i&&i.length>10&&t.push(i)}return t.join(" ").slice(0,5e3)}async function ye(){if(!await Q())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=Ye();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=ge();if(!a)throw new Error("Summarizer API not available");let n=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),i=await n.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 n.destroy(),Ue(i.trim()),{success:!0,summary:i.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function Ue(e){W();let t=document.createElement("div");t.id=be,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;
@@ -19,7 +19,7 @@
19
19
  background: none; border: none; color: #ffffff;
20
20
  font-size: 20px; cursor: pointer; padding: 0 4px;
21
21
  line-height: 1; flex-shrink: 0;
22
- `,n.addEventListener("click",W),t.appendChild(a),t.appendChild(n),document.body.prepend(t)}function W(){let e=document.getElementById(be);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"}],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 xe(e){if(e===B)return{success:!0,language:e,fixed:0};if(e==="en")return ee(),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 a=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"),i=0;for(let s of n){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let o=s.innerText?.trim();if(!o||o.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=o);let c=await a.translate(o);c&&c!==o&&(s.innerText=c,i++)}return a.destroy(),B=e,{success:!0,language:e,fixed:i}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function ee(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let a=t.dataset.yuktaiTranslationOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiTranslationOriginal)}B="en"}var Xe=[{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"}],k=null,O=!1,C=null;function te(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function Ze(e){let t=e.toLowerCase().trim();for(let a of Xe)for(let n of a.phrases)if(t.includes(n))return{action:a.action,label:a.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=he(),a=t.indexOf(document.activeElement),n=t[a+1]||t[0];n&&n.focus();break}case"tab-back":{let t=he(),a=t.indexOf(document.activeElement),n=t[a-1]||t[t.length-1];n&&n.focus();break}case"stop-voice":{ae();break}}}function he(){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 we(e){if(!te())return!1;if(O)return!0;e&&(C=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return k=new t,k.continuous=!0,k.interimResults=!1,k.lang="en-US",k.onresult=a=>{let n=a.results[a.results.length-1][0].transcript,i=Ze(n);if(i){Qe(i.action);let s={success:!0,command:n,action:i.label};if(C&&C(s),i.action==="stop-voice")return}},k.onend=()=>{O&&k?.start()},k.onerror=a=>{a.error!=="no-speech"&&C&&C({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},k.start(),O=!0,et(),!0}function ae(){O=!1,k&&(k.stop(),k=null),C=null,ke()}var ve="yuktai-voice-indicator";function et(){ke();let e=document.createElement("div");e.id=ve,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
22
+ `,n.addEventListener("click",W),t.appendChild(a),t.appendChild(n),document.body.prepend(t)}function W(){let e=document.getElementById(be);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"}],B="en";function Je(){let e=window;return e.Translator||e.translation||null}async function Xe(e){try{let t=window;if(!Je())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let n=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return n==="readily"||n==="available"||n==="downloadable"||n==="after-download"}catch{}return t.Translator&&typeof t.Translator.canTranslate=="function"?await t.Translator.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":t.translation&&typeof t.translation.canTranslate=="function"?await t.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function Ze(e){let t=window,a={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(a);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(a);throw new Error("Translation API not available")}async function xe(e){if(e===B)return{success:!0,language:e,fixed:0};if(e==="en")return ee(),B="en",{success:!0,language:"en",fixed:0};if(!await Xe(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let a=await Ze(e),n=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),i=0;for(let s of n){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let o=s.innerText?.trim();if(!o||o.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=o);let c=await a.translate(o);c&&c!==o&&(s.innerText=c,i++)}return typeof a.destroy=="function"&&a.destroy(),B=e,{success:!0,language:e,fixed:i}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function ee(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let a=t.dataset.yuktaiTranslationOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiTranslationOriginal)}B="en"}var Qe=[{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"}],k=null,O=!1,C=null;function te(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function et(e){let t=e.toLowerCase().trim();for(let a of Qe)for(let n of a.phrases)if(t.includes(n))return{action:a.action,label:a.label};return null}function tt(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=he(),a=t.indexOf(document.activeElement),n=t[a+1]||t[0];n&&n.focus();break}case"tab-back":{let t=he(),a=t.indexOf(document.activeElement),n=t[a-1]||t[t.length-1];n&&n.focus();break}case"stop-voice":{ae();break}}}function he(){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 we(e){if(!te())return!1;if(O)return!0;e&&(C=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return k=new t,k.continuous=!0,k.interimResults=!1,k.lang="en-US",k.onresult=a=>{let n=a.results[a.results.length-1][0].transcript,i=et(n);if(i){tt(i.action);let s={success:!0,command:n,action:i.label};if(C&&C(s),i.action==="stop-voice")return}},k.onend=()=>{O&&k?.start()},k.onerror=a=>{a.error!=="no-speech"&&C&&C({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},k.start(),O=!0,at(),!0}function ae(){O=!1,k&&(k.stop(),k=null),C=null,ke()}var ve="yuktai-voice-indicator";function at(){ke();let e=document.createElement("div");e.id=ve,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
23
23
  position: fixed;
24
24
  bottom: 80px;
25
25
  left: 50%;
@@ -49,7 +49,7 @@
49
49
  0%, 100% { opacity: 1; transform: scale(1); }
50
50
  50% { opacity: 0.4; transform: scale(0.7); }
51
51
  }
52
- `,document.head.appendChild(n)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function ke(){let e=document.getElementById(ve);e&&e.remove()}var tt=["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(", ");function Ae(){let e=window;return e.Writer||e.ai?.writer||null}async function oe(){try{let e=Ae();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function at(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let n=e.placeholder?.trim();n&&t.push(`placeholder: "${n}"`);let i=e.getAttribute("name")?.trim();i&&t.push(`name: "${i}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let o=e.id;if(o){let u=document.querySelector(`label[for="${o}"]`);u&&t.push(`label: "${u.innerText?.trim()}"`)}let c=e.parentElement?.innerText?.trim().slice(0,60);c&&t.push(`parent context: "${c}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let f=e.getAttribute("role");return f&&t.push(`role: ${f}`),t.join(". ")}async function ot(e,t){let a=`
52
+ `,document.head.appendChild(n)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function ke(){let e=document.getElementById(ve);e&&e.remove()}var ot=["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(", ");function Ae(){let e=window;return e.Writer||e.ai?.writer||null}async function oe(){try{let e=Ae();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function it(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let n=e.placeholder?.trim();n&&t.push(`placeholder: "${n}"`);let i=e.getAttribute("name")?.trim();i&&t.push(`name: "${i}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let o=e.id;if(o){let u=document.querySelector(`label[for="${o}"]`);u&&t.push(`label: "${u.innerText?.trim()}"`)}let c=e.parentElement?.innerText?.trim().slice(0,60);c&&t.push(`parent context: "${c}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let f=e.getAttribute("role");return f&&t.push(`role: ${f}`),t.join(". ")}async function nt(e,t){let a=`
53
53
  Generate a short, clear aria-label for an HTML element.
54
54
  The label must be 2-6 words maximum.
55
55
  The label must describe what the element does or what it is.
@@ -60,7 +60,7 @@
60
60
  ${t}
61
61
 
62
62
  Output only the label. Nothing else.
63
- `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Se(){if(!await oe())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(tt);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=Ae();if(!a)throw new Error("Writer API not available");let n=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),i=0,s=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let c=window.getComputedStyle(o);if(c.display==="none"||c.visibility==="hidden")continue;let f=at(o),u=await ot(n,f);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),i++,s.push({tag:o.tagName.toLowerCase(),label:u}))}return n.destroy(),{success:!0,fixed:i,elements:s}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function Ee(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let a=t.dataset.yuktaiLabelOriginal;a?t.setAttribute("aria-label",a):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var q=null,Te=null;var Ce=null,ie=null,m=null,L=null,_=null,ne=null,M=null,D={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Le=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 a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let n=window.speechSynthesis.getVoices();n.length>0&&(a.voice=n[0]),window.speechSynthesis.speak(a)}function $e(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=`
63
+ `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Se(){if(!await oe())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(ot);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=Ae();if(!a)throw new Error("Writer API not available");let n=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),i=0,s=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let c=window.getComputedStyle(o);if(c.display==="none"||c.visibility==="hidden")continue;let f=it(o),u=await nt(n,f);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),i++,s.push({tag:o.tagName.toLowerCase(),label:u}))}return n.destroy(),{success:!0,fixed:i,elements:s}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function Ee(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let a=t.dataset.yuktaiLabelOriginal;a?t.setAttribute("aria-label",a):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var q=null,Te=null;var Ce=null,ie=null,m=null,L=null,_=null,ne=null,M=null,D={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Le=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 a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let n=window.speechSynthesis.getVoices();n.length>0&&(a.voice=n[0]),window.speechSynthesis.speak(a)}function $e(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=`
64
64
  position: fixed;
65
65
  top: 80px;
66
66
  right: 16px;
@@ -86,7 +86,7 @@
86
86
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
87
87
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
88
88
  aria-label="Close notification">\xD7</button>
89
- `,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 p(e,t="info",a=!0){q&&(q.textContent=e),$e(e,t),a&&se(e,t==="error"?"assertive":"polite")}function it(){if(typeof document>"u"||Ce)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=`
89
+ `,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 p(e,t="info",a=!0){q&&(q.textContent=e),$e(e,t),a&&se(e,t==="error"?"assertive":"polite")}function rt(){if(typeof document>"u"||Ce)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=`
90
90
  position: fixed;
91
91
  top: 0;
92
92
  left: 0;
@@ -111,7 +111,7 @@
111
111
  white-space: nowrap;
112
112
  border: 2px solid transparent;
113
113
  transition: background 0.15s, border-color 0.15s;
114
- `,c.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),c.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),c.addEventListener("click",f=>{f.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),p(`Jumped to ${i.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!a)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),Ce=t}function nt(){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=`
114
+ `,c.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),c.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),c.addEventListener("click",f=>{f.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),p(`Jumped to ${i.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!a)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),Ce=t}function st(){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=`
115
115
 
116
116
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
117
117
  [data-yuktai-a11y] *:focus-visible {
@@ -257,7 +257,7 @@
257
257
  width: auto !important;
258
258
  }
259
259
  }
260
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function rt(){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 a=t.getAttribute("role")||"";if(e.key==="Escape"){let n=t.closest("[role='dialog'],[role='alertdialog']");if(n){n.style.display="none",p("Dialog closed","info");return}let i=t.closest("[role='menu'],[role='menubar']");i&&(i.style.display="none",p("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let n=t.closest("[role='menu'],[role='menubar']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='menuitem']:not([disabled])")),s=i.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),i[(s+1)%i.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),i[(s-1+i.length)%i.length]?.focus()):e.key==="Home"?(e.preventDefault(),i[0]?.focus()):e.key==="End"&&(e.preventDefault(),i[i.length-1]?.focus())}if(a==="tab"||t.closest("[role='tablist']")){let n=t.closest("[role='tablist']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='tab']:not([disabled])")),s=i.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=i[(s+1)%i.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=i[(s-1+i.length)%i.length];o?.focus(),o?.click()}}if(a==="option"||t.closest("[role='listbox']")){let n=t.closest("[role='listbox']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=i.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),i[(s+1)%i.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),i[(s-1+i.length)%i.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),i.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),p(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),st()),e.key==="Tab"&&M?.speechEnabled&&setTimeout(()=>{let n=document.activeElement;if(!n)return;let i=n.getAttribute("aria-label")||n.getAttribute("title")||n.textContent?.trim()||n.tagName.toLowerCase(),s=n.getAttribute("role")||n.tagName.toLowerCase();se(`${i}, ${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 a=t[0],n=t[t.length-1];a.focus(),e.addEventListener("keydown",i=>{i.key==="Tab"&&(i.shiftKey?document.activeElement===a&&(i.preventDefault(),n.focus()):document.activeElement===n&&(i.preventDefault(),a.focus()))})}function st(){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=`
260
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function lt(){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 a=t.getAttribute("role")||"";if(e.key==="Escape"){let n=t.closest("[role='dialog'],[role='alertdialog']");if(n){n.style.display="none",p("Dialog closed","info");return}let i=t.closest("[role='menu'],[role='menubar']");i&&(i.style.display="none",p("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let n=t.closest("[role='menu'],[role='menubar']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='menuitem']:not([disabled])")),s=i.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),i[(s+1)%i.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),i[(s-1+i.length)%i.length]?.focus()):e.key==="Home"?(e.preventDefault(),i[0]?.focus()):e.key==="End"&&(e.preventDefault(),i[i.length-1]?.focus())}if(a==="tab"||t.closest("[role='tablist']")){let n=t.closest("[role='tablist']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='tab']:not([disabled])")),s=i.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=i[(s+1)%i.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=i[(s-1+i.length)%i.length];o?.focus(),o?.click()}}if(a==="option"||t.closest("[role='listbox']")){let n=t.closest("[role='listbox']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=i.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),i[(s+1)%i.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),i[(s-1+i.length)%i.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),i.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),p(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),ct()),e.key==="Tab"&&M?.speechEnabled&&setTimeout(()=>{let n=document.activeElement;if(!n)return;let i=n.getAttribute("aria-label")||n.getAttribute("title")||n.textContent?.trim()||n.tagName.toLowerCase(),s=n.getAttribute("role")||n.tagName.toLowerCase();se(`${i}, ${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 a=t[0],n=t[t.length-1];a.focus(),e.addEventListener("keydown",i=>{i.key==="Tab"&&(i.shiftKey?document.activeElement===a&&(i.preventDefault(),n.focus()):document.activeElement===n&&(i.preventDefault(),a.focus()))})}function ct(){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=`
261
261
  position: fixed;
262
262
  top: 50%;
263
263
  left: 50%;
@@ -287,7 +287,7 @@
287
287
  <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${i}</span>
288
288
  </div>
289
289
  `).join("")}
290
- `,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,G(e),p("Keyboard shortcuts opened. Press Escape to close.","info")}function lt(e){if(typeof document>"u"||!M?.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,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",n=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",i=document.createElement("button");i.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),i.setAttribute("data-yuktai-badge","true"),i.style.cssText=`
290
+ `,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,G(e),p("Keyboard shortcuts opened. Press Escape to close.","info")}function dt(e){if(typeof document>"u"||!M?.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,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",n=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",i=document.createElement("button");i.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),i.setAttribute("data-yuktai-badge","true"),i.style.cssText=`
291
291
  position: fixed;
292
292
  bottom: 16px;
293
293
  left: 16px;
@@ -306,7 +306,7 @@
306
306
  align-items: center;
307
307
  gap: 6px;
308
308
  transition: transform 0.15s;
309
- `,i.innerHTML=`${n} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,i.addEventListener("click",()=>ct(e)),document.body.appendChild(i),ie=i}function ct(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let a=document.createElement("div");a.setAttribute("data-yuktai-audit-details","true"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","Accessibility audit details"),a.style.cssText=`
309
+ `,i.innerHTML=`${n} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,i.addEventListener("click",()=>ut(e)),document.body.appendChild(i),ie=i}function ut(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let a=document.createElement("div");a.setAttribute("data-yuktai-audit-details","true"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","Accessibility audit details"),a.style.cssText=`
310
310
  position: fixed;
311
311
  bottom: 56px;
312
312
  left: 16px;
@@ -367,7 +367,7 @@
367
367
  No, sign out
368
368
  </button>
369
369
  </div>
370
- `;let a=t.querySelector("[data-yuktai-extend]"),n=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),_=null,p("Session extended. You have more time.","success"),M?.timeoutWarning&&Fe(M.timeoutWarning)}),n?.addEventListener("click",()=>{t.remove(),_=null}),document.body.appendChild(t),_=t,G(t),p("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function dt(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 a=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${D[e.colorBlindMode]})`;document.body.style.filter=a}else document.body.style.filter=""}function ut(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Me(e){if(e){if(!await Z()){p("Plain English requires Chrome 127+","warning");return}p("Rewriting page in plain English...","info",!1);let a=await fe();p(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else me(),p("Original text restored","info",!1)}async function Re(e){if(e){if(!await Q()){p("Page summariser requires Chrome 127+","warning");return}p("Generating page summary...","info",!1);let a=await ye();p(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else W(),p("Page summary removed","info",!1)}async function Pe(e){if(e==="en"){ee(),p("Page restored to English","info",!1);return}p(`Translating page to ${e}...`,"info",!1);let t=await xe(e);p(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function ze(e){if(e){if(!te()){p("Voice control not supported in this browser","warning");return}we(t=>{t.success&&p(`Voice: ${t.action}`,"info",!1)}),p("Voice control started. Say a command.","success",!1)}else ae(),p("Voice control stopped","info",!1)}async function Ie(e){if(e){if(!await oe()){p("Smart labels requires Chrome 127+","warning");return}p("Generating smart labels...","info",!1);let a=await Se();p(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else Ee(),p("Smart labels removed","info",!1)}function pt(){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 ft(){if(typeof document>"u"||Te)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=`
370
+ `;let a=t.querySelector("[data-yuktai-extend]"),n=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),_=null,p("Session extended. You have more time.","success"),M?.timeoutWarning&&Fe(M.timeoutWarning)}),n?.addEventListener("click",()=>{t.remove(),_=null}),document.body.appendChild(t),_=t,G(t),p("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function pt(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 a=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${D[e.colorBlindMode]})`;document.body.style.filter=a}else document.body.style.filter=""}function ft(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Me(e){if(e){if(!await Z()){p("Plain English requires Chrome 127+","warning");return}p("Rewriting page in plain English...","info",!1);let a=await fe();p(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else me(),p("Original text restored","info",!1)}async function Re(e){if(e){if(!await Q()){p("Page summariser requires Chrome 127+","warning");return}p("Generating page summary...","info",!1);let a=await ye();p(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else W(),p("Page summary removed","info",!1)}async function Pe(e){if(e==="en"){ee(),p("Page restored to English","info",!1);return}p(`Translating page to ${e}...`,"info",!1);let t=await xe(e);p(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function ze(e){if(e){if(!te()){p("Voice control not supported in this browser","warning");return}we(t=>{t.success&&p(`Voice: ${t.action}`,"info",!1)}),p("Voice control started. Say a command.","success",!1)}else ae(),p("Voice control stopped","info",!1)}async function Ie(e){if(e){if(!await oe()){p("Smart labels requires Chrome 127+","warning");return}p("Generating smart labels...","info",!1);let a=await Se();p(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else Ee(),p("Smart labels removed","info",!1)}function mt(){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 bt(){if(typeof document>"u"||Te)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=`
371
371
  <defs>
372
372
  <filter id="${D.deuteranopia}">
373
373
  <feColorMatrix type="matrix"
@@ -382,4 +382,4 @@
382
382
  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"/>
383
383
  </filter>
384
384
  </defs>
385
- `,document.body.appendChild(e),Te=e}function He(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((n,i)=>n+(t[i.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var w={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";M=e,ut(e),pt(),ft(),nt(),rt(),e.showSkipLinks!==!1&&it(),e.showPreferencePanel,dt(e);let t=this.applyFixes(e);t.score=He(t),e.showAuditBadge&&lt(t),e.timeoutWarning&&Fe(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Me(!0),e.summarisePage&&await Re(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Pe(e.translateLanguage),e.voiceControl&&await ze(!0),e.smartLabels&&await Ie(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return p(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} 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 a=performance.now(),n=document.querySelectorAll("*");t.scanned=n.length;let i=(s,o,c,f)=>{t.details.push({tag:s,fix:o,severity:c,element:f.outerHTML.slice(0,100)}),t.fixed++};return n.forEach(s=>{let o=s,c=o.tagName.toLowerCase();if(c==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),i(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),y=o.getAttribute("content")||"";u==="viewport"&&y.includes("user-scalable=no")&&(o.setAttribute("content",y.replace("user-scalable=no","user-scalable=yes")),i(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(y)&&(o.setAttribute("content",y.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),i(c,"maximum-scale=5 restored","serious",o))}if(c==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),c==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),i(c,'alt="" aria-hidden="true"',"serious",o))),c==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!s.querySelector("title")&&(o.setAttribute("aria-hidden","true"),i(c,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),c==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),i(c,"title + aria-label added","serious",o)),c==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let u=o.getAttribute("title")||"button";o.setAttribute("aria-label",u),i(c,`aria-label="${u}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(c==="a"){let u=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),i(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(Le.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let y=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",y),i(c,`aria-label="${y}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let y=u.name||"";u.type==="email"||y.includes("email")?u.autocomplete="email":u.type==="tel"||y.includes("tel")?u.autocomplete="tel":u.type==="password"&&(u.autocomplete="current-password"),t.fixed++}}c==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),i(c,"scope added to <th>","moderate",o)),re[c]&&!o.getAttribute("role")&&(o.setAttribute("role",re[c]),i(c,`role="${re[c]}"`,"minor",o));let f=o.getAttribute("role")||"";f==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(f)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",f==="alert"?"assertive":"polite"),i(c,`aria-live added on role=${f}`,"moderate",o)),f==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),i(c,'aria-expanded="false" on combobox',"serious",o)),(f==="checkbox"||f==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),i(c,`aria-checked="false" on role=${f}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-a).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(),a=document.querySelectorAll("*");e.scanned=a.length;let n=(i,s,o,c)=>e.details.push({tag:i,fix:s,severity:o,element:c.outerHTML.slice(0,100)});return a.forEach(i=>{let s=i,o=s.tagName.toLowerCase();(o==="a"||o==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&n(o,"needs aria-label (empty)","critical",s),o==="img"&&!s.hasAttribute("alt")&&n(o,"needs alt text","serious",s),Le.has(o)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&n(o,"needs aria-label","serious",s),o==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&n(o,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=He(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:p,speak:se,showVisualAlert:$e,trapFocus:G,handlePlainEnglish:Me,handleSummarisePage:Re,handleTranslate:Pe,handleVoiceControl:ze,handleSmartLabels:Ie,SUPPORTED_LANGUAGES:N};var b=Ve(require("react"));var S=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],mt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],bt=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function gt(){let[e,t]=(0,S.useState)(typeof window<"u"?window.innerWidth:1024);return(0,S.useEffect)(()=>{let a=()=>t(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function yt({checked:e,onChange:t,label:a,disabled:n=!1}){return(0,r.jsxs)("label",{"aria-label":a,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:i=>t(i.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:a}){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}),a&&(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:a})]})}function A({icon:e,label:t,desc:a,checked:n,onChange:i,disabled:s=!1,disabledReason:o}){return(0,r.jsxs)("div",{title:s?o: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?o:a})]})]}),(0,r.jsx)(yt,{checked:n,onChange:i,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:a,isActive:n,aiSupported:i,voiceSupported:s,set:o,onApply:c,onReset:f,onClose:u},y)=>{let{isMobile:g,isTablet:K}=gt(),[H,Y]=(0,S.useState)([]);(0,S.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:y,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"}),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:u,"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)(A,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:l=>o("autoFix",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:l=>o("speechEnabled",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:l=>o("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser"}),(0,r.jsx)(x,{}),(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:i?"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."}),!i&&(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:bt.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)(A,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:l=>o("plainEnglish",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:l=>o("summarisePage",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:l=>o("smartLabels",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(V,{label:"Visual"}),(0,r.jsx)(A,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:l=>o("highContrast",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:l=>o("darkMode",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:l=>o("reduceMotion",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>o("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:mt.map(l=>(0,r.jsx)("button",{onClick:()=>o("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)(V,{label:"Font"}),(0,r.jsx)(A,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:l=>o("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"}),H.length>0?(0,r.jsxs)("select",{value:t.localFont,onChange:l=>o("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)(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&&o("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:()=>o("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&&o("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:N.slice(0,g?8:18).map(l=>(0,r.jsx)("button",{onClick:()=>o("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!i,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:i?"pointer":"not-allowed",opacity:i?1:.5,minHeight:g?"36px":"auto"},children:l.code.toUpperCase()},l.code))}),!i&&(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."})]}),a&&(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:a.fixed>0?`\u2713 ${a.fixed} fixes \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms \xB7 Score: ${a.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${a.scanned} nodes \xB7 ${a.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:c,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");async function xt(){try{if(typeof window>"u")return!1;let e=window;if(e.LanguageModel)try{if(typeof e.LanguageModel.availability=="function"){let a=await e.LanguageModel.availability();if(console.log("yuktai: LanguageModel.availability() =",a),a==="readily"||a==="available"||a==="downloadable")return!0}else return!0}catch{}if(e.Summarizer)try{if(typeof e.Summarizer.availability=="function"){let a=await e.Summarizer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Rewriter)try{if(typeof e.Rewriter.availability=="function"){let a=await e.Rewriter.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Writer)try{if(typeof e.Writer.availability=="function"){let a=await e.Writer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}let t=e.ai||globalThis.ai;if(t){if(t.languageModel?.availability)try{let a=await t.languageModel.availability();if(a==="readily"||a==="downloadable"||a==="available")return!0}catch{}if(t.languageModel?.capabilities)try{let a=await t.languageModel.capabilities();if(a?.available==="readily"||a?.available==="after-download")return!0}catch{}if(t.languageModel&&typeof t.languageModel.create=="function")return!0;if(t.summarizer?.capabilities)try{if((await t.summarizer.capabilities())?.available!=="no")return!0}catch{}if(t.rewriter?.capabilities)try{if((await t.rewriter.capabilities())?.available!=="no")return!0}catch{}if(t.writer?.capabilities)try{if((await t.writer.capabilities())?.available!=="no")return!0}catch{}if(t.summarizer||t.rewriter||t.writer||t.languageModel)return!0}return!!(e.Translator||e.translation?.canTranslate)}catch{return!1}}function j({position:e="left",children:t,config:a={}}){let[n,i]=(0,b.useState)(!1),[s,o]=(0,b.useState)(le),[c,f]=(0,b.useState)(null),[u,y]=(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 v=setTimeout(async()=>{let h=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.ai =",h.ai),console.log("yuktai: window.LanguageModel =",h.LanguageModel),console.log("yuktai: window.Summarizer =",h.Summarizer),console.log("yuktai: window.Rewriter =",h.Rewriter),console.log("yuktai: window.Writer =",h.Writer);let de=await xt();K(de),de?console.log("yuktai: Chrome Built-in AI detected \u2705"):(console.log("yuktai: Chrome Built-in AI not detected \u274C"),console.log("yuktai: Enable flags at chrome://flags and download model at chrome://components"));let Be=!!(h.SpeechRecognition||h.webkitSpeechRecognition);Y(Be)},800);return()=>clearTimeout(v)},[]),(0,b.useEffect)(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");if(d){let v=JSON.parse(d);o(h=>({...h,...v}))}}catch{}},[]);let l=(0,b.useCallback)(async d=>{let v={enabled:!0,highContrast:d.highContrast,darkMode:d.darkMode,reduceMotion:d.reduceMotion,largeTargets:d.largeTargets,speechEnabled:d.speechEnabled,autoFix:d.autoFix,dyslexiaFont:d.dyslexiaFont,localFont:d.localFont,fontSizeMultiplier:d.fontScale/100,colorBlindMode:d.colorBlindMode,showAuditBadge:d.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:d.plainEnglish,summarisePage:d.summarisePage,translateLanguage:d.translateLanguage,voiceControl:d.voiceControl,smartLabels:d.smartLabels,...a};await w.execute(v);let h=w.applyFixes(v);f(h),y(!0)},[a]),$=(0,b.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await l(s),i(!1)},[s,l]),U=(0,b.useCallback)(()=>{o(le);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let d=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(v=>d.removeAttribute(v)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",f(null),y(!1)},[]),J=(0,b.useCallback)((d,v)=>{o(h=>({...h,[d]:v}))},[]);(0,b.useEffect)(()=>{let d=v=>{v.key==="Escape"&&n&&i(!1)};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),(0,b.useEffect)(()=>{n&&P.current&&w.trapFocus(P.current)},[n]);let X={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:u?"#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":n,"data-yuktai-pref-toggle":"true",onClick:()=>i(d=>!d),onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),n&&(0,T.jsx)(ce,{ref:P,position:e,settings:s,report:c,isActive:u,aiSupported:g,voiceSupported:H,set:J,onApply:$,onReset:U,onClose:()=>i(!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 E=class{plugins=new Map;register(t,a){if(!a||typeof a.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,a)}use(t){return this.plugins.get(t)}async run(t,a){try{let n=this.use(t);if(!n)throw new Error(`Plugin not found: ${t}`);return await n.execute(a)}catch(n){throw console.error(`[YuktAI Runtime Error in ${t}]:`,n),n}}getPlugins(){return Array.from(this.plugins.keys())}};function ht(){if(typeof globalThis>"u")return new E;if(!globalThis.__yuktai_runtime__){let e=new E;e.register(w.name,w),e.register(z.name,z),e.register(I.name,I),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var We=typeof window<"u"?ht():new E,wt={wcagPlugin:w,list(){return We.getPlugins()},use(e){return We.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});
385
+ `,document.body.appendChild(e),Te=e}function He(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((n,i)=>n+(t[i.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var w={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";M=e,ft(e),mt(),bt(),st(),lt(),e.showSkipLinks!==!1&&rt(),e.showPreferencePanel,pt(e);let t=this.applyFixes(e);t.score=He(t),e.showAuditBadge&&dt(t),e.timeoutWarning&&Fe(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Me(!0),e.summarisePage&&await Re(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Pe(e.translateLanguage),e.voiceControl&&await ze(!0),e.smartLabels&&await Ie(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return p(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} 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 a=performance.now(),n=document.querySelectorAll("*");t.scanned=n.length;let i=(s,o,c,f)=>{t.details.push({tag:s,fix:o,severity:c,element:f.outerHTML.slice(0,100)}),t.fixed++};return n.forEach(s=>{let o=s,c=o.tagName.toLowerCase();if(c==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),i(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),y=o.getAttribute("content")||"";u==="viewport"&&y.includes("user-scalable=no")&&(o.setAttribute("content",y.replace("user-scalable=no","user-scalable=yes")),i(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(y)&&(o.setAttribute("content",y.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),i(c,"maximum-scale=5 restored","serious",o))}if(c==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),c==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),i(c,'alt="" aria-hidden="true"',"serious",o))),c==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!s.querySelector("title")&&(o.setAttribute("aria-hidden","true"),i(c,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),c==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),i(c,"title + aria-label added","serious",o)),c==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let u=o.getAttribute("title")||"button";o.setAttribute("aria-label",u),i(c,`aria-label="${u}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(c==="a"){let u=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),i(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(Le.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let y=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",y),i(c,`aria-label="${y}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let y=u.name||"";u.type==="email"||y.includes("email")?u.autocomplete="email":u.type==="tel"||y.includes("tel")?u.autocomplete="tel":u.type==="password"&&(u.autocomplete="current-password"),t.fixed++}}c==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),i(c,"scope added to <th>","moderate",o)),re[c]&&!o.getAttribute("role")&&(o.setAttribute("role",re[c]),i(c,`role="${re[c]}"`,"minor",o));let f=o.getAttribute("role")||"";f==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(f)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",f==="alert"?"assertive":"polite"),i(c,`aria-live added on role=${f}`,"moderate",o)),f==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),i(c,'aria-expanded="false" on combobox',"serious",o)),(f==="checkbox"||f==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),i(c,`aria-checked="false" on role=${f}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-a).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(),a=document.querySelectorAll("*");e.scanned=a.length;let n=(i,s,o,c)=>e.details.push({tag:i,fix:s,severity:o,element:c.outerHTML.slice(0,100)});return a.forEach(i=>{let s=i,o=s.tagName.toLowerCase();(o==="a"||o==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&n(o,"needs aria-label (empty)","critical",s),o==="img"&&!s.hasAttribute("alt")&&n(o,"needs alt text","serious",s),Le.has(o)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&n(o,"needs aria-label","serious",s),o==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&n(o,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=He(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:p,speak:se,showVisualAlert:$e,trapFocus:G,handlePlainEnglish:Me,handleSummarisePage:Re,handleTranslate:Pe,handleVoiceControl:ze,handleSmartLabels:Ie,SUPPORTED_LANGUAGES:N};var b=Ve(require("react"));var S=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],gt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],yt=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function xt(){let[e,t]=(0,S.useState)(typeof window<"u"?window.innerWidth:1024);return(0,S.useEffect)(()=>{let a=()=>t(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function ht({checked:e,onChange:t,label:a,disabled:n=!1}){return(0,r.jsxs)("label",{"aria-label":a,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:i=>t(i.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:a}){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}),a&&(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:a})]})}function A({icon:e,label:t,desc:a,checked:n,onChange:i,disabled:s=!1,disabledReason:o}){return(0,r.jsxs)("div",{title:s?o: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?o:a})]})]}),(0,r.jsx)(ht,{checked:n,onChange:i,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:a,isActive:n,aiSupported:i,voiceSupported:s,set:o,onApply:c,onReset:f,onClose:u},y)=>{let{isMobile:g,isTablet:K}=xt(),[H,Y]=(0,S.useState)([]);(0,S.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:y,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"}),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:u,"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)(A,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:l=>o("autoFix",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:l=>o("speechEnabled",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:l=>o("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser"}),(0,r.jsx)(x,{}),(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:i?"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."}),!i&&(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:yt.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)(A,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:l=>o("plainEnglish",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:l=>o("summarisePage",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:l=>o("smartLabels",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(V,{label:"Visual"}),(0,r.jsx)(A,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:l=>o("highContrast",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:l=>o("darkMode",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:l=>o("reduceMotion",l)}),(0,r.jsx)(x,{}),(0,r.jsx)(A,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>o("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:gt.map(l=>(0,r.jsx)("button",{onClick:()=>o("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)(V,{label:"Font"}),(0,r.jsx)(A,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:l=>o("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"}),H.length>0?(0,r.jsxs)("select",{value:t.localFont,onChange:l=>o("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)(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&&o("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:()=>o("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&&o("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:N.slice(0,g?8:18).map(l=>(0,r.jsx)("button",{onClick:()=>o("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!i,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:i?"pointer":"not-allowed",opacity:i?1:.5,minHeight:g?"36px":"auto"},children:l.code.toUpperCase()},l.code))}),!i&&(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."})]}),a&&(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:a.fixed>0?`\u2713 ${a.fixed} fixes \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms \xB7 Score: ${a.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${a.scanned} nodes \xB7 ${a.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:c,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");async function wt(){try{if(typeof window>"u")return!1;let e=window;if(e.LanguageModel)try{if(typeof e.LanguageModel.availability=="function"){let a=await e.LanguageModel.availability();if(console.log("yuktai: LanguageModel.availability() =",a),a==="readily"||a==="available"||a==="downloadable")return!0}else return!0}catch{}if(e.Summarizer)try{if(typeof e.Summarizer.availability=="function"){let a=await e.Summarizer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Rewriter)try{if(typeof e.Rewriter.availability=="function"){let a=await e.Rewriter.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Writer)try{if(typeof e.Writer.availability=="function"){let a=await e.Writer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}let t=e.ai||globalThis.ai;if(t){if(t.languageModel?.availability)try{let a=await t.languageModel.availability();if(a==="readily"||a==="downloadable"||a==="available")return!0}catch{}if(t.languageModel?.capabilities)try{let a=await t.languageModel.capabilities();if(a?.available==="readily"||a?.available==="after-download")return!0}catch{}if(t.languageModel&&typeof t.languageModel.create=="function")return!0;if(t.summarizer?.capabilities)try{if((await t.summarizer.capabilities())?.available!=="no")return!0}catch{}if(t.rewriter?.capabilities)try{if((await t.rewriter.capabilities())?.available!=="no")return!0}catch{}if(t.writer?.capabilities)try{if((await t.writer.capabilities())?.available!=="no")return!0}catch{}if(t.summarizer||t.rewriter||t.writer||t.languageModel)return!0}return!!(e.Translator||e.translation?.canTranslate)}catch{return!1}}function j({position:e="left",children:t,config:a={}}){let[n,i]=(0,b.useState)(!1),[s,o]=(0,b.useState)(le),[c,f]=(0,b.useState)(null),[u,y]=(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 v=setTimeout(async()=>{let h=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.ai =",h.ai),console.log("yuktai: window.LanguageModel =",h.LanguageModel),console.log("yuktai: window.Summarizer =",h.Summarizer),console.log("yuktai: window.Rewriter =",h.Rewriter),console.log("yuktai: window.Writer =",h.Writer);let de=await wt();K(de),de?console.log("yuktai: Chrome Built-in AI detected \u2705"):(console.log("yuktai: Chrome Built-in AI not detected \u274C"),console.log("yuktai: Enable flags at chrome://flags and download model at chrome://components"));let Be=!!(h.SpeechRecognition||h.webkitSpeechRecognition);Y(Be)},800);return()=>clearTimeout(v)},[]),(0,b.useEffect)(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");if(d){let v=JSON.parse(d);o(h=>({...h,...v}))}}catch{}},[]);let l=(0,b.useCallback)(async d=>{let v={enabled:!0,highContrast:d.highContrast,darkMode:d.darkMode,reduceMotion:d.reduceMotion,largeTargets:d.largeTargets,speechEnabled:d.speechEnabled,autoFix:d.autoFix,dyslexiaFont:d.dyslexiaFont,localFont:d.localFont,fontSizeMultiplier:d.fontScale/100,colorBlindMode:d.colorBlindMode,showAuditBadge:d.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:d.plainEnglish,summarisePage:d.summarisePage,translateLanguage:d.translateLanguage,voiceControl:d.voiceControl,smartLabels:d.smartLabels,...a};await w.execute(v);let h=w.applyFixes(v);f(h),y(!0)},[a]),$=(0,b.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await l(s),i(!1)},[s,l]),U=(0,b.useCallback)(()=>{o(le);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let d=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(v=>d.removeAttribute(v)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",f(null),y(!1)},[]),J=(0,b.useCallback)((d,v)=>{o(h=>({...h,[d]:v}))},[]);(0,b.useEffect)(()=>{let d=v=>{v.key==="Escape"&&n&&i(!1)};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),(0,b.useEffect)(()=>{n&&P.current&&w.trapFocus(P.current)},[n]);let X={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:u?"#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":n,"data-yuktai-pref-toggle":"true",onClick:()=>i(d=>!d),onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),n&&(0,T.jsx)(ce,{ref:P,position:e,settings:s,report:c,isActive:u,aiSupported:g,voiceSupported:H,set:J,onApply:$,onReset:U,onClose:()=>i(!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 E=class{plugins=new Map;register(t,a){if(!a||typeof a.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,a)}use(t){return this.plugins.get(t)}async run(t,a){try{let n=this.use(t);if(!n)throw new Error(`Plugin not found: ${t}`);return await n.execute(a)}catch(n){throw console.error(`[YuktAI Runtime Error in ${t}]:`,n),n}}getPlugins(){return Array.from(this.plugins.keys())}};function vt(){if(typeof globalThis>"u")return new E;if(!globalThis.__yuktai_runtime__){let e=new E;e.register(w.name,w),e.register(z.name,z),e.register(I.name,I),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var We=typeof window<"u"?vt():new E,kt={wcagPlugin:w,list(){return We.getPlugins()},use(e){return We.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
- function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function X(){try{let e=ue();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}async function _e(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=ue();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),n=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:n.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function pe(){if(!await X())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let n of t){let i=n.innerText?.trim();if(!i||i.length<20||n.closest("[data-yuktai-panel]"))continue;let s=await _e(i);s.success&&s.rewritten!==i&&(n.dataset.yuktaiOriginal=i,n.innerText=s.rewritten,a++)}return{fixed:a}}function fe(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let a=t.dataset.yuktaiOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiOriginal)}}var me="yuktai-summary-box";function be(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function Z(){try{let e=be();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function De(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let n=window.getComputedStyle(a);if(n.display==="none"||n.visibility==="hidden")continue;let i=a.innerText?.trim();i&&i.length>10&&t.push(i)}return t.join(" ").slice(0,5e3)}async function ge(){if(!await Z())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=De();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=be();if(!a)throw new Error("Summarizer API not available");let n=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),i=await n.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 n.destroy(),qe(i.trim()),{success:!0,summary:i.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function qe(e){I();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=`
1
+ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function X(){try{let e=ue();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}async function _e(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=ue();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),i=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:i.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function pe(){if(!await X())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let i of t){let n=i.innerText?.trim();if(!n||n.length<20||i.closest("[data-yuktai-panel]"))continue;let s=await _e(n);s.success&&s.rewritten!==n&&(i.dataset.yuktaiOriginal=n,i.innerText=s.rewritten,a++)}return{fixed:a}}function fe(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let a=t.dataset.yuktaiOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiOriginal)}}var me="yuktai-summary-box";function be(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function Z(){try{let e=be();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function De(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(a);if(i.display==="none"||i.visibility==="hidden")continue;let n=a.innerText?.trim();n&&n.length>10&&t.push(n)}return t.join(" ").slice(0,5e3)}async function ge(){if(!await Z())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=De();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=be();if(!a)throw new Error("Summarizer API not available");let i=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),n=await i.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 i.destroy(),qe(n.trim()),{success:!0,summary:n.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function qe(e){I();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,11 +15,11 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
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 a=document.createElement("p");a.style.cssText="margin: 0; flex: 1;",a.textContent=`\u{1F4CB} Page summary: ${e}`;let n=document.createElement("button");n.textContent="\xD7",n.setAttribute("aria-label","Close page summary"),n.style.cssText=`
18
+ `;let a=document.createElement("p");a.style.cssText="margin: 0; flex: 1;",a.textContent=`\u{1F4CB} Page summary: ${e}`;let i=document.createElement("button");i.textContent="\xD7",i.setAttribute("aria-label","Close page summary"),i.style.cssText=`
19
19
  background: none; border: none; color: #ffffff;
20
20
  font-size: 20px; cursor: pointer; padding: 0 4px;
21
21
  line-height: 1; flex-shrink: 0;
22
- `,n.addEventListener("click",I),t.appendChild(a),t.appendChild(n),document.body.prepend(t)}function I(){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"}],H="en";async function Ge(e){try{return window.translation?await window.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function ye(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 Ge(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Chrome 127+ required.`};try{let a=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"),i=0;for(let s of n){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let o=s.innerText?.trim();if(!o||o.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=o);let c=await a.translate(o);c&&c!==o&&(s.innerText=c,i++)}return a.destroy(),H=e,{success:!0,language:e,fixed:i}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function Q(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let a=t.dataset.yuktaiTranslationOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiTranslationOriginal)}H="en"}var Ve=[{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,F=!1,E=null;function ee(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function je(e){let t=e.toLowerCase().trim();for(let a of Ve)for(let n of a.phrases)if(t.includes(n))return{action:a.action,label:a.label};return null}function Ke(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=xe(),a=t.indexOf(document.activeElement),n=t[a+1]||t[0];n&&n.focus();break}case"tab-back":{let t=xe(),a=t.indexOf(document.activeElement),n=t[a-1]||t[t.length-1];n&&n.focus();break}case"stop-voice":{te();break}}}function xe(){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 he(e){if(!ee())return!1;if(F)return!0;e&&(E=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return v=new t,v.continuous=!0,v.interimResults=!1,v.lang="en-US",v.onresult=a=>{let n=a.results[a.results.length-1][0].transcript,i=je(n);if(i){Ke(i.action);let s={success:!0,command:n,action:i.label};if(E&&E(s),i.action==="stop-voice")return}},v.onend=()=>{F&&v?.start()},v.onerror=a=>{a.error!=="no-speech"&&E&&E({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},v.start(),F=!0,Ye(),!0}function te(){F=!1,v&&(v.stop(),v=null),E=null,ve()}var we="yuktai-voice-indicator";function Ye(){ve();let e=document.createElement("div");e.id=we,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
22
+ `,i.addEventListener("click",I),t.appendChild(a),t.appendChild(i),document.body.prepend(t)}function I(){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"}],H="en";function Ge(){let e=window;return e.Translator||e.translation||null}async function Ve(e){try{let t=window;if(!Ge())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let i=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return i==="readily"||i==="available"||i==="downloadable"||i==="after-download"}catch{}return t.Translator&&typeof t.Translator.canTranslate=="function"?await t.Translator.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":t.translation&&typeof t.translation.canTranslate=="function"?await t.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function je(e){let t=window,a={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(a);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(a);throw new Error("Translation API not available")}async function ye(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 Ve(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let a=await je(e),i=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),n=0;for(let s of i){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let o=s.innerText?.trim();if(!o||o.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=o);let c=await a.translate(o);c&&c!==o&&(s.innerText=c,n++)}return typeof a.destroy=="function"&&a.destroy(),H=e,{success:!0,language:e,fixed:n}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function Q(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let a=t.dataset.yuktaiTranslationOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiTranslationOriginal)}H="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,F=!1,E=null;function ee(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function Ye(e){let t=e.toLowerCase().trim();for(let a of Ke)for(let i of a.phrases)if(t.includes(i))return{action:a.action,label:a.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=xe(),a=t.indexOf(document.activeElement),i=t[a+1]||t[0];i&&i.focus();break}case"tab-back":{let t=xe(),a=t.indexOf(document.activeElement),i=t[a-1]||t[t.length-1];i&&i.focus();break}case"stop-voice":{te();break}}}function xe(){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 he(e){if(!ee())return!1;if(F)return!0;e&&(E=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return v=new t,v.continuous=!0,v.interimResults=!1,v.lang="en-US",v.onresult=a=>{let i=a.results[a.results.length-1][0].transcript,n=Ye(i);if(n){Ue(n.action);let s={success:!0,command:i,action:n.label};if(E&&E(s),n.action==="stop-voice")return}},v.onend=()=>{F&&v?.start()},v.onerror=a=>{a.error!=="no-speech"&&E&&E({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},v.start(),F=!0,Je(),!0}function te(){F=!1,v&&(v.stop(),v=null),E=null,ve()}var we="yuktai-voice-indicator";function Je(){ve();let e=document.createElement("div");e.id=we,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
23
23
  position: fixed;
24
24
  bottom: 80px;
25
25
  left: 50%;
@@ -44,12 +44,12 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
44
44
  background: #ffffff;
45
45
  animation: yuktai-pulse 1.2s infinite;
46
46
  flex-shrink: 0;
47
- `,!document.getElementById("yuktai-pulse-style")){let n=document.createElement("style");n.id="yuktai-pulse-style",n.textContent=`
47
+ `,!document.getElementById("yuktai-pulse-style")){let i=document.createElement("style");i.id="yuktai-pulse-style",i.textContent=`
48
48
  @keyframes yuktai-pulse {
49
49
  0%, 100% { opacity: 1; transform: scale(1); }
50
50
  50% { opacity: 0.4; transform: scale(0.7); }
51
51
  }
52
- `,document.head.appendChild(n)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function ve(){let e=document.getElementById(we);e&&e.remove()}var Ue=["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(", ");function ke(){let e=window;return e.Writer||e.ai?.writer||null}async function ae(){try{let e=ke();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function Je(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let n=e.placeholder?.trim();n&&t.push(`placeholder: "${n}"`);let i=e.getAttribute("name")?.trim();i&&t.push(`name: "${i}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let o=e.id;if(o){let u=document.querySelector(`label[for="${o}"]`);u&&t.push(`label: "${u.innerText?.trim()}"`)}let c=e.parentElement?.innerText?.trim().slice(0,60);c&&t.push(`parent context: "${c}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let m=e.getAttribute("role");return m&&t.push(`role: ${m}`),t.join(". ")}async function Xe(e,t){let a=`
52
+ `,document.head.appendChild(i)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function ve(){let e=document.getElementById(we);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(", ");function ke(){let e=window;return e.Writer||e.ai?.writer||null}async function ae(){try{let e=ke();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function Ze(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let i=e.placeholder?.trim();i&&t.push(`placeholder: "${i}"`);let n=e.getAttribute("name")?.trim();n&&t.push(`name: "${n}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let o=e.id;if(o){let u=document.querySelector(`label[for="${o}"]`);u&&t.push(`label: "${u.innerText?.trim()}"`)}let c=e.parentElement?.innerText?.trim().slice(0,60);c&&t.push(`parent context: "${c}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let m=e.getAttribute("role");return m&&t.push(`role: ${m}`),t.join(". ")}async function Qe(e,t){let a=`
53
53
  Generate a short, clear aria-label for an HTML element.
54
54
  The label must be 2-6 words maximum.
55
55
  The label must describe what the element does or what it is.
@@ -60,7 +60,7 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
60
60
  ${t}
61
61
 
62
62
  Output only the label. Nothing else.
63
- `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Ae(){if(!await ae())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(Ue);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=ke();if(!a)throw new Error("Writer API not available");let n=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),i=0,s=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let c=window.getComputedStyle(o);if(c.display==="none"||c.visibility==="hidden")continue;let m=Je(o),u=await Xe(n,m);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),i++,s.push({tag:o.tagName.toLowerCase(),label:u}))}return n.destroy(),{success:!0,fixed:i,elements:s}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function Se(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let a=t.dataset.yuktaiLabelOriginal;a?t.setAttribute("aria-label",a):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var N=null,Ee=null;var Te=null,oe=null,b=null,T=null,W=null,ie=null,C=null,B={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Ce=new Set(["input","select","textarea"]);var ne={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 a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let n=window.speechSynthesis.getVoices();n.length>0&&(a.voice=n[0]),window.speechSynthesis.speak(a)}function He(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=`
63
+ `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Ae(){if(!await ae())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(Xe);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=ke();if(!a)throw new Error("Writer API not available");let i=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),n=0,s=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let c=window.getComputedStyle(o);if(c.display==="none"||c.visibility==="hidden")continue;let m=Ze(o),u=await Qe(i,m);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),n++,s.push({tag:o.tagName.toLowerCase(),label:u}))}return i.destroy(),{success:!0,fixed:n,elements:s}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function Se(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let a=t.dataset.yuktaiLabelOriginal;a?t.setAttribute("aria-label",a):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var N=null,Ee=null;var Te=null,oe=null,b=null,T=null,W=null,ie=null,C=null,B={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Ce=new Set(["input","select","textarea"]);var ne={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 a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let i=window.speechSynthesis.getVoices();i.length>0&&(a.voice=i[0]),window.speechSynthesis.speak(a)}function He(e,t="info"){if(typeof document>"u")return;let i={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=`
64
64
  position: fixed;
65
65
  top: 80px;
66
66
  right: 16px;
@@ -79,14 +79,14 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
79
79
  transition: transform 0.3s, opacity 0.3s;
80
80
  transform: translateX(120%);
81
81
  opacity: 0;
82
- `,document.body.appendChild(b)),b.style.background=n.bg,b.style.border=`1px solid ${n.border}`,b.style.color="#fff",b.innerHTML=`
83
- <span style="font-size:18px;font-weight:700">${n.icon}</span>
82
+ `,document.body.appendChild(b)),b.style.background=i.bg,b.style.border=`1px solid ${i.border}`,b.style.color="#fff",b.innerHTML=`
83
+ <span style="font-size:18px;font-weight:700">${i.icon}</span>
84
84
  <span style="flex:1;line-height:1.4">${e}</span>
85
85
  <button
86
86
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
87
87
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
88
88
  aria-label="Close notification">\xD7</button>
89
- `,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 p(e,t="info",a=!0){N&&(N.textContent=e),He(e,t),a&&re(e,t==="error"?"assertive":"polite")}function Ze(){if(typeof document>"u"||Te)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=`
89
+ `,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 p(e,t="info",a=!0){N&&(N.textContent=e),He(e,t),a&&re(e,t==="error"?"assertive":"polite")}function et(){if(typeof document>"u"||Te)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=`
90
90
  position: fixed;
91
91
  top: 0;
92
92
  left: 0;
@@ -100,7 +100,7 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
100
100
  transform: translateY(-100%);
101
101
  transition: transform 0.2s ease;
102
102
  font-family: system-ui, sans-serif;
103
- `;let a=!1;if(e.forEach(({label:i,selector:s})=>{let o=document.querySelector(s);if(!o)return;a=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let c=document.createElement("a");c.href="#",c.textContent=i,c.style.cssText=`
103
+ `;let a=!1;if(e.forEach(({label:n,selector:s})=>{let o=document.querySelector(s);if(!o)return;a=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let c=document.createElement("a");c.href="#",c.textContent=n,c.style.cssText=`
104
104
  color: #fff;
105
105
  background: #1a73e8;
106
106
  padding: 8px 14px;
@@ -111,7 +111,7 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
111
111
  white-space: nowrap;
112
112
  border: 2px solid transparent;
113
113
  transition: background 0.15s, border-color 0.15s;
114
- `,c.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),c.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),c.addEventListener("click",m=>{m.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),p(`Jumped to ${i.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!a)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),Te=t}function Qe(){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=`
114
+ `,c.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),c.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),c.addEventListener("click",m=>{m.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),p(`Jumped to ${n.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!a)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),Te=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=`
115
115
 
116
116
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
117
117
  [data-yuktai-a11y] *:focus-visible {
@@ -257,7 +257,7 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
257
257
  width: auto !important;
258
258
  }
259
259
  }
260
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function et(){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 a=t.getAttribute("role")||"";if(e.key==="Escape"){let n=t.closest("[role='dialog'],[role='alertdialog']");if(n){n.style.display="none",p("Dialog closed","info");return}let i=t.closest("[role='menu'],[role='menubar']");i&&(i.style.display="none",p("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let n=t.closest("[role='menu'],[role='menubar']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='menuitem']:not([disabled])")),s=i.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),i[(s+1)%i.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),i[(s-1+i.length)%i.length]?.focus()):e.key==="Home"?(e.preventDefault(),i[0]?.focus()):e.key==="End"&&(e.preventDefault(),i[i.length-1]?.focus())}if(a==="tab"||t.closest("[role='tablist']")){let n=t.closest("[role='tablist']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='tab']:not([disabled])")),s=i.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=i[(s+1)%i.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=i[(s-1+i.length)%i.length];o?.focus(),o?.click()}}if(a==="option"||t.closest("[role='listbox']")){let n=t.closest("[role='listbox']");if(!n)return;let i=Array.from(n.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=i.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),i[(s+1)%i.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),i[(s-1+i.length)%i.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),i.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),p(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),tt()),e.key==="Tab"&&C?.speechEnabled&&setTimeout(()=>{let n=document.activeElement;if(!n)return;let i=n.getAttribute("aria-label")||n.getAttribute("title")||n.textContent?.trim()||n.tagName.toLowerCase(),s=n.getAttribute("role")||n.tagName.toLowerCase();re(`${i}, ${s}`)},100)}))}function O(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 a=t[0],n=t[t.length-1];a.focus(),e.addEventListener("keydown",i=>{i.key==="Tab"&&(i.shiftKey?document.activeElement===a&&(i.preventDefault(),n.focus()):document.activeElement===n&&(i.preventDefault(),a.focus()))})}function tt(){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=`
260
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function at(){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 a=t.getAttribute("role")||"";if(e.key==="Escape"){let i=t.closest("[role='dialog'],[role='alertdialog']");if(i){i.style.display="none",p("Dialog closed","info");return}let n=t.closest("[role='menu'],[role='menubar']");n&&(n.style.display="none",p("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let i=t.closest("[role='menu'],[role='menubar']");if(!i)return;let n=Array.from(i.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(a==="tab"||t.closest("[role='tablist']")){let i=t.closest("[role='tablist']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='tab']:not([disabled])")),s=n.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=n[(s+1)%n.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=n[(s-1+n.length)%n.length];o?.focus(),o?.click()}}if(a==="option"||t.closest("[role='listbox']")){let i=t.closest("[role='listbox']");if(!i)return;let n=Array.from(i.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(o=>{o!==t&&o.setAttribute("aria-selected","false")}),p(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),ot()),e.key==="Tab"&&C?.speechEnabled&&setTimeout(()=>{let i=document.activeElement;if(!i)return;let n=i.getAttribute("aria-label")||i.getAttribute("title")||i.textContent?.trim()||i.tagName.toLowerCase(),s=i.getAttribute("role")||i.tagName.toLowerCase();re(`${n}, ${s}`)},100)}))}function O(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 a=t[0],i=t[t.length-1];a.focus(),e.addEventListener("keydown",n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===a&&(n.preventDefault(),i.focus()):document.activeElement===i&&(n.preventDefault(),a.focus()))})}function ot(){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=`
261
261
  position: fixed;
262
262
  top: 50%;
263
263
  left: 50%;
@@ -281,13 +281,13 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
281
281
  style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1"
282
282
  aria-label="Close shortcuts">\xD7</button>
283
283
  </div>
284
- ${t.map(([n,i])=>`
284
+ ${t.map(([i,n])=>`
285
285
  <div style="display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid #2a2a4a">
286
- <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${n}</kbd>
287
- <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${i}</span>
286
+ <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${i}</kbd>
287
+ <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${n}</span>
288
288
  </div>
289
289
  `).join("")}
290
- `,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,O(e),p("Keyboard shortcuts opened. Press Escape to close.","info")}function at(e){if(typeof document>"u"||!C?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;oe&&oe.remove();let t=e.score,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",n=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",i=document.createElement("button");i.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),i.setAttribute("data-yuktai-badge","true"),i.style.cssText=`
290
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),T=null}),e.addEventListener("keydown",i=>{i.key==="Escape"&&(e.remove(),T=null)}),document.body.appendChild(e),T=e,O(e),p("Keyboard shortcuts opened. Press Escape to close.","info")}function it(e){if(typeof document>"u"||!C?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;oe&&oe.remove();let t=e.score,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",i=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=`
291
291
  position: fixed;
292
292
  bottom: 16px;
293
293
  left: 16px;
@@ -306,7 +306,7 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
306
306
  align-items: center;
307
307
  gap: 6px;
308
308
  transition: transform 0.15s;
309
- `,i.innerHTML=`${n} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,i.addEventListener("click",()=>ot(e)),document.body.appendChild(i),oe=i}function ot(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let a=document.createElement("div");a.setAttribute("data-yuktai-audit-details","true"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","Accessibility audit details"),a.style.cssText=`
309
+ `,n.innerHTML=`${i} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,n.addEventListener("click",()=>nt(e)),document.body.appendChild(n),oe=n}function nt(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let a=document.createElement("div");a.setAttribute("data-yuktai-audit-details","true"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","Accessibility audit details"),a.style.cssText=`
310
310
  position: fixed;
311
311
  bottom: 56px;
312
312
  left: 16px;
@@ -323,22 +323,22 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
323
323
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
324
324
  font-family: system-ui, sans-serif;
325
325
  font-size: 12px;
326
- `;let n={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};a.innerHTML=`
326
+ `;let i={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};a.innerHTML=`
327
327
  <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
328
328
  <strong style="font-size:14px;color:#74c0fc">Audit report</strong>
329
329
  <span style="color:#aaa">${e.fixed} fixed \xB7 ${e.renderTime}ms</span>
330
330
  </div>
331
- ${e.details.slice(0,20).map(i=>`
331
+ ${e.details.slice(0,20).map(n=>`
332
332
  <div style="padding:6px 0;border-bottom:1px solid #2a2a4a">
333
333
  <div style="display:flex;gap:6px;align-items:center">
334
- <span style="background:${n[i.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${i.severity}</span>
335
- <code style="color:#74c0fc">&lt;${i.tag}&gt;</code>
334
+ <span style="background:${i[n.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${n.severity}</span>
335
+ <code style="color:#74c0fc">&lt;${n.tag}&gt;</code>
336
336
  </div>
337
- <div style="color:#ccc;margin-top:3px">${i.fix}</div>
337
+ <div style="color:#ccc;margin-top:3px">${n.fix}</div>
338
338
  </div>
339
339
  `).join("")}
340
340
  ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
341
- `,a.addEventListener("keydown",i=>{i.key==="Escape"&&a.remove()}),document.body.appendChild(a),O(a)}function $e(e){typeof document>"u"||(ie&&clearTimeout(ie),ie=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=`
341
+ `,a.addEventListener("keydown",n=>{n.key==="Escape"&&a.remove()}),document.body.appendChild(a),O(a)}function $e(e){typeof document>"u"||(ie&&clearTimeout(ie),ie=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=`
342
342
  position: fixed;
343
343
  top: 50%;
344
344
  left: 50%;
@@ -367,7 +367,7 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
367
367
  No, sign out
368
368
  </button>
369
369
  </div>
370
- `;let a=t.querySelector("[data-yuktai-extend]"),n=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),W=null,p("Session extended. You have more time.","success"),C?.timeoutWarning&&$e(C.timeoutWarning)}),n?.addEventListener("click",()=>{t.remove(),W=null}),document.body.appendChild(t),W=t,O(t),p("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function it(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 a=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${B[e.colorBlindMode]})`;document.body.style.filter=a}else document.body.style.filter=""}function nt(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Le(e){if(e){if(!await X()){p("Plain English requires Chrome 127+","warning");return}p("Rewriting page in plain English...","info",!1);let a=await pe();p(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else fe(),p("Original text restored","info",!1)}async function Me(e){if(e){if(!await Z()){p("Page summariser requires Chrome 127+","warning");return}p("Generating page summary...","info",!1);let a=await ge();p(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else I(),p("Page summary removed","info",!1)}async function Re(e){if(e==="en"){Q(),p("Page restored to English","info",!1);return}p(`Translating page to ${e}...`,"info",!1);let t=await ye(e);p(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Pe(e){if(e){if(!ee()){p("Voice control not supported in this browser","warning");return}he(t=>{t.success&&p(`Voice: ${t.action}`,"info",!1)}),p("Voice control started. Say a command.","success",!1)}else te(),p("Voice control stopped","info",!1)}async function ze(e){if(e){if(!await ae()){p("Smart labels requires Chrome 127+","warning");return}p("Generating smart labels...","info",!1);let a=await Ae();p(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else Se(),p("Smart labels removed","info",!1)}function rt(){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 st(){if(typeof document>"u"||Ee)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=`
370
+ `;let a=t.querySelector("[data-yuktai-extend]"),i=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),W=null,p("Session extended. You have more time.","success"),C?.timeoutWarning&&$e(C.timeoutWarning)}),i?.addEventListener("click",()=>{t.remove(),W=null}),document.body.appendChild(t),W=t,O(t),p("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 a=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${B[e.colorBlindMode]})`;document.body.style.filter=a}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 Le(e){if(e){if(!await X()){p("Plain English requires Chrome 127+","warning");return}p("Rewriting page in plain English...","info",!1);let a=await pe();p(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else fe(),p("Original text restored","info",!1)}async function Me(e){if(e){if(!await Z()){p("Page summariser requires Chrome 127+","warning");return}p("Generating page summary...","info",!1);let a=await ge();p(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else I(),p("Page summary removed","info",!1)}async function Re(e){if(e==="en"){Q(),p("Page restored to English","info",!1);return}p(`Translating page to ${e}...`,"info",!1);let t=await ye(e);p(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Pe(e){if(e){if(!ee()){p("Voice control not supported in this browser","warning");return}he(t=>{t.success&&p(`Voice: ${t.action}`,"info",!1)}),p("Voice control started. Say a command.","success",!1)}else te(),p("Voice control stopped","info",!1)}async function ze(e){if(e){if(!await ae()){p("Smart labels requires Chrome 127+","warning");return}p("Generating smart labels...","info",!1);let a=await Ae();p(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else Se(),p("Smart labels removed","info",!1)}function lt(){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 ct(){if(typeof document>"u"||Ee)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=`
371
371
  <defs>
372
372
  <filter id="${B.deuteranopia}">
373
373
  <feColorMatrix type="matrix"
@@ -382,4 +382,4 @@ function ue(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
382
382
  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"/>
383
383
  </filter>
384
384
  </defs>
385
- `,document.body.appendChild(e),Ee=e}function Ie(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((n,i)=>n+(t[i.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var k={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";C=e,nt(e),rt(),st(),Qe(),et(),e.showSkipLinks!==!1&&Ze(),e.showPreferencePanel,it(e);let t=this.applyFixes(e);t.score=Ie(t),e.showAuditBadge&&at(t),e.timeoutWarning&&$e(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Le(!0),e.summarisePage&&await Me(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Re(e.translateLanguage),e.voiceControl&&await Pe(!0),e.smartLabels&&await ze(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return p(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} 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 a=performance.now(),n=document.querySelectorAll("*");t.scanned=n.length;let i=(s,o,c,m)=>{t.details.push({tag:s,fix:o,severity:c,element:m.outerHTML.slice(0,100)}),t.fixed++};return n.forEach(s=>{let o=s,c=o.tagName.toLowerCase();if(c==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),i(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),y=o.getAttribute("content")||"";u==="viewport"&&y.includes("user-scalable=no")&&(o.setAttribute("content",y.replace("user-scalable=no","user-scalable=yes")),i(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(y)&&(o.setAttribute("content",y.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),i(c,"maximum-scale=5 restored","serious",o))}if(c==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),c==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),i(c,'alt="" aria-hidden="true"',"serious",o))),c==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!s.querySelector("title")&&(o.setAttribute("aria-hidden","true"),i(c,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),c==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),i(c,"title + aria-label added","serious",o)),c==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let u=o.getAttribute("title")||"button";o.setAttribute("aria-label",u),i(c,`aria-label="${u}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(c==="a"){let u=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),i(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(Ce.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let y=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",y),i(c,`aria-label="${y}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let y=u.name||"";u.type==="email"||y.includes("email")?u.autocomplete="email":u.type==="tel"||y.includes("tel")?u.autocomplete="tel":u.type==="password"&&(u.autocomplete="current-password"),t.fixed++}}c==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),i(c,"scope added to <th>","moderate",o)),ne[c]&&!o.getAttribute("role")&&(o.setAttribute("role",ne[c]),i(c,`role="${ne[c]}"`,"minor",o));let m=o.getAttribute("role")||"";m==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(m)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",m==="alert"?"assertive":"polite"),i(c,`aria-live added on role=${m}`,"moderate",o)),m==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),i(c,'aria-expanded="false" on combobox',"serious",o)),(m==="checkbox"||m==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),i(c,`aria-checked="false" on role=${m}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-a).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(),a=document.querySelectorAll("*");e.scanned=a.length;let n=(i,s,o,c)=>e.details.push({tag:i,fix:s,severity:o,element:c.outerHTML.slice(0,100)});return a.forEach(i=>{let s=i,o=s.tagName.toLowerCase();(o==="a"||o==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&n(o,"needs aria-label (empty)","critical",s),o==="img"&&!s.hasAttribute("alt")&&n(o,"needs alt text","serious",s),Ce.has(o)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&n(o,"needs aria-label","serious",s),o==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&n(o,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=Ie(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:p,speak:re,showVisualAlert:He,trapFocus:O,handlePlainEnglish:Le,handleSummarisePage:Me,handleTranslate:Re,handleVoiceControl:Pe,handleSmartLabels:ze,SUPPORTED_LANGUAGES:$};import ft,{useEffect as D,useState as M,useCallback as q}from"react";import{forwardRef as lt,useEffect as Fe,useState as We}from"react";import{jsx as r,jsxs as f}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],ct=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],dt=["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]=We(typeof window<"u"?window.innerWidth:1024);return Fe(()=>{let a=()=>t(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function pt({checked:e,onChange:t,label:a,disabled:n=!1}){return f("label",{"aria-label":a,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:i=>t(i.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:a}){return f("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}),a&&r("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:a})]})}function A({icon:e,label:t,desc:a,checked:n,onChange:i,disabled:s=!1,disabledReason:o}){return f("div",{title:s?o:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[f("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}),f("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?o:a})]})]}),r(pt,{checked:n,onChange:i,label:`Toggle ${t}`,disabled:s})]})}function x(){return r("div",{style:{height:"1px",background:"#f1f5f9",margin:"0"}})}var le=lt(({position:e,settings:t,report:a,isActive:n,aiSupported:i,voiceSupported:s,set:o,onApply:c,onReset:m,onClose:u},y)=>{let{isMobile:g,isTablet:j}=ut(),[P,K]=We([]);Fe(()=>{(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 f("div",{ref:y,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:R,children:[f("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:[f("div",{children:[f("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:u,"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(A,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:l=>o("autoFix",l)}),r(x,{}),r(A,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:l=>o("speechEnabled",l)}),r(x,{}),r(A,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:l=>o("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser"}),r(x,{}),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:i?"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."}),!i&&f("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:"}),f("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"})]}),f("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:dt.map(l=>f("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",l]},l))}),f("p",{style:{margin:"0 0 3px"},children:["3. Click ",r("strong",{style:{color:"#0f172a"},children:"Relaunch"})," when Chrome prompts you"]}),f("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"})]}),f("p",{style:{margin:"0 0 3px 10px"},children:["\u2192 Find ",r("strong",{style:{color:"#0f172a"},children:"Optimization Guide On Device Model"})]}),f("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(A,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:l=>o("plainEnglish",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(A,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:l=>o("summarisePage",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(A,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:l=>o("smartLabels",l),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(_,{label:"Visual"}),r(A,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:l=>o("highContrast",l)}),r(x,{}),r(A,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:l=>o("darkMode",l)}),r(x,{}),r(A,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:l=>o("reduceMotion",l)}),r(x,{}),r(A,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>o("largeTargets",l)}),r(x,{}),f("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:ct.map(l=>r("button",{onClick:()=>o("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(_,{label:"Font"}),r(A,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:l=>o("dyslexiaFont",l)}),r(x,{}),f("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?f("select",{value:t.localFont,onChange:l=>o("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(x,{}),f("div",{style:{padding:"10px 18px 14px"},children:[f("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"}),f("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),f("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[r("button",{onClick:()=>{let l=L.indexOf(t.fontScale);l>0&&o("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:()=>o("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&&o("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,{}),f("div",{style:{padding:"10px 18px"},children:[f("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:()=>o("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!i,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:i?"pointer":"not-allowed",opacity:i?1:.5,minHeight:g?"36px":"auto"},children:l.code.toUpperCase()},l.code))}),!i&&r("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above to unlock translation."})]}),a&&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:a.fixed>0?`\u2713 ${a.fixed} fixes \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms \xB7 Score: ${a.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms`}),f("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:c,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 bt,jsx as Be,jsxs as gt}from"react/jsx-runtime";async function mt(){try{if(typeof window>"u")return!1;let e=window;if(e.LanguageModel)try{if(typeof e.LanguageModel.availability=="function"){let a=await e.LanguageModel.availability();if(console.log("yuktai: LanguageModel.availability() =",a),a==="readily"||a==="available"||a==="downloadable")return!0}else return!0}catch{}if(e.Summarizer)try{if(typeof e.Summarizer.availability=="function"){let a=await e.Summarizer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Rewriter)try{if(typeof e.Rewriter.availability=="function"){let a=await e.Rewriter.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Writer)try{if(typeof e.Writer.availability=="function"){let a=await e.Writer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}let t=e.ai||globalThis.ai;if(t){if(t.languageModel?.availability)try{let a=await t.languageModel.availability();if(a==="readily"||a==="downloadable"||a==="available")return!0}catch{}if(t.languageModel?.capabilities)try{let a=await t.languageModel.capabilities();if(a?.available==="readily"||a?.available==="after-download")return!0}catch{}if(t.languageModel&&typeof t.languageModel.create=="function")return!0;if(t.summarizer?.capabilities)try{if((await t.summarizer.capabilities())?.available!=="no")return!0}catch{}if(t.rewriter?.capabilities)try{if((await t.rewriter.capabilities())?.available!=="no")return!0}catch{}if(t.writer?.capabilities)try{if((await t.writer.capabilities())?.available!=="no")return!0}catch{}if(t.summarizer||t.rewriter||t.writer||t.languageModel)return!0}return!!(e.Translator||e.translation?.canTranslate)}catch{return!1}}function ce({position:e="left",children:t,config:a={}}){let[n,i]=M(!1),[s,o]=M(se),[c,m]=M(null),[u,y]=M(!1),[g,j]=M(!1),[P,K]=M(!1),R=ft.useRef(null);D(()=>{if(typeof window>"u")return;let w=setTimeout(async()=>{let h=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.ai =",h.ai),console.log("yuktai: window.LanguageModel =",h.LanguageModel),console.log("yuktai: window.Summarizer =",h.Summarizer),console.log("yuktai: window.Rewriter =",h.Rewriter),console.log("yuktai: window.Writer =",h.Writer);let de=await mt();j(de),de?console.log("yuktai: Chrome Built-in AI detected \u2705"):(console.log("yuktai: Chrome Built-in AI not detected \u274C"),console.log("yuktai: Enable flags at chrome://flags and download model at chrome://components"));let Oe=!!(h.SpeechRecognition||h.webkitSpeechRecognition);K(Oe)},800);return()=>clearTimeout(w)},[]),D(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");if(d){let w=JSON.parse(d);o(h=>({...h,...w}))}}catch{}},[]);let l=q(async d=>{let w={enabled:!0,highContrast:d.highContrast,darkMode:d.darkMode,reduceMotion:d.reduceMotion,largeTargets:d.largeTargets,speechEnabled:d.speechEnabled,autoFix:d.autoFix,dyslexiaFont:d.dyslexiaFont,localFont:d.localFont,fontSizeMultiplier:d.fontScale/100,colorBlindMode:d.colorBlindMode,showAuditBadge:d.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:d.plainEnglish,summarisePage:d.summarisePage,translateLanguage:d.translateLanguage,voiceControl:d.voiceControl,smartLabels:d.smartLabels,...a};await k.execute(w);let h=k.applyFixes(w);m(h),y(!0)},[a]),z=q(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await l(s),i(!1)},[s,l]),Y=q(()=>{o(se);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let d=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(w=>d.removeAttribute(w)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",m(null),y(!1)},[]),U=q((d,w)=>{o(h=>({...h,[d]:w}))},[]);D(()=>{let d=w=>{w.key==="Escape"&&n&&i(!1)};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),D(()=>{n&&R.current&&k.trapFocus(R.current)},[n]);let J={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:u?"#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 gt(bt,{children:[t,Be("button",{style:J,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":n,"data-yuktai-pref-toggle":"true",onClick:()=>i(d=>!d),onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),n&&Be(le,{ref:R,position:e,settings:s,report:c,isActive:u,aiSupported:g,voiceSupported:P,set:U,onApply:z,onReset:Y,onClose:()=>i(!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,a){if(!a||typeof a.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,a)}use(t){return this.plugins.get(t)}async run(t,a){try{let n=this.use(t);if(!n)throw new Error(`Plugin not found: ${t}`);return await n.execute(a)}catch(n){throw console.error(`[YuktAI Runtime Error in ${t}]:`,n),n}}getPlugins(){return Array.from(this.plugins.keys())}};function yt(){if(typeof globalThis>"u")return new S;if(!globalThis.__yuktai_runtime__){let e=new S;e.register(k.name,k),e.register(G.name,G),e.register(V.name,V),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var Ne=typeof window<"u"?yt():new S,Yt={wcagPlugin:k,list(){return Ne.getPlugins()},use(e){return Ne.use(e)},fix(e){return k.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return k.scan()}};export{S as Runtime,Yt as YuktAI,ce as YuktAIWrapper,G as aiPlugin,ce as default,V as voicePlugin,k as wcag,k as wcagPlugin};
385
+ `,document.body.appendChild(e),Ee=e}function Ie(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((i,n)=>i+(t[n.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var k={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";C=e,st(e),lt(),ct(),tt(),at(),e.showSkipLinks!==!1&&et(),e.showPreferencePanel,rt(e);let t=this.applyFixes(e);t.score=Ie(t),e.showAuditBadge&&it(t),e.timeoutWarning&&$e(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Le(!0),e.summarisePage&&await Me(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Re(e.translateLanguage),e.voiceControl&&await Pe(!0),e.smartLabels&&await ze(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return p(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} 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 a=performance.now(),i=document.querySelectorAll("*");t.scanned=i.length;let n=(s,o,c,m)=>{t.details.push({tag:s,fix:o,severity:c,element:m.outerHTML.slice(0,100)}),t.fixed++};return i.forEach(s=>{let o=s,c=o.tagName.toLowerCase();if(c==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),n(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),y=o.getAttribute("content")||"";u==="viewport"&&y.includes("user-scalable=no")&&(o.setAttribute("content",y.replace("user-scalable=no","user-scalable=yes")),n(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(y)&&(o.setAttribute("content",y.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),n(c,"maximum-scale=5 restored","serious",o))}if(c==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),c==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),n(c,'alt="" aria-hidden="true"',"serious",o))),c==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!s.querySelector("title")&&(o.setAttribute("aria-hidden","true"),n(c,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),c==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),n(c,"title + aria-label added","serious",o)),c==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let u=o.getAttribute("title")||"button";o.setAttribute("aria-label",u),n(c,`aria-label="${u}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(c==="a"){let u=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),n(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(Ce.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let y=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",y),n(c,`aria-label="${y}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let y=u.name||"";u.type==="email"||y.includes("email")?u.autocomplete="email":u.type==="tel"||y.includes("tel")?u.autocomplete="tel":u.type==="password"&&(u.autocomplete="current-password"),t.fixed++}}c==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),n(c,"scope added to <th>","moderate",o)),ne[c]&&!o.getAttribute("role")&&(o.setAttribute("role",ne[c]),n(c,`role="${ne[c]}"`,"minor",o));let m=o.getAttribute("role")||"";m==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(m)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",m==="alert"?"assertive":"polite"),n(c,`aria-live added on role=${m}`,"moderate",o)),m==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),n(c,'aria-expanded="false" on combobox',"serious",o)),(m==="checkbox"||m==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),n(c,`aria-checked="false" on role=${m}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-a).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(),a=document.querySelectorAll("*");e.scanned=a.length;let i=(n,s,o,c)=>e.details.push({tag:n,fix:s,severity:o,element:c.outerHTML.slice(0,100)});return a.forEach(n=>{let s=n,o=s.tagName.toLowerCase();(o==="a"||o==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&i(o,"needs aria-label (empty)","critical",s),o==="img"&&!s.hasAttribute("alt")&&i(o,"needs alt text","serious",s),Ce.has(o)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&i(o,"needs aria-label","serious",s),o==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&i(o,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=Ie(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:p,speak:re,showVisualAlert:He,trapFocus:O,handlePlainEnglish:Le,handleSummarisePage:Me,handleTranslate:Re,handleVoiceControl:Pe,handleSmartLabels:ze,SUPPORTED_LANGUAGES:$};import bt,{useEffect as D,useState as M,useCallback as q}from"react";import{forwardRef as dt,useEffect as Fe,useState as We}from"react";import{jsx as r,jsxs as f}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],ut=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],pt=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function ft(){let[e,t]=We(typeof window<"u"?window.innerWidth:1024);return Fe(()=>{let a=()=>t(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function mt({checked:e,onChange:t,label:a,disabled:i=!1}){return f("label",{"aria-label":a,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:i?"not-allowed":"pointer",flexShrink:0,opacity:i?.4:1},children:[r("input",{type:"checkbox",checked:e,disabled:i,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:a}){return f("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}),a&&r("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:a})]})}function A({icon:e,label:t,desc:a,checked:i,onChange:n,disabled:s=!1,disabledReason:o}){return f("div",{title:s?o:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[f("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}),f("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?o:a})]})]}),r(mt,{checked:i,onChange:n,label:`Toggle ${t}`,disabled:s})]})}function x(){return r("div",{style:{height:"1px",background:"#f1f5f9",margin:"0"}})}var le=dt(({position:e,settings:t,report:a,isActive:i,aiSupported:n,voiceSupported:s,set:o,onApply:c,onReset:m,onClose:u},y)=>{let{isMobile:g,isTablet:j}=ft(),[P,K]=We([]);Fe(()=>{(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 f("div",{ref:y,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:R,children:[f("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:[f("div",{children:[f("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"}),i&&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:u,"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(A,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:l=>o("autoFix",l)}),r(x,{}),r(A,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:l=>o("speechEnabled",l)}),r(x,{}),r(A,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:l=>o("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser"}),r(x,{}),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&&f("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:"}),f("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"})]}),f("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:pt.map(l=>f("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",l]},l))}),f("p",{style:{margin:"0 0 3px"},children:["3. Click ",r("strong",{style:{color:"#0f172a"},children:"Relaunch"})," when Chrome prompts you"]}),f("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"})]}),f("p",{style:{margin:"0 0 3px 10px"},children:["\u2192 Find ",r("strong",{style:{color:"#0f172a"},children:"Optimization Guide On Device Model"})]}),f("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(A,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:l=>o("plainEnglish",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(A,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:l=>o("summarisePage",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(A,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:l=>o("smartLabels",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),r(x,{}),r(_,{label:"Visual"}),r(A,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:l=>o("highContrast",l)}),r(x,{}),r(A,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:l=>o("darkMode",l)}),r(x,{}),r(A,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:l=>o("reduceMotion",l)}),r(x,{}),r(A,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>o("largeTargets",l)}),r(x,{}),f("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:ut.map(l=>r("button",{onClick:()=>o("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(_,{label:"Font"}),r(A,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:l=>o("dyslexiaFont",l)}),r(x,{}),f("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?f("select",{value:t.localFont,onChange:l=>o("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(x,{}),f("div",{style:{padding:"10px 18px 14px"},children:[f("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"}),f("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),f("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[r("button",{onClick:()=>{let l=L.indexOf(t.fontScale);l>0&&o("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:()=>o("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&&o("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,{}),f("div",{style:{padding:"10px 18px"},children:[f("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:()=>o("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."})]}),a&&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:a.fixed>0?`\u2713 ${a.fixed} fixes \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms \xB7 Score: ${a.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms`}),f("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:c,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 yt,jsx as Be,jsxs as xt}from"react/jsx-runtime";async function gt(){try{if(typeof window>"u")return!1;let e=window;if(e.LanguageModel)try{if(typeof e.LanguageModel.availability=="function"){let a=await e.LanguageModel.availability();if(console.log("yuktai: LanguageModel.availability() =",a),a==="readily"||a==="available"||a==="downloadable")return!0}else return!0}catch{}if(e.Summarizer)try{if(typeof e.Summarizer.availability=="function"){let a=await e.Summarizer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Rewriter)try{if(typeof e.Rewriter.availability=="function"){let a=await e.Rewriter.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Writer)try{if(typeof e.Writer.availability=="function"){let a=await e.Writer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}let t=e.ai||globalThis.ai;if(t){if(t.languageModel?.availability)try{let a=await t.languageModel.availability();if(a==="readily"||a==="downloadable"||a==="available")return!0}catch{}if(t.languageModel?.capabilities)try{let a=await t.languageModel.capabilities();if(a?.available==="readily"||a?.available==="after-download")return!0}catch{}if(t.languageModel&&typeof t.languageModel.create=="function")return!0;if(t.summarizer?.capabilities)try{if((await t.summarizer.capabilities())?.available!=="no")return!0}catch{}if(t.rewriter?.capabilities)try{if((await t.rewriter.capabilities())?.available!=="no")return!0}catch{}if(t.writer?.capabilities)try{if((await t.writer.capabilities())?.available!=="no")return!0}catch{}if(t.summarizer||t.rewriter||t.writer||t.languageModel)return!0}return!!(e.Translator||e.translation?.canTranslate)}catch{return!1}}function ce({position:e="left",children:t,config:a={}}){let[i,n]=M(!1),[s,o]=M(se),[c,m]=M(null),[u,y]=M(!1),[g,j]=M(!1),[P,K]=M(!1),R=bt.useRef(null);D(()=>{if(typeof window>"u")return;let w=setTimeout(async()=>{let h=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.ai =",h.ai),console.log("yuktai: window.LanguageModel =",h.LanguageModel),console.log("yuktai: window.Summarizer =",h.Summarizer),console.log("yuktai: window.Rewriter =",h.Rewriter),console.log("yuktai: window.Writer =",h.Writer);let de=await gt();j(de),de?console.log("yuktai: Chrome Built-in AI detected \u2705"):(console.log("yuktai: Chrome Built-in AI not detected \u274C"),console.log("yuktai: Enable flags at chrome://flags and download model at chrome://components"));let Oe=!!(h.SpeechRecognition||h.webkitSpeechRecognition);K(Oe)},800);return()=>clearTimeout(w)},[]),D(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");if(d){let w=JSON.parse(d);o(h=>({...h,...w}))}}catch{}},[]);let l=q(async d=>{let w={enabled:!0,highContrast:d.highContrast,darkMode:d.darkMode,reduceMotion:d.reduceMotion,largeTargets:d.largeTargets,speechEnabled:d.speechEnabled,autoFix:d.autoFix,dyslexiaFont:d.dyslexiaFont,localFont:d.localFont,fontSizeMultiplier:d.fontScale/100,colorBlindMode:d.colorBlindMode,showAuditBadge:d.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:d.plainEnglish,summarisePage:d.summarisePage,translateLanguage:d.translateLanguage,voiceControl:d.voiceControl,smartLabels:d.smartLabels,...a};await k.execute(w);let h=k.applyFixes(w);m(h),y(!0)},[a]),z=q(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await l(s),n(!1)},[s,l]),Y=q(()=>{o(se);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let d=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(w=>d.removeAttribute(w)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",m(null),y(!1)},[]),U=q((d,w)=>{o(h=>({...h,[d]:w}))},[]);D(()=>{let d=w=>{w.key==="Escape"&&i&&n(!1)};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i]),D(()=>{i&&R.current&&k.trapFocus(R.current)},[i]);let J={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:u?"#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 xt(yt,{children:[t,Be("button",{style:J,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":i,"data-yuktai-pref-toggle":"true",onClick:()=>n(d=>!d),onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),i&&Be(le,{ref:R,position:e,settings:s,report:c,isActive:u,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,a){if(!a||typeof a.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,a)}use(t){return this.plugins.get(t)}async run(t,a){try{let i=this.use(t);if(!i)throw new Error(`Plugin not found: ${t}`);return await i.execute(a)}catch(i){throw console.error(`[YuktAI Runtime Error in ${t}]:`,i),i}}getPlugins(){return Array.from(this.plugins.keys())}};function ht(){if(typeof globalThis>"u")return new S;if(!globalThis.__yuktai_runtime__){let e=new S;e.register(k.name,k),e.register(G.name,G),e.register(V.name,V),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var Ne=typeof window<"u"?ht():new S,Jt={wcagPlugin:k,list(){return Ne.getPlugins()},use(e){return Ne.use(e)},fix(e){return k.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return k.scan()}};export{S as Runtime,Jt as YuktAI,ce as YuktAIWrapper,G as aiPlugin,ce as default,V as voicePlugin,k as wcag,k as wcagPlugin};
@@ -1,4 +1,4 @@
1
- "use strict";var YuktAI=(()=>{var T=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var de=(e,t)=>{for(var i in t)T(e,i,{get:t[i],enumerable:!0})},pe=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ce(t))!ue.call(e,n)&&n!==i&&T(e,n,{get:()=>t[n],enumerable:!(r=le(t,n))||r.enumerable});return e};var me=e=>pe(T({},"__esModule",{value:!0}),e);var Oe={};de(Oe,{wcagPlugin:()=>Ie});function O(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function S(){try{let e=O();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}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=O();if(!t)throw new Error("Rewriter API not available");let i=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),r=await i.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return i.destroy(),{success:!0,original:e,rewritten:r.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function q(){if(!await S())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),i=0;for(let r of t){let n=r.innerText?.trim();if(!n||n.length<20||r.closest("[data-yuktai-panel]"))continue;let o=await fe(n);o.success&&o.rewritten!==n&&(r.dataset.yuktaiOriginal=n,r.innerText=o.rewritten,i++)}return{fixed:i}}function B(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let i=t.dataset.yuktaiOriginal;i&&(t.innerText=i,delete t.dataset.yuktaiOriginal)}}var D="yuktai-summary-box";function N(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function L(){try{let e=N();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function be(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let i of e){if(i.closest("[data-yuktai-panel]"))continue;let r=window.getComputedStyle(i);if(r.display==="none"||r.visibility==="hidden")continue;let n=i.innerText?.trim();n&&n.length>10&&t.push(n)}return t.join(" ").slice(0,5e3)}async function F(){if(!await L())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=be();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let i=N();if(!i)throw new Error("Summarizer API not available");let r=await i.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),n=await r.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 r.destroy(),ye(n.trim()),{success:!0,summary:n.trim()}}catch(i){return{success:!1,summary:"",error:i instanceof Error?i.message:"Summary failed"}}}function ye(e){h();let t=document.createElement("div");t.id=D,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 YuktAI=(()=>{var T=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var de=(e,t)=>{for(var a in t)T(e,a,{get:t[a],enumerable:!0})},fe=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ce(t))!ue.call(e,i)&&i!==a&&T(e,i,{get:()=>t[i],enumerable:!(r=le(t,i))||r.enumerable});return e};var pe=e=>fe(T({},"__esModule",{value:!0}),e);var Be={};de(Be,{wcagPlugin:()=>qe});function O(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function S(){try{let e=O();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}async function me(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=O();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),r=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:r.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function q(){if(!await S())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let r of t){let i=r.innerText?.trim();if(!i||i.length<20||r.closest("[data-yuktai-panel]"))continue;let o=await me(i);o.success&&o.rewritten!==i&&(r.dataset.yuktaiOriginal=i,r.innerText=o.rewritten,a++)}return{fixed:a}}function B(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let a=t.dataset.yuktaiOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiOriginal)}}var D="yuktai-summary-box";function N(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function L(){try{let e=N();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function be(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let r=window.getComputedStyle(a);if(r.display==="none"||r.visibility==="hidden")continue;let i=a.innerText?.trim();i&&i.length>10&&t.push(i)}return t.join(" ").slice(0,5e3)}async function F(){if(!await L())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=be();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=N();if(!a)throw new Error("Summarizer API not available");let r=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),i=await r.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 r.destroy(),ye(i.trim()),{success:!0,summary:i.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function ye(e){h();let t=document.createElement("div");t.id=D,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,11 +15,11 @@
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 i=document.createElement("p");i.style.cssText="margin: 0; flex: 1;",i.textContent=`\u{1F4CB} Page summary: ${e}`;let r=document.createElement("button");r.textContent="\xD7",r.setAttribute("aria-label","Close page summary"),r.style.cssText=`
18
+ `;let a=document.createElement("p");a.style.cssText="margin: 0; flex: 1;",a.textContent=`\u{1F4CB} Page summary: ${e}`;let r=document.createElement("button");r.textContent="\xD7",r.setAttribute("aria-label","Close page summary"),r.style.cssText=`
19
19
  background: none; border: none; color: #ffffff;
20
20
  font-size: 20px; cursor: pointer; padding: 0 4px;
21
21
  line-height: 1; flex-shrink: 0;
22
- `,r.addEventListener("click",h),t.appendChild(i),t.appendChild(r),document.body.prepend(t)}function h(){let e=document.getElementById(D);e&&e.remove()}var V=[{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"}],x="en";async function ge(e){try{return window.translation?await window.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function _(e){if(e===x)return{success:!0,language:e,fixed:0};if(e==="en")return M(),x="en",{success:!0,language:"en",fixed:0};if(!await ge(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Chrome 127+ required.`};try{let i=await window.translation.createTranslator({sourceLanguage:"en",targetLanguage:e}),r=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),n=0;for(let o of r){if(o.closest("[data-yuktai-panel]")||o.children.length>0)continue;let a=o.innerText?.trim();if(!a||a.length<2)continue;o.dataset.yuktaiTranslationOriginal||(o.dataset.yuktaiTranslationOriginal=a);let s=await i.translate(a);s&&s!==a&&(o.innerText=s,n++)}return i.destroy(),x=e,{success:!0,language:e,fixed:n}}catch(i){return{success:!1,language:e,fixed:0,error:i instanceof Error?i.message:"Translation failed"}}}function M(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let i=t.dataset.yuktaiTranslationOriginal;i&&(t.innerText=i,delete t.dataset.yuktaiTranslationOriginal)}x="en"}var he=[{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"}],p=null,w=!1,f=null;function C(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function xe(e){let t=e.toLowerCase().trim();for(let i of he)for(let r of i.phrases)if(t.includes(r))return{action:i.action,label:i.label};return null}function we(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=G(),i=t.indexOf(document.activeElement),r=t[i+1]||t[0];r&&r.focus();break}case"tab-back":{let t=G(),i=t.indexOf(document.activeElement),r=t[i-1]||t[t.length-1];r&&r.focus();break}case"stop-voice":{P();break}}}function G(){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 W(e){if(!C())return!1;if(w)return!0;e&&(f=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return p=new t,p.continuous=!0,p.interimResults=!1,p.lang="en-US",p.onresult=i=>{let r=i.results[i.results.length-1][0].transcript,n=xe(r);if(n){we(n.action);let o={success:!0,command:r,action:n.label};if(f&&f(o),n.action==="stop-voice")return}},p.onend=()=>{w&&p?.start()},p.onerror=i=>{i.error!=="no-speech"&&f&&f({success:!1,command:"",action:"",error:`Voice error: ${i.error}`})},p.start(),w=!0,ve(),!0}function P(){w=!1,p&&(p.stop(),p=null),f=null,K()}var j="yuktai-voice-indicator";function ve(){K();let e=document.createElement("div");e.id=j,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
22
+ `,r.addEventListener("click",h),t.appendChild(a),t.appendChild(r),document.body.prepend(t)}function h(){let e=document.getElementById(D);e&&e.remove()}var V=[{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"}],x="en";function ge(){let e=window;return e.Translator||e.translation||null}async function he(e){try{let t=window;if(!ge())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let r=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return r==="readily"||r==="available"||r==="downloadable"||r==="after-download"}catch{}return t.Translator&&typeof t.Translator.canTranslate=="function"?await t.Translator.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":t.translation&&typeof t.translation.canTranslate=="function"?await t.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function xe(e){let t=window,a={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(a);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(a);throw new Error("Translation API not available")}async function _(e){if(e===x)return{success:!0,language:e,fixed:0};if(e==="en")return M(),x="en",{success:!0,language:"en",fixed:0};if(!await he(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let a=await xe(e),r=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),i=0;for(let o of r){if(o.closest("[data-yuktai-panel]")||o.children.length>0)continue;let n=o.innerText?.trim();if(!n||n.length<2)continue;o.dataset.yuktaiTranslationOriginal||(o.dataset.yuktaiTranslationOriginal=n);let s=await a.translate(n);s&&s!==n&&(o.innerText=s,i++)}return typeof a.destroy=="function"&&a.destroy(),x=e,{success:!0,language:e,fixed:i}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function M(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let a=t.dataset.yuktaiTranslationOriginal;a&&(t.innerText=a,delete t.dataset.yuktaiTranslationOriginal)}x="en"}var we=[{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"}],f=null,w=!1,m=null;function C(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function ve(e){let t=e.toLowerCase().trim();for(let a of we)for(let r of a.phrases)if(t.includes(r))return{action:a.action,label:a.label};return null}function ke(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=G(),a=t.indexOf(document.activeElement),r=t[a+1]||t[0];r&&r.focus();break}case"tab-back":{let t=G(),a=t.indexOf(document.activeElement),r=t[a-1]||t[t.length-1];r&&r.focus();break}case"stop-voice":{P();break}}}function G(){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 W(e){if(!C())return!1;if(w)return!0;e&&(m=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return f=new t,f.continuous=!0,f.interimResults=!1,f.lang="en-US",f.onresult=a=>{let r=a.results[a.results.length-1][0].transcript,i=ve(r);if(i){ke(i.action);let o={success:!0,command:r,action:i.label};if(m&&m(o),i.action==="stop-voice")return}},f.onend=()=>{w&&f?.start()},f.onerror=a=>{a.error!=="no-speech"&&m&&m({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},f.start(),w=!0,Ae(),!0}function P(){w=!1,f&&(f.stop(),f=null),m=null,K()}var j="yuktai-voice-indicator";function Ae(){K();let e=document.createElement("div");e.id=j,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
23
23
  position: fixed;
24
24
  bottom: 80px;
25
25
  left: 50%;
@@ -49,7 +49,7 @@
49
49
  0%, 100% { opacity: 1; transform: scale(1); }
50
50
  50% { opacity: 0.4; transform: scale(0.7); }
51
51
  }
52
- `,document.head.appendChild(r)}let i=document.createElement("span");i.textContent="Listening for commands...",e.appendChild(t),e.appendChild(i),document.body.appendChild(e)}function K(){let e=document.getElementById(j);e&&e.remove()}var ke=["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(", ");function U(){let e=window;return e.Writer||e.ai?.writer||null}async function $(){try{let e=U();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function Ae(e){let t=[],i=e.innerText?.trim();i&&t.push(`element text: "${i}"`);let r=e.placeholder?.trim();r&&t.push(`placeholder: "${r}"`);let n=e.getAttribute("name")?.trim();n&&t.push(`name: "${n}"`);let o=e.getAttribute("type")?.trim();o&&t.push(`type: "${o}"`);let a=e.id;if(a){let c=document.querySelector(`label[for="${a}"]`);c&&t.push(`label: "${c.innerText?.trim()}"`)}let s=e.parentElement?.innerText?.trim().slice(0,60);s&&t.push(`parent context: "${s}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let d=e.getAttribute("role");return d&&t.push(`role: ${d}`),t.join(". ")}async function Ee(e,t){let i=`
52
+ `,document.head.appendChild(r)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function K(){let e=document.getElementById(j);e&&e.remove()}var Ee=["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(", ");function U(){let e=window;return e.Writer||e.ai?.writer||null}async function $(){try{let e=U();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function Te(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let r=e.placeholder?.trim();r&&t.push(`placeholder: "${r}"`);let i=e.getAttribute("name")?.trim();i&&t.push(`name: "${i}"`);let o=e.getAttribute("type")?.trim();o&&t.push(`type: "${o}"`);let n=e.id;if(n){let c=document.querySelector(`label[for="${n}"]`);c&&t.push(`label: "${c.innerText?.trim()}"`)}let s=e.parentElement?.innerText?.trim().slice(0,60);s&&t.push(`parent context: "${s}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let d=e.getAttribute("role");return d&&t.push(`role: ${d}`),t.join(". ")}async function Se(e,t){let a=`
53
53
  Generate a short, clear aria-label for an HTML element.
54
54
  The label must be 2-6 words maximum.
55
55
  The label must describe what the element does or what it is.
@@ -60,7 +60,7 @@
60
60
  ${t}
61
61
 
62
62
  Output only the label. Nothing else.
63
- `.trim();return(await e.write(i)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Y(){if(!await $())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(ke);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let i=U();if(!i)throw new Error("Writer API not available");let r=await i.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),n=0,o=[];for(let a of t){if(a.closest("[data-yuktai-panel]"))continue;let s=window.getComputedStyle(a);if(s.display==="none"||s.visibility==="hidden")continue;let d=Ae(a),c=await Ee(r,d);c&&c.length>0&&(a.dataset.yuktaiLabelOriginal=a.getAttribute("aria-label")||"",a.setAttribute("aria-label",c),n++,o.push({tag:a.tagName.toLowerCase(),label:c}))}return r.destroy(),{success:!0,fixed:n,elements:o}}catch(i){return{success:!1,fixed:0,elements:[],error:i instanceof Error?i.message:"Label generation failed"}}}function J(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let i=t.dataset.yuktaiLabelOriginal;i?t.setAttribute("aria-label",i):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var A=null,X=null;var Q=null,H=null,u=null,b=null,v=null,R=null,y=null,k={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Z=new Set(["input","select","textarea"]);var z={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function I(e,t="polite"){if(typeof window>"u"||!y?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let i=new SpeechSynthesisUtterance(e);i.rate=1,i.pitch=1,i.volume=1;let r=window.speechSynthesis.getVoices();r.length>0&&(i.voice=r[0]),window.speechSynthesis.speak(i)}function oe(e,t="info"){if(typeof document>"u")return;let r={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];u||(u=document.createElement("div"),u.setAttribute("role","alert"),u.setAttribute("aria-live","assertive"),u.setAttribute("aria-atomic","true"),u.style.cssText=`
63
+ `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Y(){if(!await $())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(Ee);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=U();if(!a)throw new Error("Writer API not available");let r=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),i=0,o=[];for(let n of t){if(n.closest("[data-yuktai-panel]"))continue;let s=window.getComputedStyle(n);if(s.display==="none"||s.visibility==="hidden")continue;let d=Te(n),c=await Se(r,d);c&&c.length>0&&(n.dataset.yuktaiLabelOriginal=n.getAttribute("aria-label")||"",n.setAttribute("aria-label",c),i++,o.push({tag:n.tagName.toLowerCase(),label:c}))}return r.destroy(),{success:!0,fixed:i,elements:o}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function J(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let a=t.dataset.yuktaiLabelOriginal;a?t.setAttribute("aria-label",a):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var A=null,X=null;var Q=null,H=null,u=null,b=null,v=null,R=null,y=null,k={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Z=new Set(["input","select","textarea"]);var z={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function I(e,t="polite"){if(typeof window>"u"||!y?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let r=window.speechSynthesis.getVoices();r.length>0&&(a.voice=r[0]),window.speechSynthesis.speak(a)}function oe(e,t="info"){if(typeof document>"u")return;let r={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];u||(u=document.createElement("div"),u.setAttribute("role","alert"),u.setAttribute("aria-live","assertive"),u.setAttribute("aria-atomic","true"),u.style.cssText=`
64
64
  position: fixed;
65
65
  top: 80px;
66
66
  right: 16px;
@@ -86,7 +86,7 @@
86
86
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
87
87
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
88
88
  aria-label="Close notification">\xD7</button>
89
- `,window.innerWidth<=480&&(u.style.right="8px",u.style.left="8px",u.style.maxWidth="none",u.style.width="auto"),requestAnimationFrame(()=>{u&&(u.style.transform="translateX(0)",u.style.opacity="1")}),setTimeout(()=>{u&&(u.style.transform="translateX(120%)",u.style.opacity="0")},5e3)}function l(e,t="info",i=!0){A&&(A.textContent=e),oe(e,t),i&&I(e,t==="error"?"assertive":"polite")}function Te(){if(typeof document>"u"||Q)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=`
89
+ `,window.innerWidth<=480&&(u.style.right="8px",u.style.left="8px",u.style.maxWidth="none",u.style.width="auto"),requestAnimationFrame(()=>{u&&(u.style.transform="translateX(0)",u.style.opacity="1")}),setTimeout(()=>{u&&(u.style.transform="translateX(120%)",u.style.opacity="0")},5e3)}function l(e,t="info",a=!0){A&&(A.textContent=e),oe(e,t),a&&I(e,t==="error"?"assertive":"polite")}function Le(){if(typeof document>"u"||Q)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=`
90
90
  position: fixed;
91
91
  top: 0;
92
92
  left: 0;
@@ -100,7 +100,7 @@
100
100
  transform: translateY(-100%);
101
101
  transition: transform 0.2s ease;
102
102
  font-family: system-ui, sans-serif;
103
- `;let i=!1;if(e.forEach(({label:n,selector:o})=>{let a=document.querySelector(o);if(!a)return;i=!0,a.getAttribute("tabindex")||a.setAttribute("tabindex","-1");let s=document.createElement("a");s.href="#",s.textContent=n,s.style.cssText=`
103
+ `;let a=!1;if(e.forEach(({label:i,selector:o})=>{let n=document.querySelector(o);if(!n)return;a=!0,n.getAttribute("tabindex")||n.setAttribute("tabindex","-1");let s=document.createElement("a");s.href="#",s.textContent=i,s.style.cssText=`
104
104
  color: #fff;
105
105
  background: #1a73e8;
106
106
  padding: 8px 14px;
@@ -111,7 +111,7 @@
111
111
  white-space: nowrap;
112
112
  border: 2px solid transparent;
113
113
  transition: background 0.15s, border-color 0.15s;
114
- `,s.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),s.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),s.addEventListener("click",d=>{d.preventDefault(),a.focus(),a.scrollIntoView({behavior:"smooth",block:"start"}),l(`Jumped to ${n.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(s)}),!i)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),Q=t}function Se(){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=`
114
+ `,s.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),s.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),s.addEventListener("click",d=>{d.preventDefault(),n.focus(),n.scrollIntoView({behavior:"smooth",block:"start"}),l(`Jumped to ${i.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(s)}),!a)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),Q=t}function Me(){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=`
115
115
 
116
116
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
117
117
  [data-yuktai-a11y] *:focus-visible {
@@ -257,7 +257,7 @@
257
257
  width: auto !important;
258
258
  }
259
259
  }
260
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function Le(){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 i=t.getAttribute("role")||"";if(e.key==="Escape"){let r=t.closest("[role='dialog'],[role='alertdialog']");if(r){r.style.display="none",l("Dialog closed","info");return}let n=t.closest("[role='menu'],[role='menubar']");n&&(n.style.display="none",l("Menu closed","info"))}if(i==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let r=t.closest("[role='menu'],[role='menubar']");if(!r)return;let n=Array.from(r.querySelectorAll("[role='menuitem']:not([disabled])")),o=n.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),n[(o+1)%n.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),n[(o-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(i==="tab"||t.closest("[role='tablist']")){let r=t.closest("[role='tablist']");if(!r)return;let n=Array.from(r.querySelectorAll("[role='tab']:not([disabled])")),o=n.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let a=n[(o+1)%n.length];a?.focus(),a?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let a=n[(o-1+n.length)%n.length];a?.focus(),a?.click()}}if(i==="option"||t.closest("[role='listbox']")){let r=t.closest("[role='listbox']");if(!r)return;let n=Array.from(r.querySelectorAll("[role='option']:not([aria-disabled='true'])")),o=n.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),n[(o+1)%n.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),n[(o-1+n.length)%n.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),n.forEach(a=>{a!==t&&a.setAttribute("aria-selected","false")}),l(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Me()),e.key==="Tab"&&y?.speechEnabled&&setTimeout(()=>{let r=document.activeElement;if(!r)return;let n=r.getAttribute("aria-label")||r.getAttribute("title")||r.textContent?.trim()||r.tagName.toLowerCase(),o=r.getAttribute("role")||r.tagName.toLowerCase();I(`${n}, ${o}`)},100)}))}function E(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 i=t[0],r=t[t.length-1];i.focus(),e.addEventListener("keydown",n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===i&&(n.preventDefault(),r.focus()):document.activeElement===r&&(n.preventDefault(),i.focus()))})}function Me(){if(typeof document>"u")return;if(b){b.remove(),b=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=`
260
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function Ce(){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 a=t.getAttribute("role")||"";if(e.key==="Escape"){let r=t.closest("[role='dialog'],[role='alertdialog']");if(r){r.style.display="none",l("Dialog closed","info");return}let i=t.closest("[role='menu'],[role='menubar']");i&&(i.style.display="none",l("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let r=t.closest("[role='menu'],[role='menubar']");if(!r)return;let i=Array.from(r.querySelectorAll("[role='menuitem']:not([disabled])")),o=i.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),i[(o+1)%i.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),i[(o-1+i.length)%i.length]?.focus()):e.key==="Home"?(e.preventDefault(),i[0]?.focus()):e.key==="End"&&(e.preventDefault(),i[i.length-1]?.focus())}if(a==="tab"||t.closest("[role='tablist']")){let r=t.closest("[role='tablist']");if(!r)return;let i=Array.from(r.querySelectorAll("[role='tab']:not([disabled])")),o=i.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let n=i[(o+1)%i.length];n?.focus(),n?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let n=i[(o-1+i.length)%i.length];n?.focus(),n?.click()}}if(a==="option"||t.closest("[role='listbox']")){let r=t.closest("[role='listbox']");if(!r)return;let i=Array.from(r.querySelectorAll("[role='option']:not([aria-disabled='true'])")),o=i.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),i[(o+1)%i.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),i[(o-1+i.length)%i.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),i.forEach(n=>{n!==t&&n.setAttribute("aria-selected","false")}),l(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Pe()),e.key==="Tab"&&y?.speechEnabled&&setTimeout(()=>{let r=document.activeElement;if(!r)return;let i=r.getAttribute("aria-label")||r.getAttribute("title")||r.textContent?.trim()||r.tagName.toLowerCase(),o=r.getAttribute("role")||r.tagName.toLowerCase();I(`${i}, ${o}`)},100)}))}function E(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 a=t[0],r=t[t.length-1];a.focus(),e.addEventListener("keydown",i=>{i.key==="Tab"&&(i.shiftKey?document.activeElement===a&&(i.preventDefault(),r.focus()):document.activeElement===r&&(i.preventDefault(),a.focus()))})}function Pe(){if(typeof document>"u")return;if(b){b.remove(),b=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=`
261
261
  position: fixed;
262
262
  top: 50%;
263
263
  left: 50%;
@@ -281,18 +281,18 @@
281
281
  style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1"
282
282
  aria-label="Close shortcuts">\xD7</button>
283
283
  </div>
284
- ${t.map(([r,n])=>`
284
+ ${t.map(([r,i])=>`
285
285
  <div style="display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid #2a2a4a">
286
286
  <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${r}</kbd>
287
- <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${n}</span>
287
+ <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${i}</span>
288
288
  </div>
289
289
  `).join("")}
290
- `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),b=null}),e.addEventListener("keydown",r=>{r.key==="Escape"&&(e.remove(),b=null)}),document.body.appendChild(e),b=e,E(e),l("Keyboard shortcuts opened. Press Escape to close.","info")}function Ce(e){if(typeof document>"u"||!y?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;H&&H.remove();let t=e.score,i=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",r=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=`
290
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),b=null}),e.addEventListener("keydown",r=>{r.key==="Escape"&&(e.remove(),b=null)}),document.body.appendChild(e),b=e,E(e),l("Keyboard shortcuts opened. Press Escape to close.","info")}function $e(e){if(typeof document>"u"||!y?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;H&&H.remove();let t=e.score,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",r=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",i=document.createElement("button");i.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),i.setAttribute("data-yuktai-badge","true"),i.style.cssText=`
291
291
  position: fixed;
292
292
  bottom: 16px;
293
293
  left: 16px;
294
294
  z-index: 999998;
295
- background: ${i};
295
+ background: ${a};
296
296
  color: #fff;
297
297
  border: none;
298
298
  border-radius: 20px;
@@ -306,7 +306,7 @@
306
306
  align-items: center;
307
307
  gap: 6px;
308
308
  transition: transform 0.15s;
309
- `,n.innerHTML=`${r} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,n.addEventListener("click",()=>Pe(e)),document.body.appendChild(n),H=n}function Pe(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let i=document.createElement("div");i.setAttribute("data-yuktai-audit-details","true"),i.setAttribute("role","dialog"),i.setAttribute("aria-label","Accessibility audit details"),i.style.cssText=`
309
+ `,i.innerHTML=`${r} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,i.addEventListener("click",()=>He(e)),document.body.appendChild(i),H=i}function He(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let a=document.createElement("div");a.setAttribute("data-yuktai-audit-details","true"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","Accessibility audit details"),a.style.cssText=`
310
310
  position: fixed;
311
311
  bottom: 56px;
312
312
  left: 16px;
@@ -323,22 +323,22 @@
323
323
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
324
324
  font-family: system-ui, sans-serif;
325
325
  font-size: 12px;
326
- `;let r={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};i.innerHTML=`
326
+ `;let r={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};a.innerHTML=`
327
327
  <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
328
328
  <strong style="font-size:14px;color:#74c0fc">Audit report</strong>
329
329
  <span style="color:#aaa">${e.fixed} fixed \xB7 ${e.renderTime}ms</span>
330
330
  </div>
331
- ${e.details.slice(0,20).map(n=>`
331
+ ${e.details.slice(0,20).map(i=>`
332
332
  <div style="padding:6px 0;border-bottom:1px solid #2a2a4a">
333
333
  <div style="display:flex;gap:6px;align-items:center">
334
- <span style="background:${r[n.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${n.severity}</span>
335
- <code style="color:#74c0fc">&lt;${n.tag}&gt;</code>
334
+ <span style="background:${r[i.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${i.severity}</span>
335
+ <code style="color:#74c0fc">&lt;${i.tag}&gt;</code>
336
336
  </div>
337
- <div style="color:#ccc;margin-top:3px">${n.fix}</div>
337
+ <div style="color:#ccc;margin-top:3px">${i.fix}</div>
338
338
  </div>
339
339
  `).join("")}
340
340
  ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
341
- `,i.addEventListener("keydown",n=>{n.key==="Escape"&&i.remove()}),document.body.appendChild(i),E(i)}function se(e){typeof document>"u"||(R&&clearTimeout(R),R=setTimeout(()=>{if(v)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=`
341
+ `,a.addEventListener("keydown",i=>{i.key==="Escape"&&a.remove()}),document.body.appendChild(a),E(a)}function se(e){typeof document>"u"||(R&&clearTimeout(R),R=setTimeout(()=>{if(v)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=`
342
342
  position: fixed;
343
343
  top: 50%;
344
344
  left: 50%;
@@ -367,7 +367,7 @@
367
367
  No, sign out
368
368
  </button>
369
369
  </div>
370
- `;let i=t.querySelector("[data-yuktai-extend]"),r=t.querySelector("[data-yuktai-dismiss]");i?.addEventListener("click",()=>{t.remove(),v=null,l("Session extended. You have more time.","success"),y?.timeoutWarning&&se(y.timeoutWarning)}),r?.addEventListener("click",()=>{t.remove(),v=null}),document.body.appendChild(t),v=t,E(t),l("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function $e(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 i=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${k[e.colorBlindMode]})`;document.body.style.filter=i}else document.body.style.filter=""}function He(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 S()){l("Plain English requires Chrome 127+","warning");return}l("Rewriting page in plain English...","info",!1);let i=await q();l(i.error?`Plain English failed: ${i.error}`:`${i.fixed} sections rewritten in plain English`,i.error?"error":"success",!1)}else B(),l("Original text restored","info",!1)}async function te(e){if(e){if(!await L()){l("Page summariser requires Chrome 127+","warning");return}l("Generating page summary...","info",!1);let i=await F();l(i.error?`Summary failed: ${i.error}`:"Page summary added at top",i.error?"error":"success",!1)}else h(),l("Page summary removed","info",!1)}async function ie(e){if(e==="en"){M(),l("Page restored to English","info",!1);return}l(`Translating page to ${e}...`,"info",!1);let t=await _(e);l(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function ae(e){if(e){if(!C()){l("Voice control not supported in this browser","warning");return}W(t=>{t.success&&l(`Voice: ${t.action}`,"info",!1)}),l("Voice control started. Say a command.","success",!1)}else P(),l("Voice control stopped","info",!1)}async function ne(e){if(e){if(!await $()){l("Smart labels requires Chrome 127+","warning");return}l("Generating smart labels...","info",!1);let i=await Y();l(i.error?`Smart labels failed: ${i.error}`:`${i.fixed} elements labelled`,i.error?"error":"success",!1)}else J(),l("Smart labels removed","info",!1)}function Re(){if(typeof document>"u"||A)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),A=e}function ze(){if(typeof document>"u"||X)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=`
370
+ `;let a=t.querySelector("[data-yuktai-extend]"),r=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),v=null,l("Session extended. You have more time.","success"),y?.timeoutWarning&&se(y.timeoutWarning)}),r?.addEventListener("click",()=>{t.remove(),v=null}),document.body.appendChild(t),v=t,E(t),l("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function Re(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 a=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${k[e.colorBlindMode]})`;document.body.style.filter=a}else document.body.style.filter=""}function ze(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 S()){l("Plain English requires Chrome 127+","warning");return}l("Rewriting page in plain English...","info",!1);let a=await q();l(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else B(),l("Original text restored","info",!1)}async function te(e){if(e){if(!await L()){l("Page summariser requires Chrome 127+","warning");return}l("Generating page summary...","info",!1);let a=await F();l(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else h(),l("Page summary removed","info",!1)}async function ae(e){if(e==="en"){M(),l("Page restored to English","info",!1);return}l(`Translating page to ${e}...`,"info",!1);let t=await _(e);l(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function ne(e){if(e){if(!C()){l("Voice control not supported in this browser","warning");return}W(t=>{t.success&&l(`Voice: ${t.action}`,"info",!1)}),l("Voice control started. Say a command.","success",!1)}else P(),l("Voice control stopped","info",!1)}async function ie(e){if(e){if(!await $()){l("Smart labels requires Chrome 127+","warning");return}l("Generating smart labels...","info",!1);let a=await Y();l(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else J(),l("Smart labels removed","info",!1)}function Ie(){if(typeof document>"u"||A)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),A=e}function Oe(){if(typeof document>"u"||X)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=`
371
371
  <defs>
372
372
  <filter id="${k.deuteranopia}">
373
373
  <feColorMatrix type="matrix"
@@ -382,4 +382,4 @@
382
382
  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"/>
383
383
  </filter>
384
384
  </defs>
385
- `,document.body.appendChild(e),X=e}function re(e){let t={critical:20,serious:10,moderate:5,minor:2},i=e.details.reduce((r,n)=>r+(t[n.severity]||0),0);return Math.max(0,Math.min(100,100-i))}var Ie={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";y=e,He(e),Re(),ze(),Se(),Le(),e.showSkipLinks!==!1&&Te(),e.showPreferencePanel,$e(e);let t=this.applyFixes(e);t.score=re(t),e.showAuditBadge&&Ce(t),e.timeoutWarning&&se(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await ee(!0),e.summarisePage&&await te(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await ie(e.translateLanguage),e.voiceControl&&await ae(!0),e.smartLabels&&await ne(!0);let i=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return l(i,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${i} 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 i=performance.now(),r=document.querySelectorAll("*");t.scanned=r.length;let n=(o,a,s,d)=>{t.details.push({tag:o,fix:a,severity:s,element:d.outerHTML.slice(0,100)}),t.fixed++};return r.forEach(o=>{let a=o,s=a.tagName.toLowerCase();if(s==="html"&&!a.getAttribute("lang")&&(a.setAttribute("lang","en"),n(s,'lang="en" added',"critical",a)),s==="meta"){let c=a.getAttribute("name"),m=a.getAttribute("content")||"";c==="viewport"&&m.includes("user-scalable=no")&&(a.setAttribute("content",m.replace("user-scalable=no","user-scalable=yes")),n(s,"user-scalable=yes restored","serious",a)),c==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(m)&&(a.setAttribute("content",m.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),n(s,"maximum-scale=5 restored","serious",a))}if(s==="main"&&!a.getAttribute("tabindex")&&(a.setAttribute("tabindex","-1"),a.getAttribute("id")||a.setAttribute("id","main-content")),s==="img"&&(a.hasAttribute("alt")||(a.setAttribute("alt",""),a.setAttribute("aria-hidden","true"),n(s,'alt="" aria-hidden="true"',"serious",a))),s==="svg"&&(!a.getAttribute("aria-hidden")&&!a.getAttribute("aria-label")&&!o.querySelector("title")&&(a.setAttribute("aria-hidden","true"),n(s,'aria-hidden="true" (decorative svg)',"minor",a)),a.getAttribute("focusable")||a.setAttribute("focusable","false")),s==="iframe"&&!a.getAttribute("title")&&!a.getAttribute("aria-label")&&(a.setAttribute("title","embedded content"),a.setAttribute("aria-label","embedded content"),n(s,"title + aria-label added","serious",a)),s==="button"){if(!a.innerText?.trim()&&!a.getAttribute("aria-label")){let c=a.getAttribute("title")||"button";a.setAttribute("aria-label",c),n(s,`aria-label="${c}" (empty button)`,"critical",a)}a.hasAttribute("disabled")&&!a.getAttribute("aria-disabled")&&(a.setAttribute("aria-disabled","true"),t.fixed++)}if(s==="a"){let c=a;!a.innerText?.trim()&&!a.getAttribute("aria-label")&&(a.setAttribute("aria-label",a.getAttribute("title")||"link"),n(s,"aria-label added (empty link)","critical",a)),c.target==="_blank"&&!c.rel?.includes("noopener")&&(c.rel="noopener noreferrer",t.fixed++)}if(Z.has(s)){let c=a;if(!a.getAttribute("aria-label")&&!a.getAttribute("aria-labelledby")){let m=a.getAttribute("placeholder")||a.getAttribute("name")||s;a.setAttribute("aria-label",m),n(s,`aria-label="${m}"`,"serious",a)}if(a.hasAttribute("required")&&!a.getAttribute("aria-required")&&(a.setAttribute("aria-required","true"),t.fixed++),s==="input"&&!c.autocomplete){let m=c.name||"";c.type==="email"||m.includes("email")?c.autocomplete="email":c.type==="tel"||m.includes("tel")?c.autocomplete="tel":c.type==="password"&&(c.autocomplete="current-password"),t.fixed++}}s==="th"&&!a.getAttribute("scope")&&(a.setAttribute("scope",a.closest("thead")?"col":"row"),n(s,"scope added to <th>","moderate",a)),z[s]&&!a.getAttribute("role")&&(a.setAttribute("role",z[s]),n(s,`role="${z[s]}"`,"minor",a));let d=a.getAttribute("role")||"";d==="tab"&&!a.getAttribute("aria-selected")&&(a.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(d)&&!a.getAttribute("aria-live")&&(a.setAttribute("aria-live",d==="alert"?"assertive":"polite"),n(s,`aria-live added on role=${d}`,"moderate",a)),d==="combobox"&&!a.getAttribute("aria-expanded")&&(a.setAttribute("aria-expanded","false"),n(s,'aria-expanded="false" on combobox',"serious",a)),(d==="checkbox"||d==="radio")&&!a.getAttribute("aria-checked")&&(a.setAttribute("aria-checked","false"),n(s,`aria-checked="false" on role=${d}`,"serious",a))}),t.renderTime=parseFloat((performance.now()-i).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(),i=document.querySelectorAll("*");e.scanned=i.length;let r=(n,o,a,s)=>e.details.push({tag:n,fix:o,severity:a,element:s.outerHTML.slice(0,100)});return i.forEach(n=>{let o=n,a=o.tagName.toLowerCase();(a==="a"||a==="button")&&!o.innerText?.trim()&&!o.getAttribute("aria-label")&&r(a,"needs aria-label (empty)","critical",o),a==="img"&&!o.hasAttribute("alt")&&r(a,"needs alt text","serious",o),Z.has(a)&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")&&r(a,"needs aria-label","serious",o),a==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&r(a,"iframe needs title","serious",o)}),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:l,speak:I,showVisualAlert:oe,trapFocus:E,handlePlainEnglish:ee,handleSummarisePage:te,handleTranslate:ie,handleVoiceControl:ae,handleSmartLabels:ne,SUPPORTED_LANGUAGES:V};return me(Oe);})();
385
+ `,document.body.appendChild(e),X=e}function re(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((r,i)=>r+(t[i.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var qe={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";y=e,ze(e),Ie(),Oe(),Me(),Ce(),e.showSkipLinks!==!1&&Le(),e.showPreferencePanel,Re(e);let t=this.applyFixes(e);t.score=re(t),e.showAuditBadge&&$e(t),e.timeoutWarning&&se(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await ee(!0),e.summarisePage&&await te(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await ae(e.translateLanguage),e.voiceControl&&await ne(!0),e.smartLabels&&await ie(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return l(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} 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 a=performance.now(),r=document.querySelectorAll("*");t.scanned=r.length;let i=(o,n,s,d)=>{t.details.push({tag:o,fix:n,severity:s,element:d.outerHTML.slice(0,100)}),t.fixed++};return r.forEach(o=>{let n=o,s=n.tagName.toLowerCase();if(s==="html"&&!n.getAttribute("lang")&&(n.setAttribute("lang","en"),i(s,'lang="en" added',"critical",n)),s==="meta"){let c=n.getAttribute("name"),p=n.getAttribute("content")||"";c==="viewport"&&p.includes("user-scalable=no")&&(n.setAttribute("content",p.replace("user-scalable=no","user-scalable=yes")),i(s,"user-scalable=yes restored","serious",n)),c==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(p)&&(n.setAttribute("content",p.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),i(s,"maximum-scale=5 restored","serious",n))}if(s==="main"&&!n.getAttribute("tabindex")&&(n.setAttribute("tabindex","-1"),n.getAttribute("id")||n.setAttribute("id","main-content")),s==="img"&&(n.hasAttribute("alt")||(n.setAttribute("alt",""),n.setAttribute("aria-hidden","true"),i(s,'alt="" aria-hidden="true"',"serious",n))),s==="svg"&&(!n.getAttribute("aria-hidden")&&!n.getAttribute("aria-label")&&!o.querySelector("title")&&(n.setAttribute("aria-hidden","true"),i(s,'aria-hidden="true" (decorative svg)',"minor",n)),n.getAttribute("focusable")||n.setAttribute("focusable","false")),s==="iframe"&&!n.getAttribute("title")&&!n.getAttribute("aria-label")&&(n.setAttribute("title","embedded content"),n.setAttribute("aria-label","embedded content"),i(s,"title + aria-label added","serious",n)),s==="button"){if(!n.innerText?.trim()&&!n.getAttribute("aria-label")){let c=n.getAttribute("title")||"button";n.setAttribute("aria-label",c),i(s,`aria-label="${c}" (empty button)`,"critical",n)}n.hasAttribute("disabled")&&!n.getAttribute("aria-disabled")&&(n.setAttribute("aria-disabled","true"),t.fixed++)}if(s==="a"){let c=n;!n.innerText?.trim()&&!n.getAttribute("aria-label")&&(n.setAttribute("aria-label",n.getAttribute("title")||"link"),i(s,"aria-label added (empty link)","critical",n)),c.target==="_blank"&&!c.rel?.includes("noopener")&&(c.rel="noopener noreferrer",t.fixed++)}if(Z.has(s)){let c=n;if(!n.getAttribute("aria-label")&&!n.getAttribute("aria-labelledby")){let p=n.getAttribute("placeholder")||n.getAttribute("name")||s;n.setAttribute("aria-label",p),i(s,`aria-label="${p}"`,"serious",n)}if(n.hasAttribute("required")&&!n.getAttribute("aria-required")&&(n.setAttribute("aria-required","true"),t.fixed++),s==="input"&&!c.autocomplete){let p=c.name||"";c.type==="email"||p.includes("email")?c.autocomplete="email":c.type==="tel"||p.includes("tel")?c.autocomplete="tel":c.type==="password"&&(c.autocomplete="current-password"),t.fixed++}}s==="th"&&!n.getAttribute("scope")&&(n.setAttribute("scope",n.closest("thead")?"col":"row"),i(s,"scope added to <th>","moderate",n)),z[s]&&!n.getAttribute("role")&&(n.setAttribute("role",z[s]),i(s,`role="${z[s]}"`,"minor",n));let d=n.getAttribute("role")||"";d==="tab"&&!n.getAttribute("aria-selected")&&(n.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(d)&&!n.getAttribute("aria-live")&&(n.setAttribute("aria-live",d==="alert"?"assertive":"polite"),i(s,`aria-live added on role=${d}`,"moderate",n)),d==="combobox"&&!n.getAttribute("aria-expanded")&&(n.setAttribute("aria-expanded","false"),i(s,'aria-expanded="false" on combobox',"serious",n)),(d==="checkbox"||d==="radio")&&!n.getAttribute("aria-checked")&&(n.setAttribute("aria-checked","false"),i(s,`aria-checked="false" on role=${d}`,"serious",n))}),t.renderTime=parseFloat((performance.now()-a).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(),a=document.querySelectorAll("*");e.scanned=a.length;let r=(i,o,n,s)=>e.details.push({tag:i,fix:o,severity:n,element:s.outerHTML.slice(0,100)});return a.forEach(i=>{let o=i,n=o.tagName.toLowerCase();(n==="a"||n==="button")&&!o.innerText?.trim()&&!o.getAttribute("aria-label")&&r(n,"needs aria-label (empty)","critical",o),n==="img"&&!o.hasAttribute("alt")&&r(n,"needs alt text","serious",o),Z.has(n)&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")&&r(n,"needs aria-label","serious",o),n==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&r(n,"iframe needs title","serious",o)}),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:l,speak:I,showVisualAlert:oe,trapFocus:E,handlePlainEnglish:ee,handleSummarisePage:te,handleTranslate:ae,handleVoiceControl:ne,handleSmartLabels:ie,SUPPORTED_LANGUAGES:V};return pe(Be);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuktishaalaa/yuktai",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
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",