@yuktishaalaa/yuktai 3.0.2 → 3.0.4

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.
@@ -0,0 +1,6 @@
1
+ function i(){return new Promise(t=>{let n=setTimeout(t,1500),e=new MutationObserver(()=>{clearTimeout(n),n=setTimeout(()=>{e.disconnect(),t()},500)});e.observe(document.body,{childList:!0,subtree:!0})})}function c(){let t=[],n=document.querySelectorAll("*");for(let e of n){if(e.closest("[data-yuktai-panel]"))continue;let s=e.innerText?.trim();s&&s.length>30&&t.push(s);let r=e.getAttribute("aria-label");if(r&&r.length>10&&t.push(r),(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(e.placeholder&&t.push(e.placeholder),e.value&&t.push(e.value)),e instanceof HTMLButtonElement){let a=e.innerText||e.getAttribute("aria-label");a&&t.push(a)}}return t.join(" ").slice(0,3500)}async function u(t){if(!t.trim())return{success:!1,answer:"",error:"Please type a question."};try{let n=window,e=n.LanguageModel||n.ai?.languageModel;if(!e)return{success:!1,answer:"",error:"Gemini Nano not available."};await i();let s=c();if(!s||s.length<100)return{success:!1,answer:"",error:"Page content not readable."};let r;try{r=await e.create({systemPrompt:`Answer ONLY using page content.
2
+ Keep answer short (2\u20133 sentences).
3
+ If not found say: "I could not find that on this page."`,outputLanguage:"en"})}catch{r=await e.create()}let a=`Page:
4
+ ${s}
5
+
6
+ Q: ${t}`,o=await r.prompt(a);return r?.destroy&&r.destroy(),{success:!0,answer:o?.trim()||"No answer found."}}catch(n){return{success:!1,answer:"",error:n instanceof Error?n.message:"Error occurred"}}}export{u as a};
package/dist/index.d.mts CHANGED
@@ -96,8 +96,9 @@ interface YuktAIWrapperProps {
96
96
  position?: "left" | "right";
97
97
  children: ReactNode;
98
98
  config?: Partial<A11yConfig>;
99
+ showRag?: boolean;
99
100
  }
100
- declare function YuktAIWrapper({ position, children, config: configOverrides, }: YuktAIWrapperProps): react_jsx_runtime.JSX.Element;
101
+ declare function YuktAIWrapper({ position, children, config: configOverrides, showRag, }: YuktAIWrapperProps): react_jsx_runtime.JSX.Element;
101
102
 
102
103
  declare const aiPlugin: {
103
104
  name: string;
package/dist/index.d.ts CHANGED
@@ -96,8 +96,9 @@ interface YuktAIWrapperProps {
96
96
  position?: "left" | "right";
97
97
  children: ReactNode;
98
98
  config?: Partial<A11yConfig>;
99
+ showRag?: boolean;
99
100
  }
100
- declare function YuktAIWrapper({ position, children, config: configOverrides, }: YuktAIWrapperProps): react_jsx_runtime.JSX.Element;
101
+ declare function YuktAIWrapper({ position, children, config: configOverrides, showRag, }: YuktAIWrapperProps): react_jsx_runtime.JSX.Element;
101
102
 
102
103
  declare const aiPlugin: {
103
104
  name: string;
package/dist/index.js CHANGED
@@ -1,4 +1,9 @@
1
- "use strict";var De=Object.create;var _=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var a in t)_(e,a,{get:t[a],enumerable:!0})},pe=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ge(t))!je.call(e,n)&&n!==a&&_(e,n,{get:()=>t[n],enumerable:!(i=qe(t,n))||i.enumerable});return e};var Ye=(e,t,a)=>(a=e!=null?De(Ve(e)):{},pe(t||!e||!e.__esModule?_(a,"default",{value:e,enumerable:!0}):a,e)),Ue=e=>pe(_({},"__esModule",{value:!0}),e);var Lt={};Ke(Lt,{Runtime:()=>E,YuktAI:()=>Ct,YuktAIWrapper:()=>J,aiPlugin:()=>$,default:()=>J,voicePlugin:()=>F,wcag:()=>w,wcagPlugin:()=>w});module.exports=Ue(Lt);function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function ee(){try{let e=fe();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 Je(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=fe();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),i=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:i.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function me(){if(!await ee())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let i of t){let n=i.innerText?.trim();if(!n||n.length<20||i.closest("[data-yuktai-panel]"))continue;let l=await Je(n);l.success&&l.rewritten!==n&&(i.dataset.yuktaiOriginal=n,i.innerText=l.rewritten,a++)}return{fixed:a}}function be(){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 ge="yuktai-summary-box";function ye(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function te(){try{let e=ye();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 Xe(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(a);if(i.display==="none"||i.visibility==="hidden")continue;let n=a.innerText?.trim();n&&n.length>10&&t.push(n)}return t.join(" ").slice(0,5e3)}async function xe(){if(!await te())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=Xe();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=ye();if(!a)throw new Error("Summarizer API not available");let i=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),n=await i.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return i.destroy(),Qe(n.trim()),{success:!0,summary:n.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function Qe(e){D();let t=document.createElement("div");t.id=ge,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
1
+ "use strict";var dt=Object.create;var X=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var gt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ce=(e,t)=>{for(var a in t)X(e,a,{get:t[a],enumerable:!0})},Le=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of pt(t))!mt.call(e,n)&&n!==a&&X(e,n,{get:()=>t[n],enumerable:!(i=ut(t,n))||i.enumerable});return e};var Me=(e,t,a)=>(a=e!=null?dt(ft(e)):{},Le(t||!e||!e.__esModule?X(a,"default",{value:e,enumerable:!0}):a,e)),bt=e=>Le(X({},"__esModule",{value:!0}),e);var tt={};Ce(tt,{askPage:()=>ve});function Ot(){return new Promise(e=>{let t=setTimeout(e,1500),a=new MutationObserver(()=>{clearTimeout(t),t=setTimeout(()=>{a.disconnect(),e()},500)});a.observe(document.body,{childList:!0,subtree:!0})})}function qt(){let e=[],t=document.querySelectorAll("*");for(let a of t){if(a.closest("[data-yuktai-panel]"))continue;let i=a.innerText?.trim();i&&i.length>30&&e.push(i);let n=a.getAttribute("aria-label");if(n&&n.length>10&&e.push(n),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&(a.placeholder&&e.push(a.placeholder),a.value&&e.push(a.value)),a instanceof HTMLButtonElement){let s=a.innerText||a.getAttribute("aria-label");s&&e.push(s)}}return e.join(" ").slice(0,3500)}async function ve(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{let t=window,a=t.LanguageModel||t.ai?.languageModel;if(!a)return{success:!1,answer:"",error:"Gemini Nano not available."};await Ot();let i=qt();if(!i||i.length<100)return{success:!1,answer:"",error:"Page content not readable."};let n;try{n=await a.create({systemPrompt:`Answer ONLY using page content.
2
+ Keep answer short (2\u20133 sentences).
3
+ If not found say: "I could not find that on this page."`,outputLanguage:"en"})}catch{n=await a.create()}let s=`Page:
4
+ ${i}
5
+
6
+ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o?.trim()||"No answer found."}}catch(t){return{success:!1,answer:"",error:t instanceof Error?t.message:"Error occurred"}}}var ke=gt(()=>{"use strict"});var ta={};Ce(ta,{Runtime:()=>I,YuktAI:()=>ea,YuktAIWrapper:()=>re,aiPlugin:()=>K,default:()=>re,voicePlugin:()=>Y,wcag:()=>T,wcagPlugin:()=>T});module.exports=bt(ta);function Re(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function ue(){try{let e=Re();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 yt(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=Re();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),i=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:i.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function Pe(){if(!await ue())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let i of t){let n=i.innerText?.trim();if(!n||n.length<20||i.closest("[data-yuktai-panel]"))continue;let s=await yt(n);s.success&&s.rewritten!==n&&(i.dataset.yuktaiOriginal=n,i.innerText=s.rewritten,a++)}return{fixed:a}}function ze(){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 Ie="yuktai-summary-box";function He(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function pe(){try{let e=He();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 xt(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(a);if(i.display==="none"||i.visibility==="hidden")continue;let n=a.innerText?.trim();n&&n.length>10&&t.push(n)}return t.join(" ").slice(0,5e3)}async function We(){if(!await pe())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=xt();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=He();if(!a)throw new Error("Summarizer API not available");let i=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),n=await i.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return i.destroy(),ht(n.trim()),{success:!0,summary:n.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function ht(e){Q();let t=document.createElement("div");t.id=Ie,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
2
7
  position: fixed;
3
8
  top: 0;
4
9
  left: 0;
@@ -19,7 +24,7 @@
19
24
  background: none; border: none; color: #ffffff;
20
25
  font-size: 20px; cursor: pointer; padding: 0 4px;
21
26
  line-height: 1; flex-shrink: 0;
22
- `,i.addEventListener("click",D),t.appendChild(a),t.appendChild(i),document.body.prepend(t)}function D(){let e=document.getElementById(ge);e&&e.remove()}var G=[{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"}],q="en";function Ze(){let e=window;return e.Translator||e.translation||null}async function et(e){try{let t=window;if(!Ze())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let i=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return i==="readily"||i==="available"||i==="downloadable"||i==="after-download"}catch{}return t.Translator&&typeof t.Translator.canTranslate=="function"?await t.Translator.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":t.translation&&typeof t.translation.canTranslate=="function"?await t.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function tt(e){let t=window,a={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(a);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(a);throw new Error("Translation API not available")}async function he(e){if(e===q)return{success:!0,language:e,fixed:0};if(e==="en")return ae(),q="en",{success:!0,language:"en",fixed:0};if(!await et(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let a=await tt(e),i=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),n=0;for(let l of i){if(l.closest("[data-yuktai-panel]")||l.children.length>0)continue;let o=l.innerText?.trim();if(!o||o.length<2)continue;l.dataset.yuktaiTranslationOriginal||(l.dataset.yuktaiTranslationOriginal=o);let c=await a.translate(o);c&&c!==o&&(l.innerText=c,n++)}return typeof a.destroy=="function"&&a.destroy(),q=e,{success:!0,language:e,fixed:n}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function ae(){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)}q="en"}var at=[{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,V=!1,M=null;function oe(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function ot(e){let t=e.toLowerCase().trim();for(let a of at)for(let i of a.phrases)if(t.includes(i))return{action:a.action,label:a.label};return null}function nt(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=we(),a=t.indexOf(document.activeElement),i=t[a+1]||t[0];i&&i.focus();break}case"tab-back":{let t=we(),a=t.indexOf(document.activeElement),i=t[a-1]||t[t.length-1];i&&i.focus();break}case"stop-voice":{ne();break}}}function we(){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 ve(e){if(!oe())return!1;if(V)return!0;e&&(M=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return v=new t,v.continuous=!0,v.interimResults=!1,v.lang="en-US",v.onresult=a=>{let i=a.results[a.results.length-1][0].transcript,n=ot(i);if(n){nt(n.action);let l={success:!0,command:i,action:n.label};if(M&&M(l),n.action==="stop-voice")return}},v.onend=()=>{V&&v?.start()},v.onerror=a=>{a.error!=="no-speech"&&M&&M({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},v.start(),V=!0,it(),!0}function ne(){V=!1,v&&(v.stop(),v=null),M=null,Ae()}var ke="yuktai-voice-indicator";function it(){Ae();let e=document.createElement("div");e.id=ke,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
27
+ `,i.addEventListener("click",Q),t.appendChild(a),t.appendChild(i),document.body.prepend(t)}function Q(){let e=document.getElementById(Ie);e&&e.remove()}var ee=[{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"}],Z="en";function wt(){let e=window;return e.Translator||e.translation||null}async function vt(e){try{let t=window;if(!wt())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let i=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return i==="readily"||i==="available"||i==="downloadable"||i==="after-download"}catch{}return t.Translator&&typeof t.Translator.canTranslate=="function"?await t.Translator.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":t.translation&&typeof t.translation.canTranslate=="function"?await t.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function kt(e){let t=window,a={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(a);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(a);throw new Error("Translation API not available")}async function Fe(e){if(e===Z)return{success:!0,language:e,fixed:0};if(e==="en")return fe(),Z="en",{success:!0,language:"en",fixed:0};if(!await vt(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let a=await kt(e),i=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),n=0;for(let s of i){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let o=s.innerText?.trim();if(!o||o.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=o);let c=await a.translate(o);c&&c!==o&&(s.innerText=c,n++)}return typeof a.destroy=="function"&&a.destroy(),Z=e,{success:!0,language:e,fixed:n}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function fe(){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)}Z="en"}var At=[{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"}],L=null,te=!1,$=null;function me(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function St(e){let t=e.toLowerCase().trim();for(let a of At)for(let i of a.phrases)if(t.includes(i))return{action:a.action,label:a.label};return null}function Tt(e){switch(e){case"focus-main":{let t=document.querySelector("main, [role='main'], #main");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-nav":{let t=document.querySelector("nav, [role='navigation']");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-search":{let t=document.querySelector("input[type='search'], input[role='searchbox'], [aria-label*='search' i]");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"scroll-down":{window.scrollBy({top:400,behavior:"smooth"});break}case"scroll-up":{window.scrollBy({top:-400,behavior:"smooth"});break}case"go-back":{window.history.back();break}case"click-focused":{let t=document.activeElement;t&&t!==document.body&&t.click();break}case"tab-forward":{let t=$e(),a=t.indexOf(document.activeElement),i=t[a+1]||t[0];i&&i.focus();break}case"tab-back":{let t=$e(),a=t.indexOf(document.activeElement),i=t[a-1]||t[t.length-1];i&&i.focus();break}case"stop-voice":{ge();break}}}function $e(){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 Be(e){if(!me())return!1;if(te)return!0;e&&($=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return L=new t,L.continuous=!0,L.interimResults=!1,L.lang="en-US",L.onresult=a=>{let i=a.results[a.results.length-1][0].transcript,n=St(i);if(n){Tt(n.action);let s={success:!0,command:i,action:n.label};if($&&$(s),n.action==="stop-voice")return}},L.onend=()=>{te&&L?.start()},L.onerror=a=>{a.error!=="no-speech"&&$&&$({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},L.start(),te=!0,Et(),!0}function ge(){te=!1,L&&(L.stop(),L=null),$=null,Oe()}var Ne="yuktai-voice-indicator";function Et(){Oe();let e=document.createElement("div");e.id=Ne,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
23
28
  position: fixed;
24
29
  bottom: 80px;
25
30
  left: 50%;
@@ -49,7 +54,7 @@
49
54
  0%, 100% { opacity: 1; transform: scale(1); }
50
55
  50% { opacity: 0.4; transform: scale(0.7); }
51
56
  }
52
- `,document.head.appendChild(i)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function Ae(){let e=document.getElementById(ke);e&&e.remove()}var rt=["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 Se(){let e=window;return e.Writer||e.ai?.writer||null}async function ie(){try{let e=Se();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 st(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let i=e.placeholder?.trim();i&&t.push(`placeholder: "${i}"`);let n=e.getAttribute("name")?.trim();n&&t.push(`name: "${n}"`);let l=e.getAttribute("type")?.trim();l&&t.push(`type: "${l}"`);let o=e.id;if(o){let u=document.querySelector(`label[for="${o}"]`);u&&t.push(`label: "${u.innerText?.trim()}"`)}let c=e.parentElement?.innerText?.trim().slice(0,60);c&&t.push(`parent context: "${c}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let f=e.getAttribute("role");return f&&t.push(`role: ${f}`),t.join(". ")}async function lt(e,t){let a=`
57
+ `,document.head.appendChild(i)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function Oe(){let e=document.getElementById(Ne);e&&e.remove()}var Ct=["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 qe(){let e=window;return e.Writer||e.ai?.writer||null}async function be(){try{let e=qe();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 Lt(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let i=e.placeholder?.trim();i&&t.push(`placeholder: "${i}"`);let n=e.getAttribute("name")?.trim();n&&t.push(`name: "${n}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let o=e.id;if(o){let u=document.querySelector(`label[for="${o}"]`);u&&t.push(`label: "${u.innerText?.trim()}"`)}let c=e.parentElement?.innerText?.trim().slice(0,60);c&&t.push(`parent context: "${c}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let g=e.getAttribute("role");return g&&t.push(`role: ${g}`),t.join(". ")}async function Mt(e,t){let a=`
53
58
  Generate a short, clear aria-label for an HTML element.
54
59
  The label must be 2-6 words maximum.
55
60
  The label must describe what the element does or what it is.
@@ -60,7 +65,7 @@
60
65
  ${t}
61
66
 
62
67
  Output only the label. Nothing else.
63
- `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Te(){if(!await ie())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(rt);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=Se();if(!a)throw new Error("Writer API not available");let i=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),n=0,l=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let c=window.getComputedStyle(o);if(c.display==="none"||c.visibility==="hidden")continue;let f=st(o),u=await lt(i,f);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),n++,l.push({tag:o.tagName.toLowerCase(),label:u}))}return i.destroy(),{success:!0,fixed:n,elements:l}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function Ee(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let a=t.dataset.yuktaiLabelOriginal;a?t.setAttribute("aria-label",a):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var Y=null,Ce=null;var Le=null,re=null,m=null,R=null,j=null,se=null,P=null,K={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Me=new Set(["input","select","textarea"]);var le={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function ce(e,t="polite"){if(typeof window>"u"||!P?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let i=window.speechSynthesis.getVoices();i.length>0&&(a.voice=i[0]),window.speechSynthesis.speak(a)}function Fe(e,t="info"){if(typeof document>"u")return;let i={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];m||(m=document.createElement("div"),m.setAttribute("role","alert"),m.setAttribute("aria-live","assertive"),m.setAttribute("aria-atomic","true"),m.style.cssText=`
68
+ `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Ge(){if(!await be())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(Ct);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=qe();if(!a)throw new Error("Writer API not available");let i=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),n=0,s=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let c=window.getComputedStyle(o);if(c.display==="none"||c.visibility==="hidden")continue;let g=Lt(o),u=await Mt(i,g);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),n++,s.push({tag:o.tagName.toLowerCase(),label:u}))}return i.destroy(),{success:!0,fixed:n,elements:s}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function De(){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 oe=null,_e=null;var Ve=null,ye=null,b=null,B=null,ae=null,xe=null,N=null,ne={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var je=new Set(["input","select","textarea"]);var he={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function we(e,t="polite"){if(typeof window>"u"||!N?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let i=window.speechSynthesis.getVoices();i.length>0&&(a.voice=i[0]),window.speechSynthesis.speak(a)}function Ze(e,t="info"){if(typeof document>"u")return;let i={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];b||(b=document.createElement("div"),b.setAttribute("role","alert"),b.setAttribute("aria-live","assertive"),b.setAttribute("aria-atomic","true"),b.style.cssText=`
64
69
  position: fixed;
65
70
  top: 80px;
66
71
  right: 16px;
@@ -79,14 +84,14 @@
79
84
  transition: transform 0.3s, opacity 0.3s;
80
85
  transform: translateX(120%);
81
86
  opacity: 0;
82
- `,document.body.appendChild(m)),m.style.background=i.bg,m.style.border=`1px solid ${i.border}`,m.style.color="#fff",m.innerHTML=`
87
+ `,document.body.appendChild(b)),b.style.background=i.bg,b.style.border=`1px solid ${i.border}`,b.style.color="#fff",b.innerHTML=`
83
88
  <span style="font-size:18px;font-weight:700">${i.icon}</span>
84
89
  <span style="flex:1;line-height:1.4">${e}</span>
85
90
  <button
86
91
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
87
92
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
88
93
  aria-label="Close notification">\xD7</button>
89
- `,window.innerWidth<=480&&(m.style.right="8px",m.style.left="8px",m.style.maxWidth="none",m.style.width="auto"),requestAnimationFrame(()=>{m&&(m.style.transform="translateX(0)",m.style.opacity="1")}),setTimeout(()=>{m&&(m.style.transform="translateX(120%)",m.style.opacity="0")},5e3)}function p(e,t="info",a=!0){Y&&(Y.textContent=e),Fe(e,t),a&&ce(e,t==="error"?"assertive":"polite")}function ct(){if(typeof document>"u"||Le)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
94
+ `,window.innerWidth<=480&&(b.style.right="8px",b.style.left="8px",b.style.maxWidth="none",b.style.width="auto"),requestAnimationFrame(()=>{b&&(b.style.transform="translateX(0)",b.style.opacity="1")}),setTimeout(()=>{b&&(b.style.transform="translateX(120%)",b.style.opacity="0")},5e3)}function f(e,t="info",a=!0){oe&&(oe.textContent=e),Ze(e,t),a&&we(e,t==="error"?"assertive":"polite")}function Rt(){if(typeof document>"u"||Ve)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
90
95
  position: fixed;
91
96
  top: 0;
92
97
  left: 0;
@@ -100,7 +105,7 @@
100
105
  transform: translateY(-100%);
101
106
  transition: transform 0.2s ease;
102
107
  font-family: system-ui, sans-serif;
103
- `;let a=!1;if(e.forEach(({label:n,selector:l})=>{let o=document.querySelector(l);if(!o)return;a=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let c=document.createElement("a");c.href="#",c.textContent=n,c.style.cssText=`
108
+ `;let a=!1;if(e.forEach(({label:n,selector:s})=>{let o=document.querySelector(s);if(!o)return;a=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let c=document.createElement("a");c.href="#",c.textContent=n,c.style.cssText=`
104
109
  color: #fff;
105
110
  background: #1a73e8;
106
111
  padding: 8px 14px;
@@ -111,7 +116,7 @@
111
116
  white-space: nowrap;
112
117
  border: 2px solid transparent;
113
118
  transition: background 0.15s, border-color 0.15s;
114
- `,c.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),c.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),c.addEventListener("click",f=>{f.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),p(`Jumped to ${n.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!a)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Le=t}function dt(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
119
+ `,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",g=>{g.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),f(`Jumped to ${n.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!a)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Ve=t}function Pt(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
115
120
 
116
121
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
117
122
  [data-yuktai-a11y] *:focus-visible {
@@ -257,7 +262,7 @@
257
262
  width: auto !important;
258
263
  }
259
264
  }
260
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function ut(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let a=t.getAttribute("role")||"";if(e.key==="Escape"){let i=t.closest("[role='dialog'],[role='alertdialog']");if(i){i.style.display="none",p("Dialog closed","info");return}let n=t.closest("[role='menu'],[role='menubar']");n&&(n.style.display="none",p("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let i=t.closest("[role='menu'],[role='menubar']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='menuitem']:not([disabled])")),l=n.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),n[(l+1)%n.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),n[(l-1+n.length)%n.length]?.focus()):e.key==="Home"?(e.preventDefault(),n[0]?.focus()):e.key==="End"&&(e.preventDefault(),n[n.length-1]?.focus())}if(a==="tab"||t.closest("[role='tablist']")){let i=t.closest("[role='tablist']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='tab']:not([disabled])")),l=n.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=n[(l+1)%n.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=n[(l-1+n.length)%n.length];o?.focus(),o?.click()}}if(a==="option"||t.closest("[role='listbox']")){let i=t.closest("[role='listbox']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='option']:not([aria-disabled='true'])")),l=n.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),n[(l+1)%n.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),n[(l-1+n.length)%n.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),n.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),p(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),pt()),e.key==="Tab"&&P?.speechEnabled&&setTimeout(()=>{let i=document.activeElement;if(!i)return;let n=i.getAttribute("aria-label")||i.getAttribute("title")||i.textContent?.trim()||i.tagName.toLowerCase(),l=i.getAttribute("role")||i.tagName.toLowerCase();ce(`${n}, ${l}`)},100)}))}function U(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let a=t[0],i=t[t.length-1];a.focus(),e.addEventListener("keydown",n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===a&&(n.preventDefault(),i.focus()):document.activeElement===i&&(n.preventDefault(),a.focus()))})}function pt(){if(typeof document>"u")return;if(R){R.remove(),R=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
265
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function zt(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let a=t.getAttribute("role")||"";if(e.key==="Escape"){let i=t.closest("[role='dialog'],[role='alertdialog']");if(i){i.style.display="none",f("Dialog closed","info");return}let n=t.closest("[role='menu'],[role='menubar']");n&&(n.style.display="none",f("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let i=t.closest("[role='menu'],[role='menubar']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='menuitem']:not([disabled])")),s=n.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),n[(s+1)%n.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),n[(s-1+n.length)%n.length]?.focus()):e.key==="Home"?(e.preventDefault(),n[0]?.focus()):e.key==="End"&&(e.preventDefault(),n[n.length-1]?.focus())}if(a==="tab"||t.closest("[role='tablist']")){let i=t.closest("[role='tablist']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='tab']:not([disabled])")),s=n.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=n[(s+1)%n.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=n[(s-1+n.length)%n.length];o?.focus(),o?.click()}}if(a==="option"||t.closest("[role='listbox']")){let i=t.closest("[role='listbox']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=n.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),n[(s+1)%n.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),n[(s-1+n.length)%n.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),n.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),f(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),It()),e.key==="Tab"&&N?.speechEnabled&&setTimeout(()=>{let i=document.activeElement;if(!i)return;let n=i.getAttribute("aria-label")||i.getAttribute("title")||i.textContent?.trim()||i.tagName.toLowerCase(),s=i.getAttribute("role")||i.tagName.toLowerCase();we(`${n}, ${s}`)},100)}))}function ie(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let a=t[0],i=t[t.length-1];a.focus(),e.addEventListener("keydown",n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===a&&(n.preventDefault(),i.focus()):document.activeElement===i&&(n.preventDefault(),a.focus()))})}function It(){if(typeof document>"u")return;if(B){B.remove(),B=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
261
266
  position: fixed;
262
267
  top: 50%;
263
268
  left: 50%;
@@ -287,7 +292,7 @@
287
292
  <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${n}</span>
288
293
  </div>
289
294
  `).join("")}
290
- `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),R=null}),e.addEventListener("keydown",i=>{i.key==="Escape"&&(e.remove(),R=null)}),document.body.appendChild(e),R=e,U(e),p("Keyboard shortcuts opened. Press Escape to close.","info")}function ft(e){if(typeof document>"u"||!P?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;re&&re.remove();let t=e.score,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",i=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",n=document.createElement("button");n.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),n.setAttribute("data-yuktai-badge","true"),n.style.cssText=`
295
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),B=null}),e.addEventListener("keydown",i=>{i.key==="Escape"&&(e.remove(),B=null)}),document.body.appendChild(e),B=e,ie(e),f("Keyboard shortcuts opened. Press Escape to close.","info")}function Ht(e){if(typeof document>"u"||!N?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;ye&&ye.remove();let t=e.score,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",i=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",n=document.createElement("button");n.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),n.setAttribute("data-yuktai-badge","true"),n.style.cssText=`
291
296
  position: fixed;
292
297
  bottom: 16px;
293
298
  left: 16px;
@@ -306,7 +311,7 @@
306
311
  align-items: center;
307
312
  gap: 6px;
308
313
  transition: transform 0.15s;
309
- `,n.innerHTML=`${i} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,n.addEventListener("click",()=>mt(e)),document.body.appendChild(n),re=n}function mt(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=`
314
+ `,n.innerHTML=`${i} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,n.addEventListener("click",()=>Wt(e)),document.body.appendChild(n),ye=n}function Wt(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let a=document.createElement("div");a.setAttribute("data-yuktai-audit-details","true"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","Accessibility audit details"),a.style.cssText=`
310
315
  position: fixed;
311
316
  bottom: 56px;
312
317
  left: 16px;
@@ -338,7 +343,7 @@
338
343
  </div>
339
344
  `).join("")}
340
345
  ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
341
- `,a.addEventListener("keydown",n=>{n.key==="Escape"&&a.remove()}),document.body.appendChild(a),U(a)}function We(e){typeof document>"u"||(se&&clearTimeout(se),se=setTimeout(()=>{if(j)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
346
+ `,a.addEventListener("keydown",n=>{n.key==="Escape"&&a.remove()}),document.body.appendChild(a),ie(a)}function et(e){typeof document>"u"||(xe&&clearTimeout(xe),xe=setTimeout(()=>{if(ae)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
342
347
  position: fixed;
343
348
  top: 50%;
344
349
  left: 50%;
@@ -367,24 +372,19 @@
367
372
  No, sign out
368
373
  </button>
369
374
  </div>
370
- `;let a=t.querySelector("[data-yuktai-extend]"),i=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),j=null,p("Session extended. You have more time.","success"),P?.timeoutWarning&&We(P.timeoutWarning)}),i?.addEventListener("click",()=>{t.remove(),j=null}),document.body.appendChild(t),j=t,U(t),p("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function bt(e){if(typeof document>"u")return;let t=document.documentElement;if(t.toggleAttribute("data-yuktai-high-contrast",!!e.highContrast),t.toggleAttribute("data-yuktai-dark",!!e.darkMode),t.toggleAttribute("data-yuktai-reduce-motion",!!e.reduceMotion),t.toggleAttribute("data-yuktai-large-targets",!!e.largeTargets),t.toggleAttribute("data-yuktai-keyboard",!!e.keyboardHints),t.toggleAttribute("data-yuktai-dyslexia",!!e.dyslexiaFont),e.localFont?document.body.style.fontFamily=`"${e.localFont}", system-ui, sans-serif`:e.dyslexiaFont||(document.body.style.fontFamily=""),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1?document.documentElement.style.fontSize=`${e.fontSizeMultiplier*100}%`:document.documentElement.style.fontSize="",e.colorBlindMode&&e.colorBlindMode!=="none"){let a=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${K[e.colorBlindMode]})`;document.body.style.filter=a}else document.body.style.filter=""}function gt(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Re(e){if(e){if(!await ee()){p("Plain English requires Chrome 127+","warning");return}p("Rewriting page in plain English...","info",!1);let a=await me();p(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else be(),p("Original text restored","info",!1)}async function Pe(e){if(e){if(!await te()){p("Page summariser requires Chrome 127+","warning");return}p("Generating page summary...","info",!1);let a=await xe();p(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else D(),p("Page summary removed","info",!1)}async function Ie(e){if(e==="en"){ae(),p("Page restored to English","info",!1);return}p(`Translating page to ${e}...`,"info",!1);let t=await he(e);p(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function ze(e){if(e){if(!oe()){p("Voice control not supported in this browser","warning");return}ve(t=>{t.success&&p(`Voice: ${t.action}`,"info",!1)}),p("Voice control started. Say a command.","success",!1)}else ne(),p("Voice control stopped","info",!1)}async function He(e){if(e){if(!await ie()){p("Smart labels requires Chrome 127+","warning");return}p("Generating smart labels...","info",!1);let a=await Te();p(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else Ee(),p("Smart labels removed","info",!1)}function yt(){if(typeof document>"u"||Y)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),Y=e}function xt(){if(typeof document>"u"||Ce)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
375
+ `;let a=t.querySelector("[data-yuktai-extend]"),i=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),ae=null,f("Session extended. You have more time.","success"),N?.timeoutWarning&&et(N.timeoutWarning)}),i?.addEventListener("click",()=>{t.remove(),ae=null}),document.body.appendChild(t),ae=t,ie(t),f("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function Ft(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(#${ne[e.colorBlindMode]})`;document.body.style.filter=a}else document.body.style.filter=""}function $t(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Ke(e){if(e){if(!await ue()){f("Plain English requires Chrome 127+","warning");return}f("Rewriting page in plain English...","info",!1);let a=await Pe();f(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else ze(),f("Original text restored","info",!1)}async function Ye(e){if(e){if(!await pe()){f("Page summariser requires Chrome 127+","warning");return}f("Generating page summary...","info",!1);let a=await We();f(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else Q(),f("Page summary removed","info",!1)}async function Ue(e){if(e==="en"){fe(),f("Page restored to English","info",!1);return}f(`Translating page to ${e}...`,"info",!1);let t=await Fe(e);f(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Je(e){if(e){if(!me()){f("Voice control not supported in this browser","warning");return}Be(t=>{t.success&&f(`Voice: ${t.action}`,"info",!1)}),f("Voice control started. Say a command.","success",!1)}else ge(),f("Voice control stopped","info",!1)}async function Xe(e){if(e){if(!await be()){f("Smart labels requires Chrome 127+","warning");return}f("Generating smart labels...","info",!1);let a=await Ge();f(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else De(),f("Smart labels removed","info",!1)}function Bt(){if(typeof document>"u"||oe)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),oe=e}function Nt(){if(typeof document>"u"||_e)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
371
376
  <defs>
372
- <filter id="${K.deuteranopia}">
377
+ <filter id="${ne.deuteranopia}">
373
378
  <feColorMatrix type="matrix"
374
379
  values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
375
380
  </filter>
376
- <filter id="${K.protanopia}">
381
+ <filter id="${ne.protanopia}">
377
382
  <feColorMatrix type="matrix"
378
383
  values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
379
384
  </filter>
380
- <filter id="${K.tritanopia}">
385
+ <filter id="${ne.tritanopia}">
381
386
  <feColorMatrix type="matrix"
382
387
  values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
383
388
  </filter>
384
389
  </defs>
385
- `,document.body.appendChild(e),Ce=e}function $e(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((i,n)=>i+(t[n.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var w={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";P=e,gt(e),yt(),xt(),dt(),ut(),e.showSkipLinks!==!1&&ct(),e.showPreferencePanel,bt(e);let t=this.applyFixes(e);t.score=$e(t),e.showAuditBadge&&ft(t),e.timeoutWarning&&We(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Re(!0),e.summarisePage&&await Pe(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Ie(e.translateLanguage),e.voiceControl&&await ze(!0),e.smartLabels&&await He(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return p(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let a=performance.now(),i=document.querySelectorAll("*");t.scanned=i.length;let n=(l,o,c,f)=>{t.details.push({tag:l,fix:o,severity:c,element:f.outerHTML.slice(0,100)}),t.fixed++};return i.forEach(l=>{let o=l,c=o.tagName.toLowerCase();if(c==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),n(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),y=o.getAttribute("content")||"";u==="viewport"&&y.includes("user-scalable=no")&&(o.setAttribute("content",y.replace("user-scalable=no","user-scalable=yes")),n(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(y)&&(o.setAttribute("content",y.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),n(c,"maximum-scale=5 restored","serious",o))}if(c==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),c==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),n(c,'alt="" aria-hidden="true"',"serious",o))),c==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!l.querySelector("title")&&(o.setAttribute("aria-hidden","true"),n(c,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),c==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),n(c,"title + aria-label added","serious",o)),c==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let u=o.getAttribute("title")||"button";o.setAttribute("aria-label",u),n(c,`aria-label="${u}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(c==="a"){let u=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),n(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(Me.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let y=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",y),n(c,`aria-label="${y}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let y=u.name||"";u.type==="email"||y.includes("email")?u.autocomplete="email":u.type==="tel"||y.includes("tel")?u.autocomplete="tel":u.type==="password"&&(u.autocomplete="current-password"),t.fixed++}}c==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),n(c,"scope added to <th>","moderate",o)),le[c]&&!o.getAttribute("role")&&(o.setAttribute("role",le[c]),n(c,`role="${le[c]}"`,"minor",o));let f=o.getAttribute("role")||"";f==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(f)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",f==="alert"?"assertive":"polite"),n(c,`aria-live added on role=${f}`,"moderate",o)),f==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),n(c,'aria-expanded="false" on combobox',"serious",o)),(f==="checkbox"||f==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),n(c,`aria-checked="false" on role=${f}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-a).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),a=document.querySelectorAll("*");e.scanned=a.length;let i=(n,l,o,c)=>e.details.push({tag:n,fix:l,severity:o,element:c.outerHTML.slice(0,100)});return a.forEach(n=>{let l=n,o=l.tagName.toLowerCase();(o==="a"||o==="button")&&!l.innerText?.trim()&&!l.getAttribute("aria-label")&&i(o,"needs aria-label (empty)","critical",l),o==="img"&&!l.hasAttribute("alt")&&i(o,"needs alt text","serious",l),Me.has(o)&&!l.getAttribute("aria-label")&&!l.getAttribute("aria-labelledby")&&i(o,"needs aria-label","serious",l),o==="iframe"&&!l.getAttribute("title")&&!l.getAttribute("aria-label")&&i(o,"iframe needs title","serious",l)}),e.fixed=e.details.length,e.score=$e(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:ce,showVisualAlert:Fe,trapFocus:U,handlePlainEnglish:Re,handleSummarisePage:Pe,handleTranslate:Ie,handleVoiceControl:ze,handleSmartLabels:He,SUPPORTED_LANGUAGES:G};var b=Ye(require("react"));var T=require("react");function ht(){return new Promise(e=>{let t=setTimeout(e,1500),a=new MutationObserver(()=>{clearTimeout(t),t=setTimeout(()=>{a.disconnect(),e()},500)});a.observe(document.body,{childList:!0,subtree:!0})})}function wt(){let e=[],t=document.querySelectorAll("*");for(let a of t){if(a.closest("[data-yuktai-panel]"))continue;let i=a.innerText?.trim();i&&i.length>30&&e.push(i);let n=a.getAttribute("aria-label");if(n&&n.length>10&&e.push(n),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&(a.placeholder&&e.push(a.placeholder),a.value&&e.push(a.value)),a instanceof HTMLButtonElement){let l=a.innerText||a.getAttribute("aria-label");l&&e.push(l)}}return e.join(" ").slice(0,3500)}async function Ne(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{let t=window,a=t.LanguageModel||t.ai?.languageModel;if(!a)return{success:!1,answer:"",error:"Gemini Nano not available."};await ht();let i=wt();if(!i||i.length<100)return{success:!1,answer:"",error:"Page content not readable."};let n;try{n=await a.create({systemPrompt:`Answer ONLY using page content.
386
- Keep answer short (2\u20133 sentences).
387
- If not found say: "I could not find that on this page."`,outputLanguage:"en"})}catch{n=await a.create()}let l=`Page:
388
- ${i}
389
-
390
- Q: ${e}`,o=await n.prompt(l);return n?.destroy&&n.destroy(),{success:!0,answer:o?.trim()||"No answer found."}}catch(t){return{success:!1,answer:"",error:t instanceof Error?t.message:"Error occurred"}}}var r=require("react/jsx-runtime"),de={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100,localFont:"",darkMode:!1,largeTargets:!1,speechEnabled:!1,colorBlindMode:"none",showAuditBadge:!1,timeoutWarning:void 0,plainEnglish:!1,summarisePage:!1,translateLanguage:"en",voiceControl:!1,smartLabels:!1},I=[80,90,100,110,120,130],vt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],kt=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function At(){let[e,t]=(0,T.useState)(typeof window<"u"?window.innerWidth:1024);return(0,T.useEffect)(()=>{let a=()=>t(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function St({checked:e,onChange:t,label:a,disabled:i=!1}){return(0,r.jsxs)("label",{"aria-label":a,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:i?"not-allowed":"pointer",flexShrink:0,opacity:i?.4:1},children:[(0,r.jsx)("input",{type:"checkbox",checked:e,disabled:i,onChange:n=>t(n.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,r.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,r.jsx)("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function H({label:e,color:t="#64748b",badge:a}){return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",margin:"8px 18px 4px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),a&&(0,r.jsx)("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:a})]})}function S({icon:e,label:t,desc:a,checked:i,onChange:n,disabled:l=!1,disabledReason:o}){return(0,r.jsxs)("div",{title:l?o:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:"30px",height:"30px",borderRadius:"8px",background:l?"#f1f5f9":"#f0fdfa",color:l?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",flexShrink:0,fontWeight:700},children:e}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:l?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:l?o:a})]})]}),(0,r.jsx)(St,{checked:i,onChange:n,label:`Toggle ${t}`,disabled:l})]})}function x(){return(0,r.jsx)("div",{style:{height:"1px",background:"#f1f5f9",margin:"0"}})}var ue=(0,T.forwardRef)(({position:e,settings:t,report:a,isActive:i,aiSupported:n,voiceSupported:l,set:o,onApply:c,onReset:f,onClose:u},y)=>{let{isMobile:g,isTablet:X}=At(),[W,Q]=(0,T.useState)([]),[k,N]=(0,T.useState)(""),[B,L]=(0,T.useState)(""),[A,O]=(0,T.useState)(!1),d=async()=>{if(!(!k.trim()||A||!n)){O(!0),L("");try{let s=await Ne(k);s.success&&s.answer?L(s.answer):L("\u26A0\uFE0F "+(s.error||"No answer found on this page"))}catch{L("\u26A0\uFE0F Failed to fetch answer")}O(!1)}};(0,T.useEffect)(()=>{(async()=>{try{let z=window;if(!z.queryLocalFonts)return;let Z=await z.queryLocalFonts(),Oe=[...new Set(Z.map(_e=>_e.family))].sort();Q(Oe.slice(0,50))}catch{}})()},[]);let h=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:X?"300px":"320px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",maxHeight:"80vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif"};return(0,r.jsxs)("div",{ref:y,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:h,children:[(0,r.jsxs)("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between",position:"sticky",top:0,background:"#fff",zIndex:1},children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"7px",marginBottom:"5px",flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v2.0.18"}),i&&(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),(0,r.jsx)("p",{style:{margin:"0 0 2px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),(0,r.jsx)("p",{style:{margin:0,fontSize:"12px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost"})]}),(0,r.jsx)("button",{onClick:u,"aria-label":"Close accessibility panel",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#94a3b8",fontSize:"20px",lineHeight:1,borderRadius:"6px",flexShrink:0,minWidth:g?"44px":"auto",minHeight:g?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,r.jsx)(H,{label:"Core"}),(0,r.jsx)(S,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:s=>o("autoFix",s)}),(0,r.jsx)(x,{}),(0,r.jsx)(S,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:s=>o("speechEnabled",s)}),(0,r.jsx)(x,{}),(0,r.jsx)(S,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:s=>o("voiceControl",s),disabled:!l,disabledReason:"Not supported in this browser"}),(0,r.jsx)(x,{}),(0,r.jsx)(H,{label:"AI features",color:"#7c3aed",badge:"Gemini Nano \xB7 Chrome 127+"}),(0,r.jsx)("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:"#f5f3ff",borderRadius:"8px",border:"0.5px solid #c4b5fd",fontSize:"10px",color:"#7c3aed",lineHeight:1.5},children:n?"Gemini Nano detected \u2014 AI features ready. Runs privately on your device. No data leaves your browser.":"AI features need setup \u2014 see guide below."}),!n&&(0,r.jsxs)("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[(0,r.jsx)("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} How to enable AI features:"}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome and go to"," ",(0,r.jsx)("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["2. Search and set each to ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Enabled:"})]}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:kt.map(s=>(0,r.jsxs)("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",s]},s))}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["3. Click ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Relaunch"})," when Chrome prompts you"]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["4. Go to"," ",(0,r.jsx)("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://components"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px 10px"},children:["\u2192 Find ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Optimization Guide On Device Model"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 6px 10px"},children:["\u2192 Click ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Check for update"})," and wait for download"]}),(0,r.jsx)("p",{style:{margin:"0"},children:"5. Refresh this page \u2014 AI features will unlock automatically"})]}),(0,r.jsx)(S,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:s=>o("plainEnglish",s),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(S,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:s=>o("summarisePage",s),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(S,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:s=>o("smartLabels",s),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),(0,r.jsx)(x,{}),(0,r.jsx)(H,{label:"Visual"}),(0,r.jsx)(S,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:s=>o("highContrast",s)}),(0,r.jsx)(x,{}),(0,r.jsx)(S,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:s=>o("darkMode",s)}),(0,r.jsx)(x,{}),(0,r.jsx)(S,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:s=>o("reduceMotion",s)}),(0,r.jsx)(x,{}),(0,r.jsx)(S,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:s=>o("largeTargets",s)}),(0,r.jsx)(x,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:vt.map(s=>(0,r.jsx)("button",{onClick:()=>o("colorBlindMode",s.value),"aria-pressed":t.colorBlindMode===s.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===s.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===s.value?"#f0fdfa":"#fff",color:t.colorBlindMode===s.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:g?"36px":"auto"},children:s.label},s.value))})]}),(0,r.jsx)(x,{}),(0,r.jsx)(H,{label:"Font"}),(0,r.jsx)(S,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:s=>o("dyslexiaFont",s)}),(0,r.jsx)(x,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F524} Local font"}),W.length>0?(0,r.jsxs)("select",{value:t.localFont,onChange:s=>o("localFont",s.target.value),"aria-label":"Choose a font from your device",style:{width:"100%",padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"13px",color:"#0f172a",background:"#fff",cursor:"pointer",height:g?"44px":"36px"},children:[(0,r.jsx)("option",{value:"",children:"System default"}),W.map(s=>(0,r.jsx)("option",{value:s,style:{fontFamily:s},children:s},s))]}):(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Local font access available in Chrome 103+. Allow font access when prompted."})]}),(0,r.jsx)(x,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px 14px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"Text size"}),(0,r.jsxs)("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,r.jsx)("button",{onClick:()=>{let s=I.indexOf(t.fontScale);s>0&&o("fontScale",I[s-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale<=80?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),(0,r.jsx)("div",{style:{flex:1,display:"flex",gap:"3px"},children:I.map(s=>(0,r.jsx)("button",{onClick:()=>o("fontScale",s),"aria-label":`Set text size to ${s}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:s<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},s))}),(0,r.jsx)("button",{onClick:()=>{let s=I.indexOf(t.fontScale);s<I.length-1&&o("fontScale",I[s+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:g?"44px":"30px",height:g?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale>=130?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale>=130?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),(0,r.jsx)(x,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsxs)("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:["\u{1F310} Translate page"," ",(0,r.jsx)("span",{style:{marginLeft:"6px",fontSize:"9px",fontWeight:500,padding:"1px 6px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd"},children:"Gemini Nano"})]}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:G.slice(0,g?8:18).map(s=>(0,r.jsx)("button",{onClick:()=>o("translateLanguage",s.code),"aria-pressed":t.translateLanguage===s.code,disabled:!n,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===s.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===s.code?"#f5f3ff":"#fff",color:t.translateLanguage===s.code?"#7c3aed":"#64748b",cursor:n?"pointer":"not-allowed",opacity:n?1:.5,minHeight:g?"36px":"auto"},children:s.code.toUpperCase()},s.code))}),!n&&(0,r.jsx)("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above to unlock translation."})]}),(0,r.jsx)(x,{}),(0,r.jsx)(H,{label:"Ask this page",color:"#0d9488",badge:"Gemini Nano"}),(0,r.jsxs)("div",{style:{padding:"10px 18px 14px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"11px",color:"#64748b"},children:"Ask any question \u2014 answered from this page. On device. Zero cost."}),(0,r.jsxs)("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[(0,r.jsx)("input",{type:"text",value:k,onChange:s=>N(s.target.value),onKeyDown:s=>{s.key==="Enter"&&d()},placeholder:"Ask something...",disabled:!n||A,style:{flex:1,padding:"8px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px"}}),(0,r.jsx)("button",{onClick:d,disabled:!k.trim()||A||!n,style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:k.trim()&&!A&&n?"#0d9488":"#e2e8f0",color:k.trim()&&!A&&n?"#fff":"#94a3b8",cursor:k.trim()&&!A&&n?"pointer":"not-allowed"},children:A?"\u23F3 Thinking...":"Ask"})]}),(B||A)&&(0,r.jsxs)("div",{style:{padding:"10px",background:"#f0fdfa",borderRadius:"8px",fontSize:"12px",color:"#0f766e"},children:[(0,r.jsx)("strong",{style:{display:"block",marginBottom:"4px"},children:"\u{1F4AC} Answer"}),A?"\u23F3 Thinking...":B||"No answer found"]})]}),a&&(0,r.jsx)("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:"8px",fontSize:"12px",color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:a.fixed>0?`\u2713 ${a.fixed} fixes \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms \xB7 Score: ${a.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms`}),(0,r.jsxs)("div",{style:{display:"flex",gap:"8px",padding:"12px 14px 14px",position:g?"sticky":"relative",bottom:g?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[(0,r.jsx)("button",{onClick:f,style:{flex:1,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:500,borderRadius:"9px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),(0,r.jsx)("button",{onClick:c,style:{flex:2,padding:g?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});ue.displayName="WidgetPanel";var C=require("react/jsx-runtime");async function Tt(){try{if(typeof window>"u")return!1;let e=window;if(e.LanguageModel)try{if(typeof e.LanguageModel.availability=="function"){let a=await e.LanguageModel.availability();if(console.log("yuktai: LanguageModel.availability() =",a),a==="readily"||a==="available"||a==="downloadable")return!0}else return!0}catch{}if(e.Summarizer)try{if(typeof e.Summarizer.availability=="function"){let a=await e.Summarizer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Rewriter)try{if(typeof e.Rewriter.availability=="function"){let a=await e.Rewriter.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}if(e.Writer)try{if(typeof e.Writer.availability=="function"){let a=await e.Writer.availability();if(a==="readily"||a==="available")return!0}else return!0}catch{}let t=e.ai||globalThis.ai;if(t){if(t.languageModel?.availability)try{let a=await t.languageModel.availability();if(a==="readily"||a==="downloadable"||a==="available")return!0}catch{}if(t.languageModel?.capabilities)try{let a=await t.languageModel.capabilities();if(a?.available==="readily"||a?.available==="after-download")return!0}catch{}if(t.languageModel&&typeof t.languageModel.create=="function")return!0;if(t.summarizer?.capabilities)try{if((await t.summarizer.capabilities())?.available!=="no")return!0}catch{}if(t.rewriter?.capabilities)try{if((await t.rewriter.capabilities())?.available!=="no")return!0}catch{}if(t.writer?.capabilities)try{if((await t.writer.capabilities())?.available!=="no")return!0}catch{}if(t.summarizer||t.rewriter||t.writer||t.languageModel)return!0}return!!(e.Translator||e.translation?.canTranslate)}catch{return!1}}function J({position:e="left",children:t,config:a={}}){let[i,n]=(0,b.useState)(!1),[l,o]=(0,b.useState)(de),[c,f]=(0,b.useState)(null),[u,y]=(0,b.useState)(!1),[g,X]=(0,b.useState)(!1),[W,Q]=(0,b.useState)(!1),k=b.default.useRef(null);(0,b.useEffect)(()=>{if(typeof window>"u")return;let h=setTimeout(async()=>{let s=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.ai =",s.ai),console.log("yuktai: window.LanguageModel =",s.LanguageModel),console.log("yuktai: window.Summarizer =",s.Summarizer),console.log("yuktai: window.Rewriter =",s.Rewriter),console.log("yuktai: window.Writer =",s.Writer);let z=await Tt();X(z),z?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 Z=!!(s.SpeechRecognition||s.webkitSpeechRecognition);Q(Z)},800);return()=>clearTimeout(h)},[]),(0,b.useEffect)(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");if(d){let h=JSON.parse(d);o(s=>({...s,...h}))}}catch{}},[]);let N=(0,b.useCallback)(async d=>{let h={enabled:!0,highContrast:d.highContrast,darkMode:d.darkMode,reduceMotion:d.reduceMotion,largeTargets:d.largeTargets,speechEnabled:d.speechEnabled,autoFix:d.autoFix,dyslexiaFont:d.dyslexiaFont,localFont:d.localFont,fontSizeMultiplier:d.fontScale/100,colorBlindMode:d.colorBlindMode,showAuditBadge:d.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:d.plainEnglish,summarisePage:d.summarisePage,translateLanguage:d.translateLanguage,voiceControl:d.voiceControl,smartLabels:d.smartLabels,...a};await w.execute(h);let s=w.applyFixes(h);f(s),y(!0)},[a]),B=(0,b.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(l))}catch{}await N(l),n(!1)},[l,N]),L=(0,b.useCallback)(()=>{o(de);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(h=>d.removeAttribute(h)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",f(null),y(!1)},[]),A=(0,b.useCallback)((d,h)=>{o(s=>({...s,[d]:h}))},[]);(0,b.useEffect)(()=>{let d=h=>{h.key==="Escape"&&i&&n(!1)};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i]),(0,b.useEffect)(()=>{i&&k.current&&w.trapFocus(k.current)},[i]);let O={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:u?"#0d9488":"#1a73e8",color:"#fff",border:"none",cursor:"pointer",fontSize:"22px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(0,0,0,0.25)",transition:"transform 0.15s, background 0.2s"};return(0,C.jsxs)(C.Fragment,{children:[t,(0,C.jsx)("button",{style:O,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":i,"data-yuktai-pref-toggle":"true",onClick:()=>n(d=>!d),onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),i&&(0,C.jsx)(ue,{ref:k,position:e,settings:l,report:c,isActive:u,aiSupported:g,voiceSupported:W,set:A,onApply:B,onReset:L,onClose:()=>n(!1)})]})}var $={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var F={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var E=class{plugins=new Map;register(t,a){if(!a||typeof a.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,a)}use(t){return this.plugins.get(t)}async run(t,a){try{let i=this.use(t);if(!i)throw new Error(`Plugin not found: ${t}`);return await i.execute(a)}catch(i){throw console.error(`[YuktAI Runtime Error in ${t}]:`,i),i}}getPlugins(){return Array.from(this.plugins.keys())}};function Et(){if(typeof globalThis>"u")return new E;if(!globalThis.__yuktai_runtime__){let e=new E;e.register(w.name,w),e.register($.name,$),e.register(F.name,F),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var Be=typeof window<"u"?Et():new E,Ct={wcagPlugin:w,list(){return Be.getPlugins()},use(e){return Be.use(e)},fix(e){return w.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return w.scan()}};0&&(module.exports={Runtime,YuktAI,YuktAIWrapper,aiPlugin,voicePlugin,wcag,wcagPlugin});
390
+ `,document.body.appendChild(e),_e=e}function Qe(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((i,n)=>i+(t[n.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var T={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";N=e,$t(e),Bt(),Nt(),Pt(),zt(),e.showSkipLinks!==!1&&Rt(),e.showPreferencePanel,Ft(e);let t=this.applyFixes(e);t.score=Qe(t),e.showAuditBadge&&Ht(t),e.timeoutWarning&&et(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Ke(!0),e.summarisePage&&await Ye(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Ue(e.translateLanguage),e.voiceControl&&await Je(!0),e.smartLabels&&await Xe(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return f(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let a=performance.now(),i=document.querySelectorAll("*");t.scanned=i.length;let n=(s,o,c,g)=>{t.details.push({tag:s,fix:o,severity:c,element:g.outerHTML.slice(0,100)}),t.fixed++};return i.forEach(s=>{let o=s,c=o.tagName.toLowerCase();if(c==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),n(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),v=o.getAttribute("content")||"";u==="viewport"&&v.includes("user-scalable=no")&&(o.setAttribute("content",v.replace("user-scalable=no","user-scalable=yes")),n(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(v)&&(o.setAttribute("content",v.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),n(c,"maximum-scale=5 restored","serious",o))}if(c==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),c==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),n(c,'alt="" aria-hidden="true"',"serious",o))),c==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!s.querySelector("title")&&(o.setAttribute("aria-hidden","true"),n(c,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),c==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),n(c,"title + aria-label added","serious",o)),c==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let u=o.getAttribute("title")||"button";o.setAttribute("aria-label",u),n(c,`aria-label="${u}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(c==="a"){let u=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),n(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(je.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let v=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",v),n(c,`aria-label="${v}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let v=u.name||"";u.type==="email"||v.includes("email")?u.autocomplete="email":u.type==="tel"||v.includes("tel")?u.autocomplete="tel":u.type==="password"&&(u.autocomplete="current-password"),t.fixed++}}c==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),n(c,"scope added to <th>","moderate",o)),he[c]&&!o.getAttribute("role")&&(o.setAttribute("role",he[c]),n(c,`role="${he[c]}"`,"minor",o));let g=o.getAttribute("role")||"";g==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(g)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",g==="alert"?"assertive":"polite"),n(c,`aria-live added on role=${g}`,"moderate",o)),g==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),n(c,'aria-expanded="false" on combobox',"serious",o)),(g==="checkbox"||g==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),n(c,`aria-checked="false" on role=${g}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-a).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),a=document.querySelectorAll("*");e.scanned=a.length;let i=(n,s,o,c)=>e.details.push({tag:n,fix:s,severity:o,element:c.outerHTML.slice(0,100)});return a.forEach(n=>{let s=n,o=s.tagName.toLowerCase();(o==="a"||o==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&i(o,"needs aria-label (empty)","critical",s),o==="img"&&!s.hasAttribute("alt")&&i(o,"needs alt text","serious",s),je.has(o)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&i(o,"needs aria-label","serious",s),o==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&i(o,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=Qe(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:f,speak:we,showVisualAlert:Ze,trapFocus:ie,handlePlainEnglish:Ke,handleSummarisePage:Ye,handleTranslate:Ue,handleVoiceControl:Je,handleSmartLabels:Xe,SUPPORTED_LANGUAGES:ee};var m=Me(require("react"));var A=require("react");ke();var nt=null,ot=null,O=!1,Ae=!1;async function Gt(){if(!Ae){if(O){for(;O;)await new Promise(e=>setTimeout(e,200));return}O=!0;try{let{pipeline:e}=await import("@huggingface/transformers");nt=await e("feature-extraction","Xenova/all-MiniLM-L6-v2",{device:"webgpu"}),ot=await e("question-answering","Xenova/distilbert-base-cased-distilled-squad",{device:"webgpu"}),Ae=!0,O=!1,console.log("yuktai: Transformers.js models loaded \u2705")}catch(e){throw O=!1,console.error("yuktai: Transformers.js model load failed",e),e}}}function Dt(){return new Promise(e=>{let t=setTimeout(e,1500),a=new MutationObserver(()=>{clearTimeout(t),t=setTimeout(()=>{a.disconnect(),e()},500)});a.observe(document.body,{childList:!0,subtree:!0})})}function _t(){let e=[],t=document.querySelectorAll("*");for(let a of t){if(a.closest("[data-yuktai-panel]"))continue;let i=a.innerText?.trim();i&&i.length>30&&e.push(i);let n=a.getAttribute("aria-label");n&&n.length>10&&e.push(n),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&a.placeholder&&e.push(a.placeholder)}return e.join(" ").slice(0,8e3)}function Vt(e,t=200,a=50){let i=e.split(/\s+/),n=[];for(let s=0;s<i.length;s+=t-a){let o=i.slice(s,s+t).join(" ");o.trim().length>20&&n.push(o)}return n}function jt(e,t){let a=0,i=0,n=0;for(let s=0;s<e.length;s++)a+=e[s]*t[s],i+=e[s]*e[s],n+=t[s]*t[s];return a/(Math.sqrt(i)*Math.sqrt(n)+1e-8)}async function at(e){let t=await nt(e,{pooling:"mean",normalize:!0});return Array.from(t.data)}async function Kt(e,t,a=3){let i=await at(e),n=await Promise.all(t.map(async s=>{let o=await at(s),c=jt(i,o);return{chunk:s,score:c}}));return n.sort((s,o)=>o.score-s.score),n.slice(0,a).map(s=>s.chunk)}async function it(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{await Gt(),await Dt();let t=_t();if(!t||t.length<50)return{success:!1,answer:"",error:"Not enough content on this page to answer from."};let a=Vt(t);if(a.length===0)return{success:!1,answer:"",error:"Could not process page content."};let n=(await Kt(e,a,3)).join(" ... "),s=await ot({question:e,context:n});return!s?.answer||s.answer.trim().length===0?{success:!0,answer:"I could not find a specific answer on this page."}:{success:!0,answer:s.answer.trim()}}catch(t){return console.error("yuktai: Transformers RAG error",t),{success:!1,answer:"",error:t instanceof Error?t.message:"Transformers.js error \u2014 please try again."}}}function rt(){try{return typeof WebAssembly<"u"&&typeof Worker<"u"}catch{return!1}}function st(){return Ae?"ready":O?"loading":"idle"}var r=require("react/jsx-runtime"),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},q=[80,90,100,110,120,130],Yt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],Ut=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function Jt(){let[e,t]=(0,A.useState)(typeof window<"u"?window.innerWidth:1024);return(0,A.useEffect)(()=>{let a=()=>t(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function Xt({checked:e,onChange:t,label:a,disabled:i=!1}){return(0,r.jsxs)("label",{"aria-label":a,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:i?"not-allowed":"pointer",flexShrink:0,opacity:i?.4:1},children:[(0,r.jsx)("input",{type:"checkbox",checked:e,disabled:i,onChange:n=>t(n.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,r.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,r.jsx)("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function G({label:e,color:t="#64748b",badge:a,concept:i}){return(0,r.jsxs)("div",{style:{margin:"10px 18px 4px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),a&&(0,r.jsx)("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:a})]}),i&&(0,r.jsx)("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8",fontStyle:"italic"},children:i})]})}function M({icon:e,label:t,desc:a,checked:i,onChange:n,disabled:s=!1,disabledReason:o,tip:c}){return(0,r.jsxs)("div",{title:s?o:c,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:"32px",height:"32px",borderRadius:"8px",background:s?"#f1f5f9":"#f0fdfa",color:s?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"15px",flexShrink:0,fontWeight:700},children:e}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:s?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),(0,r.jsx)("p",{style:{margin:0,fontSize:"10px",color:"#94a3b8"},children:s?o:a})]})]}),(0,r.jsx)(Xt,{checked:i,onChange:n,label:`Toggle ${t}`,disabled:s})]})}function k(){return(0,r.jsx)("div",{style:{height:"1px",background:"#f1f5f9"}})}function j({steps:e}){return(0,r.jsxs)("div",{style:{margin:"0 18px 8px",padding:"8px 10px",background:"#f8fafc",borderRadius:"8px",border:"0.5px solid #e2e8f0"},children:[(0,r.jsx)("p",{style:{margin:"0 0 4px",fontSize:"9px",fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.05em"},children:"How to use"}),e.map((t,a)=>(0,r.jsxs)("p",{style:{margin:"0 0 2px",fontSize:"10px",color:"#475569"},children:[a+1,". ",t]},a))]})}var Te=(0,A.forwardRef)(({position:e,settings:t,report:a,isActive:i,aiSupported:n,voiceSupported:s,set:o,onApply:c,onReset:g,onClose:u},v)=>{let{isMobile:x,isTablet:E}=Jt(),[U,se]=(0,A.useState)([]),[R,W]=(0,A.useState)(""),[z,P]=(0,A.useState)(""),[w,D]=(0,A.useState)(!1),[p,H]=(0,A.useState)(null),[C,F]=(0,A.useState)("idle");(0,A.useEffect)(()=>{let l=window;!!(l.LanguageModel||l.ai?.languageModel)&&n?H("gemini"):rt()&&H("transformers")},[n]),(0,A.useEffect)(()=>{if(p!=="transformers")return;let l=setInterval(()=>{F(st())},500);return()=>clearInterval(l)},[p]);let _=async()=>{if(!(!R.trim()||w)){if(!p){P("\u26A0\uFE0F No AI engine available on this device.");return}D(!0),P("");try{let l;p==="gemini"?l=await ve(R):(F("loading"),l=await it(R),F("ready")),P(l.success&&l.answer?l.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(l.error||"No answer found on this page"))}catch{P("\u26A0\uFE0F Failed to get answer. Please try again.")}D(!1)}};(0,A.useEffect)(()=>{(async()=>{try{let V=window;if(!V.queryLocalFonts)return;let de=await V.queryLocalFonts(),d=[...new Set(de.map(h=>h.family))].sort();se(d.slice(0,50))}catch{}})()},[]);let J=p==="gemini"?"Gemini Nano":p==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",le=p==="transformers"&&C==="loading"?"Loading AI model... (first time only)":"...",ce=x?{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:E?"300px":"320px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",maxHeight:"80vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif"};return(0,r.jsxs)("div",{ref:v,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:ce,children:[(0,r.jsxs)("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between",position:"sticky",top:0,background:"#fff",zIndex:1},children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"7px",marginBottom:"4px",flexWrap:"wrap"},children:[(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v2.1.0"}),i&&(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),(0,r.jsx)("p",{style:{margin:"0 0 1px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost \xB7 All devices"})]}),(0,r.jsx)("button",{onClick:u,"aria-label":"Close accessibility panel",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#94a3b8",fontSize:"20px",lineHeight:1,borderRadius:"6px",flexShrink:0,minWidth:x?"44px":"auto",minHeight:x?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,r.jsx)(G,{label:"\u267F Core Accessibility",concept:"Rule-based engine \u2014 works on all browsers and devices"}),(0,r.jsx)(j,{steps:["Toggle any feature on","Click Apply settings","Preferences saved automatically"]}),(0,r.jsx)(M,{icon:"\u{1F527}",label:"Auto-fix ARIA",desc:"Injects missing labels and roles automatically",checked:t.autoFix,onChange:l=>o("autoFix",l),tip:"Fixes aria-label, alt text, roles on every element"}),(0,r.jsx)(k,{}),(0,r.jsx)(M,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud as you tab",checked:t.speechEnabled,onChange:l=>o("speechEnabled",l),tip:"Uses browser SpeechSynthesis \u2014 no install needed"}),(0,r.jsx)(k,{}),(0,r.jsx)(M,{icon:"\u{1F399}\uFE0F",label:"Voice control",desc:"Say commands to navigate the page",checked:t.voiceControl,onChange:l=>o("voiceControl",l),disabled:!s,disabledReason:"Not supported in this browser",tip:'Say "scroll down", "go to main", "click"'}),(0,r.jsx)(k,{}),(0,r.jsx)(G,{label:"\u{1F916} AI Features",color:"#7c3aed",badge:"Gemini Nano",concept:"Large Language Model running privately on your device \u2014 Chrome 127+ only"}),(0,r.jsx)("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:n?"#f0fdfa":"#f5f3ff",borderRadius:"8px",border:`0.5px solid ${n?"#99f6e4":"#c4b5fd"}`,fontSize:"10px",color:n?"#0f766e":"#7c3aed",lineHeight:1.5},children:n?"\u2705 Gemini Nano detected \u2014 AI features ready. Runs privately on your device.":"\u2699\uFE0F AI features need one-time setup \u2014 see guide below."}),!n&&(0,r.jsxs)("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[(0,r.jsx)("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} One-time setup \u2014 5 steps:"}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome \u2192 ",(0,r.jsx)("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),(0,r.jsx)("p",{style:{margin:"0 0 3px"},children:"2. Enable each flag:"}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:Ut.map(l=>(0,r.jsxs)("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",l]},l))}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["3. Click ",(0,r.jsx)("strong",{style:{color:"#0f172a"},children:"Relaunch"})]}),(0,r.jsxs)("p",{style:{margin:"0 0 3px"},children:["4. ",(0,r.jsx)("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://components"})," \u2192 Optimization Guide On Device Model \u2192 Check for update"]}),(0,r.jsx)("p",{style:{margin:"0"},children:"5. Refresh \u2014 AI features unlock automatically \u2705"})]}),(0,r.jsx)(M,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Rewrites complex text in simple language",checked:t.plainEnglish,onChange:l=>o("plainEnglish",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: LLM text rewriting"}),(0,r.jsx)(k,{}),(0,r.jsx)(M,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary appears at top",checked:t.summarisePage,onChange:l=>o("summarisePage",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Abstractive summarisation"}),(0,r.jsx)(k,{}),(0,r.jsx)(M,{icon:"\u{1F3F7}\uFE0F",label:"Smart aria-labels",desc:"AI generates meaningful labels for elements",checked:t.smartLabels,onChange:l=>o("smartLabels",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Context-aware label generation"}),(0,r.jsx)(k,{}),(0,r.jsx)(G,{label:"\u{1F441}\uFE0F Visual",concept:"CSS filter-based \u2014 works on all browsers and devices"}),(0,r.jsx)(j,{steps:["Toggle any visual mode","Changes apply instantly","Works on mobile and desktop"]}),(0,r.jsx)(M,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision users",checked:t.highContrast,onChange:l=>o("highContrast",l),tip:"CSS filter: contrast()"}),(0,r.jsx)(k,{}),(0,r.jsx)(M,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours \u2014 easy on eyes at night",checked:t.darkMode,onChange:l=>o("darkMode",l),tip:"CSS filter: invert + hue-rotate"}),(0,r.jsx)(k,{}),(0,r.jsx)(M,{icon:"\u23F8\uFE0F",label:"Reduce motion",desc:"Disables all animations",checked:t.reduceMotion,onChange:l=>o("reduceMotion",l),tip:"WCAG 2.3.3 \u2014 vestibular disorders"}),(0,r.jsx)(k,{}),(0,r.jsx)(M,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>o("largeTargets",l),tip:"WCAG 2.5.8 \u2014 motor impaired users"}),(0,r.jsx)(k,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 2px",fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"10px",color:"#94a3b8"},children:"SVG colour matrix filters \u2014 all devices"}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Yt.map(l=>(0,r.jsx)("button",{onClick:()=>o("colorBlindMode",l.value),"aria-pressed":t.colorBlindMode===l.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===l.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===l.value?"#f0fdfa":"#fff",color:t.colorBlindMode===l.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:x?"36px":"auto"},children:l.label},l.value))})]}),(0,r.jsx)(k,{}),(0,r.jsx)(G,{label:"\u{1F524} Font",concept:"Browser Font API + CSS \u2014 Chrome 103+"}),(0,r.jsx)(j,{steps:["Toggle dyslexia font or pick from device","Adjust size with + / \u2212","Saved across visits"]}),(0,r.jsx)(M,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible \u2014 research-backed",checked:t.dyslexiaFont,onChange:l=>o("dyslexiaFont",l),tip:"By Braille Institute \u2014 free and open source"}),(0,r.jsx)(k,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px"},children:[(0,r.jsx)("p",{style:{margin:"0 0 2px",fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F5A5}\uFE0F Local font"}),(0,r.jsx)("p",{style:{margin:"0 0 8px",fontSize:"10px",color:"#94a3b8"},children:"window.queryLocalFonts() \u2014 Chrome 103+"}),U.length>0?(0,r.jsxs)("select",{value:t.localFont,onChange:l=>o("localFont",l.target.value),"aria-label":"Choose a font from your device",style:{width:"100%",padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"13px",color:"#0f172a",background:"#fff",cursor:"pointer",height:x?"44px":"36px"},children:[(0,r.jsx)("option",{value:"",children:"System default"}),U.map(l=>(0,r.jsx)("option",{value:l,style:{fontFamily:l},children:l},l))]}):(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Allow font access when Chrome prompts you."})]}),(0,r.jsx)(k,{}),(0,r.jsxs)("div",{style:{padding:"10px 18px 14px"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{style:{margin:0,fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F4CF} Text size"}),(0,r.jsx)("p",{style:{margin:0,fontSize:"10px",color:"#94a3b8"},children:"Scales all text on the page"})]}),(0,r.jsxs)("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,r.jsx)("button",{onClick:()=>{let l=q.indexOf(t.fontScale);l>0&&o("fontScale",q[l-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:x?"44px":"30px",height:x?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale<=80?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),(0,r.jsx)("div",{style:{flex:1,display:"flex",gap:"3px"},children:q.map(l=>(0,r.jsx)("button",{onClick:()=>o("fontScale",l),"aria-label":`Set text size to ${l}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:l<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},l))}),(0,r.jsx)("button",{onClick:()=>{let l=q.indexOf(t.fontScale);l<q.length-1&&o("fontScale",q[l+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:x?"44px":"30px",height:x?"44px":"30px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",cursor:t.fontScale>=130?"not-allowed":"pointer",fontSize:"16px",color:t.fontScale>=130?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),(0,r.jsx)(k,{}),(0,r.jsx)(G,{label:"\u{1F310} Translate",color:"#7c3aed",badge:"Gemini Nano",concept:"Chrome Translation API \u2014 on device, no internet after setup"}),(0,r.jsx)(j,{steps:["Enable Gemini Nano first","Pick your language","Full page translates instantly"]}),(0,r.jsxs)("div",{style:{padding:"6px 18px 12px"},children:[(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ee.slice(0,x?8:18).map(l=>(0,r.jsx)("button",{onClick:()=>o("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!n,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===l.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===l.code?"#f5f3ff":"#fff",color:t.translateLanguage===l.code?"#7c3aed":"#64748b",cursor:n?"pointer":"not-allowed",opacity:n?1:.5,minHeight:x?"36px":"auto"},children:l.label},l.code))}),!n&&(0,r.jsx)("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above."})]}),(0,r.jsx)(k,{}),(0,r.jsx)(G,{label:"\u{1F4AC} Ask This Page",color:"#0d9488",badge:J,concept:"RAG \u2014 Retrieval Augmented Generation. Works on all devices including mobile."}),(0,r.jsx)(j,{steps:["Type any question about this page","Press Ask or hit Enter",p==="transformers"?"Transformers.js answers \u2014 works on mobile, offline":"Gemini Nano reads page and answers privately","Zero cost. No data leaves your device."]}),(0,r.jsxs)("div",{style:{margin:"0 18px 8px",padding:"6px 10px",background:p==="gemini"?"#f0fdfa":p==="transformers"?"#f5f3ff":"#f8fafc",borderRadius:"8px",border:`0.5px solid ${p==="gemini"?"#99f6e4":p==="transformers"?"#c4b5fd":"#e2e8f0"}`,fontSize:"10px",color:p==="gemini"?"#0f766e":p==="transformers"?"#7c3aed":"#94a3b8"},children:[p==="gemini"&&"\u2705 Using Gemini Nano \u2014 on device, private, instant",p==="transformers"&&"\u2705 Using Transformers.js \u2014 works on mobile and all browsers",!p&&"\u23F3 Detecting AI engine...",p==="transformers"&&C==="loading"&&" \xB7 Loading model...",p==="transformers"&&C==="ready"&&" \xB7 Model ready \u2705"]}),(0,r.jsxs)("div",{style:{padding:"0 18px 14px"},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[(0,r.jsx)("input",{type:"text",value:R,onChange:l=>W(l.target.value),onKeyDown:l=>{l.key==="Enter"&&_()},placeholder:"e.g. What does this page do?",disabled:w||!p,"aria-label":"Ask a question about this page",style:{flex:1,padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px",color:"#0f172a",background:p?"#fff":"#f8fafc",outline:"none",height:x?"44px":"36px"}}),(0,r.jsx)("button",{onClick:_,disabled:w||!R.trim()||!p,"aria-label":"Ask question",style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:p&&R.trim()&&!w?"#0d9488":"#e2e8f0",color:p&&R.trim()&&!w?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:p&&R.trim()&&!w?"pointer":"not-allowed",flexShrink:0,height:x?"44px":"36px",minWidth:"52px",transition:"background 0.2s"},children:w?le:"Ask"})]}),z&&(0,r.jsxs)("div",{role:"status","aria-live":"polite",style:{padding:"10px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:"8px",fontSize:"12px",color:"#0f766e",lineHeight:1.6,maxHeight:"180px",overflowY:"auto"},children:[(0,r.jsx)("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#0d9488"},children:"\u{1F4AC} Answer"}),z,(0,r.jsx)("button",{onClick:()=>{P(""),W("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]})]}),a&&(0,r.jsx)("div",{role:"status",style:{margin:"0 14px 10px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:"8px",fontSize:"12px",color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:a.fixed>0?`\u2713 ${a.fixed} fixes \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms \xB7 Score: ${a.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${a.scanned} nodes \xB7 ${a.renderTime}ms`}),(0,r.jsxs)("div",{style:{display:"flex",gap:"8px",padding:"12px 14px 14px",position:x?"sticky":"relative",bottom:x?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[(0,r.jsx)("button",{onClick:g,style:{flex:1,padding:x?"12px 0":"8px 0",fontSize:"13px",fontWeight:500,borderRadius:"9px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),(0,r.jsx)("button",{onClick:c,style:{flex:2,padding:x?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});Te.displayName="WidgetPanel";var y=require("react/jsx-runtime");async function Qt(){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 re({position:e="left",children:t,config:a={},showRag:i=!1}){let[n,s]=(0,m.useState)(!1),[o,c]=(0,m.useState)(Se),[g,u]=(0,m.useState)(null),[v,x]=(0,m.useState)(!1),[E,U]=(0,m.useState)(!1),[se,R]=(0,m.useState)(!1),W=m.default.useRef(null),[z,P]=(0,m.useState)(!1),[w,D]=(0,m.useState)(""),[p,H]=(0,m.useState)(""),[C,F]=(0,m.useState)(!1),_=(0,m.useCallback)(async()=>{if(!(!w.trim()||C||!E)){F(!0),H("");try{let{askPage:d}=await Promise.resolve().then(()=>(ke(),tt)),h=await d(w);H(h.success?h.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(h.error||"No answer found."))}catch{H("\u26A0\uFE0F Something went wrong.")}F(!1)}},[w,C,E]);(0,m.useEffect)(()=>{if(typeof window>"u")return;let h=setTimeout(async()=>{let S=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.ai =",S.ai),console.log("yuktai: window.LanguageModel =",S.LanguageModel),console.log("yuktai: window.Summarizer =",S.Summarizer),console.log("yuktai: window.Rewriter =",S.Rewriter),console.log("yuktai: window.Writer =",S.Writer);let Ee=await Qt();U(Ee),Ee?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 ct=!!(S.SpeechRecognition||S.webkitSpeechRecognition);R(ct)},800);return()=>clearTimeout(h)},[]),(0,m.useEffect)(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");if(d){let h=JSON.parse(d);c(S=>({...S,...h}))}}catch{}},[]);let J=(0,m.useCallback)(async d=>{let h={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 T.execute(h);let S=T.applyFixes(h);u(S),x(!0)},[a]),le=(0,m.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(o))}catch{}await J(o),s(!1)},[o,J]),ce=(0,m.useCallback)(()=>{c(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(h=>d.removeAttribute(h)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",u(null),x(!1)},[]),l=(0,m.useCallback)((d,h)=>{c(S=>({...S,[d]:h}))},[]);(0,m.useEffect)(()=>{let d=h=>{h.key==="Escape"&&(n&&s(!1),z&&P(!1))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,z]),(0,m.useEffect)(()=>{n&&W.current&&T.trapFocus(W.current)},[n]);let V={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:v?"#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"},de={position:"fixed",bottom:"84px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:z?"#7c3aed":"#6d28d9",color:"#fff",border:"none",cursor:"pointer",fontSize:"22px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(0,0,0,0.25)",transition:"transform 0.15s, background 0.2s"};return(0,y.jsxs)(y.Fragment,{children:[t,i&&(0,y.jsx)("button",{style:de,"aria-label":"Ask a question about this page","aria-haspopup":"dialog","aria-expanded":z,onClick:()=>{P(d=>!d),s(!1)},onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u{1F4AC}"}),i&&z&&(0,y.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Ask this page","data-yuktai-panel":"true",style:{position:"fixed",bottom:"148px",[e]:"24px",zIndex:9999,width:"300px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",fontFamily:"system-ui,-apple-system,sans-serif",padding:"14px"},children:[(0,y.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"10px"},children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:600,color:"#0f172a"},children:"\u{1F4AC} Ask this page"}),(0,y.jsx)("p",{style:{margin:0,fontSize:"10px",color:"#7c3aed"},children:"Gemini Nano \xB7 On device \xB7 Zero cost"})]}),(0,y.jsx)("button",{onClick:()=>P(!1),"aria-label":"Close ask panel",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",lineHeight:1,padding:"2px",borderRadius:"4px"},children:"\xD7"})]}),(0,y.jsxs)("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[(0,y.jsx)("input",{type:"text",value:w,onChange:d=>D(d.target.value),onKeyDown:d=>{d.key==="Enter"&&_()},placeholder:"e.g. What does this page do?",disabled:!E||C,"aria-label":"Ask a question about this page",style:{flex:1,padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px",color:"#0f172a",background:E?"#fff":"#f8fafc",outline:"none",height:"36px"}}),(0,y.jsx)("button",{onClick:_,disabled:!E||C||!w.trim(),"aria-label":"Submit question",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:E&&w.trim()&&!C?"#7c3aed":"#e2e8f0",color:E&&w.trim()&&!C?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:E&&w.trim()&&!C?"pointer":"not-allowed",height:"36px",minWidth:"48px",transition:"background 0.2s"},children:C?"...":"Ask"})]}),p&&(0,y.jsxs)("div",{style:{padding:"10px",background:"#f5f3ff",borderRadius:"8px",fontSize:"12px",color:"#4c1d95",lineHeight:1.6,maxHeight:"180px",overflowY:"auto"},children:[(0,y.jsx)("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#7c3aed"},children:"\u{1F4AC} Answer"}),p,(0,y.jsx)("button",{onClick:()=>{H(""),D("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!E&&(0,y.jsx)("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano via chrome://flags to use this feature."})]}),(0,y.jsx)("button",{style:V,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":n,"data-yuktai-pref-toggle":"true",onClick:()=>{s(d=>!d),P(!1)},onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),n&&(0,y.jsx)(Te,{ref:W,position:e,settings:o,report:g,isActive:v,aiSupported:E,voiceSupported:se,set:l,onApply:le,onReset:ce,onClose:()=>s(!1)})]})}var K={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var Y={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var I=class{plugins=new Map;register(t,a){if(!a||typeof a.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,a)}use(t){return this.plugins.get(t)}async run(t,a){try{let i=this.use(t);if(!i)throw new Error(`Plugin not found: ${t}`);return await i.execute(a)}catch(i){throw console.error(`[YuktAI Runtime Error in ${t}]:`,i),i}}getPlugins(){return Array.from(this.plugins.keys())}};function Zt(){if(typeof globalThis>"u")return new I;if(!globalThis.__yuktai_runtime__){let e=new I;e.register(T.name,T),e.register(K.name,K),e.register(Y.name,Y),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var lt=typeof window<"u"?Zt():new I,ea={wcagPlugin:T,list(){return lt.getPlugins()},use(e){return lt.use(e)},fix(e){return T.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return T.scan()}};0&&(module.exports={Runtime,YuktAI,YuktAIWrapper,aiPlugin,voicePlugin,wcag,wcagPlugin});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function ee(){try{let e=fe();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 Ge(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=fe();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),i=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:i.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function me(){if(!await ee())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let i of t){let n=i.innerText?.trim();if(!n||n.length<20||i.closest("[data-yuktai-panel]"))continue;let l=await Ge(n);l.success&&l.rewritten!==n&&(i.dataset.yuktaiOriginal=n,i.innerText=l.rewritten,a++)}return{fixed:a}}function be(){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 ge="yuktai-summary-box";function ye(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function te(){try{let e=ye();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 Ve(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(a);if(i.display==="none"||i.visibility==="hidden")continue;let n=a.innerText?.trim();n&&n.length>10&&t.push(n)}return t.join(" ").slice(0,5e3)}async function xe(){if(!await te())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=Ve();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=ye();if(!a)throw new Error("Summarizer API not available");let i=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),n=await i.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return i.destroy(),je(n.trim()),{success:!0,summary:n.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function je(e){B();let t=document.createElement("div");t.id=ge,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
1
+ import{a as Me}from"./chunk-56MYCLBI.mjs";function Re(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function me(){try{let e=Re();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 ct(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=Re();if(!t)throw new Error("Rewriter API not available");let a=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),i=await a.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return a.destroy(),{success:!0,original:e,rewritten:i.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function Pe(){if(!await me())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),a=0;for(let i of t){let n=i.innerText?.trim();if(!n||n.length<20||i.closest("[data-yuktai-panel]"))continue;let r=await ct(n);r.success&&r.rewritten!==n&&(i.dataset.yuktaiOriginal=n,i.innerText=r.rewritten,a++)}return{fixed:a}}function ze(){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 Ie="yuktai-summary-box";function We(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function ge(){try{let e=We();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 dt(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let a of e){if(a.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(a);if(i.display==="none"||i.visibility==="hidden")continue;let n=a.innerText?.trim();n&&n.length>10&&t.push(n)}return t.join(" ").slice(0,5e3)}async function He(){if(!await ge())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=dt();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let a=We();if(!a)throw new Error("Summarizer API not available");let i=await a.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),n=await i.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return i.destroy(),ut(n.trim()),{success:!0,summary:n.trim()}}catch(a){return{success:!1,summary:"",error:a instanceof Error?a.message:"Summary failed"}}}function ut(e){Q();let t=document.createElement("div");t.id=Ie,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -19,7 +19,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
19
19
  background: none; border: none; color: #ffffff;
20
20
  font-size: 20px; cursor: pointer; padding: 0 4px;
21
21
  line-height: 1; flex-shrink: 0;
22
- `,i.addEventListener("click",B),t.appendChild(a),t.appendChild(i),document.body.prepend(t)}function B(){let e=document.getElementById(ge);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"}],O="en";function Ke(){let e=window;return e.Translator||e.translation||null}async function Ye(e){try{let t=window;if(!Ke())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let i=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return i==="readily"||i==="available"||i==="downloadable"||i==="after-download"}catch{}return t.Translator&&typeof t.Translator.canTranslate=="function"?await t.Translator.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":t.translation&&typeof t.translation.canTranslate=="function"?await t.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function Ue(e){let t=window,a={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(a);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(a);throw new Error("Translation API not available")}async function he(e){if(e===O)return{success:!0,language:e,fixed:0};if(e==="en")return ae(),O="en",{success:!0,language:"en",fixed:0};if(!await Ye(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let a=await Ue(e),i=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),n=0;for(let l of i){if(l.closest("[data-yuktai-panel]")||l.children.length>0)continue;let o=l.innerText?.trim();if(!o||o.length<2)continue;l.dataset.yuktaiTranslationOriginal||(l.dataset.yuktaiTranslationOriginal=o);let c=await a.translate(o);c&&c!==o&&(l.innerText=c,n++)}return typeof a.destroy=="function"&&a.destroy(),O=e,{success:!0,language:e,fixed:n}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function ae(){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)}O="en"}var Je=[{phrases:["go to main","skip to main","main content"],action:"focus-main",label:"Jump to main content"},{phrases:["go to navigation","go to nav","open menu"],action:"focus-nav",label:"Jump to navigation"},{phrases:["go to search","search","find"],action:"focus-search",label:"Jump to search"},{phrases:["scroll down","page down","next"],action:"scroll-down",label:"Scroll down"},{phrases:["scroll up","page up","back up"],action:"scroll-up",label:"Scroll up"},{phrases:["go back","previous page"],action:"go-back",label:"Go back"},{phrases:["click","press","select"],action:"click-focused",label:"Click focused element"},{phrases:["next item","tab forward","tab"],action:"tab-forward",label:"Move to next element"},{phrases:["previous item","tab back","shift tab"],action:"tab-back",label:"Move to previous element"},{phrases:["stop listening","stop voice","quiet"],action:"stop-voice",label:"Stop voice control"}],w=null,D=!1,C=null;function oe(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function Xe(e){let t=e.toLowerCase().trim();for(let a of Je)for(let i of a.phrases)if(t.includes(i))return{action:a.action,label:a.label};return null}function Qe(e){switch(e){case"focus-main":{let t=document.querySelector("main, [role='main'], #main");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-nav":{let t=document.querySelector("nav, [role='navigation']");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"focus-search":{let t=document.querySelector("input[type='search'], input[role='searchbox'], [aria-label*='search' i]");t&&(t.focus(),t.scrollIntoView({behavior:"smooth"}));break}case"scroll-down":{window.scrollBy({top:400,behavior:"smooth"});break}case"scroll-up":{window.scrollBy({top:-400,behavior:"smooth"});break}case"go-back":{window.history.back();break}case"click-focused":{let t=document.activeElement;t&&t!==document.body&&t.click();break}case"tab-forward":{let t=we(),a=t.indexOf(document.activeElement),i=t[a+1]||t[0];i&&i.focus();break}case"tab-back":{let t=we(),a=t.indexOf(document.activeElement),i=t[a-1]||t[t.length-1];i&&i.focus();break}case"stop-voice":{ne();break}}}function we(){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 ve(e){if(!oe())return!1;if(D)return!0;e&&(C=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return w=new t,w.continuous=!0,w.interimResults=!1,w.lang="en-US",w.onresult=a=>{let i=a.results[a.results.length-1][0].transcript,n=Xe(i);if(n){Qe(n.action);let l={success:!0,command:i,action:n.label};if(C&&C(l),n.action==="stop-voice")return}},w.onend=()=>{D&&w?.start()},w.onerror=a=>{a.error!=="no-speech"&&C&&C({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},w.start(),D=!0,Ze(),!0}function ne(){D=!1,w&&(w.stop(),w=null),C=null,Ae()}var ke="yuktai-voice-indicator";function Ze(){Ae();let e=document.createElement("div");e.id=ke,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
22
+ `,i.addEventListener("click",Q),t.appendChild(a),t.appendChild(i),document.body.prepend(t)}function Q(){let e=document.getElementById(Ie);e&&e.remove()}var ee=[{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"}],Z="en";function pt(){let e=window;return e.Translator||e.translation||null}async function ft(e){try{let t=window;if(!pt())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let i=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return i==="readily"||i==="available"||i==="downloadable"||i==="after-download"}catch{}return t.Translator&&typeof t.Translator.canTranslate=="function"?await t.Translator.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":t.translation&&typeof t.translation.canTranslate=="function"?await t.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function mt(e){let t=window,a={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(a);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(a);throw new Error("Translation API not available")}async function Fe(e){if(e===Z)return{success:!0,language:e,fixed:0};if(e==="en")return be(),Z="en",{success:!0,language:"en",fixed:0};if(!await ft(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let a=await mt(e),i=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),n=0;for(let r of i){if(r.closest("[data-yuktai-panel]")||r.children.length>0)continue;let o=r.innerText?.trim();if(!o||o.length<2)continue;r.dataset.yuktaiTranslationOriginal||(r.dataset.yuktaiTranslationOriginal=o);let c=await a.translate(o);c&&c!==o&&(r.innerText=c,n++)}return typeof a.destroy=="function"&&a.destroy(),Z=e,{success:!0,language:e,fixed:n}}catch(a){return{success:!1,language:e,fixed:0,error:a instanceof Error?a.message:"Translation failed"}}}function be(){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)}Z="en"}var gt=[{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"}],T=null,te=!1,B=null;function ye(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function bt(e){let t=e.toLowerCase().trim();for(let a of gt)for(let i of a.phrases)if(t.includes(i))return{action:a.action,label:a.label};return null}function yt(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=$e(),a=t.indexOf(document.activeElement),i=t[a+1]||t[0];i&&i.focus();break}case"tab-back":{let t=$e(),a=t.indexOf(document.activeElement),i=t[a-1]||t[t.length-1];i&&i.focus();break}case"stop-voice":{xe();break}}}function $e(){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 Be(e){if(!ye())return!1;if(te)return!0;e&&(B=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return T=new t,T.continuous=!0,T.interimResults=!1,T.lang="en-US",T.onresult=a=>{let i=a.results[a.results.length-1][0].transcript,n=bt(i);if(n){yt(n.action);let r={success:!0,command:i,action:n.label};if(B&&B(r),n.action==="stop-voice")return}},T.onend=()=>{te&&T?.start()},T.onerror=a=>{a.error!=="no-speech"&&B&&B({success:!1,command:"",action:"",error:`Voice error: ${a.error}`})},T.start(),te=!0,xt(),!0}function xe(){te=!1,T&&(T.stop(),T=null),B=null,Oe()}var Ne="yuktai-voice-indicator";function xt(){Oe();let e=document.createElement("div");e.id=Ne,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
23
23
  position: fixed;
24
24
  bottom: 80px;
25
25
  left: 50%;
@@ -49,7 +49,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
49
49
  0%, 100% { opacity: 1; transform: scale(1); }
50
50
  50% { opacity: 0.4; transform: scale(0.7); }
51
51
  }
52
- `,document.head.appendChild(i)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function Ae(){let e=document.getElementById(ke);e&&e.remove()}var et=["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 Se(){let e=window;return e.Writer||e.ai?.writer||null}async function ie(){try{let e=Se();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 tt(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let i=e.placeholder?.trim();i&&t.push(`placeholder: "${i}"`);let n=e.getAttribute("name")?.trim();n&&t.push(`name: "${n}"`);let l=e.getAttribute("type")?.trim();l&&t.push(`type: "${l}"`);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 at(e,t){let a=`
52
+ `,document.head.appendChild(i)}let a=document.createElement("span");a.textContent="Listening for commands...",e.appendChild(t),e.appendChild(a),document.body.appendChild(e)}function Oe(){let e=document.getElementById(Ne);e&&e.remove()}var ht=["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 qe(){let e=window;return e.Writer||e.ai?.writer||null}async function he(){try{let e=qe();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 wt(e){let t=[],a=e.innerText?.trim();a&&t.push(`element text: "${a}"`);let i=e.placeholder?.trim();i&&t.push(`placeholder: "${i}"`);let n=e.getAttribute("name")?.trim();n&&t.push(`name: "${n}"`);let r=e.getAttribute("type")?.trim();r&&t.push(`type: "${r}"`);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 g=e.getAttribute("role");return g&&t.push(`role: ${g}`),t.join(". ")}async function vt(e,t){let a=`
53
53
  Generate a short, clear aria-label for an HTML element.
54
54
  The label must be 2-6 words maximum.
55
55
  The label must describe what the element does or what it is.
@@ -60,7 +60,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
60
60
  ${t}
61
61
 
62
62
  Output only the label. Nothing else.
63
- `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Te(){if(!await ie())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(et);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=Se();if(!a)throw new Error("Writer API not available");let i=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),n=0,l=[];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=tt(o),u=await at(i,m);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),n++,l.push({tag:o.tagName.toLowerCase(),label:u}))}return i.destroy(),{success:!0,fixed:n,elements:l}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function Ee(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let a=t.dataset.yuktaiLabelOriginal;a?t.setAttribute("aria-label",a):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var V=null,Ce=null;var Le=null,re=null,b=null,L=null,q=null,se=null,M=null,G={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var Me=new Set(["input","select","textarea"]);var le={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function ce(e,t="polite"){if(typeof window>"u"||!M?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let i=window.speechSynthesis.getVoices();i.length>0&&(a.voice=i[0]),window.speechSynthesis.speak(a)}function Fe(e,t="info"){if(typeof document>"u")return;let i={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];b||(b=document.createElement("div"),b.setAttribute("role","alert"),b.setAttribute("aria-live","assertive"),b.setAttribute("aria-atomic","true"),b.style.cssText=`
63
+ `.trim();return(await e.write(a)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function De(){if(!await he())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(ht);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let a=qe();if(!a)throw new Error("Writer API not available");let i=await a.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),n=0,r=[];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 g=wt(o),u=await vt(i,g);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),n++,r.push({tag:o.tagName.toLowerCase(),label:u}))}return i.destroy(),{success:!0,fixed:n,elements:r}}catch(a){return{success:!1,fixed:0,elements:[],error:a instanceof Error?a.message:"Label generation failed"}}}function Ge(){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 ne=null,_e=null;var Ve=null,we=null,b=null,N=null,ae=null,ve=null,O=null,oe={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var je=new Set(["input","select","textarea"]);var ke={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function Ae(e,t="polite"){if(typeof window>"u"||!O?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.rate=1,a.pitch=1,a.volume=1;let i=window.speechSynthesis.getVoices();i.length>0&&(a.voice=i[0]),window.speechSynthesis.speak(a)}function Ze(e,t="info"){if(typeof document>"u")return;let i={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];b||(b=document.createElement("div"),b.setAttribute("role","alert"),b.setAttribute("aria-live","assertive"),b.setAttribute("aria-atomic","true"),b.style.cssText=`
64
64
  position: fixed;
65
65
  top: 80px;
66
66
  right: 16px;
@@ -86,7 +86,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
86
86
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
87
87
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
88
88
  aria-label="Close notification">\xD7</button>
89
- `,window.innerWidth<=480&&(b.style.right="8px",b.style.left="8px",b.style.maxWidth="none",b.style.width="auto"),requestAnimationFrame(()=>{b&&(b.style.transform="translateX(0)",b.style.opacity="1")}),setTimeout(()=>{b&&(b.style.transform="translateX(120%)",b.style.opacity="0")},5e3)}function f(e,t="info",a=!0){V&&(V.textContent=e),Fe(e,t),a&&ce(e,t==="error"?"assertive":"polite")}function ot(){if(typeof document>"u"||Le)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 m(e,t="info",a=!0){ne&&(ne.textContent=e),Ze(e,t),a&&Ae(e,t==="error"?"assertive":"polite")}function kt(){if(typeof document>"u"||Ve)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
90
90
  position: fixed;
91
91
  top: 0;
92
92
  left: 0;
@@ -100,7 +100,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
100
100
  transform: translateY(-100%);
101
101
  transition: transform 0.2s ease;
102
102
  font-family: system-ui, sans-serif;
103
- `;let a=!1;if(e.forEach(({label:n,selector:l})=>{let o=document.querySelector(l);if(!o)return;a=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let c=document.createElement("a");c.href="#",c.textContent=n,c.style.cssText=`
103
+ `;let a=!1;if(e.forEach(({label:n,selector:r})=>{let o=document.querySelector(r);if(!o)return;a=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let c=document.createElement("a");c.href="#",c.textContent=n,c.style.cssText=`
104
104
  color: #fff;
105
105
  background: #1a73e8;
106
106
  padding: 8px 14px;
@@ -111,7 +111,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
111
111
  white-space: nowrap;
112
112
  border: 2px solid transparent;
113
113
  transition: background 0.15s, border-color 0.15s;
114
- `,c.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),c.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),c.addEventListener("click",m=>{m.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),f(`Jumped to ${n.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!a)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Le=t}function nt(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
114
+ `,c.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),c.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),c.addEventListener("click",g=>{g.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),m(`Jumped to ${n.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!a)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Ve=t}function At(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
115
115
 
116
116
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
117
117
  [data-yuktai-a11y] *:focus-visible {
@@ -257,7 +257,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
257
257
  width: auto !important;
258
258
  }
259
259
  }
260
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function it(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let a=t.getAttribute("role")||"";if(e.key==="Escape"){let i=t.closest("[role='dialog'],[role='alertdialog']");if(i){i.style.display="none",f("Dialog closed","info");return}let n=t.closest("[role='menu'],[role='menubar']");n&&(n.style.display="none",f("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let i=t.closest("[role='menu'],[role='menubar']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='menuitem']:not([disabled])")),l=n.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),n[(l+1)%n.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),n[(l-1+n.length)%n.length]?.focus()):e.key==="Home"?(e.preventDefault(),n[0]?.focus()):e.key==="End"&&(e.preventDefault(),n[n.length-1]?.focus())}if(a==="tab"||t.closest("[role='tablist']")){let i=t.closest("[role='tablist']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='tab']:not([disabled])")),l=n.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=n[(l+1)%n.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=n[(l-1+n.length)%n.length];o?.focus(),o?.click()}}if(a==="option"||t.closest("[role='listbox']")){let i=t.closest("[role='listbox']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='option']:not([aria-disabled='true'])")),l=n.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),n[(l+1)%n.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),n[(l-1+n.length)%n.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),n.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),f(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),rt()),e.key==="Tab"&&M?.speechEnabled&&setTimeout(()=>{let i=document.activeElement;if(!i)return;let n=i.getAttribute("aria-label")||i.getAttribute("title")||i.textContent?.trim()||i.tagName.toLowerCase(),l=i.getAttribute("role")||i.tagName.toLowerCase();ce(`${n}, ${l}`)},100)}))}function j(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let a=t[0],i=t[t.length-1];a.focus(),e.addEventListener("keydown",n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===a&&(n.preventDefault(),i.focus()):document.activeElement===i&&(n.preventDefault(),a.focus()))})}function rt(){if(typeof document>"u")return;if(L){L.remove(),L=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
260
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function St(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let a=t.getAttribute("role")||"";if(e.key==="Escape"){let i=t.closest("[role='dialog'],[role='alertdialog']");if(i){i.style.display="none",m("Dialog closed","info");return}let n=t.closest("[role='menu'],[role='menubar']");n&&(n.style.display="none",m("Menu closed","info"))}if(a==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let i=t.closest("[role='menu'],[role='menubar']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='menuitem']:not([disabled])")),r=n.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),n[(r+1)%n.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),n[(r-1+n.length)%n.length]?.focus()):e.key==="Home"?(e.preventDefault(),n[0]?.focus()):e.key==="End"&&(e.preventDefault(),n[n.length-1]?.focus())}if(a==="tab"||t.closest("[role='tablist']")){let i=t.closest("[role='tablist']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='tab']:not([disabled])")),r=n.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=n[(r+1)%n.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=n[(r-1+n.length)%n.length];o?.focus(),o?.click()}}if(a==="option"||t.closest("[role='listbox']")){let i=t.closest("[role='listbox']");if(!i)return;let n=Array.from(i.querySelectorAll("[role='option']:not([aria-disabled='true'])")),r=n.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),n[(r+1)%n.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),n[(r-1+n.length)%n.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),n.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),m(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Tt()),e.key==="Tab"&&O?.speechEnabled&&setTimeout(()=>{let i=document.activeElement;if(!i)return;let n=i.getAttribute("aria-label")||i.getAttribute("title")||i.textContent?.trim()||i.tagName.toLowerCase(),r=i.getAttribute("role")||i.tagName.toLowerCase();Ae(`${n}, ${r}`)},100)}))}function ie(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let a=t[0],i=t[t.length-1];a.focus(),e.addEventListener("keydown",n=>{n.key==="Tab"&&(n.shiftKey?document.activeElement===a&&(n.preventDefault(),i.focus()):document.activeElement===i&&(n.preventDefault(),a.focus()))})}function Tt(){if(typeof document>"u")return;if(N){N.remove(),N=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
261
261
  position: fixed;
262
262
  top: 50%;
263
263
  left: 50%;
@@ -287,7 +287,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
287
287
  <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${n}</span>
288
288
  </div>
289
289
  `).join("")}
290
- `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),L=null}),e.addEventListener("keydown",i=>{i.key==="Escape"&&(e.remove(),L=null)}),document.body.appendChild(e),L=e,j(e),f("Keyboard shortcuts opened. Press Escape to close.","info")}function st(e){if(typeof document>"u"||!M?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;re&&re.remove();let t=e.score,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",i=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",n=document.createElement("button");n.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),n.setAttribute("data-yuktai-badge","true"),n.style.cssText=`
290
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),N=null}),e.addEventListener("keydown",i=>{i.key==="Escape"&&(e.remove(),N=null)}),document.body.appendChild(e),N=e,ie(e),m("Keyboard shortcuts opened. Press Escape to close.","info")}function Et(e){if(typeof document>"u"||!O?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;we&&we.remove();let t=e.score,a=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",i=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",n=document.createElement("button");n.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),n.setAttribute("data-yuktai-badge","true"),n.style.cssText=`
291
291
  position: fixed;
292
292
  bottom: 16px;
293
293
  left: 16px;
@@ -306,7 +306,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
306
306
  align-items: center;
307
307
  gap: 6px;
308
308
  transition: transform 0.15s;
309
- `,n.innerHTML=`${i} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,n.addEventListener("click",()=>lt(e)),document.body.appendChild(n),re=n}function lt(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let a=document.createElement("div");a.setAttribute("data-yuktai-audit-details","true"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","Accessibility audit details"),a.style.cssText=`
309
+ `,n.innerHTML=`${i} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,n.addEventListener("click",()=>Ct(e)),document.body.appendChild(n),we=n}function Ct(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let a=document.createElement("div");a.setAttribute("data-yuktai-audit-details","true"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","Accessibility audit details"),a.style.cssText=`
310
310
  position: fixed;
311
311
  bottom: 56px;
312
312
  left: 16px;
@@ -338,7 +338,7 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
338
338
  </div>
339
339
  `).join("")}
340
340
  ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
341
- `,a.addEventListener("keydown",n=>{n.key==="Escape"&&a.remove()}),document.body.appendChild(a),j(a)}function We(e){typeof document>"u"||(se&&clearTimeout(se),se=setTimeout(()=>{if(q)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
341
+ `,a.addEventListener("keydown",n=>{n.key==="Escape"&&a.remove()}),document.body.appendChild(a),ie(a)}function et(e){typeof document>"u"||(ve&&clearTimeout(ve),ve=setTimeout(()=>{if(ae)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
342
342
  position: fixed;
343
343
  top: 50%;
344
344
  left: 50%;
@@ -367,24 +367,19 @@ function fe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async functio
367
367
  No, sign out
368
368
  </button>
369
369
  </div>
370
- `;let a=t.querySelector("[data-yuktai-extend]"),i=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),q=null,f("Session extended. You have more time.","success"),M?.timeoutWarning&&We(M.timeoutWarning)}),i?.addEventListener("click",()=>{t.remove(),q=null}),document.body.appendChild(t),q=t,j(t),f("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function ct(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(#${G[e.colorBlindMode]})`;document.body.style.filter=a}else document.body.style.filter=""}function dt(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Re(e){if(e){if(!await ee()){f("Plain English requires Chrome 127+","warning");return}f("Rewriting page in plain English...","info",!1);let a=await me();f(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else be(),f("Original text restored","info",!1)}async function Pe(e){if(e){if(!await te()){f("Page summariser requires Chrome 127+","warning");return}f("Generating page summary...","info",!1);let a=await xe();f(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else B(),f("Page summary removed","info",!1)}async function Ie(e){if(e==="en"){ae(),f("Page restored to English","info",!1);return}f(`Translating page to ${e}...`,"info",!1);let t=await he(e);f(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function ze(e){if(e){if(!oe()){f("Voice control not supported in this browser","warning");return}ve(t=>{t.success&&f(`Voice: ${t.action}`,"info",!1)}),f("Voice control started. Say a command.","success",!1)}else ne(),f("Voice control stopped","info",!1)}async function He(e){if(e){if(!await ie()){f("Smart labels requires Chrome 127+","warning");return}f("Generating smart labels...","info",!1);let a=await Te();f(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else Ee(),f("Smart labels removed","info",!1)}function ut(){if(typeof document>"u"||V)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("aria-relevant","text"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);",document.body.appendChild(e),V=e}function pt(){if(typeof document>"u"||Ce)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
370
+ `;let a=t.querySelector("[data-yuktai-extend]"),i=t.querySelector("[data-yuktai-dismiss]");a?.addEventListener("click",()=>{t.remove(),ae=null,m("Session extended. You have more time.","success"),O?.timeoutWarning&&et(O.timeoutWarning)}),i?.addEventListener("click",()=>{t.remove(),ae=null}),document.body.appendChild(t),ae=t,ie(t),m("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function Lt(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(#${oe[e.colorBlindMode]})`;document.body.style.filter=a}else document.body.style.filter=""}function Mt(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function Ke(e){if(e){if(!await me()){m("Plain English requires Chrome 127+","warning");return}m("Rewriting page in plain English...","info",!1);let a=await Pe();m(a.error?`Plain English failed: ${a.error}`:`${a.fixed} sections rewritten in plain English`,a.error?"error":"success",!1)}else ze(),m("Original text restored","info",!1)}async function Ye(e){if(e){if(!await ge()){m("Page summariser requires Chrome 127+","warning");return}m("Generating page summary...","info",!1);let a=await He();m(a.error?`Summary failed: ${a.error}`:"Page summary added at top",a.error?"error":"success",!1)}else Q(),m("Page summary removed","info",!1)}async function Ue(e){if(e==="en"){be(),m("Page restored to English","info",!1);return}m(`Translating page to ${e}...`,"info",!1);let t=await Fe(e);m(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Je(e){if(e){if(!ye()){m("Voice control not supported in this browser","warning");return}Be(t=>{t.success&&m(`Voice: ${t.action}`,"info",!1)}),m("Voice control started. Say a command.","success",!1)}else xe(),m("Voice control stopped","info",!1)}async function Xe(e){if(e){if(!await he()){m("Smart labels requires Chrome 127+","warning");return}m("Generating smart labels...","info",!1);let a=await De();m(a.error?`Smart labels failed: ${a.error}`:`${a.fixed} elements labelled`,a.error?"error":"success",!1)}else Ge(),m("Smart labels removed","info",!1)}function Rt(){if(typeof document>"u"||ne)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),ne=e}function Pt(){if(typeof document>"u"||_e)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
371
371
  <defs>
372
- <filter id="${G.deuteranopia}">
372
+ <filter id="${oe.deuteranopia}">
373
373
  <feColorMatrix type="matrix"
374
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"/>
375
375
  </filter>
376
- <filter id="${G.protanopia}">
376
+ <filter id="${oe.protanopia}">
377
377
  <feColorMatrix type="matrix"
378
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"/>
379
379
  </filter>
380
- <filter id="${G.tritanopia}">
380
+ <filter id="${oe.tritanopia}">
381
381
  <feColorMatrix type="matrix"
382
382
  values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
383
383
  </filter>
384
384
  </defs>
385
- `,document.body.appendChild(e),Ce=e}function $e(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((i,n)=>i+(t[n.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var v={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";M=e,dt(e),ut(),pt(),nt(),it(),e.showSkipLinks!==!1&&ot(),e.showPreferencePanel,ct(e);let t=this.applyFixes(e);t.score=$e(t),e.showAuditBadge&&st(t),e.timeoutWarning&&We(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Re(!0),e.summarisePage&&await Pe(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Ie(e.translateLanguage),e.voiceControl&&await ze(!0),e.smartLabels&&await He(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return f(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let a=performance.now(),i=document.querySelectorAll("*");t.scanned=i.length;let n=(l,o,c,m)=>{t.details.push({tag:l,fix:o,severity:c,element:m.outerHTML.slice(0,100)}),t.fixed++};return i.forEach(l=>{let o=l,c=o.tagName.toLowerCase();if(c==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),n(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),y=o.getAttribute("content")||"";u==="viewport"&&y.includes("user-scalable=no")&&(o.setAttribute("content",y.replace("user-scalable=no","user-scalable=yes")),n(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(y)&&(o.setAttribute("content",y.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),n(c,"maximum-scale=5 restored","serious",o))}if(c==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),c==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),n(c,'alt="" aria-hidden="true"',"serious",o))),c==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!l.querySelector("title")&&(o.setAttribute("aria-hidden","true"),n(c,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),c==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),n(c,"title + aria-label added","serious",o)),c==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let u=o.getAttribute("title")||"button";o.setAttribute("aria-label",u),n(c,`aria-label="${u}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(c==="a"){let u=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),n(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(Me.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let y=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",y),n(c,`aria-label="${y}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let y=u.name||"";u.type==="email"||y.includes("email")?u.autocomplete="email":u.type==="tel"||y.includes("tel")?u.autocomplete="tel":u.type==="password"&&(u.autocomplete="current-password"),t.fixed++}}c==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),n(c,"scope added to <th>","moderate",o)),le[c]&&!o.getAttribute("role")&&(o.setAttribute("role",le[c]),n(c,`role="${le[c]}"`,"minor",o));let m=o.getAttribute("role")||"";m==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(m)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",m==="alert"?"assertive":"polite"),n(c,`aria-live added on role=${m}`,"moderate",o)),m==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),n(c,'aria-expanded="false" on combobox',"serious",o)),(m==="checkbox"||m==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),n(c,`aria-checked="false" on role=${m}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-a).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),a=document.querySelectorAll("*");e.scanned=a.length;let i=(n,l,o,c)=>e.details.push({tag:n,fix:l,severity:o,element:c.outerHTML.slice(0,100)});return a.forEach(n=>{let l=n,o=l.tagName.toLowerCase();(o==="a"||o==="button")&&!l.innerText?.trim()&&!l.getAttribute("aria-label")&&i(o,"needs aria-label (empty)","critical",l),o==="img"&&!l.hasAttribute("alt")&&i(o,"needs alt text","serious",l),Me.has(o)&&!l.getAttribute("aria-label")&&!l.getAttribute("aria-labelledby")&&i(o,"needs aria-label","serious",l),o==="iframe"&&!l.getAttribute("title")&&!l.getAttribute("aria-label")&&i(o,"iframe needs title","serious",l)}),e.fixed=e.details.length,e.score=$e(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:f,speak:ce,showVisualAlert:Fe,trapFocus:j,handlePlainEnglish:Re,handleSummarisePage:Pe,handleTranslate:Ie,handleVoiceControl:ze,handleSmartLabels:He,SUPPORTED_LANGUAGES:_};import wt,{useEffect as K,useState as P,useCallback as Y}from"react";import{forwardRef as bt,useEffect as Be,useState as H}from"react";function ft(){return new Promise(e=>{let t=setTimeout(e,1500),a=new MutationObserver(()=>{clearTimeout(t),t=setTimeout(()=>{a.disconnect(),e()},500)});a.observe(document.body,{childList:!0,subtree:!0})})}function mt(){let e=[],t=document.querySelectorAll("*");for(let a of t){if(a.closest("[data-yuktai-panel]"))continue;let i=a.innerText?.trim();i&&i.length>30&&e.push(i);let n=a.getAttribute("aria-label");if(n&&n.length>10&&e.push(n),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&(a.placeholder&&e.push(a.placeholder),a.value&&e.push(a.value)),a instanceof HTMLButtonElement){let l=a.innerText||a.getAttribute("aria-label");l&&e.push(l)}}return e.join(" ").slice(0,3500)}async function Ne(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{let t=window,a=t.LanguageModel||t.ai?.languageModel;if(!a)return{success:!1,answer:"",error:"Gemini Nano not available."};await ft();let i=mt();if(!i||i.length<100)return{success:!1,answer:"",error:"Page content not readable."};let n;try{n=await a.create({systemPrompt:`Answer ONLY using page content.
386
- Keep answer short (2\u20133 sentences).
387
- If not found say: "I could not find that on this page."`,outputLanguage:"en"})}catch{n=await a.create()}let l=`Page:
388
- ${i}
389
-
390
- Q: ${e}`,o=await n.prompt(l);return n?.destroy&&n.destroy(),{success:!0,answer:o?.trim()||"No answer found."}}catch(t){return{success:!1,answer:"",error:t instanceof Error?t.message:"Error occurred"}}}import{jsx as s,jsxs as p}from"react/jsx-runtime";var de={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100,localFont:"",darkMode:!1,largeTargets:!1,speechEnabled:!1,colorBlindMode:"none",showAuditBadge:!1,timeoutWarning:void 0,plainEnglish:!1,summarisePage:!1,translateLanguage:"en",voiceControl:!1,smartLabels:!1},R=[80,90,100,110,120,130],gt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],yt=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function xt(){let[e,t]=H(typeof window<"u"?window.innerWidth:1024);return Be(()=>{let a=()=>t(window.innerWidth);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function ht({checked:e,onChange:t,label:a,disabled:i=!1}){return p("label",{"aria-label":a,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:i?"not-allowed":"pointer",flexShrink:0,opacity:i?.4:1},children:[s("input",{type:"checkbox",checked:e,disabled:i,onChange:n=>t(n.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),s("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),s("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 z({label:e,color:t="#64748b",badge:a}){return p("div",{style:{display:"flex",alignItems:"center",gap:"8px",margin:"8px 18px 4px"},children:[s("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),a&&s("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 S({icon:e,label:t,desc:a,checked:i,onChange:n,disabled:l=!1,disabledReason:o}){return p("div",{title:l?o: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:[s("span",{"aria-hidden":"true",style:{width:"30px",height:"30px",borderRadius:"8px",background:l?"#f1f5f9":"#f0fdfa",color:l?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",flexShrink:0,fontWeight:700},children:e}),p("div",{style:{minWidth:0},children:[s("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:l?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),s("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:l?o:a})]})]}),s(ht,{checked:i,onChange:n,label:`Toggle ${t}`,disabled:l})]})}function x(){return s("div",{style:{height:"1px",background:"#f1f5f9",margin:"0"}})}var ue=bt(({position:e,settings:t,report:a,isActive:i,aiSupported:n,voiceSupported:l,set:o,onApply:c,onReset:m,onClose:u},y)=>{let{isMobile:g,isTablet:X}=xt(),[$,Q]=H([]),[k,F]=H(""),[W,E]=H(""),[A,N]=H(!1),d=async()=>{if(!(!k.trim()||A||!n)){N(!0),E("");try{let r=await Ne(k);r.success&&r.answer?E(r.answer):E("\u26A0\uFE0F "+(r.error||"No answer found on this page"))}catch{E("\u26A0\uFE0F Failed to fetch answer")}N(!1)}};Be(()=>{(async()=>{try{let I=window;if(!I.queryLocalFonts)return;let Z=await I.queryLocalFonts(),De=[...new Set(Z.map(qe=>qe.family))].sort();Q(De.slice(0,50))}catch{}})()},[]);let h=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:X?"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:h,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:[s("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v2.0.18"}),i&&s("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),s("p",{style:{margin:"0 0 2px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),s("p",{style:{margin:0,fontSize:"12px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost"})]}),s("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"})]}),s(z,{label:"Core"}),s(S,{icon:"\u267F",label:"Auto-fix ARIA",desc:"Injects missing labels and roles",checked:t.autoFix,onChange:r=>o("autoFix",r)}),s(x,{}),s(S,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud",checked:t.speechEnabled,onChange:r=>o("speechEnabled",r)}),s(x,{}),s(S,{icon:"\u{1F399}",label:"Voice control",desc:"Navigate page by voice",checked:t.voiceControl,onChange:r=>o("voiceControl",r),disabled:!l,disabledReason:"Not supported in this browser"}),s(x,{}),s(z,{label:"AI features",color:"#7c3aed",badge:"Gemini Nano \xB7 Chrome 127+"}),s("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:"#f5f3ff",borderRadius:"8px",border:"0.5px solid #c4b5fd",fontSize:"10px",color:"#7c3aed",lineHeight:1.5},children:n?"Gemini Nano detected \u2014 AI features ready. Runs privately on your device. No data leaves your browser.":"AI features need setup \u2014 see guide below."}),!n&&p("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[s("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"," ",s("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 ",s("strong",{style:{color:"#0f172a"},children:"Enabled:"})]}),s("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:yt.map(r=>p("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",r]},r))}),p("p",{style:{margin:"0 0 3px"},children:["3. Click ",s("strong",{style:{color:"#0f172a"},children:"Relaunch"})," when Chrome prompts you"]}),p("p",{style:{margin:"0 0 3px"},children:["4. Go to"," ",s("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 ",s("strong",{style:{color:"#0f172a"},children:"Optimization Guide On Device Model"})]}),p("p",{style:{margin:"0 0 6px 10px"},children:["\u2192 Click ",s("strong",{style:{color:"#0f172a"},children:"Check for update"})," and wait for download"]}),s("p",{style:{margin:"0"},children:"5. Refresh this page \u2014 AI features will unlock automatically"})]}),s(S,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Simplifies complex page text",checked:t.plainEnglish,onChange:r=>o("plainEnglish",r),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),s(x,{}),s(S,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary at top",checked:t.summarisePage,onChange:r=>o("summarisePage",r),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),s(x,{}),s(S,{icon:"\u{1F3F7}",label:"Smart aria-labels",desc:"AI generates meaningful labels",checked:t.smartLabels,onChange:r=>o("smartLabels",r),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup guide above"}),s(x,{}),s(z,{label:"Visual"}),s(S,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision",checked:t.highContrast,onChange:r=>o("highContrast",r)}),s(x,{}),s(S,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours",checked:t.darkMode,onChange:r=>o("darkMode",r)}),s(x,{}),s(S,{icon:"\u23F8",label:"Reduce motion",desc:"Disables animations",checked:t.reduceMotion,onChange:r=>o("reduceMotion",r)}),s(x,{}),s(S,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:r=>o("largeTargets",r)}),s(x,{}),p("div",{style:{padding:"10px 18px"},children:[s("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),s("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:gt.map(r=>s("button",{onClick:()=>o("colorBlindMode",r.value),"aria-pressed":t.colorBlindMode===r.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===r.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===r.value?"#f0fdfa":"#fff",color:t.colorBlindMode===r.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:g?"36px":"auto"},children:r.label},r.value))})]}),s(x,{}),s(z,{label:"Font"}),s(S,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible",checked:t.dyslexiaFont,onChange:r=>o("dyslexiaFont",r)}),s(x,{}),p("div",{style:{padding:"10px 18px"},children:[s("p",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:500,color:"#0f172a"},children:"\u{1F524} Local font"}),$.length>0?p("select",{value:t.localFont,onChange:r=>o("localFont",r.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:[s("option",{value:"",children:"System default"}),$.map(r=>s("option",{value:r,style:{fontFamily:r},children:r},r))]}):s("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Local font access available in Chrome 103+. Allow font access when prompted."})]}),s(x,{}),p("div",{style:{padding:"10px 18px 14px"},children:[p("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[s("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:[s("button",{onClick:()=>{let r=R.indexOf(t.fontScale);r>0&&o("fontScale",R[r-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"}),s("div",{style:{flex:1,display:"flex",gap:"3px"},children:R.map(r=>s("button",{onClick:()=>o("fontScale",r),"aria-label":`Set text size to ${r}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:r<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},r))}),s("button",{onClick:()=>{let r=R.indexOf(t.fontScale);r<R.length-1&&o("fontScale",R[r+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:"+"})]})]}),s(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"," ",s("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"})]}),s("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.slice(0,g?8:18).map(r=>s("button",{onClick:()=>o("translateLanguage",r.code),"aria-pressed":t.translateLanguage===r.code,disabled:!n,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===r.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===r.code?"#f5f3ff":"#fff",color:t.translateLanguage===r.code?"#7c3aed":"#64748b",cursor:n?"pointer":"not-allowed",opacity:n?1:.5,minHeight:g?"36px":"auto"},children:r.code.toUpperCase()},r.code))}),!n&&s("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above to unlock translation."})]}),s(x,{}),s(z,{label:"Ask this page",color:"#0d9488",badge:"Gemini Nano"}),p("div",{style:{padding:"10px 18px 14px"},children:[s("p",{style:{margin:"0 0 8px",fontSize:"11px",color:"#64748b"},children:"Ask any question \u2014 answered from this page. On device. Zero cost."}),p("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[s("input",{type:"text",value:k,onChange:r=>F(r.target.value),onKeyDown:r=>{r.key==="Enter"&&d()},placeholder:"Ask something...",disabled:!n||A,style:{flex:1,padding:"8px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px"}}),s("button",{onClick:d,disabled:!k.trim()||A||!n,style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:k.trim()&&!A&&n?"#0d9488":"#e2e8f0",color:k.trim()&&!A&&n?"#fff":"#94a3b8",cursor:k.trim()&&!A&&n?"pointer":"not-allowed"},children:A?"\u23F3 Thinking...":"Ask"})]}),(W||A)&&p("div",{style:{padding:"10px",background:"#f0fdfa",borderRadius:"8px",fontSize:"12px",color:"#0f766e"},children:[s("strong",{style:{display:"block",marginBottom:"4px"},children:"\u{1F4AC} Answer"}),A?"\u23F3 Thinking...":W||"No answer found"]})]}),a&&s("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:[s("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"}),s("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"})]})]})});ue.displayName="WidgetPanel";import{Fragment as kt,jsx as Oe,jsxs as At}from"react/jsx-runtime";async function vt(){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 pe({position:e="left",children:t,config:a={}}){let[i,n]=P(!1),[l,o]=P(de),[c,m]=P(null),[u,y]=P(!1),[g,X]=P(!1),[$,Q]=P(!1),k=wt.useRef(null);K(()=>{if(typeof window>"u")return;let h=setTimeout(async()=>{let r=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.ai =",r.ai),console.log("yuktai: window.LanguageModel =",r.LanguageModel),console.log("yuktai: window.Summarizer =",r.Summarizer),console.log("yuktai: window.Rewriter =",r.Rewriter),console.log("yuktai: window.Writer =",r.Writer);let I=await vt();X(I),I?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 Z=!!(r.SpeechRecognition||r.webkitSpeechRecognition);Q(Z)},800);return()=>clearTimeout(h)},[]),K(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");if(d){let h=JSON.parse(d);o(r=>({...r,...h}))}}catch{}},[]);let F=Y(async d=>{let h={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 v.execute(h);let r=v.applyFixes(h);m(r),y(!0)},[a]),W=Y(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(l))}catch{}await F(l),n(!1)},[l,F]),E=Y(()=>{o(de);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(h=>d.removeAttribute(h)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",m(null),y(!1)},[]),A=Y((d,h)=>{o(r=>({...r,[d]:h}))},[]);K(()=>{let d=h=>{h.key==="Escape"&&i&&n(!1)};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[i]),K(()=>{i&&k.current&&v.trapFocus(k.current)},[i]);let N={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 At(kt,{children:[t,Oe("button",{style:N,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":i,"data-yuktai-pref-toggle":"true",onClick:()=>n(d=>!d),onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),i&&Oe(ue,{ref:k,position:e,settings:l,report:c,isActive:u,aiSupported:g,voiceSupported:$,set:A,onApply:W,onReset:E,onClose:()=>n(!1)})]})}var U={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var J={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var T=class{plugins=new Map;register(t,a){if(!a||typeof a.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,a)}use(t){return this.plugins.get(t)}async run(t,a){try{let i=this.use(t);if(!i)throw new Error(`Plugin not found: ${t}`);return await i.execute(a)}catch(i){throw console.error(`[YuktAI Runtime Error in ${t}]:`,i),i}}getPlugins(){return Array.from(this.plugins.keys())}};function St(){if(typeof globalThis>"u")return new T;if(!globalThis.__yuktai_runtime__){let e=new T;e.register(v.name,v),e.register(U.name,U),e.register(J.name,J),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var _e=typeof window<"u"?St():new T,oa={wcagPlugin:v,list(){return _e.getPlugins()},use(e){return _e.use(e)},fix(e){return v.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return v.scan()}};export{T as Runtime,oa as YuktAI,pe as YuktAIWrapper,U as aiPlugin,pe as default,J as voicePlugin,v as wcag,v as wcagPlugin};
385
+ `,document.body.appendChild(e),_e=e}function Qe(e){let t={critical:20,serious:10,moderate:5,minor:2},a=e.details.reduce((i,n)=>i+(t[n.severity]||0),0);return Math.max(0,Math.min(100,100-a))}var E={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";O=e,Mt(e),Rt(),Pt(),At(),St(),e.showSkipLinks!==!1&&kt(),e.showPreferencePanel,Lt(e);let t=this.applyFixes(e);t.score=Qe(t),e.showAuditBadge&&Et(t),e.timeoutWarning&&et(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Ke(!0),e.summarisePage&&await Ye(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Ue(e.translateLanguage),e.voiceControl&&await Je(!0),e.smartLabels&&await Xe(!0);let a=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return m(a,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${a} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let a=performance.now(),i=document.querySelectorAll("*");t.scanned=i.length;let n=(r,o,c,g)=>{t.details.push({tag:r,fix:o,severity:c,element:g.outerHTML.slice(0,100)}),t.fixed++};return i.forEach(r=>{let o=r,c=o.tagName.toLowerCase();if(c==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),n(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),w=o.getAttribute("content")||"";u==="viewport"&&w.includes("user-scalable=no")&&(o.setAttribute("content",w.replace("user-scalable=no","user-scalable=yes")),n(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(w)&&(o.setAttribute("content",w.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),n(c,"maximum-scale=5 restored","serious",o))}if(c==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),c==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),n(c,'alt="" aria-hidden="true"',"serious",o))),c==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!r.querySelector("title")&&(o.setAttribute("aria-hidden","true"),n(c,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),c==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),n(c,"title + aria-label added","serious",o)),c==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let u=o.getAttribute("title")||"button";o.setAttribute("aria-label",u),n(c,`aria-label="${u}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(c==="a"){let u=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),n(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(je.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let w=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",w),n(c,`aria-label="${w}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let w=u.name||"";u.type==="email"||w.includes("email")?u.autocomplete="email":u.type==="tel"||w.includes("tel")?u.autocomplete="tel":u.type==="password"&&(u.autocomplete="current-password"),t.fixed++}}c==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),n(c,"scope added to <th>","moderate",o)),ke[c]&&!o.getAttribute("role")&&(o.setAttribute("role",ke[c]),n(c,`role="${ke[c]}"`,"minor",o));let g=o.getAttribute("role")||"";g==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(g)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",g==="alert"?"assertive":"polite"),n(c,`aria-live added on role=${g}`,"moderate",o)),g==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),n(c,'aria-expanded="false" on combobox',"serious",o)),(g==="checkbox"||g==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),n(c,`aria-checked="false" on role=${g}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-a).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),a=document.querySelectorAll("*");e.scanned=a.length;let i=(n,r,o,c)=>e.details.push({tag:n,fix:r,severity:o,element:c.outerHTML.slice(0,100)});return a.forEach(n=>{let r=n,o=r.tagName.toLowerCase();(o==="a"||o==="button")&&!r.innerText?.trim()&&!r.getAttribute("aria-label")&&i(o,"needs aria-label (empty)","critical",r),o==="img"&&!r.hasAttribute("alt")&&i(o,"needs alt text","serious",r),je.has(o)&&!r.getAttribute("aria-label")&&!r.getAttribute("aria-labelledby")&&i(o,"needs aria-label","serious",r),o==="iframe"&&!r.getAttribute("title")&&!r.getAttribute("aria-label")&&i(o,"iframe needs title","serious",r)}),e.fixed=e.details.length,e.score=Qe(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:m,speak:Ae,showVisualAlert:Ze,trapFocus:ie,handlePlainEnglish:Ke,handleSummarisePage:Ye,handleTranslate:Ue,handleVoiceControl:Je,handleSmartLabels:Xe,SUPPORTED_LANGUAGES:ee};import Gt,{useEffect as se,useState as P,useCallback as U}from"react";import{forwardRef as Bt,useEffect as re,useState as W}from"react";var at=null,ot=null,q=!1,Se=!1;async function zt(){if(!Se){if(q){for(;q;)await new Promise(e=>setTimeout(e,200));return}q=!0;try{let{pipeline:e}=await import("@huggingface/transformers");at=await e("feature-extraction","Xenova/all-MiniLM-L6-v2",{device:"webgpu"}),ot=await e("question-answering","Xenova/distilbert-base-cased-distilled-squad",{device:"webgpu"}),Se=!0,q=!1,console.log("yuktai: Transformers.js models loaded \u2705")}catch(e){throw q=!1,console.error("yuktai: Transformers.js model load failed",e),e}}}function It(){return new Promise(e=>{let t=setTimeout(e,1500),a=new MutationObserver(()=>{clearTimeout(t),t=setTimeout(()=>{a.disconnect(),e()},500)});a.observe(document.body,{childList:!0,subtree:!0})})}function Wt(){let e=[],t=document.querySelectorAll("*");for(let a of t){if(a.closest("[data-yuktai-panel]"))continue;let i=a.innerText?.trim();i&&i.length>30&&e.push(i);let n=a.getAttribute("aria-label");n&&n.length>10&&e.push(n),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&a.placeholder&&e.push(a.placeholder)}return e.join(" ").slice(0,8e3)}function Ht(e,t=200,a=50){let i=e.split(/\s+/),n=[];for(let r=0;r<i.length;r+=t-a){let o=i.slice(r,r+t).join(" ");o.trim().length>20&&n.push(o)}return n}function Ft(e,t){let a=0,i=0,n=0;for(let r=0;r<e.length;r++)a+=e[r]*t[r],i+=e[r]*e[r],n+=t[r]*t[r];return a/(Math.sqrt(i)*Math.sqrt(n)+1e-8)}async function tt(e){let t=await at(e,{pooling:"mean",normalize:!0});return Array.from(t.data)}async function $t(e,t,a=3){let i=await tt(e),n=await Promise.all(t.map(async r=>{let o=await tt(r),c=Ft(i,o);return{chunk:r,score:c}}));return n.sort((r,o)=>o.score-r.score),n.slice(0,a).map(r=>r.chunk)}async function nt(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{await zt(),await It();let t=Wt();if(!t||t.length<50)return{success:!1,answer:"",error:"Not enough content on this page to answer from."};let a=Ht(t);if(a.length===0)return{success:!1,answer:"",error:"Could not process page content."};let n=(await $t(e,a,3)).join(" ... "),r=await ot({question:e,context:n});return!r?.answer||r.answer.trim().length===0?{success:!0,answer:"I could not find a specific answer on this page."}:{success:!0,answer:r.answer.trim()}}catch(t){return console.error("yuktai: Transformers RAG error",t),{success:!1,answer:"",error:t instanceof Error?t.message:"Transformers.js error \u2014 please try again."}}}function it(){try{return typeof WebAssembly<"u"&&typeof Worker<"u"}catch{return!1}}function rt(){return Se?"ready":q?"loading":"idle"}import{jsx as s,jsxs as p}from"react/jsx-runtime";var Te={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},D=[80,90,100,110,120,130],Nt=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],Ot=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function qt(){let[e,t]=W(typeof window<"u"?window.innerWidth:1024);return re(()=>{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:i=!1}){return p("label",{"aria-label":a,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:i?"not-allowed":"pointer",flexShrink:0,opacity:i?.4:1},children:[s("input",{type:"checkbox",checked:e,disabled:i,onChange:n=>t(n.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),s("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),s("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 G({label:e,color:t="#64748b",badge:a,concept:i}){return p("div",{style:{margin:"10px 18px 4px"},children:[p("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[s("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),a&&s("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:a})]}),i&&s("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8",fontStyle:"italic"},children:i})]})}function C({icon:e,label:t,desc:a,checked:i,onChange:n,disabled:r=!1,disabledReason:o,tip:c}){return p("div",{title:r?o:c,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:[s("span",{"aria-hidden":"true",style:{width:"32px",height:"32px",borderRadius:"8px",background:r?"#f1f5f9":"#f0fdfa",color:r?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"15px",flexShrink:0,fontWeight:700},children:e}),p("div",{style:{minWidth:0},children:[s("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:r?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),s("p",{style:{margin:0,fontSize:"10px",color:"#94a3b8"},children:r?o:a})]})]}),s(Dt,{checked:i,onChange:n,label:`Toggle ${t}`,disabled:r})]})}function v(){return s("div",{style:{height:"1px",background:"#f1f5f9"}})}function Y({steps:e}){return p("div",{style:{margin:"0 18px 8px",padding:"8px 10px",background:"#f8fafc",borderRadius:"8px",border:"0.5px solid #e2e8f0"},children:[s("p",{style:{margin:"0 0 4px",fontSize:"9px",fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.05em"},children:"How to use"}),e.map((t,a)=>p("p",{style:{margin:"0 0 2px",fontSize:"10px",color:"#475569"},children:[a+1,". ",t]},a))]})}var Ee=Bt(({position:e,settings:t,report:a,isActive:i,aiSupported:n,voiceSupported:r,set:o,onApply:c,onReset:g,onClose:u},w)=>{let{isMobile:y,isTablet:A}=qt(),[J,de]=W([]),[M,F]=W(""),[z,R]=W(""),[h,V]=W(!1),[f,I]=W(null),[S,$]=W("idle");re(()=>{let l=window;!!(l.LanguageModel||l.ai?.languageModel)&&n?I("gemini"):it()&&I("transformers")},[n]),re(()=>{if(f!=="transformers")return;let l=setInterval(()=>{$(rt())},500);return()=>clearInterval(l)},[f]);let j=async()=>{if(!(!M.trim()||h)){if(!f){R("\u26A0\uFE0F No AI engine available on this device.");return}V(!0),R("");try{let l;f==="gemini"?l=await Me(M):($("loading"),l=await nt(M),$("ready")),R(l.success&&l.answer?l.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(l.error||"No answer found on this page"))}catch{R("\u26A0\uFE0F Failed to get answer. Please try again.")}V(!1)}};re(()=>{(async()=>{try{let K=window;if(!K.queryLocalFonts)return;let fe=await K.queryLocalFonts(),d=[...new Set(fe.map(x=>x.family))].sort();de(d.slice(0,50))}catch{}})()},[]);let X=f==="gemini"?"Gemini Nano":f==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",ue=f==="transformers"&&S==="loading"?"Loading AI model... (first time only)":"...",pe=y?{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:A?"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:w,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:pe,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:"4px",flexWrap:"wrap"},children:[s("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v2.1.0"}),i&&s("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),s("p",{style:{margin:"0 0 1px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),s("p",{style:{margin:0,fontSize:"11px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost \xB7 All devices"})]}),s("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:y?"44px":"auto",minHeight:y?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),s(G,{label:"\u267F Core Accessibility",concept:"Rule-based engine \u2014 works on all browsers and devices"}),s(Y,{steps:["Toggle any feature on","Click Apply settings","Preferences saved automatically"]}),s(C,{icon:"\u{1F527}",label:"Auto-fix ARIA",desc:"Injects missing labels and roles automatically",checked:t.autoFix,onChange:l=>o("autoFix",l),tip:"Fixes aria-label, alt text, roles on every element"}),s(v,{}),s(C,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud as you tab",checked:t.speechEnabled,onChange:l=>o("speechEnabled",l),tip:"Uses browser SpeechSynthesis \u2014 no install needed"}),s(v,{}),s(C,{icon:"\u{1F399}\uFE0F",label:"Voice control",desc:"Say commands to navigate the page",checked:t.voiceControl,onChange:l=>o("voiceControl",l),disabled:!r,disabledReason:"Not supported in this browser",tip:'Say "scroll down", "go to main", "click"'}),s(v,{}),s(G,{label:"\u{1F916} AI Features",color:"#7c3aed",badge:"Gemini Nano",concept:"Large Language Model running privately on your device \u2014 Chrome 127+ only"}),s("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:n?"#f0fdfa":"#f5f3ff",borderRadius:"8px",border:`0.5px solid ${n?"#99f6e4":"#c4b5fd"}`,fontSize:"10px",color:n?"#0f766e":"#7c3aed",lineHeight:1.5},children:n?"\u2705 Gemini Nano detected \u2014 AI features ready. Runs privately on your device.":"\u2699\uFE0F AI features need one-time setup \u2014 see guide below."}),!n&&p("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[s("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} One-time setup \u2014 5 steps:"}),p("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome \u2192 ",s("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),s("p",{style:{margin:"0 0 3px"},children:"2. Enable each flag:"}),s("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:Ot.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 ",s("strong",{style:{color:"#0f172a"},children:"Relaunch"})]}),p("p",{style:{margin:"0 0 3px"},children:["4. ",s("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://components"})," \u2192 Optimization Guide On Device Model \u2192 Check for update"]}),s("p",{style:{margin:"0"},children:"5. Refresh \u2014 AI features unlock automatically \u2705"})]}),s(C,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Rewrites complex text in simple language",checked:t.plainEnglish,onChange:l=>o("plainEnglish",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: LLM text rewriting"}),s(v,{}),s(C,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary appears at top",checked:t.summarisePage,onChange:l=>o("summarisePage",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Abstractive summarisation"}),s(v,{}),s(C,{icon:"\u{1F3F7}\uFE0F",label:"Smart aria-labels",desc:"AI generates meaningful labels for elements",checked:t.smartLabels,onChange:l=>o("smartLabels",l),disabled:!n,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Context-aware label generation"}),s(v,{}),s(G,{label:"\u{1F441}\uFE0F Visual",concept:"CSS filter-based \u2014 works on all browsers and devices"}),s(Y,{steps:["Toggle any visual mode","Changes apply instantly","Works on mobile and desktop"]}),s(C,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision users",checked:t.highContrast,onChange:l=>o("highContrast",l),tip:"CSS filter: contrast()"}),s(v,{}),s(C,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours \u2014 easy on eyes at night",checked:t.darkMode,onChange:l=>o("darkMode",l),tip:"CSS filter: invert + hue-rotate"}),s(v,{}),s(C,{icon:"\u23F8\uFE0F",label:"Reduce motion",desc:"Disables all animations",checked:t.reduceMotion,onChange:l=>o("reduceMotion",l),tip:"WCAG 2.3.3 \u2014 vestibular disorders"}),s(v,{}),s(C,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:l=>o("largeTargets",l),tip:"WCAG 2.5.8 \u2014 motor impaired users"}),s(v,{}),p("div",{style:{padding:"10px 18px"},children:[s("p",{style:{margin:"0 0 2px",fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),s("p",{style:{margin:"0 0 8px",fontSize:"10px",color:"#94a3b8"},children:"SVG colour matrix filters \u2014 all devices"}),s("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Nt.map(l=>s("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:y?"36px":"auto"},children:l.label},l.value))})]}),s(v,{}),s(G,{label:"\u{1F524} Font",concept:"Browser Font API + CSS \u2014 Chrome 103+"}),s(Y,{steps:["Toggle dyslexia font or pick from device","Adjust size with + / \u2212","Saved across visits"]}),s(C,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible \u2014 research-backed",checked:t.dyslexiaFont,onChange:l=>o("dyslexiaFont",l),tip:"By Braille Institute \u2014 free and open source"}),s(v,{}),p("div",{style:{padding:"10px 18px"},children:[s("p",{style:{margin:"0 0 2px",fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F5A5}\uFE0F Local font"}),s("p",{style:{margin:"0 0 8px",fontSize:"10px",color:"#94a3b8"},children:"window.queryLocalFonts() \u2014 Chrome 103+"}),J.length>0?p("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:y?"44px":"36px"},children:[s("option",{value:"",children:"System default"}),J.map(l=>s("option",{value:l,style:{fontFamily:l},children:l},l))]}):s("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Allow font access when Chrome prompts you."})]}),s(v,{}),p("div",{style:{padding:"10px 18px 14px"},children:[p("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[p("div",{children:[s("p",{style:{margin:0,fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F4CF} Text size"}),s("p",{style:{margin:0,fontSize:"10px",color:"#94a3b8"},children:"Scales all text on the page"})]}),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:[s("button",{onClick:()=>{let l=D.indexOf(t.fontScale);l>0&&o("fontScale",D[l-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:y?"44px":"30px",height:y?"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"}),s("div",{style:{flex:1,display:"flex",gap:"3px"},children:D.map(l=>s("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))}),s("button",{onClick:()=>{let l=D.indexOf(t.fontScale);l<D.length-1&&o("fontScale",D[l+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:y?"44px":"30px",height:y?"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:"+"})]})]}),s(v,{}),s(G,{label:"\u{1F310} Translate",color:"#7c3aed",badge:"Gemini Nano",concept:"Chrome Translation API \u2014 on device, no internet after setup"}),s(Y,{steps:["Enable Gemini Nano first","Pick your language","Full page translates instantly"]}),p("div",{style:{padding:"6px 18px 12px"},children:[s("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ee.slice(0,y?8:18).map(l=>s("button",{onClick:()=>o("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!n,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===l.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===l.code?"#f5f3ff":"#fff",color:t.translateLanguage===l.code?"#7c3aed":"#64748b",cursor:n?"pointer":"not-allowed",opacity:n?1:.5,minHeight:y?"36px":"auto"},children:l.label},l.code))}),!n&&s("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above."})]}),s(v,{}),s(G,{label:"\u{1F4AC} Ask This Page",color:"#0d9488",badge:X,concept:"RAG \u2014 Retrieval Augmented Generation. Works on all devices including mobile."}),s(Y,{steps:["Type any question about this page","Press Ask or hit Enter",f==="transformers"?"Transformers.js answers \u2014 works on mobile, offline":"Gemini Nano reads page and answers privately","Zero cost. No data leaves your device."]}),p("div",{style:{margin:"0 18px 8px",padding:"6px 10px",background:f==="gemini"?"#f0fdfa":f==="transformers"?"#f5f3ff":"#f8fafc",borderRadius:"8px",border:`0.5px solid ${f==="gemini"?"#99f6e4":f==="transformers"?"#c4b5fd":"#e2e8f0"}`,fontSize:"10px",color:f==="gemini"?"#0f766e":f==="transformers"?"#7c3aed":"#94a3b8"},children:[f==="gemini"&&"\u2705 Using Gemini Nano \u2014 on device, private, instant",f==="transformers"&&"\u2705 Using Transformers.js \u2014 works on mobile and all browsers",!f&&"\u23F3 Detecting AI engine...",f==="transformers"&&S==="loading"&&" \xB7 Loading model...",f==="transformers"&&S==="ready"&&" \xB7 Model ready \u2705"]}),p("div",{style:{padding:"0 18px 14px"},children:[p("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[s("input",{type:"text",value:M,onChange:l=>F(l.target.value),onKeyDown:l=>{l.key==="Enter"&&j()},placeholder:"e.g. What does this page do?",disabled:h||!f,"aria-label":"Ask a question about this page",style:{flex:1,padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px",color:"#0f172a",background:f?"#fff":"#f8fafc",outline:"none",height:y?"44px":"36px"}}),s("button",{onClick:j,disabled:h||!M.trim()||!f,"aria-label":"Ask question",style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:f&&M.trim()&&!h?"#0d9488":"#e2e8f0",color:f&&M.trim()&&!h?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:f&&M.trim()&&!h?"pointer":"not-allowed",flexShrink:0,height:y?"44px":"36px",minWidth:"52px",transition:"background 0.2s"},children:h?ue:"Ask"})]}),z&&p("div",{role:"status","aria-live":"polite",style:{padding:"10px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:"8px",fontSize:"12px",color:"#0f766e",lineHeight:1.6,maxHeight:"180px",overflowY:"auto"},children:[s("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#0d9488"},children:"\u{1F4AC} Answer"}),z,s("button",{onClick:()=>{R(""),F("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]})]}),a&&s("div",{role:"status",style:{margin:"0 14px 10px",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:y?"sticky":"relative",bottom:y?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[s("button",{onClick:g,style:{flex:1,padding:y?"12px 0":"8px 0",fontSize:"13px",fontWeight:500,borderRadius:"9px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),s("button",{onClick:c,style:{flex:2,padding:y?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});Ee.displayName="WidgetPanel";import{Fragment as Vt,jsx as L,jsxs as _}from"react/jsx-runtime";async function _t(){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={},showRag:i=!1}){let[n,r]=P(!1),[o,c]=P(Te),[g,u]=P(null),[w,y]=P(!1),[A,J]=P(!1),[de,M]=P(!1),F=Gt.useRef(null),[z,R]=P(!1),[h,V]=P(""),[f,I]=P(""),[S,$]=P(!1),j=U(async()=>{if(!(!h.trim()||S||!A)){$(!0),I("");try{let{askPage:d}=await import("./rag-HDO3PUIJ.mjs"),x=await d(h);I(x.success?x.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(x.error||"No answer found."))}catch{I("\u26A0\uFE0F Something went wrong.")}$(!1)}},[h,S,A]);se(()=>{if(typeof window>"u")return;let x=setTimeout(async()=>{let k=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.ai =",k.ai),console.log("yuktai: window.LanguageModel =",k.LanguageModel),console.log("yuktai: window.Summarizer =",k.Summarizer),console.log("yuktai: window.Rewriter =",k.Rewriter),console.log("yuktai: window.Writer =",k.Writer);let Le=await _t();J(Le),Le?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 lt=!!(k.SpeechRecognition||k.webkitSpeechRecognition);M(lt)},800);return()=>clearTimeout(x)},[]),se(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");if(d){let x=JSON.parse(d);c(k=>({...k,...x}))}}catch{}},[]);let X=U(async d=>{let x={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 E.execute(x);let k=E.applyFixes(x);u(k),y(!0)},[a]),ue=U(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(o))}catch{}await X(o),r(!1)},[o,X]),pe=U(()=>{c(Te);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(x=>d.removeAttribute(x)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",u(null),y(!1)},[]),l=U((d,x)=>{c(k=>({...k,[d]:x}))},[]);se(()=>{let d=x=>{x.key==="Escape"&&(n&&r(!1),z&&R(!1))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n,z]),se(()=>{n&&F.current&&E.trapFocus(F.current)},[n]);let K={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:w?"#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"},fe={position:"fixed",bottom:"84px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:z?"#7c3aed":"#6d28d9",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 _(Vt,{children:[t,i&&L("button",{style:fe,"aria-label":"Ask a question about this page","aria-haspopup":"dialog","aria-expanded":z,onClick:()=>{R(d=>!d),r(!1)},onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u{1F4AC}"}),i&&z&&_("div",{role:"dialog","aria-modal":"true","aria-label":"Ask this page","data-yuktai-panel":"true",style:{position:"fixed",bottom:"148px",[e]:"24px",zIndex:9999,width:"300px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",fontFamily:"system-ui,-apple-system,sans-serif",padding:"14px"},children:[_("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"10px"},children:[_("div",{children:[L("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:600,color:"#0f172a"},children:"\u{1F4AC} Ask this page"}),L("p",{style:{margin:0,fontSize:"10px",color:"#7c3aed"},children:"Gemini Nano \xB7 On device \xB7 Zero cost"})]}),L("button",{onClick:()=>R(!1),"aria-label":"Close ask panel",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",lineHeight:1,padding:"2px",borderRadius:"4px"},children:"\xD7"})]}),_("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[L("input",{type:"text",value:h,onChange:d=>V(d.target.value),onKeyDown:d=>{d.key==="Enter"&&j()},placeholder:"e.g. What does this page do?",disabled:!A||S,"aria-label":"Ask a question about this page",style:{flex:1,padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px",color:"#0f172a",background:A?"#fff":"#f8fafc",outline:"none",height:"36px"}}),L("button",{onClick:j,disabled:!A||S||!h.trim(),"aria-label":"Submit question",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:A&&h.trim()&&!S?"#7c3aed":"#e2e8f0",color:A&&h.trim()&&!S?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:A&&h.trim()&&!S?"pointer":"not-allowed",height:"36px",minWidth:"48px",transition:"background 0.2s"},children:S?"...":"Ask"})]}),f&&_("div",{style:{padding:"10px",background:"#f5f3ff",borderRadius:"8px",fontSize:"12px",color:"#4c1d95",lineHeight:1.6,maxHeight:"180px",overflowY:"auto"},children:[L("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#7c3aed"},children:"\u{1F4AC} Answer"}),f,L("button",{onClick:()=>{I(""),V("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!A&&L("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano via chrome://flags to use this feature."})]}),L("button",{style:K,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":n,"data-yuktai-pref-toggle":"true",onClick:()=>{r(d=>!d),R(!1)},onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),n&&L(Ee,{ref:F,position:e,settings:o,report:g,isActive:w,aiSupported:A,voiceSupported:de,set:l,onApply:ue,onReset:pe,onClose:()=>r(!1)})]})}var le={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var ce={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var H=class{plugins=new Map;register(t,a){if(!a||typeof a.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,a)}use(t){return this.plugins.get(t)}async run(t,a){try{let i=this.use(t);if(!i)throw new Error(`Plugin not found: ${t}`);return await i.execute(a)}catch(i){throw console.error(`[YuktAI Runtime Error in ${t}]:`,i),i}}getPlugins(){return Array.from(this.plugins.keys())}};function jt(){if(typeof globalThis>"u")return new H;if(!globalThis.__yuktai_runtime__){let e=new H;e.register(E.name,E),e.register(le.name,le),e.register(ce.name,ce),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var st=typeof window<"u"?jt():new H,Ea={wcagPlugin:E,list(){return st.getPlugins()},use(e){return st.use(e)},fix(e){return E.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return E.scan()}};export{H as Runtime,Ea as YuktAI,Ce as YuktAIWrapper,le as aiPlugin,Ce as default,ce as voicePlugin,E as wcag,E as wcagPlugin};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-56MYCLBI.mjs";export{a as askPage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuktishaalaa/yuktai",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "Universal runtime accessibility plugin — auto-fixes WCAG 2.2 violations with on-device AI features. Desktop only. Zero API keys. Zero cost.",
5
5
  "author": "Sandeep Miriyala — Yuktishaalaa AI Lab",
6
6
  "license": "ISC",
@@ -44,6 +44,7 @@
44
44
  "prepublishOnly": "npm run build"
45
45
  },
46
46
  "dependencies": {
47
+ "@huggingface/transformers": "^4.2.0",
47
48
  "react": ">=17.0.0"
48
49
  },
49
50
  "peerDependencies": {
@@ -51,18 +52,18 @@
51
52
  "react-dom": ">=17.0.0"
52
53
  },
53
54
  "devDependencies": {
54
- "typescript": "^5.4.5",
55
- "tsup": "^8.0.2",
56
- "vitest": "^1.6.0",
57
- "eslint": "^8.57.0",
55
+ "@emotion/react": "^11.13.3",
56
+ "@emotion/styled": "^11.13.0",
57
+ "@mui/icons-material": "^6.0.0",
58
+ "@mui/material": "^6.0.0",
58
59
  "@types/react": "^18.3.3",
59
60
  "@types/react-dom": "^18.3.0",
61
+ "eslint": "^8.57.0",
60
62
  "react": "^18.3.1",
61
63
  "react-dom": "^18.3.1",
62
- "@mui/material": "^6.0.0",
63
- "@mui/icons-material": "^6.0.0",
64
- "@emotion/react": "^11.13.3",
65
- "@emotion/styled": "^11.13.0"
64
+ "tsup": "^8.0.2",
65
+ "typescript": "^5.4.5",
66
+ "vitest": "^1.6.0"
66
67
  },
67
68
  "tsup": {
68
69
  "entry": [