@yuktishaalaa/yuktai 2.0.21 → 2.0.22

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