@yuktishaalaa/yuktai 3.0.9 → 3.0.11

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 @@
1
+ var m=null,g=null,i=!1,u=!1;async function p(){if(!u){if(i){for(;i;)await new Promise(e=>setTimeout(e,200));return}i=!0;try{let{pipeline:e,env:t}=await import("@huggingface/transformers");t.allowRemoteModels=!0,t.allowLocalModels=!1,t.useBrowserCache=!0,m=await e("feature-extraction","Xenova/all-MiniLM-L6-v2",{device:typeof navigator<"u"&&"gpu"in navigator?"webgpu":"wasm"}),g=await e("question-answering","Xenova/distilbert-base-cased-distilled-squad",{device:typeof navigator<"u"&&"gpu"in navigator?"webgpu":"wasm"}),u=!0,i=!1,console.log("yuktai: Transformers.js models loaded \u2705")}catch(e){throw i=!1,console.error("yuktai: Transformers.js model load failed",e),e}}}function w(){return new Promise(e=>{let t=setTimeout(e,1500),r=new MutationObserver(()=>{clearTimeout(t),t=setTimeout(()=>{r.disconnect(),e()},500)});r.observe(document.body,{childList:!0,subtree:!0})})}function h(){let e=[],t=document.querySelectorAll("*");for(let r of t){if(r.closest("[data-yuktai-panel]"))continue;let o=r.innerText?.trim();o&&o.length>30&&e.push(o);let s=r.getAttribute("aria-label");s&&s.length>10&&e.push(s),(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&r.placeholder&&e.push(r.placeholder)}return e.join(" ").slice(0,8e3)}function y(e,t=200,r=50){if(typeof e!="string")try{e=String(e??"")}catch{return[]}let o=e.trim();if(!o)return[];let s=Math.min(r,Math.floor(t/2)),n=o.split(/\s+/),a=[],l=t-s;for(let c=0;c<n.length;c+=l){let f=n.slice(c,c+t).join(" ");f.trim().length>20&&a.push(f)}return a}function b(e,t){let r=0,o=0,s=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n],o+=e[n]*e[n],s+=t[n]*t[n];return r/(Math.sqrt(o)*Math.sqrt(s)+1e-8)}async function d(e){let t=await m(e,{pooling:"mean",normalize:!0}),r=t?.data??t;return Array.from(r)}async function v(e,t,r=3){let o=await d(e),s=await Promise.all(t.map(async n=>{let a=await d(n),l=b(o,a);return{chunk:n,score:l}}));return s.sort((n,a)=>a.score-n.score),s.slice(0,r).map(n=>n.chunk)}async function M(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{await p(),await w();let t=h();if(!t||t.length<50)return{success:!1,answer:"",error:"Not enough content on this page."};let r=y(t);if(r.length===0)return{success:!1,answer:"",error:"Could not process page content."};let s=(await v(e,r,3)).join(" ... "),n=await g(e,s);return!n?.answer||n.answer.trim().length===0?{success:!0,answer:"I could not find a specific answer on this page."}:{success:!0,answer:n.answer.trim()}}catch(t){return console.error("yuktai: Transformers RAG error",t),{success:!1,answer:"",error:t instanceof Error?t.message:"Transformers.js error."}}}function k(){try{return typeof WebAssembly<"u"&&typeof Worker<"u"}catch{return!1}}function P(){return u?"ready":i?"loading":"idle"}export{M as a,k as b,P as c};
@@ -1,6 +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.
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 l(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
2
  Keep answer short (2\u20133 sentences).
3
3
  If not found say: "I could not find that on this page."`,outputLanguage:"en"})}catch{r=await e.create()}let a=`Page:
4
4
  ${s}
5
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};
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{l as a};
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
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.
1
+ "use strict";var wt=Object.create;var ae=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var xe=(e,t)=>()=>(e&&(t=e(e=0)),t);var he=(e,t)=>{for(var n in t)ae(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of kt(t))!St.call(e,a)&&a!==n&&ae(e,a,{get:()=>t[a],enumerable:!(i=vt(t,a))||i.enumerable});return e};var Ne=(e,t,n)=>(n=e!=null?wt(At(e)):{},Be(t||!e||!e.__esModule?ae(n,"default",{value:e,enumerable:!0}):n,e)),Tt=e=>Be(ae({},"__esModule",{value:!0}),e);var p=xe(()=>{});var ut={};he(ut,{askPage:()=>Pe});function Ut(){return new Promise(e=>{let t=setTimeout(e,1500),n=new MutationObserver(()=>{clearTimeout(t),t=setTimeout(()=>{n.disconnect(),e()},500)});n.observe(document.body,{childList:!0,subtree:!0})})}function Jt(){let e=[],t=document.querySelectorAll("*");for(let n of t){if(n.closest("[data-yuktai-panel]"))continue;let i=n.innerText?.trim();i&&i.length>30&&e.push(i);let a=n.getAttribute("aria-label");if(a&&a.length>10&&e.push(a),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&(n.placeholder&&e.push(n.placeholder),n.value&&e.push(n.value)),n instanceof HTMLButtonElement){let s=n.innerText||n.getAttribute("aria-label");s&&e.push(s)}}return e.join(" ").slice(0,3500)}async function Pe(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{let t=window,n=t.LanguageModel||t.ai?.languageModel;if(!n)return{success:!1,answer:"",error:"Gemini Nano not available."};await Ut();let i=Jt();if(!i||i.length<100)return{success:!1,answer:"",error:"Page content not readable."};let a;try{a=await n.create({systemPrompt:`Answer ONLY using page content.
2
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:
3
+ If not found say: "I could not find that on this page."`,outputLanguage:"en"})}catch{a=await n.create()}let s=`Page:
4
4
  ${i}
5
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=`
6
+ Q: ${e}`,o=await a.prompt(s);return a?.destroy&&a.destroy(),{success:!0,answer:o?.trim()||"No answer found."}}catch(t){return{success:!1,answer:"",error:t instanceof Error?t.message:"Error occurred"}}}var Re=xe(()=>{"use strict";p()});var gt={};he(gt,{askPageWithTransformers:()=>ze,getModelLoadStatus:()=>X,isTransformersSupported:()=>J});async function Xt(){if(!Ie){if(G){for(;G;)await new Promise(e=>setTimeout(e,200));return}G=!0;try{let{pipeline:e,env:t}=await import("@huggingface/transformers");t.allowRemoteModels=!0,t.allowLocalModels=!1,t.useBrowserCache=!0,ft=await e("feature-extraction","Xenova/all-MiniLM-L6-v2",{device:typeof navigator<"u"&&"gpu"in navigator?"webgpu":"wasm"}),mt=await e("question-answering","Xenova/distilbert-base-cased-distilled-squad",{device:typeof navigator<"u"&&"gpu"in navigator?"webgpu":"wasm"}),Ie=!0,G=!1,console.log("yuktai: Transformers.js models loaded \u2705")}catch(e){throw G=!1,console.error("yuktai: Transformers.js model load failed",e),e}}}function Qt(){return new Promise(e=>{let t=setTimeout(e,1500),n=new MutationObserver(()=>{clearTimeout(t),t=setTimeout(()=>{n.disconnect(),e()},500)});n.observe(document.body,{childList:!0,subtree:!0})})}function Zt(){let e=[],t=document.querySelectorAll("*");for(let n of t){if(n.closest("[data-yuktai-panel]"))continue;let i=n.innerText?.trim();i&&i.length>30&&e.push(i);let a=n.getAttribute("aria-label");a&&a.length>10&&e.push(a),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&n.placeholder&&e.push(n.placeholder)}return e.join(" ").slice(0,8e3)}function en(e,t=200,n=50){if(typeof e!="string")try{e=String(e??"")}catch{return[]}let i=e.trim();if(!i)return[];let a=Math.min(n,Math.floor(t/2)),s=i.split(/\s+/),o=[],c=t-a;for(let b=0;b<s.length;b+=c){let u=s.slice(b,b+t).join(" ");u.trim().length>20&&o.push(u)}return o}function tn(e,t){let n=0,i=0,a=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s],i+=e[s]*e[s],a+=t[s]*t[s];return n/(Math.sqrt(i)*Math.sqrt(a)+1e-8)}async function pt(e){let t=await ft(e,{pooling:"mean",normalize:!0}),n=t?.data??t;return Array.from(n)}async function nn(e,t,n=3){let i=await pt(e),a=await Promise.all(t.map(async s=>{let o=await pt(s),c=tn(i,o);return{chunk:s,score:c}}));return a.sort((s,o)=>o.score-s.score),a.slice(0,n).map(s=>s.chunk)}async function ze(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{await Xt(),await Qt();let t=Zt();if(!t||t.length<50)return{success:!1,answer:"",error:"Not enough content on this page."};let n=en(t);if(n.length===0)return{success:!1,answer:"",error:"Could not process page content."};let a=(await nn(e,n,3)).join(" ... "),s=await mt(e,a);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."}}}function J(){try{return typeof WebAssembly<"u"&&typeof Worker<"u"}catch{return!1}}function X(){return Ie?"ready":G?"loading":"idle"}var ft,mt,G,Ie,pe=xe(()=>{"use strict";p();ft=null,mt=null,G=!1,Ie=!1});var un={};he(un,{Runtime:()=>W,YuktAI:()=>dn,YuktAIWrapper:()=>fe,aiPlugin:()=>Z,default:()=>fe,voicePlugin:()=>ee,wcag:()=>C,wcagPlugin:()=>C});module.exports=Tt(un);p();p();p();function Oe(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function we(){try{let e=Oe();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 Et(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=Oe();if(!t)throw new Error("Rewriter API not available");let n=await t.create({tone:"more-casual",format:"plain-text",length:"as-is",outputLanguage:"en"}),i=await n.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return n.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 De(){if(!await we())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"),n=0;for(let i of t){let a=i.innerText?.trim();if(!a||a.length<20||i.closest("[data-yuktai-panel]"))continue;let s=await Et(a);s.success&&s.rewritten!==a&&(i.dataset.yuktaiOriginal=a,i.innerText=s.rewritten,n++)}return{fixed:n}}function Ge(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let n=t.dataset.yuktaiOriginal;n&&(t.innerText=n,delete t.dataset.yuktaiOriginal)}}p();var qe="yuktai-summary-box";function _e(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function ve(){try{let e=_e();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 Ct(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let n of e){if(n.closest("[data-yuktai-panel]"))continue;let i=window.getComputedStyle(n);if(i.display==="none"||i.visibility==="hidden")continue;let a=n.innerText?.trim();a&&a.length>10&&t.push(a)}return t.join(" ").slice(0,5e3)}async function je(){if(!await ve())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=Ct();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let n=_e();if(!n)throw new Error("Summarizer API not available");let i=await n.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),a=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(),Lt(a.trim()),{success:!0,summary:a.trim()}}catch(n){return{success:!1,summary:"",error:n instanceof Error?n.message:"Summary failed"}}}function Lt(e){oe();let t=document.createElement("div");t.id=qe,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
7
7
  position: fixed;
8
8
  top: 0;
9
9
  left: 0;
@@ -20,11 +20,11 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
20
20
  justify-content: space-between;
21
21
  gap: 12px;
22
22
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
23
- `;let a=document.createElement("p");a.style.cssText="margin: 0; flex: 1;",a.textContent=`\u{1F4CB} Page summary: ${e}`;let i=document.createElement("button");i.textContent="\xD7",i.setAttribute("aria-label","Close page summary"),i.style.cssText=`
23
+ `;let n=document.createElement("p");n.style.cssText="margin: 0; flex: 1;",n.textContent=`\u{1F4CB} Page summary: ${e}`;let i=document.createElement("button");i.textContent="\xD7",i.setAttribute("aria-label","Close page summary"),i.style.cssText=`
24
24
  background: none; border: none; color: #ffffff;
25
25
  font-size: 20px; cursor: pointer; padding: 0 4px;
26
26
  line-height: 1; flex-shrink: 0;
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=`
27
+ `,i.addEventListener("click",oe),t.appendChild(n),t.appendChild(i),document.body.prepend(t)}function oe(){let e=document.getElementById(qe);e&&e.remove()}p();var re=[{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"}],ie="en";function Mt(){let e=window;return e.Translator||e.translation||null}async function Pt(e){try{let t=window;if(!Mt())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 Rt(e){let t=window,n={sourceLanguage:"en",targetLanguage:e};if(t.Translator&&typeof t.Translator.create=="function")return await t.Translator.create(n);if(t.translation&&typeof t.translation.createTranslator=="function")return await t.translation.createTranslator(n);throw new Error("Translation API not available")}async function Ve(e){if(e===ie)return{success:!0,language:e,fixed:0};if(e==="en")return ke(),ie="en",{success:!0,language:"en",fixed:0};if(!await Pt(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let n=await Rt(e),i=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),a=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 n.translate(o);c&&c!==o&&(s.innerText=c,a++)}return typeof n.destroy=="function"&&n.destroy(),ie=e,{success:!0,language:e,fixed:a}}catch(n){return{success:!1,language:e,fixed:0,error:n instanceof Error?n.message:"Translation failed"}}}function ke(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let n=t.dataset.yuktaiTranslationOriginal;n&&(t.innerText=n,delete t.dataset.yuktaiTranslationOriginal)}ie="en"}p();var It=[{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"}],M=null,se=!1,N=null;function Ae(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function zt(e){let t=e.toLowerCase().trim();for(let n of It)for(let i of n.phrases)if(t.includes(i))return{action:n.action,label:n.label};return null}function Ht(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=Ke(),n=t.indexOf(document.activeElement),i=t[n+1]||t[0];i&&i.focus();break}case"tab-back":{let t=Ke(),n=t.indexOf(document.activeElement),i=t[n-1]||t[t.length-1];i&&i.focus();break}case"stop-voice":{Se();break}}}function Ke(){return Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>!e.closest("[data-yuktai-panel]"))}function Ye(e){if(!Ae())return!1;if(se)return!0;e&&(N=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return M=new t,M.continuous=!0,M.interimResults=!1,M.lang="en-US",M.onresult=n=>{let i=n.results[n.results.length-1][0].transcript,a=zt(i);if(a){Ht(a.action);let s={success:!0,command:i,action:a.label};if(N&&N(s),a.action==="stop-voice")return}},M.onend=()=>{se&&M?.start()},M.onerror=n=>{n.error!=="no-speech"&&N&&N({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},M.start(),se=!0,Wt(),!0}function Se(){se=!1,M&&(M.stop(),M=null),N=null,Je()}var Ue="yuktai-voice-indicator";function Wt(){Je();let e=document.createElement("div");e.id=Ue,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
28
28
  position: fixed;
29
29
  bottom: 80px;
30
30
  left: 50%;
@@ -54,7 +54,7 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
54
54
  0%, 100% { opacity: 1; transform: scale(1); }
55
55
  50% { opacity: 0.4; transform: scale(0.7); }
56
56
  }
57
- `,document.head.appendChild(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=`
57
+ `,document.head.appendChild(i)}let n=document.createElement("span");n.textContent="Listening for commands...",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}function Je(){let e=document.getElementById(Ue);e&&e.remove()}p();var Ft=["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 Xe(){let e=window;return e.Writer||e.ai?.writer||null}async function Te(){try{let e=Xe();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 $t(e){let t=[],n=e.innerText?.trim();n&&t.push(`element text: "${n}"`);let i=e.placeholder?.trim();i&&t.push(`placeholder: "${i}"`);let a=e.getAttribute("name")?.trim();a&&t.push(`name: "${a}"`);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 b=e.getAttribute("role");return b&&t.push(`role: ${b}`),t.join(". ")}async function Bt(e,t){let n=`
58
58
  Generate a short, clear aria-label for an HTML element.
59
59
  The label must be 2-6 words maximum.
60
60
  The label must describe what the element does or what it is.
@@ -65,7 +65,7 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
65
65
  ${t}
66
66
 
67
67
  Output only the label. Nothing else.
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=`
68
+ `.trim();return(await e.write(n)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Qe(){if(!await Te())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(Ft);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let n=Xe();if(!n)throw new Error("Writer API not available");let i=await n.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),a=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 b=$t(o),u=await Bt(i,b);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),a++,s.push({tag:o.tagName.toLowerCase(),label:u}))}return i.destroy(),{success:!0,fixed:a,elements:s}}catch(n){return{success:!1,fixed:0,elements:[],error:n instanceof Error?n.message:"Label generation failed"}}}function Ze(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let n=t.dataset.yuktaiLabelOriginal;n?t.setAttribute("aria-label",n):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var de=null,et=null;var tt=null,Ee=null,h=null,O=null,le=null,Ce=null,D=null,ce={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var nt=new Set(["input","select","textarea"]);var Le={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function Me(e,t="polite"){if(typeof window>"u"||!D?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.rate=1,n.pitch=1,n.volume=1;let i=window.speechSynthesis.getVoices();i.length>0&&(n.voice=i[0]),window.speechSynthesis.speak(n)}function ct(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];h||(h=document.createElement("div"),h.setAttribute("role","alert"),h.setAttribute("aria-live","assertive"),h.setAttribute("aria-atomic","true"),h.style.cssText=`
69
69
  position: fixed;
70
70
  top: 80px;
71
71
  right: 16px;
@@ -84,14 +84,14 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
84
84
  transition: transform 0.3s, opacity 0.3s;
85
85
  transform: translateX(120%);
86
86
  opacity: 0;
87
- `,document.body.appendChild(b)),b.style.background=i.bg,b.style.border=`1px solid ${i.border}`,b.style.color="#fff",b.innerHTML=`
87
+ `,document.body.appendChild(h)),h.style.background=i.bg,h.style.border=`1px solid ${i.border}`,h.style.color="#fff",h.innerHTML=`
88
88
  <span style="font-size:18px;font-weight:700">${i.icon}</span>
89
89
  <span style="flex:1;line-height:1.4">${e}</span>
90
90
  <button
91
91
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
92
92
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
93
93
  aria-label="Close notification">\xD7</button>
94
- `,window.innerWidth<=480&&(b.style.right="8px",b.style.left="8px",b.style.maxWidth="none",b.style.width="auto"),requestAnimationFrame(()=>{b&&(b.style.transform="translateX(0)",b.style.opacity="1")}),setTimeout(()=>{b&&(b.style.transform="translateX(120%)",b.style.opacity="0")},5e3)}function 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=`
94
+ `,window.innerWidth<=480&&(h.style.right="8px",h.style.left="8px",h.style.maxWidth="none",h.style.width="auto"),requestAnimationFrame(()=>{h&&(h.style.transform="translateX(0)",h.style.opacity="1")}),setTimeout(()=>{h&&(h.style.transform="translateX(120%)",h.style.opacity="0")},5e3)}function m(e,t="info",n=!0){de&&(de.textContent=e),ct(e,t),n&&Me(e,t==="error"?"assertive":"polite")}function Nt(){if(typeof document>"u"||tt)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
95
95
  position: fixed;
96
96
  top: 0;
97
97
  left: 0;
@@ -105,7 +105,7 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
105
105
  transform: translateY(-100%);
106
106
  transition: transform 0.2s ease;
107
107
  font-family: system-ui, sans-serif;
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=`
108
+ `;let n=!1;if(e.forEach(({label:a,selector:s})=>{let o=document.querySelector(s);if(!o)return;n=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let c=document.createElement("a");c.href="#",c.textContent=a,c.style.cssText=`
109
109
  color: #fff;
110
110
  background: #1a73e8;
111
111
  padding: 8px 14px;
@@ -116,7 +116,7 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
116
116
  white-space: nowrap;
117
117
  border: 2px solid transparent;
118
118
  transition: background 0.15s, border-color 0.15s;
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=`
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",b=>{b.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),m(`Jumped to ${a.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(c)}),!n)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),tt=t}function Ot(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
120
120
 
121
121
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
122
122
  [data-yuktai-a11y] *:focus-visible {
@@ -262,7 +262,7 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
262
262
  width: auto !important;
263
263
  }
264
264
  }
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=`
265
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function Dt(){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 n=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 a=t.closest("[role='menu'],[role='menubar']");a&&(a.style.display="none",m("Menu closed","info"))}if(n==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let i=t.closest("[role='menu'],[role='menubar']");if(!i)return;let a=Array.from(i.querySelectorAll("[role='menuitem']:not([disabled])")),s=a.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),a[(s+1)%a.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),a[(s-1+a.length)%a.length]?.focus()):e.key==="Home"?(e.preventDefault(),a[0]?.focus()):e.key==="End"&&(e.preventDefault(),a[a.length-1]?.focus())}if(n==="tab"||t.closest("[role='tablist']")){let i=t.closest("[role='tablist']");if(!i)return;let a=Array.from(i.querySelectorAll("[role='tab']:not([disabled])")),s=a.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=a[(s+1)%a.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=a[(s-1+a.length)%a.length];o?.focus(),o?.click()}}if(n==="option"||t.closest("[role='listbox']")){let i=t.closest("[role='listbox']");if(!i)return;let a=Array.from(i.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=a.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),a[(s+1)%a.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),a[(s-1+a.length)%a.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),a.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),m(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Gt()),e.key==="Tab"&&D?.speechEnabled&&setTimeout(()=>{let i=document.activeElement;if(!i)return;let a=i.getAttribute("aria-label")||i.getAttribute("title")||i.textContent?.trim()||i.tagName.toLowerCase(),s=i.getAttribute("role")||i.tagName.toLowerCase();Me(`${a}, ${s}`)},100)}))}function ue(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 n=t[0],i=t[t.length-1];n.focus(),e.addEventListener("keydown",a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===n&&(a.preventDefault(),i.focus()):document.activeElement===i&&(a.preventDefault(),n.focus()))})}function Gt(){if(typeof document>"u")return;if(O){O.remove(),O=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
266
266
  position: fixed;
267
267
  top: 50%;
268
268
  left: 50%;
@@ -286,18 +286,18 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
286
286
  style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1"
287
287
  aria-label="Close shortcuts">\xD7</button>
288
288
  </div>
289
- ${t.map(([i,n])=>`
289
+ ${t.map(([i,a])=>`
290
290
  <div style="display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid #2a2a4a">
291
291
  <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${i}</kbd>
292
- <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${n}</span>
292
+ <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${a}</span>
293
293
  </div>
294
294
  `).join("")}
295
- `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),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=`
295
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),O=null}),e.addEventListener("keydown",i=>{i.key==="Escape"&&(e.remove(),O=null)}),document.body.appendChild(e),O=e,ue(e),m("Keyboard shortcuts opened. Press Escape to close.","info")}function qt(e){if(typeof document>"u"||!D?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;Ee&&Ee.remove();let t=e.score,n=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",i=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",a=document.createElement("button");a.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),a.setAttribute("data-yuktai-badge","true"),a.style.cssText=`
296
296
  position: fixed;
297
297
  bottom: 16px;
298
298
  left: 16px;
299
299
  z-index: 999998;
300
- background: ${a};
300
+ background: ${n};
301
301
  color: #fff;
302
302
  border: none;
303
303
  border-radius: 20px;
@@ -311,7 +311,7 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
311
311
  align-items: center;
312
312
  gap: 6px;
313
313
  transition: transform 0.15s;
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=`
314
+ `,a.innerHTML=`${i} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,a.addEventListener("click",()=>_t(e)),document.body.appendChild(a),Ee=a}function _t(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let n=document.createElement("div");n.setAttribute("data-yuktai-audit-details","true"),n.setAttribute("role","dialog"),n.setAttribute("aria-label","Accessibility audit details"),n.style.cssText=`
315
315
  position: fixed;
316
316
  bottom: 56px;
317
317
  left: 16px;
@@ -328,22 +328,22 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
328
328
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
329
329
  font-family: system-ui, sans-serif;
330
330
  font-size: 12px;
331
- `;let i={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};a.innerHTML=`
331
+ `;let i={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};n.innerHTML=`
332
332
  <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
333
333
  <strong style="font-size:14px;color:#74c0fc">Audit report</strong>
334
334
  <span style="color:#aaa">${e.fixed} fixed \xB7 ${e.renderTime}ms</span>
335
335
  </div>
336
- ${e.details.slice(0,20).map(n=>`
336
+ ${e.details.slice(0,20).map(a=>`
337
337
  <div style="padding:6px 0;border-bottom:1px solid #2a2a4a">
338
338
  <div style="display:flex;gap:6px;align-items:center">
339
- <span style="background:${i[n.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${n.severity}</span>
340
- <code style="color:#74c0fc">&lt;${n.tag}&gt;</code>
339
+ <span style="background:${i[a.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${a.severity}</span>
340
+ <code style="color:#74c0fc">&lt;${a.tag}&gt;</code>
341
341
  </div>
342
- <div style="color:#ccc;margin-top:3px">${n.fix}</div>
342
+ <div style="color:#ccc;margin-top:3px">${a.fix}</div>
343
343
  </div>
344
344
  `).join("")}
345
345
  ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
346
- `,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=`
346
+ `,n.addEventListener("keydown",a=>{a.key==="Escape"&&n.remove()}),document.body.appendChild(n),ue(n)}function dt(e){typeof document>"u"||(Ce&&clearTimeout(Ce),Ce=setTimeout(()=>{if(le)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
347
347
  position: fixed;
348
348
  top: 50%;
349
349
  left: 50%;
@@ -372,19 +372,19 @@ Q: ${e}`,o=await n.prompt(s);return n?.destroy&&n.destroy(),{success:!0,answer:o
372
372
  No, sign out
373
373
  </button>
374
374
  </div>
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=`
375
+ `;let n=t.querySelector("[data-yuktai-extend]"),i=t.querySelector("[data-yuktai-dismiss]");n?.addEventListener("click",()=>{t.remove(),le=null,m("Session extended. You have more time.","success"),D?.timeoutWarning&&dt(D.timeoutWarning)}),i?.addEventListener("click",()=>{t.remove(),le=null}),document.body.appendChild(t),le=t,ue(t),m("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function jt(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 n=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${ce[e.colorBlindMode]})`;document.body.style.filter=n}else document.body.style.filter=""}function Vt(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function at(e){if(e){if(!await we()){m("Plain English requires Chrome 127+","warning");return}m("Rewriting page in plain English...","info",!1);let n=await De();m(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else Ge(),m("Original text restored","info",!1)}async function ot(e){if(e){if(!await ve()){m("Page summariser requires Chrome 127+","warning");return}m("Generating page summary...","info",!1);let n=await je();m(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else oe(),m("Page summary removed","info",!1)}async function it(e){if(e==="en"){ke(),m("Page restored to English","info",!1);return}m(`Translating page to ${e}...`,"info",!1);let t=await Ve(e);m(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function rt(e){if(e){if(!Ae()){m("Voice control not supported in this browser","warning");return}Ye(t=>{t.success&&m(`Voice: ${t.action}`,"info",!1)}),m("Voice control started. Say a command.","success",!1)}else Se(),m("Voice control stopped","info",!1)}async function st(e){if(e){if(!await Te()){m("Smart labels requires Chrome 127+","warning");return}m("Generating smart labels...","info",!1);let n=await Qe();m(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else Ze(),m("Smart labels removed","info",!1)}function Kt(){if(typeof document>"u"||de)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),de=e}function Yt(){if(typeof document>"u"||et)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
376
376
  <defs>
377
- <filter id="${ne.deuteranopia}">
377
+ <filter id="${ce.deuteranopia}">
378
378
  <feColorMatrix type="matrix"
379
379
  values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
380
380
  </filter>
381
- <filter id="${ne.protanopia}">
381
+ <filter id="${ce.protanopia}">
382
382
  <feColorMatrix type="matrix"
383
383
  values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
384
384
  </filter>
385
- <filter id="${ne.tritanopia}">
385
+ <filter id="${ce.tritanopia}">
386
386
  <feColorMatrix type="matrix"
387
387
  values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
388
388
  </filter>
389
389
  </defs>
390
- `,document.body.appendChild(e),_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("@xenova/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){if(typeof e!="string")try{e=String(e??"")}catch{return[]}if(e=e.trim(),!e)return[];t<=a&&(a=Math.floor(t/2));let i=e.split(/\s+/),n=[],s=t-a;for(let o=0;o<i.length;o+=s){let c=i.slice(o,o+t).join(" ");c&&c.trim().length>20&&n.push(c)}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});
390
+ `,document.body.appendChild(e),et=e}function lt(e){let t={critical:20,serious:10,moderate:5,minor:2},n=e.details.reduce((i,a)=>i+(t[a.severity]||0),0);return Math.max(0,Math.min(100,100-n))}var C={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";D=e,Vt(e),Kt(),Yt(),Ot(),Dt(),e.showSkipLinks!==!1&&Nt(),e.showPreferencePanel,jt(e);let t=this.applyFixes(e);t.score=lt(t),e.showAuditBadge&&qt(t),e.timeoutWarning&&dt(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await at(!0),e.summarisePage&&await ot(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await it(e.translateLanguage),e.voiceControl&&await rt(!0),e.smartLabels&&await st(!0);let n=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return m(n,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${n} 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 n=performance.now(),i=document.querySelectorAll("*");t.scanned=i.length;let a=(s,o,c,b)=>{t.details.push({tag:s,fix:o,severity:c,element:b.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"),a(c,'lang="en" added',"critical",o)),c==="meta"){let u=o.getAttribute("name"),A=o.getAttribute("content")||"";u==="viewport"&&A.includes("user-scalable=no")&&(o.setAttribute("content",A.replace("user-scalable=no","user-scalable=yes")),a(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(A)&&(o.setAttribute("content",A.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(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"),a(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"),a(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"),a(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),a(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"),a(c,"aria-label added (empty link)","critical",o)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(nt.has(c)){let u=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let A=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",A),a(c,`aria-label="${A}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let A=u.name||"";u.type==="email"||A.includes("email")?u.autocomplete="email":u.type==="tel"||A.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"),a(c,"scope added to <th>","moderate",o)),Le[c]&&!o.getAttribute("role")&&(o.setAttribute("role",Le[c]),a(c,`role="${Le[c]}"`,"minor",o));let b=o.getAttribute("role")||"";b==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(b)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",b==="alert"?"assertive":"polite"),a(c,`aria-live added on role=${b}`,"moderate",o)),b==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),a(c,'aria-expanded="false" on combobox',"serious",o)),(b==="checkbox"||b==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),a(c,`aria-checked="false" on role=${b}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-n).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(),n=document.querySelectorAll("*");e.scanned=n.length;let i=(a,s,o,c)=>e.details.push({tag:a,fix:s,severity:o,element:c.outerHTML.slice(0,100)});return n.forEach(a=>{let s=a,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),nt.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=lt(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:Me,showVisualAlert:ct,trapFocus:ue,handlePlainEnglish:at,handleSummarisePage:ot,handleTranslate:it,handleVoiceControl:rt,handleSmartLabels:st,SUPPORTED_LANGUAGES:re};p();p();var g=Ne(require("react"));p();var T=require("react");Re();pe();var r=require("react/jsx-runtime"),He={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],an=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],on=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function rn(){let[e,t]=(0,T.useState)(typeof window<"u"?window.innerWidth:1024);return(0,T.useEffect)(()=>{let n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function sn({checked:e,onChange:t,label:n,disabled:i=!1}){return(0,r.jsxs)("label",{"aria-label":n,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:a=>t(a.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,r.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,r.jsx)("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function _({label:e,color:t="#64748b",badge:n,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}),n&&(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:n})]}),i&&(0,r.jsx)("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8",fontStyle:"italic"},children:i})]})}function P({icon:e,label:t,desc:n,checked:i,onChange:a,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:n})]})]}),(0,r.jsx)(sn,{checked:i,onChange:a,label:`Toggle ${t}`,disabled:s})]})}function S(){return(0,r.jsx)("div",{style:{height:"1px",background:"#f1f5f9"}})}function Q({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,n)=>(0,r.jsxs)("p",{style:{margin:"0 0 2px",fontSize:"10px",color:"#475569"},children:[n+1,". ",t]},n))]})}var We=(0,T.forwardRef)(({position:e,settings:t,report:n,isActive:i,aiSupported:a,voiceSupported:s,set:o,onApply:c,onReset:b,onClose:u},A)=>{let{isMobile:w,isTablet:j}=rn(),[te,me]=(0,T.useState)([]),[R,F]=(0,T.useState)(""),[z,I]=(0,T.useState)(""),[v,V]=(0,T.useState)(!1),[f,H]=(0,T.useState)(null),[L,$]=(0,T.useState)("idle");(0,T.useEffect)(()=>{let l=window;!!(l.LanguageModel||l.ai?.languageModel)&&a?H("gemini"):J()&&H("transformers")},[a]),(0,T.useEffect)(()=>{if(f!=="transformers")return;let l=setInterval(()=>{$(X())},500);return()=>clearInterval(l)},[f]);let x=async()=>{if(!(!R.trim()||v)){if(!f){I("\u26A0\uFE0F No AI engine available on this device.");return}V(!0),I("");try{let l;f==="gemini"?l=await Pe(R):($("loading"),l=await ze(R),$("ready")),I(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{I("\u26A0\uFE0F Failed to get answer. Please try again.")}V(!1)}};(0,T.useEffect)(()=>{(async()=>{try{let B=window;if(!B.queryLocalFonts)return;let ge=await B.queryLocalFonts(),be=[...new Set(ge.map(ye=>ye.family))].sort();me(be.slice(0,50))}catch{}})()},[]);let ne=f==="gemini"?"Gemini Nano":f==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",K=f==="transformers"&&L==="loading"?"Loading AI model... (first time only)":"...",Y=w?{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px 16px 0 0",boxShadow:"0 -8px 32px rgba(0,0,0,0.12)",maxHeight:"90vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif",width:"100%"}:{position:"fixed",bottom:"84px",[e]:"24px",zIndex:9999,width:j?"300px":"320px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",maxHeight:"80vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif"};return(0,r.jsxs)("div",{ref:A,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:Y,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:w?"44px":"auto",minHeight:w?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,r.jsx)(_,{label:"\u267F Core Accessibility",concept:"Rule-based engine \u2014 works on all browsers and devices"}),(0,r.jsx)(Q,{steps:["Toggle any feature on","Click Apply settings","Preferences saved automatically"]}),(0,r.jsx)(P,{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)(S,{}),(0,r.jsx)(P,{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)(S,{}),(0,r.jsx)(P,{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)(S,{}),(0,r.jsx)(_,{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:a?"#f0fdfa":"#f5f3ff",borderRadius:"8px",border:`0.5px solid ${a?"#99f6e4":"#c4b5fd"}`,fontSize:"10px",color:a?"#0f766e":"#7c3aed",lineHeight:1.5},children:a?"\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."}),!a&&(0,r.jsxs)("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[(0,r.jsx)("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} 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:on.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)(P,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Rewrites complex text in simple language",checked:t.plainEnglish,onChange:l=>o("plainEnglish",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: LLM text rewriting"}),(0,r.jsx)(S,{}),(0,r.jsx)(P,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary appears at top",checked:t.summarisePage,onChange:l=>o("summarisePage",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Abstractive summarisation"}),(0,r.jsx)(S,{}),(0,r.jsx)(P,{icon:"\u{1F3F7}\uFE0F",label:"Smart aria-labels",desc:"AI generates meaningful labels for elements",checked:t.smartLabels,onChange:l=>o("smartLabels",l),disabled:!a,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Context-aware label generation"}),(0,r.jsx)(S,{}),(0,r.jsx)(_,{label:"\u{1F441}\uFE0F Visual",concept:"CSS filter-based \u2014 works on all browsers and devices"}),(0,r.jsx)(Q,{steps:["Toggle any visual mode","Changes apply instantly","Works on mobile and desktop"]}),(0,r.jsx)(P,{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)(S,{}),(0,r.jsx)(P,{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)(S,{}),(0,r.jsx)(P,{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)(S,{}),(0,r.jsx)(P,{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)(S,{}),(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:an.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:w?"36px":"auto"},children:l.label},l.value))})]}),(0,r.jsx)(S,{}),(0,r.jsx)(_,{label:"\u{1F524} Font",concept:"Browser Font API + CSS \u2014 Chrome 103+"}),(0,r.jsx)(Q,{steps:["Toggle dyslexia font or pick from device","Adjust size with + / \u2212","Saved across visits"]}),(0,r.jsx)(P,{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)(S,{}),(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+"}),te.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:w?"44px":"36px"},children:[(0,r.jsx)("option",{value:"",children:"System default"}),te.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)(S,{}),(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:w?"44px":"30px",height:w?"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:w?"44px":"30px",height:w?"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)(S,{}),(0,r.jsx)(_,{label:"\u{1F310} Translate",color:"#7c3aed",badge:"Gemini Nano",concept:"Chrome Translation API \u2014 on device, no internet after setup"}),(0,r.jsx)(Q,{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:re.slice(0,w?8:18).map(l=>(0,r.jsx)("button",{onClick:()=>o("translateLanguage",l.code),"aria-pressed":t.translateLanguage===l.code,disabled:!a,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===l.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===l.code?"#f5f3ff":"#fff",color:t.translateLanguage===l.code?"#7c3aed":"#64748b",cursor:a?"pointer":"not-allowed",opacity:a?1:.5,minHeight:w?"36px":"auto"},children:l.label},l.code))}),!a&&(0,r.jsx)("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above."})]}),(0,r.jsx)(S,{}),(0,r.jsx)(_,{label:"\u{1F4AC} Ask This Page",color:"#0d9488",badge:ne,concept:"RAG \u2014 Retrieval Augmented Generation. Works on all devices including mobile."}),(0,r.jsx)(Q,{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."]}),(0,r.jsxs)("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"&&L==="loading"&&" \xB7 Loading model...",f==="transformers"&&L==="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=>F(l.target.value),onKeyDown:l=>{l.key==="Enter"&&x()},placeholder:"e.g. What does this page do?",disabled:v||!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:w?"44px":"36px"}}),(0,r.jsx)("button",{onClick:x,disabled:v||!R.trim()||!f,"aria-label":"Ask question",style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:f&&R.trim()&&!v?"#0d9488":"#e2e8f0",color:f&&R.trim()&&!v?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:f&&R.trim()&&!v?"pointer":"not-allowed",flexShrink:0,height:w?"44px":"36px",minWidth:"52px",transition:"background 0.2s"},children:v?K:"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:()=>{I(""),F("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]})]}),n&&(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:n.fixed>0?`\u2713 ${n.fixed} fixes \xB7 ${n.scanned} nodes \xB7 ${n.renderTime}ms \xB7 Score: ${n.score}/100`:`\u2713 0 auto-fixes needed \xB7 ${n.scanned} nodes \xB7 ${n.renderTime}ms`}),(0,r.jsxs)("div",{style:{display:"flex",gap:"8px",padding:"12px 14px 14px",position:w?"sticky":"relative",bottom:w?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[(0,r.jsx)("button",{onClick:b,style:{flex:1,padding:w?"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:w?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});We.displayName="WidgetPanel";pe();var y=require("react/jsx-runtime");async function ln(){try{if(typeof window>"u")return!1;let e=window;if(e.LanguageModel)try{if(typeof e.LanguageModel.availability=="function"){let n=await e.LanguageModel.availability();if(n==="readily"||n==="available"||n==="downloadable")return!0}else return!0}catch{}if(e.Summarizer)try{let n=await e.Summarizer.availability?.();if(!n||n==="readily"||n==="available")return!0}catch{}if(e.Rewriter)try{let n=await e.Rewriter.availability?.();if(!n||n==="readily"||n==="available")return!0}catch{}if(e.Writer)try{let n=await e.Writer.availability?.();if(!n||n==="readily"||n==="available")return!0}catch{}let t=e.ai||globalThis.ai;if(t){if(t.languageModel?.availability)try{let n=await t.languageModel.availability();if(n==="readily"||n==="available")return!0}catch{}if(t.languageModel&&typeof t.languageModel.create=="function"||t.summarizer||t.rewriter||t.writer||t.languageModel)return!0}return!!(e.Translator||e.translation?.canTranslate)}catch{return!1}}function fe({position:e="left",children:t,config:n={},showRag:i=!1}){let[a,s]=(0,g.useState)(!1),[o,c]=(0,g.useState)(He),[b,u]=(0,g.useState)(null),[A,w]=(0,g.useState)(!1),[j,te]=(0,g.useState)(!1),[me,R]=(0,g.useState)(!1),F=g.default.useRef(null),[z,I]=(0,g.useState)(!1),[v,V]=(0,g.useState)(""),[f,H]=(0,g.useState)(""),[L,$]=(0,g.useState)(!1),[x,ne]=(0,g.useState)(null),[K,Y]=(0,g.useState)("idle");(0,g.useEffect)(()=>{if(typeof window>"u")return;let d=window;!!(d.LanguageModel||d.ai?.languageModel)&&j?ne("gemini"):J()&&ne("transformers")},[j]),(0,g.useEffect)(()=>{if(x!=="transformers")return;let d=setInterval(()=>Y(X()),500);return()=>clearInterval(d)},[x]);let l=(0,g.useCallback)(async()=>{if(!(!v.trim()||L)){if(!x){H("\u26A0\uFE0F No AI engine available on this device.");return}$(!0),H("");try{let d;if(x==="gemini"){let{askPage:k}=await Promise.resolve().then(()=>(Re(),ut));d=await k(v)}else{Y("loading");let{askPageWithTransformers:k}=await Promise.resolve().then(()=>(pe(),gt));d=await k(v),Y("ready")}H(d.success&&d.answer?d.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(d.error||"No answer found."))}catch{H("\u26A0\uFE0F Something went wrong. Please try again.")}$(!1)}},[v,L,x]);(0,g.useEffect)(()=>{if(typeof window>"u")return;let k=setTimeout(async()=>{let U=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.LanguageModel =",U.LanguageModel);let $e=await ln();te($e),console.log($e?"yuktai: Chrome Built-in AI detected \u2705":"yuktai: Chrome Built-in AI not detected \u2014 Transformers.js will handle RAG on mobile"),R(!!(U.SpeechRecognition||U.webkitSpeechRecognition))},800);return()=>clearTimeout(k)},[]),(0,g.useEffect)(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");d&&c(k=>({...k,...JSON.parse(d)}))}catch{}},[]);let B=(0,g.useCallback)(async d=>{let k={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,...n};await C.execute(k),u(C.applyFixes(k)),w(!0)},[n]),ge=(0,g.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(o))}catch{}await B(o),s(!1)},[o,B]),be=(0,g.useCallback)(()=>{c(He);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(k=>d.removeAttribute(k)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",u(null),w(!1)},[]),ye=(0,g.useCallback)((d,k)=>{c(U=>({...U,[d]:k}))},[]);(0,g.useEffect)(()=>{let d=k=>{k.key==="Escape"&&(a&&s(!1),z&&I(!1))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,z]),(0,g.useEffect)(()=>{a&&F.current&&C.trapFocus(F.current)},[a]);let yt=x==="transformers"&&K==="loading"?"Loading AI... (first time only)":"...",Fe=x==="gemini"?"Gemini Nano \xB7 On device \xB7 Instant":x==="transformers"?"Transformers.js \xB7 All devices \xB7 Offline":"Detecting engine...",xt={position:"fixed",bottom:"24px",[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:A?"#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"},ht={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:ht,"aria-label":"Ask a question about this page","aria-haspopup":"dialog","aria-expanded":z,title:`Ask this page \xB7 ${Fe}`,onClick:()=>{I(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:x==="gemini"?"#0d9488":"#7c3aed"},children:Fe}),x==="transformers"&&K==="loading"&&(0,y.jsx)("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8"},children:"Downloading AI model \u2014 first time only (~90MB)"}),x==="transformers"&&K==="ready"&&(0,y.jsx)("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#0d9488"},children:"Model ready \u2705 \u2014 works offline now"})]}),(0,y.jsx)("button",{onClick:()=>I(!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:v,onChange:d=>V(d.target.value),onKeyDown:d=>{d.key==="Enter"&&l()},placeholder:"e.g. What does this page do?",disabled:L||!x,"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:x?"#fff":"#f8fafc",outline:"none",height:"36px"}}),(0,y.jsx)("button",{onClick:l,disabled:L||!v.trim()||!x,"aria-label":"Submit question",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:x&&v.trim()&&!L?"#7c3aed":"#e2e8f0",color:x&&v.trim()&&!L?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:x&&v.trim()&&!L?"pointer":"not-allowed",height:"36px",minWidth:"48px",transition:"background 0.2s"},children:L?yt:"Ask"})]}),f&&(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"}),f,(0,y.jsx)("button",{onClick:()=>{H(""),V("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!x&&(0,y.jsx)("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Detecting AI engine..."})]}),(0,y.jsx)("button",{style:xt,"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":a,"data-yuktai-pref-toggle":"true",onClick:()=>{s(d=>!d),I(!1)},onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),a&&(0,y.jsx)(We,{ref:F,position:e,settings:o,report:b,isActive:A,aiSupported:j,voiceSupported:me,set:ye,onApply:ge,onReset:be,onClose:()=>s(!1)})]})}p();var Z={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};p();var ee={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};p();var W=class{plugins=new Map;register(t,n){if(!n||typeof n.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,n)}use(t){return this.plugins.get(t)}async run(t,n){try{let i=this.use(t);if(!i)throw new Error(`Plugin not found: ${t}`);return await i.execute(n)}catch(i){throw console.error(`[YuktAI Runtime Error in ${t}]:`,i),i}}getPlugins(){return Array.from(this.plugins.keys())}};function cn(){if(typeof globalThis>"u")return new W;if(!globalThis.__yuktai_runtime__){let e=new W;e.register(C.name,C),e.register(Z.name,Z),e.register(ee.name,ee),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var bt=typeof window<"u"?cn():new W,dn={wcagPlugin:C,list(){return bt.getPlugins()},use(e){return bt.use(e)},fix(e){return C.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return C.scan()}};