@yuktishaalaa/yuktai 3.0.13 → 3.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,29 +1,32 @@
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 f=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.
1
+ "use strict";var Vt=Object.create;var pe=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Kt=Object.getOwnPropertyNames;var Ut=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var fe=(e,t)=>()=>(e&&(t=e(e=0)),t);var me=(e,t)=>{for(var n in t)pe(e,n,{get:t[n],enumerable:!0})},et=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Kt(t))!Jt.call(e,i)&&i!==n&&pe(e,i,{get:()=>t[i],enumerable:!(a=Yt(t,i))||a.enumerable});return e};var tt=(e,t,n)=>(n=e!=null?Vt(Ut(e)):{},et(t||!e||!e.__esModule?pe(n,"default",{value:e,enumerable:!0}):n,e)),Xt=e=>et(pe({},"__esModule",{value:!0}),e);var g=fe(()=>{});var Lt={};me(Lt,{askPage:()=>Ne});function kn(){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 An(){let e=[],t=document.querySelectorAll("*");for(let n of t){if(n.closest("[data-yuktai-panel]"))continue;let a=n.innerText?.trim();a&&a.length>30&&e.push(a);let i=n.getAttribute("aria-label");if(i&&i.length>10&&e.push(i),(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 Ne(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 kn();let a=An();if(!a||a.length<100)return{success:!1,answer:"",error:"Page content not readable."};let i;try{i=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{a=await n.create()}let s=`Page:
4
- ${i}
3
+ If not found say: "I could not find that on this page."`,outputLanguage:"en"})}catch{i=await n.create()}let s=`Page:
4
+ ${a}
5
5
 
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";f()});var gt={};he(gt,{askPageWithTransformers:()=>ze,getModelLoadStatus:()=>X,isTransformersSupported:()=>J});function Xt(){try{if(typeof navigator<"u"&&"gpu"in navigator&&navigator.gpu!==void 0)return"webgpu"}catch{}return"wasm"}async function Qt(){if(!Ie){if(_){for(;_;)await new Promise(e=>setTimeout(e,200));return}_=!0;try{let{pipeline:e,env:t}=await import("@huggingface/transformers");t.allowRemoteModels=!0,t.allowLocalModels=!1,typeof window<"u"&&typeof caches<"u"?t.useBrowserCache=!0:t.useBrowserCache=!1;let n=Xt();console.log("yuktai: Transformers.js using device:",n),ft=await e("feature-extraction","Xenova/all-MiniLM-L6-v2",{device:n}),mt=await e("text2text-generation","Xenova/flan-t5-small",{device:n}),Ie=!0,_=!1,console.log("yuktai: Transformers.js models loaded \u2705")}catch(e){throw _=!1,console.error("yuktai: Transformers.js model load failed",e),e}}}function Zt(){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 en(){let e=[],t=new Set,n=document.querySelectorAll(`
7
- p, h1, h2, h3, h4, h5, h6,
8
- li, ul, ol, dl, dt, dd,
9
- td, th, tr, caption,
10
- blockquote, q, cite,
11
- figcaption, figure,
12
- label, legend, fieldset,
13
- span, a, b, strong, em, i, u, s, mark, small,
14
- abbr, acronym, dfn, code, pre, kbd, samp, var,
15
- article, section, main, aside, nav, header, footer,
16
- div, button, summary, details,
17
- time, address, bdi, bdo,
18
- ins, del, sub, sup,
19
- title, caption
20
- `);for(let a of n){if(a.closest("[data-yuktai-panel]"))continue;let s=window.getComputedStyle(a);if(s.display==="none"||s.visibility==="hidden"||s.opacity==="0"||a.querySelector("p, h1, h2, h3, h4, h5, h6, li, td, div, article, section"))continue;let c=a.innerText?.trim();if(!c||c.length<15||t.has(c))continue;t.add(c),e.push(c);let p=a.getAttribute("aria-label")?.trim();p&&p.length>8&&p!==c&&!t.has(p)&&(t.add(p),e.push(p));let u=a.getAttribute("aria-description")?.trim();u&&u.length>8&&!t.has(u)&&(t.add(u),e.push(u));let x=a.getAttribute("title")?.trim();x&&x.length>8&&x!==c&&!t.has(x)&&(t.add(x),e.push(x)),a.querySelectorAll("img").forEach(h=>{let P=h.getAttribute("alt")?.trim();P&&P.length>8&&!t.has(P)&&(t.add(P),e.push(P))})}document.querySelectorAll("input, textarea").forEach(a=>{a.closest("[data-yuktai-panel]")||(a.placeholder&&!t.has(a.placeholder)&&(t.add(a.placeholder),e.push(a.placeholder)),a.value&&a.value.length>10&&!t.has(a.value)&&(t.add(a.value),e.push(a.value)))}),document.querySelectorAll("select").forEach(a=>{a.closest("[data-yuktai-panel]")||Array.from(a.options).forEach(s=>{let o=s.text?.trim();o&&o.length>5&&!t.has(o)&&(t.add(o),e.push(o))})}),document.querySelectorAll('meta[name="description"], meta[name="keywords"], meta[property="og:title"], meta[property="og:description"]').forEach(a=>{let s=a.getAttribute("content")?.trim();s&&s.length>10&&!t.has(s)&&(t.add(s),e.push(s))});let i=document.title?.trim();return i&&!t.has(i)&&(t.add(i),e.unshift(i)),e.join(" ").slice(0,8e3)}function tn(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 p=0;p<s.length;p+=c){let u=s.slice(p,p+t).join(" ");u.trim().length>20&&o.push(u)}return o}function nn(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 an(e,t,n=5){let i=await pt(e),a=await Promise.all(t.map(async s=>{let o=await pt(s),c=nn(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 Qt(),await Zt();let t=en();if(!t||t.length<50)return{success:!1,answer:"",error:"Not enough content on this page."};let n=tn(t);if(n.length===0)return{success:!1,answer:"",error:"Could not process page content."};let s=`Answer the question based on the context below. Give a complete and helpful answer in 2-3 sentences.
6
+ Q: ${e}`,o=await i.prompt(s);return i?.destroy&&i.destroy(),{success:!0,answer:o?.trim()||"No answer found."}}catch(t){return{success:!1,answer:"",error:t instanceof Error?t.message:"Error occurred"}}}var Be=fe(()=>{"use strict";g()});var De={};me(De,{askPageWithTransformers:()=>Oe,getModelLoadStatus:()=>ie,isTransformersSupported:()=>ae});function Pt(){return typeof navigator>"u"?!1:/Android|iPhone|iPad|iPod|Mobile|Tablet/i.test(navigator.userAgent)}function Sn(){if(Pt())return"wasm";try{if(typeof navigator<"u"&&"gpu"in navigator&&navigator.gpu!==void 0)return"webgpu"}catch{}return"wasm"}async function Tn(){if(!qe){if(X){for(;X;)await new Promise(e=>setTimeout(e,200));return}X=!0;try{let{pipeline:e,env:t}=await import("@huggingface/transformers");t.allowRemoteModels=!0,t.allowLocalModels=!1,typeof window<"u"&&typeof caches<"u"&&(t.useWasmCache=!0);let n=Sn(),a=Pt();console.log(`yuktai: Transformers.js \u2014 device: ${n}, mobile: ${a}`),Ct=await e("feature-extraction","Xenova/all-MiniLM-L6-v2",{device:n,dtype:a?"q4":"fp32"}),Rt=await e("text2text-generation","Xenova/flan-t5-small",{device:n,dtype:a?"q4":"fp32"}),qe=!0,X=!1,console.log("yuktai: Transformers.js models loaded \u2705")}catch(e){throw X=!1,console.error("yuktai: Transformers.js model load failed",e),e}}}function En(){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 Ln(){let e=[],t=new Set,n=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, td, th, label, figcaption, blockquote, span, a, button, div");for(let o of n){if(o.closest("[data-yuktai-panel]")||o.querySelector("p, h1, h2, h3, h4, li, td, div"))continue;let d=o.innerText?.trim();if(!d||d.length<15||t.has(d))continue;t.add(d),e.push(d);let p=o.getAttribute("aria-label")?.trim();p&&p.length>8&&!t.has(p)&&(t.add(p),e.push(p))}let a=document.title?.trim();a&&!t.has(a)&&e.unshift(a);let s=document.querySelector('meta[name="description"]')?.getAttribute("content")?.trim();return s&&!t.has(s)&&e.unshift(s),e.join(" ").slice(0,8e3)}function Mn(e,t=150,n=30){if(typeof e!="string")try{e=String(e??"")}catch{return[]}let a=e.trim();if(!a)return[];let i=Math.min(n,Math.floor(t/2)),s=a.split(/\s+/),o=[],l=t-i;for(let d=0;d<s.length;d+=l){let p=s.slice(d,d+t).join(" ");p.trim().length>20&&o.push(p)}return o}function Cn(e,t){let n=0,a=0,i=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s],a+=e[s]*e[s],i+=t[s]*t[s];return n/(Math.sqrt(a)*Math.sqrt(i)+1e-8)}async function Mt(e){let t=await Ct(e,{pooling:"mean",normalize:!0}),n=t?.data??t;return Array.from(n)}async function Rn(e,t,n=3){let a=await Mt(e),i=await Promise.all(t.map(async s=>{let o=await Mt(s),l=Cn(a,o);return{chunk:s,score:l}}));return i.sort((s,o)=>o.score-s.score),i.slice(0,n).map(s=>s.chunk)}async function Oe(e){if(!e.trim())return{success:!1,answer:"",error:"Please type a question."};try{await Tn(),await En();let t=Ln();if(!t||t.length<50)return{success:!1,answer:"",error:"Not enough content on this page."};let n=Mn(t);if(n.length===0)return{success:!1,answer:"",error:"Could not process page content."};let s=`Answer the question based on the context. Give a complete answer in 2-3 sentences.
21
7
 
22
- Context: ${(await an(e,n,5)).join(" ").slice(0,1500)}
8
+ Context: ${(await Rn(e,n,3)).join(" ").slice(0,1200)}
23
9
 
24
10
  Question: ${e}
25
11
 
26
- Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_text?.trim()||"";return!c||c.length===0?{success:!0,answer:"I could not find a specific answer on this page."}:{success:!0,answer:c}}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":_?"loading":"idle"}var ft,mt,_,Ie,pe=xe(()=>{"use strict";f();ft=null,mt=null,_=!1,Ie=!1});var pn={};he(pn,{Runtime:()=>W,YuktAI:()=>un,YuktAIWrapper:()=>fe,aiPlugin:()=>Z,default:()=>fe,voicePlugin:()=>ee,wcag:()=>C,wcagPlugin:()=>C});module.exports=Tt(pn);f();f();f();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 qe(){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 De(){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)}}f();var _e="yuktai-summary-box";function Ge(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function ve(){try{let e=Ge();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}return typeof e.capabilities=="function"?(await e.capabilities())?.available!=="no":typeof e.create=="function"}catch{return!1}}function 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=Ge();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=_e,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
12
+ Answer:`,l=(await Rt(s,{max_new_tokens:120,min_new_tokens:10}))?.[0]?.generated_text?.trim()||"";return l?{success:!0,answer:l}:{success:!0,answer:"I could not find a specific answer on this page."}}catch(t){console.error("yuktai: Transformers RAG error",t);let n=t instanceof Error?t.message:"";return n.includes("Out of memory")||n.includes("memory")?{success:!1,answer:"",error:"Not enough device memory. Try on a device with more RAM or use desktop Chrome with Gemini Nano."}:{success:!1,answer:"",error:n||"Transformers.js error."}}}function ae(){try{return typeof WebAssembly<"u"&&typeof Worker<"u"}catch{return!1}}function ie(){return qe?"ready":X?"loading":"idle"}var Ct,Rt,X,qe,re=fe(()=>{"use strict";g();Ct=null,Rt=null,X=!1,qe=!1});var Ft={};me(Ft,{getPageText:()=>It,highlightField:()=>zt,runAgent:()=>Nn,scanFormFields:()=>Ht,scrollToSection:()=>$t});function _(e){try{let t=window.getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden"||t.opacity==="0"||e.hidden)return!1;let n=e.getBoundingClientRect();return!(n.width===0&&n.height===0)}catch{return!0}}function It(){let e=[],t=new Set,n=o=>{let l=o.trim();l&&l.length>10&&!t.has(l)&&(t.add(l),e.push(l))};document.title&&n(document.title);let a=['meta[name="description"]','meta[name="keywords"]','meta[property="og:title"]','meta[property="og:description"]','meta[name="twitter:title"]','meta[name="twitter:description"]'];for(let o of a){let l=document.querySelector(o)?.getAttribute("content");l&&n(l)}let i=["h1","h2","h3","h4","h5","h6","p","blockquote","q","pre","code","li","dt","dd","th","td","caption","a","b","strong","em","i","u","s","abbr","acronym","cite","dfn","mark","small","sub","sup","ins","del","bdi","bdo","article","section","aside","nav","header","footer","main","summary","details","figcaption","figure","address","time","output","label","legend","option","button","font","center","span","div","[role='heading']","[role='main']","[role='article']","[role='region']","[role='complementary']","[role='contentinfo']","[role='navigation']","[role='banner']","[role='listitem']","[role='cell']","[role='columnheader']","[role='rowheader']"],s=document.querySelectorAll(i.join(","));for(let o of s){if(o.closest("[data-yuktai-panel]")||!_(o)||o.querySelector("p, h1, h2, h3, h4, h5, h6, li, td, th, div, article, section, blockquote, pre"))continue;let d=o.innerText?.trim();if(d&&d.length>10&&n(d),!d){let A=o.textContent?.trim();A&&A.length>10&&n(A)}let p=o.getAttribute("aria-label")?.trim();p&&p.length>5&&n(p);let h=o.getAttribute("aria-description")?.trim();h&&h.length>5&&n(h);let b=o.getAttribute("aria-valuetext")?.trim();b&&n(b);let q=o.getAttribute("title")?.trim();q&&q.length>5&&n(q);let N=o.getAttribute("data-label")?.trim();N&&n(N);let Y=o.getAttribute("data-title")?.trim();Y&&n(Y),o.querySelectorAll("img").forEach(A=>{let O=A.getAttribute("alt")?.trim();O&&O.length>5&&n(O);let $=A.getAttribute("title")?.trim();$&&$.length>5&&n($)})}document.querySelectorAll("img").forEach(o=>{if(o.closest("[data-yuktai-panel]")||!_(o))return;let l=o.getAttribute("alt")?.trim(),d=o.getAttribute("title")?.trim();l&&l.length>5&&n(l),d&&d.length>5&&n(d)}),document.querySelectorAll("input:not([type=hidden]), textarea").forEach(o=>{if(o.closest("[data-yuktai-panel]")||!_(o))return;o.placeholder&&n(o.placeholder),o.value&&o.value.length>3&&n(o.value);let l=o.getAttribute("aria-label")?.trim();l&&n(l)}),document.querySelectorAll("select").forEach(o=>{o.closest("[data-yuktai-panel]")||_(o)&&Array.from(o.options).forEach(l=>{l.text?.trim().length>3&&n(l.text.trim())})}),document.querySelectorAll("td, th").forEach(o=>{if(o.closest("[data-yuktai-panel]")||!_(o))return;let l=o.innerText?.trim();l&&l.length>3&&n(l)});try{document.querySelectorAll("iframe").forEach(o=>{try{let l=o.contentDocument;if(!l)return;let d=l.body?.innerText?.trim();d&&d.length>20&&n(d.slice(0,500))}catch{}})}catch{}return document.querySelectorAll("a").forEach(o=>{if(o.closest("[data-yuktai-panel]")||!_(o))return;let l=o.innerText?.trim();l&&l.length>3&&l.length<100&&n(l)}),e.join(" ").slice(0,5e3)}function $n(e){let t=e.getAttribute("aria-label")?.trim();if(t)return t;let n=e.getAttribute("aria-labelledby");if(n){let d=document.getElementById(n);if(d)return d.innerText?.trim()||""}if(e.id){let d=document.querySelector(`label[for="${e.id}"]`);if(d)return d.innerText?.trim()||""}let a=e.closest("label");if(a){let d=a.cloneNode(!0);return d.querySelectorAll("input, select, textarea").forEach(p=>p.remove()),d.innerText?.trim()||""}if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.placeholder)return e.placeholder;if(e.name)return e.name.replace(/[_-]/g," ");let i=e.previousSibling;if(i?.nodeType===Node.TEXT_NODE){let d=i.textContent?.trim();if(d&&d.length>1)return d}let s=e.previousElementSibling;if(s){let d=s.innerText?.trim();if(d&&d.length>1&&d.length<60)return d}let o=e.closest("td, th");if(o){let d=o.previousElementSibling;if(d){let p=d.innerText?.trim();if(p&&p.length>1)return p}}let l=e.getAttribute("title")?.trim();return l||(e instanceof HTMLInputElement?e.type:"field")}function Ht(){let e=[],t=document.querySelectorAll(["input:not([type=hidden])","input:not([type=submit])","input:not([type=button])","input:not([type=reset])","input:not([type=image])","select","textarea","[contenteditable='true']","[role='textbox']","[role='combobox']","[role='spinbutton']","[role='searchbox']","[role='listbox']"].join(", "));for(let n of t){if(n.closest("[data-yuktai-panel]")||!_(n))continue;if(n instanceof HTMLInputElement){let i=n.type.toLowerCase();if(["submit","button","reset","image"].includes(i))continue}let a=$n(n);e.push({label:a,type:n instanceof HTMLInputElement?n.type:n.tagName.toLowerCase(),placeholder:(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&n.placeholder||"",required:n.required||n.getAttribute("aria-required")==="true"||n.getAttribute("data-required")==="true",element:n})}return e}function zt(e,t=3e3){e.scrollIntoView({behavior:"smooth",block:"center"}),e.style.outline="3px solid #0d9488",e.style.outlineOffset="3px";try{e.focus()}catch{}setTimeout(()=>{e.style.outline="",e.style.outlineOffset=""},t)}function $t(e){let t=e.toLowerCase(),n=document.querySelectorAll("h1, h2, h3, h4, h5, h6, section, article, [id], [aria-label], [role='heading'], [role='region']");for(let a of n){if(a.closest("[data-yuktai-panel]")||!_(a))continue;if((a.innerText||a.getAttribute("id")||a.getAttribute("aria-label")||a.getAttribute("name")||"").toLowerCase().includes(t))return a.scrollIntoView({behavior:"smooth",block:"center"}),a.style.outline="2px solid #0d9488",a.style.outlineOffset="4px",setTimeout(()=>{a.style.outline="",a.style.outlineOffset=""},2500),!0}return!1}async function Fn(e,t,n){let a=window,i=a.LanguageModel||a.ai?.languageModel;if(!i)throw new Error("Gemini Nano not available");let s=await i.create({systemPrompt:`You are a helpful web accessibility agent.
13
+ Create a simple action plan to help a user complete a task on a webpage.
14
+ Rules:
15
+ - Maximum 5 steps
16
+ - Short and clear \u2014 no jargon
17
+ - If filling a form \u2014 list each field and what to enter
18
+ - No markdown \u2014 no asterisks, no bold, no headers
19
+ - Number each step: 1. 2. 3.`}),l=`Page content: ${e}${n?`
20
+ The page has form fields the user may need to fill.`:""}
21
+
22
+ User task: ${t}
23
+
24
+ Action plan:`,d=await s.prompt(l);return s.destroy(),d?.trim()||""}async function Wn(e,t){let{askPageWithTransformers:n}=await Promise.resolve().then(()=>(re(),De));return(await n(`How do I: ${t}`)).answer||"I could not create a plan for this task."}async function Nn(e,t,n){if(!e.trim())return{success:!1,steps:[],error:"Please tell me what you want to do."};if(!t)return{success:!1,steps:[],error:"No AI engine available on this device."};let a=[],i=(s,o="info")=>{let l={text:s,type:o};a.push(l),n(l)};try{i("\u{1F4D6} Reading page content...","info");let s=It(),o=Ht(),l=o.length>0;s.length<50&&i("\u26A0\uFE0F Page content is very limited. This may be a static image page.","error"),i(l?`\u{1F4CB} Found ${o.length} form field${o.length!==1?"s":""} on this page`:"\u{1F4C4} No form fields found \u2014 this appears to be a content page","info"),i("\u{1F916} Creating action plan...","info");let d="";try{t==="gemini"?d=await Fn(s,e,l):d=await Wn(s,e)}catch{d=l?`1. Locate the form on this page
25
+ 2. Fill each required field
26
+ 3. Review your answers
27
+ 4. Submit the form`:`1. Read the page carefully
28
+ 2. Find the section relevant to your task
29
+ 3. Follow the on-page instructions`}if(d&&(i("\u2705 Your action plan:","success"),d.split(/\n/).map(p=>p.replace(/\*\*/g,"").replace(/\*/g,"").trim()).filter(p=>p.length>5).slice(0,6).forEach(p=>i(` ${p}`,"action"))),l){let p=o[0];i(`\u{1F3AF} First field: "${p.label}"${p.required?" \u2605 required":""}`,"field"),zt(p.element),o.length>1&&i(`\u{1F4DD} All ${o.length} fields: ${o.map(h=>h.label).join(" \u2192 ")}`,"info")}else{let p=e.toLowerCase().split(/\s+/).filter(b=>b.length>3),h=!1;for(let b of p)if($t(b)){i(`\u{1F3AF} Scrolled to relevant section: "${b}"`,"action"),h=!0;break}h||i("\u{1F4A1} Scroll through the page to find what you need.","info")}return i("\u2705 Ready. Follow the steps above. Ask me again if you need more help.","success"),{success:!0,steps:a}}catch(s){let o=s instanceof Error?s.message:"Agent error.";return i(`\u26A0\uFE0F ${o}`,"error"),{success:!1,steps:a,error:o}}}var Wt=fe(()=>{"use strict";g()});var Dn={};me(Dn,{Runtime:()=>j,YuktAI:()=>On,YuktAIWrapper:()=>Ae,aiPlugin:()=>le,default:()=>Ae,voicePlugin:()=>ce,wcag:()=>M,wcagPlugin:()=>M});module.exports=Xt(Dn);g();g();g();function nt(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function Me(){try{let e=nt();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 Qt(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=nt();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"}),a=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:a.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function ot(){if(!await Me())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),n=0;for(let a of t){let i=a.innerText?.trim();if(!i||i.length<20||a.closest("[data-yuktai-panel]"))continue;let s=await Qt(i);s.success&&s.rewritten!==i&&(a.dataset.yuktaiOriginal=i,a.innerText=s.rewritten,n++)}return{fixed:n}}function at(){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)}}g();var it="yuktai-summary-box";function rt(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function Ce(){try{let e=rt();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 Zt(){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 a=window.getComputedStyle(n);if(a.display==="none"||a.visibility==="hidden")continue;let i=n.innerText?.trim();i&&i.length>10&&t.push(i)}return t.join(" ").slice(0,5e3)}async function st(){if(!await Ce())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=Zt();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let n=rt();if(!n)throw new Error("Summarizer API not available");let a=await n.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),i=await a.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return a.destroy(),en(i.trim()),{success:!0,summary:i.trim()}}catch(n){return{success:!1,summary:"",error:n instanceof Error?n.message:"Summary failed"}}}function en(e){ge();let t=document.createElement("div");t.id=it,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
27
30
  position: fixed;
28
31
  top: 0;
29
32
  left: 0;
@@ -40,11 +43,11 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
40
43
  justify-content: space-between;
41
44
  gap: 12px;
42
45
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
43
- `;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=`
46
+ `;let n=document.createElement("p");n.style.cssText="margin: 0; flex: 1;",n.textContent=`\u{1F4CB} Page summary: ${e}`;let a=document.createElement("button");a.textContent="\xD7",a.setAttribute("aria-label","Close page summary"),a.style.cssText=`
44
47
  background: none; border: none; color: #ffffff;
45
48
  font-size: 20px; cursor: pointer; padding: 0 4px;
46
49
  line-height: 1; flex-shrink: 0;
47
- `,i.addEventListener("click",oe),t.appendChild(n),t.appendChild(i),document.body.prepend(t)}function oe(){let e=document.getElementById(_e);e&&e.remove()}f();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"}f();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,O=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&&(O=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(O&&O(s),a.action==="stop-voice")return}},M.onend=()=>{se&&M?.start()},M.onerror=n=>{n.error!=="no-speech"&&O&&O({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},M.start(),se=!0,$t(),!0}function Se(){se=!1,M&&(M.stop(),M=null),O=null,Je()}var Ue="yuktai-voice-indicator";function $t(){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=`
50
+ `,a.addEventListener("click",ge),t.appendChild(n),t.appendChild(a),document.body.prepend(t)}function ge(){let e=document.getElementById(it);e&&e.remove()}g();var ye=[{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"}],be="en";function tn(){let e=window;return e.Translator||e.translation||null}async function nn(e){try{let t=window;if(!tn())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let a=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return a==="readily"||a==="available"||a==="downloadable"||a==="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 on(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 lt(e){if(e===be)return{success:!0,language:e,fixed:0};if(e==="en")return Re(),be="en",{success:!0,language:"en",fixed:0};if(!await nn(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let n=await on(e),a=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),i=0;for(let s of a){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 l=await n.translate(o);l&&l!==o&&(s.innerText=l,i++)}return typeof n.destroy=="function"&&n.destroy(),be=e,{success:!0,language:e,fixed:i}}catch(n){return{success:!1,language:e,fixed:0,error:n instanceof Error?n.message:"Translation failed"}}}function Re(){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)}be="en"}g();var an=[{phrases:["go to main","skip to main","main content"],action:"focus-main",label:"Jump to main content"},{phrases:["go to navigation","go to nav","open menu"],action:"focus-nav",label:"Jump to navigation"},{phrases:["go to search","search","find"],action:"focus-search",label:"Jump to search"},{phrases:["scroll down","page down","next"],action:"scroll-down",label:"Scroll down"},{phrases:["scroll up","page up","back up"],action:"scroll-up",label:"Scroll up"},{phrases:["go back","previous page"],action:"go-back",label:"Go back"},{phrases:["click","press","select"],action:"click-focused",label:"Click focused element"},{phrases:["next item","tab forward","tab"],action:"tab-forward",label:"Move to next element"},{phrases:["previous item","tab back","shift tab"],action:"tab-back",label:"Move to previous element"},{phrases:["stop listening","stop voice","quiet"],action:"stop-voice",label:"Stop voice control"}],H=null,xe=!1,K=null;function Pe(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function rn(e){let t=e.toLowerCase().trim();for(let n of an)for(let a of n.phrases)if(t.includes(a))return{action:n.action,label:n.label};return null}function sn(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=ct(),n=t.indexOf(document.activeElement),a=t[n+1]||t[0];a&&a.focus();break}case"tab-back":{let t=ct(),n=t.indexOf(document.activeElement),a=t[n-1]||t[t.length-1];a&&a.focus();break}case"stop-voice":{Ie();break}}}function ct(){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 dt(e){if(!Pe())return!1;if(xe)return!0;e&&(K=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return H=new t,H.continuous=!0,H.interimResults=!1,H.lang="en-US",H.onresult=n=>{let a=n.results[n.results.length-1][0].transcript,i=rn(a);if(i){sn(i.action);let s={success:!0,command:a,action:i.label};if(K&&K(s),i.action==="stop-voice")return}},H.onend=()=>{xe&&H?.start()},H.onerror=n=>{n.error!=="no-speech"&&K&&K({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},H.start(),xe=!0,ln(),!0}function Ie(){xe=!1,H&&(H.stop(),H=null),K=null,pt()}var ut="yuktai-voice-indicator";function ln(){pt();let e=document.createElement("div");e.id=ut,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
48
51
  position: fixed;
49
52
  bottom: 80px;
50
53
  left: 50%;
@@ -69,12 +72,12 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
69
72
  background: #ffffff;
70
73
  animation: yuktai-pulse 1.2s infinite;
71
74
  flex-shrink: 0;
72
- `,!document.getElementById("yuktai-pulse-style")){let i=document.createElement("style");i.id="yuktai-pulse-style",i.textContent=`
75
+ `,!document.getElementById("yuktai-pulse-style")){let a=document.createElement("style");a.id="yuktai-pulse-style",a.textContent=`
73
76
  @keyframes yuktai-pulse {
74
77
  0%, 100% { opacity: 1; transform: scale(1); }
75
78
  50% { opacity: 0.4; transform: scale(0.7); }
76
79
  }
77
- `,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()}f();var Wt=["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 Ft(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 p=e.getAttribute("role");return p&&t.push(`role: ${p}`),t.join(". ")}async function Bt(e,t){let n=`
80
+ `,document.head.appendChild(a)}let n=document.createElement("span");n.textContent="Listening for commands...",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}function pt(){let e=document.getElementById(ut);e&&e.remove()}g();var cn=["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 ft(){let e=window;return e.Writer||e.ai?.writer||null}async function He(){try{let e=ft();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 dn(e){let t=[],n=e.innerText?.trim();n&&t.push(`element text: "${n}"`);let a=e.placeholder?.trim();a&&t.push(`placeholder: "${a}"`);let i=e.getAttribute("name")?.trim();i&&t.push(`name: "${i}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let o=e.id;if(o){let p=document.querySelector(`label[for="${o}"]`);p&&t.push(`label: "${p.innerText?.trim()}"`)}let l=e.parentElement?.innerText?.trim().slice(0,60);l&&t.push(`parent context: "${l}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let d=e.getAttribute("role");return d&&t.push(`role: ${d}`),t.join(". ")}async function un(e,t){let n=`
78
81
  Generate a short, clear aria-label for an HTML element.
79
82
  The label must be 2-6 words maximum.
80
83
  The label must describe what the element does or what it is.
@@ -85,7 +88,7 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
85
88
  ${t}
86
89
 
87
90
  Output only the label. Nothing else.
88
- `.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(Wt);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 p=Ft(o),u=await Bt(i,p);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,v=null,q=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];v||(v=document.createElement("div"),v.setAttribute("role","alert"),v.setAttribute("aria-live","assertive"),v.setAttribute("aria-atomic","true"),v.style.cssText=`
91
+ `.trim();return(await e.write(n)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function mt(){if(!await He())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(cn);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let n=ft();if(!n)throw new Error("Writer API not available");let a=await n.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),i=0,s=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let l=window.getComputedStyle(o);if(l.display==="none"||l.visibility==="hidden")continue;let d=dn(o),p=await un(a,d);p&&p.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",p),i++,s.push({tag:o.tagName.toLowerCase(),label:p}))}return a.destroy(),{success:!0,fixed:i,elements:s}}catch(n){return{success:!1,fixed:0,elements:[],error:n instanceof Error?n.message:"Label generation failed"}}}function gt(){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 ve=null,bt=null;var yt=null,ze=null,v=null,U=null,he=null,$e=null,J=null,we={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var xt=new Set(["input","select","textarea"]);var Fe={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function We(e,t="polite"){if(typeof window>"u"||!J?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.rate=1,n.pitch=1,n.volume=1;let a=window.speechSynthesis.getVoices();a.length>0&&(n.voice=a[0]),window.speechSynthesis.speak(n)}function Tt(e,t="info"){if(typeof document>"u")return;let a={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];v||(v=document.createElement("div"),v.setAttribute("role","alert"),v.setAttribute("aria-live","assertive"),v.setAttribute("aria-atomic","true"),v.style.cssText=`
89
92
  position: fixed;
90
93
  top: 80px;
91
94
  right: 16px;
@@ -104,14 +107,14 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
104
107
  transition: transform 0.3s, opacity 0.3s;
105
108
  transform: translateX(120%);
106
109
  opacity: 0;
107
- `,document.body.appendChild(v)),v.style.background=i.bg,v.style.border=`1px solid ${i.border}`,v.style.color="#fff",v.innerHTML=`
108
- <span style="font-size:18px;font-weight:700">${i.icon}</span>
110
+ `,document.body.appendChild(v)),v.style.background=a.bg,v.style.border=`1px solid ${a.border}`,v.style.color="#fff",v.innerHTML=`
111
+ <span style="font-size:18px;font-weight:700">${a.icon}</span>
109
112
  <span style="flex:1;line-height:1.4">${e}</span>
110
113
  <button
111
114
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
112
115
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
113
116
  aria-label="Close notification">\xD7</button>
114
- `,window.innerWidth<=480&&(v.style.right="8px",v.style.left="8px",v.style.maxWidth="none",v.style.width="auto"),requestAnimationFrame(()=>{v&&(v.style.transform="translateX(0)",v.style.opacity="1")}),setTimeout(()=>{v&&(v.style.transform="translateX(120%)",v.style.opacity="0")},5e3)}function g(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=`
117
+ `,window.innerWidth<=480&&(v.style.right="8px",v.style.left="8px",v.style.maxWidth="none",v.style.width="auto"),requestAnimationFrame(()=>{v&&(v.style.transform="translateX(0)",v.style.opacity="1")}),setTimeout(()=>{v&&(v.style.transform="translateX(120%)",v.style.opacity="0")},5e3)}function x(e,t="info",n=!0){ve&&(ve.textContent=e),Tt(e,t),n&&We(e,t==="error"?"assertive":"polite")}function pn(){if(typeof document>"u"||yt)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=`
115
118
  position: fixed;
116
119
  top: 0;
117
120
  left: 0;
@@ -125,7 +128,7 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
125
128
  transform: translateY(-100%);
126
129
  transition: transform 0.2s ease;
127
130
  font-family: system-ui, sans-serif;
128
- `;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=`
131
+ `;let n=!1;if(e.forEach(({label:i,selector:s})=>{let o=document.querySelector(s);if(!o)return;n=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let l=document.createElement("a");l.href="#",l.textContent=i,l.style.cssText=`
129
132
  color: #fff;
130
133
  background: #1a73e8;
131
134
  padding: 8px 14px;
@@ -136,7 +139,7 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
136
139
  white-space: nowrap;
137
140
  border: 2px solid transparent;
138
141
  transition: background 0.15s, border-color 0.15s;
139
- `,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",p=>{p.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),g(`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=`
142
+ `,l.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),l.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),l.addEventListener("click",d=>{d.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),x(`Jumped to ${i.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(l)}),!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),yt=t}function fn(){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=`
140
143
 
141
144
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
142
145
  [data-yuktai-a11y] *:focus-visible {
@@ -282,7 +285,7 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
282
285
  width: auto !important;
283
286
  }
284
287
  }
285
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function qt(){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",g("Dialog closed","info");return}let a=t.closest("[role='menu'],[role='menubar']");a&&(a.style.display="none",g("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")}),g(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Dt()),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 Dt(){if(typeof document>"u")return;if(q){q.remove(),q=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=`
288
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function mn(){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 a=t.closest("[role='dialog'],[role='alertdialog']");if(a){a.style.display="none",x("Dialog closed","info");return}let i=t.closest("[role='menu'],[role='menubar']");i&&(i.style.display="none",x("Menu closed","info"))}if(n==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let a=t.closest("[role='menu'],[role='menubar']");if(!a)return;let i=Array.from(a.querySelectorAll("[role='menuitem']:not([disabled])")),s=i.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),i[(s+1)%i.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),i[(s-1+i.length)%i.length]?.focus()):e.key==="Home"?(e.preventDefault(),i[0]?.focus()):e.key==="End"&&(e.preventDefault(),i[i.length-1]?.focus())}if(n==="tab"||t.closest("[role='tablist']")){let a=t.closest("[role='tablist']");if(!a)return;let i=Array.from(a.querySelectorAll("[role='tab']:not([disabled])")),s=i.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let o=i[(s+1)%i.length];o?.focus(),o?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let o=i[(s-1+i.length)%i.length];o?.focus(),o?.click()}}if(n==="option"||t.closest("[role='listbox']")){let a=t.closest("[role='listbox']");if(!a)return;let i=Array.from(a.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=i.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),i[(s+1)%i.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),i[(s-1+i.length)%i.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),i.forEach(o=>{o!==t&&o.setAttribute("aria-selected","false")}),x(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),gn()),e.key==="Tab"&&J?.speechEnabled&&setTimeout(()=>{let a=document.activeElement;if(!a)return;let i=a.getAttribute("aria-label")||a.getAttribute("title")||a.textContent?.trim()||a.tagName.toLowerCase(),s=a.getAttribute("role")||a.tagName.toLowerCase();We(`${i}, ${s}`)},100)}))}function ke(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],a=t[t.length-1];n.focus(),e.addEventListener("keydown",i=>{i.key==="Tab"&&(i.shiftKey?document.activeElement===n&&(i.preventDefault(),a.focus()):document.activeElement===a&&(i.preventDefault(),n.focus()))})}function gn(){if(typeof document>"u")return;if(U){U.remove(),U=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=`
286
289
  position: fixed;
287
290
  top: 50%;
288
291
  left: 50%;
@@ -306,13 +309,13 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
306
309
  style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1"
307
310
  aria-label="Close shortcuts">\xD7</button>
308
311
  </div>
309
- ${t.map(([i,a])=>`
312
+ ${t.map(([a,i])=>`
310
313
  <div style="display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid #2a2a4a">
311
- <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${i}</kbd>
312
- <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${a}</span>
314
+ <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${a}</kbd>
315
+ <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${i}</span>
313
316
  </div>
314
317
  `).join("")}
315
- `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),q=null}),e.addEventListener("keydown",i=>{i.key==="Escape"&&(e.remove(),q=null)}),document.body.appendChild(e),q=e,ue(e),g("Keyboard shortcuts opened. Press Escape to close.","info")}function _t(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=`
318
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),U=null}),e.addEventListener("keydown",a=>{a.key==="Escape"&&(e.remove(),U=null)}),document.body.appendChild(e),U=e,ke(e),x("Keyboard shortcuts opened. Press Escape to close.","info")}function bn(e){if(typeof document>"u"||!J?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;ze&&ze.remove();let t=e.score,n=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",a=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",i=document.createElement("button");i.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),i.setAttribute("data-yuktai-badge","true"),i.style.cssText=`
316
319
  position: fixed;
317
320
  bottom: 16px;
318
321
  left: 16px;
@@ -331,7 +334,7 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
331
334
  align-items: center;
332
335
  gap: 6px;
333
336
  transition: transform 0.15s;
334
- `,a.innerHTML=`${i} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,a.addEventListener("click",()=>Gt(e)),document.body.appendChild(a),Ee=a}function Gt(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=`
337
+ `,i.innerHTML=`${a} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,i.addEventListener("click",()=>yn(e)),document.body.appendChild(i),ze=i}function yn(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=`
335
338
  position: fixed;
336
339
  bottom: 56px;
337
340
  left: 16px;
@@ -348,22 +351,22 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
348
351
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
349
352
  font-family: system-ui, sans-serif;
350
353
  font-size: 12px;
351
- `;let i={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};n.innerHTML=`
354
+ `;let a={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};n.innerHTML=`
352
355
  <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
353
356
  <strong style="font-size:14px;color:#74c0fc">Audit report</strong>
354
357
  <span style="color:#aaa">${e.fixed} fixed \xB7 ${e.renderTime}ms</span>
355
358
  </div>
356
- ${e.details.slice(0,20).map(a=>`
359
+ ${e.details.slice(0,20).map(i=>`
357
360
  <div style="padding:6px 0;border-bottom:1px solid #2a2a4a">
358
361
  <div style="display:flex;gap:6px;align-items:center">
359
- <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>
360
- <code style="color:#74c0fc">&lt;${a.tag}&gt;</code>
362
+ <span style="background:${a[i.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${i.severity}</span>
363
+ <code style="color:#74c0fc">&lt;${i.tag}&gt;</code>
361
364
  </div>
362
- <div style="color:#ccc;margin-top:3px">${a.fix}</div>
365
+ <div style="color:#ccc;margin-top:3px">${i.fix}</div>
363
366
  </div>
364
367
  `).join("")}
365
368
  ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
366
- `,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=`
369
+ `,n.addEventListener("keydown",i=>{i.key==="Escape"&&n.remove()}),document.body.appendChild(n),ke(n)}function Et(e){typeof document>"u"||($e&&clearTimeout($e),$e=setTimeout(()=>{if(he)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=`
367
370
  position: fixed;
368
371
  top: 50%;
369
372
  left: 50%;
@@ -392,19 +395,19 @@ Answer:`,c=(await mt(s,{max_new_tokens:150,min_new_tokens:10}))?.[0]?.generated_
392
395
  No, sign out
393
396
  </button>
394
397
  </div>
395
- `;let n=t.querySelector("[data-yuktai-extend]"),i=t.querySelector("[data-yuktai-dismiss]");n?.addEventListener("click",()=>{t.remove(),le=null,g("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),g("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()){g("Plain English requires Chrome 127+","warning");return}g("Rewriting page in plain English...","info",!1);let n=await qe();g(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else De(),g("Original text restored","info",!1)}async function ot(e){if(e){if(!await ve()){g("Page summariser requires Chrome 127+","warning");return}g("Generating page summary...","info",!1);let n=await je();g(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else oe(),g("Page summary removed","info",!1)}async function it(e){if(e==="en"){ke(),g("Page restored to English","info",!1);return}g(`Translating page to ${e}...`,"info",!1);let t=await Ve(e);g(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function rt(e){if(e){if(!Ae()){g("Voice control not supported in this browser","warning");return}Ye(t=>{t.success&&g(`Voice: ${t.action}`,"info",!1)}),g("Voice control started. Say a command.","success",!1)}else Se(),g("Voice control stopped","info",!1)}async function st(e){if(e){if(!await Te()){g("Smart labels requires Chrome 127+","warning");return}g("Generating smart labels...","info",!1);let n=await Qe();g(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else Ze(),g("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=`
398
+ `;let n=t.querySelector("[data-yuktai-extend]"),a=t.querySelector("[data-yuktai-dismiss]");n?.addEventListener("click",()=>{t.remove(),he=null,x("Session extended. You have more time.","success"),J?.timeoutWarning&&Et(J.timeoutWarning)}),a?.addEventListener("click",()=>{t.remove(),he=null}),document.body.appendChild(t),he=t,ke(t),x("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function xn(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(#${we[e.colorBlindMode]})`;document.body.style.filter=n}else document.body.style.filter=""}function hn(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function ht(e){if(e){if(!await Me()){x("Plain English requires Chrome 127+","warning");return}x("Rewriting page in plain English...","info",!1);let n=await ot();x(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else at(),x("Original text restored","info",!1)}async function wt(e){if(e){if(!await Ce()){x("Page summariser requires Chrome 127+","warning");return}x("Generating page summary...","info",!1);let n=await st();x(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else ge(),x("Page summary removed","info",!1)}async function vt(e){if(e==="en"){Re(),x("Page restored to English","info",!1);return}x(`Translating page to ${e}...`,"info",!1);let t=await lt(e);x(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function kt(e){if(e){if(!Pe()){x("Voice control not supported in this browser","warning");return}dt(t=>{t.success&&x(`Voice: ${t.action}`,"info",!1)}),x("Voice control started. Say a command.","success",!1)}else Ie(),x("Voice control stopped","info",!1)}async function At(e){if(e){if(!await He()){x("Smart labels requires Chrome 127+","warning");return}x("Generating smart labels...","info",!1);let n=await mt();x(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else gt(),x("Smart labels removed","info",!1)}function wn(){if(typeof document>"u"||ve)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),ve=e}function vn(){if(typeof document>"u"||bt)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=`
396
399
  <defs>
397
- <filter id="${ce.deuteranopia}">
400
+ <filter id="${we.deuteranopia}">
398
401
  <feColorMatrix type="matrix"
399
402
  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"/>
400
403
  </filter>
401
- <filter id="${ce.protanopia}">
404
+ <filter id="${we.protanopia}">
402
405
  <feColorMatrix type="matrix"
403
406
  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"/>
404
407
  </filter>
405
- <filter id="${ce.tritanopia}">
408
+ <filter id="${we.tritanopia}">
406
409
  <feColorMatrix type="matrix"
407
410
  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"/>
408
411
  </filter>
409
412
  </defs>
410
- `,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(),qt(),e.showSkipLinks!==!1&&Nt(),e.showPreferencePanel,jt(e);let t=this.applyFixes(e);t.score=lt(t),e.showAuditBadge&&_t(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 g(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,p)=>{t.details.push({tag:s,fix:o,severity:c,element:p.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"),x=o.getAttribute("content")||"";u==="viewport"&&x.includes("user-scalable=no")&&(o.setAttribute("content",x.replace("user-scalable=no","user-scalable=yes")),a(c,"user-scalable=yes restored","serious",o)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(x)&&(o.setAttribute("content",x.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 x=o.getAttribute("placeholder")||o.getAttribute("name")||c;o.setAttribute("aria-label",x),a(c,`aria-label="${x}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),c==="input"&&!u.autocomplete){let x=u.name||"";u.type==="email"||x.includes("email")?u.autocomplete="email":u.type==="tel"||x.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 p=o.getAttribute("role")||"";p==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(p)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",p==="alert"?"assertive":"polite"),a(c,`aria-live added on role=${p}`,"moderate",o)),p==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),a(c,'aria-expanded="false" on combobox',"serious",o)),(p==="checkbox"||p==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),a(c,`aria-checked="false" on role=${p}`,"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:g,speak:Me,showVisualAlert:ct,trapFocus:ue,handlePlainEnglish:at,handleSummarisePage:ot,handleTranslate:it,handleVoiceControl:rt,handleSmartLabels:st,SUPPORTED_LANGUAGES:re};f();f();var b=Ne(require("react"));f();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},G=[80,90,100,110,120,130],on=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],rn=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function sn(){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 ln({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 j({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 R({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)(ln,{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 $e=(0,T.forwardRef)(({position:e,settings:t,report:n,isActive:i,aiSupported:a,voiceSupported:s,set:o,onApply:c,onReset:p,onClose:u},x)=>{let{isMobile:h,isTablet:P}=sn(),[te,me]=(0,T.useState)([]),[I,F]=(0,T.useState)(""),[H,z]=(0,T.useState)(""),[k,V]=(0,T.useState)(!1),[m,$]=(0,T.useState)(null),[L,B]=(0,T.useState)("idle");(0,T.useEffect)(()=>{let l=window;!!(l.LanguageModel||l.ai?.languageModel)&&a?$("gemini"):J()&&$("transformers")},[a]),(0,T.useEffect)(()=>{if(m!=="transformers")return;let l=setInterval(()=>{B(X())},500);return()=>clearInterval(l)},[m]);let w=async()=>{if(!(!I.trim()||k)){if(!m){z("\u26A0\uFE0F No AI engine available on this device.");return}V(!0),z("");try{let l;m==="gemini"?l=await Pe(I):(B("loading"),l=await ze(I),B("ready")),z(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{z("\u26A0\uFE0F Failed to get answer. Please try again.")}V(!1)}};(0,T.useEffect)(()=>{(async()=>{try{let N=window;if(!N.queryLocalFonts)return;let ge=await N.queryLocalFonts(),be=[...new Set(ge.map(ye=>ye.family))].sort();me(be.slice(0,50))}catch{}})()},[]);let ne=m==="gemini"?"Gemini Nano":m==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",K=m==="transformers"&&L==="loading"?"Loading AI model... (first time only)":"...",Y=h?{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px 16px 0 0",boxShadow:"0 -8px 32px rgba(0,0,0,0.12)",maxHeight:"90vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif",width:"100%"}:{position:"fixed",bottom:"84px",[e]:"24px",zIndex:9999,width:P?"300px":"320px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",maxHeight:"80vh",overflowY:"auto",fontFamily:"system-ui,-apple-system,sans-serif"};return(0,r.jsxs)("div",{ref:x,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:h?"44px":"auto",minHeight:h?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,r.jsx)(j,{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)(R,{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)(R,{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)(R,{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)(j,{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:rn.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)(R,{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)(R,{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)(R,{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)(j,{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)(R,{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)(R,{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)(R,{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)(R,{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:on.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:h?"36px":"auto"},children:l.label},l.value))})]}),(0,r.jsx)(S,{}),(0,r.jsx)(j,{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)(R,{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:h?"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=G.indexOf(t.fontScale);l>0&&o("fontScale",G[l-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:h?"44px":"30px",height:h?"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:G.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=G.indexOf(t.fontScale);l<G.length-1&&o("fontScale",G[l+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:h?"44px":"30px",height:h?"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)(j,{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,h?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:h?"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)(j,{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",m==="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:m==="gemini"?"#f0fdfa":m==="transformers"?"#f5f3ff":"#f8fafc",borderRadius:"8px",border:`0.5px solid ${m==="gemini"?"#99f6e4":m==="transformers"?"#c4b5fd":"#e2e8f0"}`,fontSize:"10px",color:m==="gemini"?"#0f766e":m==="transformers"?"#7c3aed":"#94a3b8"},children:[m==="gemini"&&"\u2705 Using Gemini Nano \u2014 on device, private, instant",m==="transformers"&&"\u2705 Using Transformers.js \u2014 works on mobile and all browsers",!m&&"\u23F3 Detecting AI engine...",m==="transformers"&&L==="loading"&&" \xB7 Loading model...",m==="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:I,onChange:l=>F(l.target.value),onKeyDown:l=>{l.key==="Enter"&&w()},placeholder:"e.g. What does this page do?",disabled:k||!m,"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:m?"#fff":"#f8fafc",outline:"none",height:h?"44px":"36px"}}),(0,r.jsx)("button",{onClick:w,disabled:k||!I.trim()||!m,"aria-label":"Ask question",style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:m&&I.trim()&&!k?"#0d9488":"#e2e8f0",color:m&&I.trim()&&!k?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:m&&I.trim()&&!k?"pointer":"not-allowed",flexShrink:0,height:h?"44px":"36px",minWidth:"52px",transition:"background 0.2s"},children:k?K:"Ask"})]}),H&&(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"}),H,(0,r.jsx)("button",{onClick:()=>{z(""),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:h?"sticky":"relative",bottom:h?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[(0,r.jsx)("button",{onClick:p,style:{flex:1,padding:h?"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:h?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});$e.displayName="WidgetPanel";pe();var y=require("react/jsx-runtime");async function cn(){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,b.useState)(!1),[o,c]=(0,b.useState)(He),[p,u]=(0,b.useState)(null),[x,h]=(0,b.useState)(!1),[P,te]=(0,b.useState)(!1),[me,I]=(0,b.useState)(!1),F=b.default.useRef(null),[H,z]=(0,b.useState)(!1),[k,V]=(0,b.useState)(""),[m,$]=(0,b.useState)(""),[L,B]=(0,b.useState)(!1),[w,ne]=(0,b.useState)(null),[K,Y]=(0,b.useState)("idle");(0,b.useEffect)(()=>{if(typeof window>"u")return;let d=window;!!(d.LanguageModel||d.ai?.languageModel)&&P?ne("gemini"):J()&&ne("transformers")},[P]),(0,b.useEffect)(()=>{if(w!=="transformers")return;let d=setInterval(()=>Y(X()),500);return()=>clearInterval(d)},[w]);let l=(0,b.useCallback)(async()=>{if(!(!k.trim()||L)){if(!w){$("\u26A0\uFE0F No AI engine available on this device.");return}B(!0),$("");try{let d;if(w==="gemini"){let{askPage:A}=await Promise.resolve().then(()=>(Re(),ut));d=await A(k)}else{Y("loading");let{askPageWithTransformers:A}=await Promise.resolve().then(()=>(pe(),gt));d=await A(k),Y("ready")}$(d.success&&d.answer?d.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(d.error||"No answer found."))}catch{$("\u26A0\uFE0F Something went wrong. Please try again.")}B(!1)}},[k,L,w]);(0,b.useEffect)(()=>{if(typeof window>"u")return;let A=setTimeout(async()=>{let U=window;console.log("yuktai: Checking AI APIs..."),console.log("yuktai: window.LanguageModel =",U.LanguageModel);let Fe=await cn();te(Fe),console.log(Fe?"yuktai: Chrome Built-in AI detected \u2705":"yuktai: Chrome Built-in AI not detected \u2014 Transformers.js will handle RAG on mobile"),I(!!(U.SpeechRecognition||U.webkitSpeechRecognition))},800);return()=>clearTimeout(A)},[]),(0,b.useEffect)(()=>{if(!(typeof window>"u"))try{let d=localStorage.getItem("yuktai-a11y-prefs");d&&c(A=>({...A,...JSON.parse(d)}))}catch{}},[]);let N=(0,b.useCallback)(async d=>{let A={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(A),u(C.applyFixes(A)),h(!0)},[n]),ge=(0,b.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(o))}catch{}await N(o),s(!1)},[o,N]),be=(0,b.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(A=>d.removeAttribute(A)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",u(null),h(!1)},[]),ye=(0,b.useCallback)((d,A)=>{c(U=>({...U,[d]:A}))},[]);(0,b.useEffect)(()=>{let d=A=>{A.key==="Escape"&&(a&&s(!1),H&&z(!1))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,H]),(0,b.useEffect)(()=>{a&&F.current&&C.trapFocus(F.current)},[a]);let yt=w==="transformers"&&K==="loading"?"Loading AI... (first time only)":"...",We=w==="gemini"?"Gemini Nano \xB7 On device \xB7 Instant":w==="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:x?"#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:H?"#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":H,title:`Ask this page \xB7 ${We}`,onClick:()=>{z(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&&H&&(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:w==="gemini"?"#0d9488":"#7c3aed"},children:We}),w==="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)"}),w==="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:()=>z(!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:k,onChange:d=>V(d.target.value),onKeyDown:d=>{d.key==="Enter"&&l()},placeholder:"e.g. What does this page do?",disabled:L||!w,"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:w?"#fff":"#f8fafc",outline:"none",height:"36px"}}),(0,y.jsx)("button",{onClick:l,disabled:L||!k.trim()||!w,"aria-label":"Submit question",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:w&&k.trim()&&!L?"#7c3aed":"#e2e8f0",color:w&&k.trim()&&!L?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:w&&k.trim()&&!L?"pointer":"not-allowed",height:"36px",minWidth:"48px",transition:"background 0.2s"},children:L?yt:"Ask"})]}),m&&(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"}),m,(0,y.jsx)("button",{onClick:()=>{$(""),V("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!w&&(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),z(!1)},onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.08)"},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)"},children:"\u267F"}),a&&(0,y.jsx)($e,{ref:F,position:e,settings:o,report:p,isActive:x,aiSupported:P,voiceSupported:me,set:ye,onApply:ge,onReset:be,onClose:()=>s(!1)})]})}f();var Z={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};f();var ee={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};f();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 dn(){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"?dn():new W,un={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()}};
413
+ `,document.body.appendChild(e),bt=e}function St(e){let t={critical:20,serious:10,moderate:5,minor:2},n=e.details.reduce((a,i)=>a+(t[i.severity]||0),0);return Math.max(0,Math.min(100,100-n))}var M={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";J=e,hn(e),wn(),vn(),fn(),mn(),e.showSkipLinks!==!1&&pn(),e.showPreferencePanel,xn(e);let t=this.applyFixes(e);t.score=St(t),e.showAuditBadge&&bn(t),e.timeoutWarning&&Et(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await ht(!0),e.summarisePage&&await wt(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await vt(e.translateLanguage),e.voiceControl&&await kt(!0),e.smartLabels&&await At(!0);let n=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return x(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(),a=document.querySelectorAll("*");t.scanned=a.length;let i=(s,o,l,d)=>{t.details.push({tag:s,fix:o,severity:l,element:d.outerHTML.slice(0,100)}),t.fixed++};return a.forEach(s=>{let o=s,l=o.tagName.toLowerCase();if(l==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),i(l,'lang="en" added',"critical",o)),l==="meta"){let p=o.getAttribute("name"),h=o.getAttribute("content")||"";p==="viewport"&&h.includes("user-scalable=no")&&(o.setAttribute("content",h.replace("user-scalable=no","user-scalable=yes")),i(l,"user-scalable=yes restored","serious",o)),p==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(h)&&(o.setAttribute("content",h.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),i(l,"maximum-scale=5 restored","serious",o))}if(l==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),l==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),i(l,'alt="" aria-hidden="true"',"serious",o))),l==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!s.querySelector("title")&&(o.setAttribute("aria-hidden","true"),i(l,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),l==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),i(l,"title + aria-label added","serious",o)),l==="button"){if(!o.innerText?.trim()&&!o.getAttribute("aria-label")){let p=o.getAttribute("title")||"button";o.setAttribute("aria-label",p),i(l,`aria-label="${p}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(l==="a"){let p=o;!o.innerText?.trim()&&!o.getAttribute("aria-label")&&(o.setAttribute("aria-label",o.getAttribute("title")||"link"),i(l,"aria-label added (empty link)","critical",o)),p.target==="_blank"&&!p.rel?.includes("noopener")&&(p.rel="noopener noreferrer",t.fixed++)}if(xt.has(l)){let p=o;if(!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let h=o.getAttribute("placeholder")||o.getAttribute("name")||l;o.setAttribute("aria-label",h),i(l,`aria-label="${h}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),l==="input"&&!p.autocomplete){let h=p.name||"";p.type==="email"||h.includes("email")?p.autocomplete="email":p.type==="tel"||h.includes("tel")?p.autocomplete="tel":p.type==="password"&&(p.autocomplete="current-password"),t.fixed++}}l==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),i(l,"scope added to <th>","moderate",o)),Fe[l]&&!o.getAttribute("role")&&(o.setAttribute("role",Fe[l]),i(l,`role="${Fe[l]}"`,"minor",o));let d=o.getAttribute("role")||"";d==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(d)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",d==="alert"?"assertive":"polite"),i(l,`aria-live added on role=${d}`,"moderate",o)),d==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),i(l,'aria-expanded="false" on combobox',"serious",o)),(d==="checkbox"||d==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),i(l,`aria-checked="false" on role=${d}`,"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 a=(i,s,o,l)=>e.details.push({tag:i,fix:s,severity:o,element:l.outerHTML.slice(0,100)});return n.forEach(i=>{let s=i,o=s.tagName.toLowerCase();(o==="a"||o==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&a(o,"needs aria-label (empty)","critical",s),o==="img"&&!s.hasAttribute("alt")&&a(o,"needs alt text","serious",s),xt.has(o)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&a(o,"needs aria-label","serious",s),o==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&a(o,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=St(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:x,speak:We,showVisualAlert:Tt,trapFocus:ke,handlePlainEnglish:ht,handleSummarisePage:wt,handleTranslate:vt,handleVoiceControl:kt,handleSmartLabels:At,SUPPORTED_LANGUAGES:ye};g();g();var m=tt(require("react"));g();var E=require("react");Be();re();var r=require("react/jsx-runtime"),Ge={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],Pn=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],In=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function Hn(){let[e,t]=(0,E.useState)(typeof window<"u"?window.innerWidth:1024);return(0,E.useEffect)(()=>{let n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function zn({checked:e,onChange:t,label:n,disabled:a=!1}){return(0,r.jsxs)("label",{"aria-label":n,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:a?"not-allowed":"pointer",flexShrink:0,opacity:a?.4:1},children:[(0,r.jsx)("input",{type:"checkbox",checked:e,disabled:a,onChange:i=>t(i.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,r.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,r.jsx)("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function Z({label:e,color:t="#64748b",badge:n,concept:a}){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})]}),a&&(0,r.jsx)("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8",fontStyle:"italic"},children:a})]})}function z({icon:e,label:t,desc:n,checked:a,onChange:i,disabled:s=!1,disabledReason:o,tip:l}){return(0,r.jsxs)("div",{title:s?o:l,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)(zn,{checked:a,onChange:i,label:`Toggle ${t}`,disabled:s})]})}function T(){return(0,r.jsx)("div",{style:{height:"1px",background:"#f1f5f9"}})}function se({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 _e=(0,E.forwardRef)(({position:e,settings:t,report:n,isActive:a,aiSupported:i,voiceSupported:s,set:o,onApply:l,onReset:d,onClose:p},h)=>{let{isMobile:b,isTablet:q}=Hn(),[N,Y]=(0,E.useState)([]),[A,O]=(0,E.useState)(""),[$,C]=(0,E.useState)(""),[L,R]=(0,E.useState)(!1),[y,ee]=(0,E.useState)(null),[B,P]=(0,E.useState)("idle");(0,E.useEffect)(()=>{let c=window;!!(c.LanguageModel||c.ai?.languageModel)&&i?ee("gemini"):ae()&&ee("transformers")},[i]),(0,E.useEffect)(()=>{if(y!=="transformers")return;let c=setInterval(()=>{P(ie())},500);return()=>clearInterval(c)},[y]);let te=async()=>{if(!(!A.trim()||L)){if(!y){C("\u26A0\uFE0F No AI engine available on this device.");return}R(!0),C("");try{let c;y==="gemini"?c=await Ne(A):(P("loading"),c=await Oe(A),P("ready")),C(c.success&&c.answer?c.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(c.error||"No answer found on this page"))}catch{C("\u26A0\uFE0F Failed to get answer. Please try again.")}R(!1)}};(0,E.useEffect)(()=>{(async()=>{try{let F=window;if(!F.queryLocalFonts)return;let V=await F.queryLocalFonts(),W=[...new Set(V.map(oe=>oe.family))].sort();Y(W.slice(0,50))}catch{}})()},[]);let k=y==="gemini"?"Gemini Nano":y==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",de=y==="transformers"&&B==="loading"?"Loading AI model... (first time only)":"...",ne=b?{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:q?"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:h,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:ne,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"}),a&&(0,r.jsx)("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),(0,r.jsx)("p",{style:{margin:"0 0 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:p,"aria-label":"Close accessibility panel",style:{background:"none",border:"none",cursor:"pointer",padding:"4px",color:"#94a3b8",fontSize:"20px",lineHeight:1,borderRadius:"6px",flexShrink:0,minWidth:b?"44px":"auto",minHeight:b?"44px":"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,r.jsx)(Z,{label:"\u267F Core Accessibility",concept:"Rule-based engine \u2014 works on all browsers and devices"}),(0,r.jsx)(se,{steps:["Toggle any feature on","Click Apply settings","Preferences saved automatically"]}),(0,r.jsx)(z,{icon:"\u{1F527}",label:"Auto-fix ARIA",desc:"Injects missing labels and roles automatically",checked:t.autoFix,onChange:c=>o("autoFix",c),tip:"Fixes aria-label, alt text, roles on every element"}),(0,r.jsx)(T,{}),(0,r.jsx)(z,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud as you tab",checked:t.speechEnabled,onChange:c=>o("speechEnabled",c),tip:"Uses browser SpeechSynthesis \u2014 no install needed"}),(0,r.jsx)(T,{}),(0,r.jsx)(z,{icon:"\u{1F399}\uFE0F",label:"Voice control",desc:"Say commands to navigate the page",checked:t.voiceControl,onChange:c=>o("voiceControl",c),disabled:!s,disabledReason:"Not supported in this browser",tip:'Say "scroll down", "go to main", "click"'}),(0,r.jsx)(T,{}),(0,r.jsx)(Z,{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:i?"#f0fdfa":"#f5f3ff",borderRadius:"8px",border:`0.5px solid ${i?"#99f6e4":"#c4b5fd"}`,fontSize:"10px",color:i?"#0f766e":"#7c3aed",lineHeight:1.5},children:i?"\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."}),!i&&(0,r.jsxs)("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[(0,r.jsx)("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} 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:In.map(c=>(0,r.jsxs)("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",c]},c))}),(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)(z,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Rewrites complex text in simple language",checked:t.plainEnglish,onChange:c=>o("plainEnglish",c),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: LLM text rewriting"}),(0,r.jsx)(T,{}),(0,r.jsx)(z,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary appears at top",checked:t.summarisePage,onChange:c=>o("summarisePage",c),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Abstractive summarisation"}),(0,r.jsx)(T,{}),(0,r.jsx)(z,{icon:"\u{1F3F7}\uFE0F",label:"Smart aria-labels",desc:"AI generates meaningful labels for elements",checked:t.smartLabels,onChange:c=>o("smartLabels",c),disabled:!i,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Context-aware label generation"}),(0,r.jsx)(T,{}),(0,r.jsx)(Z,{label:"\u{1F441}\uFE0F Visual",concept:"CSS filter-based \u2014 works on all browsers and devices"}),(0,r.jsx)(se,{steps:["Toggle any visual mode","Changes apply instantly","Works on mobile and desktop"]}),(0,r.jsx)(z,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision users",checked:t.highContrast,onChange:c=>o("highContrast",c),tip:"CSS filter: contrast()"}),(0,r.jsx)(T,{}),(0,r.jsx)(z,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours \u2014 easy on eyes at night",checked:t.darkMode,onChange:c=>o("darkMode",c),tip:"CSS filter: invert + hue-rotate"}),(0,r.jsx)(T,{}),(0,r.jsx)(z,{icon:"\u23F8\uFE0F",label:"Reduce motion",desc:"Disables all animations",checked:t.reduceMotion,onChange:c=>o("reduceMotion",c),tip:"WCAG 2.3.3 \u2014 vestibular disorders"}),(0,r.jsx)(T,{}),(0,r.jsx)(z,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:c=>o("largeTargets",c),tip:"WCAG 2.5.8 \u2014 motor impaired users"}),(0,r.jsx)(T,{}),(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:Pn.map(c=>(0,r.jsx)("button",{onClick:()=>o("colorBlindMode",c.value),"aria-pressed":t.colorBlindMode===c.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===c.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===c.value?"#f0fdfa":"#fff",color:t.colorBlindMode===c.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:b?"36px":"auto"},children:c.label},c.value))})]}),(0,r.jsx)(T,{}),(0,r.jsx)(Z,{label:"\u{1F524} Font",concept:"Browser Font API + CSS \u2014 Chrome 103+"}),(0,r.jsx)(se,{steps:["Toggle dyslexia font or pick from device","Adjust size with + / \u2212","Saved across visits"]}),(0,r.jsx)(z,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible \u2014 research-backed",checked:t.dyslexiaFont,onChange:c=>o("dyslexiaFont",c),tip:"By Braille Institute \u2014 free and open source"}),(0,r.jsx)(T,{}),(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+"}),N.length>0?(0,r.jsxs)("select",{value:t.localFont,onChange:c=>o("localFont",c.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:b?"44px":"36px"},children:[(0,r.jsx)("option",{value:"",children:"System default"}),N.map(c=>(0,r.jsx)("option",{value:c,style:{fontFamily:c},children:c},c))]}):(0,r.jsx)("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Allow font access when Chrome prompts you."})]}),(0,r.jsx)(T,{}),(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 c=Q.indexOf(t.fontScale);c>0&&o("fontScale",Q[c-1])},disabled:t.fontScale<=80,"aria-label":"Decrease text size",style:{width:b?"44px":"30px",height:b?"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(c=>(0,r.jsx)("button",{onClick:()=>o("fontScale",c),"aria-label":`Set text size to ${c}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:c<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},c))}),(0,r.jsx)("button",{onClick:()=>{let c=Q.indexOf(t.fontScale);c<Q.length-1&&o("fontScale",Q[c+1])},disabled:t.fontScale>=130,"aria-label":"Increase text size",style:{width:b?"44px":"30px",height:b?"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)(T,{}),(0,r.jsx)(Z,{label:"\u{1F310} Translate",color:"#7c3aed",badge:"Gemini Nano",concept:"Chrome Translation API \u2014 on device, no internet after setup"}),(0,r.jsx)(se,{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:ye.slice(0,b?8:18).map(c=>(0,r.jsx)("button",{onClick:()=>o("translateLanguage",c.code),"aria-pressed":t.translateLanguage===c.code,disabled:!i,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===c.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===c.code?"#f5f3ff":"#fff",color:t.translateLanguage===c.code?"#7c3aed":"#64748b",cursor:i?"pointer":"not-allowed",opacity:i?1:.5,minHeight:b?"36px":"auto"},children:c.label},c.code))}),!i&&(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)(T,{}),(0,r.jsx)(Z,{label:"\u{1F4AC} Ask This Page",color:"#0d9488",badge:k,concept:"RAG \u2014 Retrieval Augmented Generation. Works on all devices including mobile."}),(0,r.jsx)(se,{steps:["Type any question about this page","Press Ask or hit Enter",y==="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:y==="gemini"?"#f0fdfa":y==="transformers"?"#f5f3ff":"#f8fafc",borderRadius:"8px",border:`0.5px solid ${y==="gemini"?"#99f6e4":y==="transformers"?"#c4b5fd":"#e2e8f0"}`,fontSize:"10px",color:y==="gemini"?"#0f766e":y==="transformers"?"#7c3aed":"#94a3b8"},children:[y==="gemini"&&"\u2705 Using Gemini Nano \u2014 on device, private, instant",y==="transformers"&&"\u2705 Using Transformers.js \u2014 works on mobile and all browsers",!y&&"\u23F3 Detecting AI engine...",y==="transformers"&&B==="loading"&&" \xB7 Loading model...",y==="transformers"&&B==="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:A,onChange:c=>O(c.target.value),onKeyDown:c=>{c.key==="Enter"&&te()},placeholder:"e.g. What does this page do?",disabled:L||!y,"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:y?"#fff":"#f8fafc",outline:"none",height:b?"44px":"36px"}}),(0,r.jsx)("button",{onClick:te,disabled:L||!A.trim()||!y,"aria-label":"Ask question",style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:y&&A.trim()&&!L?"#0d9488":"#e2e8f0",color:y&&A.trim()&&!L?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:y&&A.trim()&&!L?"pointer":"not-allowed",flexShrink:0,height:b?"44px":"36px",minWidth:"52px",transition:"background 0.2s"},children:L?de:"Ask"})]}),$&&(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"}),$,(0,r.jsx)("button",{onClick:()=>{C(""),O("")},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:b?"sticky":"relative",bottom:b?0:"auto",background:"#fff",borderTop:"1px solid #f1f5f9"},children:[(0,r.jsx)("button",{onClick:d,style:{flex:1,padding:b?"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:l,style:{flex:2,padding:b?"12px 0":"8px 0",fontSize:"13px",fontWeight:600,borderRadius:"9px",border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})});_e.displayName="WidgetPanel";re();var f=require("react/jsx-runtime");async function Bn(){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 Ae({position:e="left",children:t,config:n={},showRag:a=!1,showAgent:i=!1}){let[s,o]=(0,m.useState)(!1),[l,d]=(0,m.useState)(Ge),[p,h]=(0,m.useState)(null),[b,q]=(0,m.useState)(!1),[N,Y]=(0,m.useState)(!1),[A,O]=(0,m.useState)(!1),$=m.default.useRef(null),[C,L]=(0,m.useState)(!1),[R,y]=(0,m.useState)(""),[ee,B]=(0,m.useState)(""),[P,te]=(0,m.useState)(!1),[k,de]=(0,m.useState)(null),[ne,c]=(0,m.useState)("idle"),[F,V]=(0,m.useState)(!1),[W,oe]=(0,m.useState)(""),[Bt,ue]=(0,m.useState)(""),[D,je]=(0,m.useState)(!1),[Ve,Se]=(0,m.useState)([]),[I,Ye]=(0,m.useState)(null),qt=24,Ke=84,Ue=a?144:84;(0,m.useEffect)(()=>{if(typeof window>"u")return;let u=window;!!(u.LanguageModel||u.ai?.languageModel)&&N?(de("gemini"),Ye("gemini")):ae()&&(de("transformers"),Ye("transformers"))},[N]),(0,m.useEffect)(()=>{if(k!=="transformers")return;let u=setInterval(()=>c(ie()),500);return()=>clearInterval(u)},[k]);let Je=(0,m.useCallback)(async()=>{if(!(!R.trim()||P)){if(!k){B("\u26A0\uFE0F No AI engine available.");return}te(!0),B("");try{let u;if(k==="gemini"){let{askPage:w}=await Promise.resolve().then(()=>(Be(),Lt));u=await w(R)}else{c("loading");let{askPageWithTransformers:w}=await Promise.resolve().then(()=>(re(),De));u=await w(R),c("ready")}B(u.success&&u.answer?u.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(u.error||"No answer found."))}catch{B("\u26A0\uFE0F Something went wrong.")}te(!1)}},[R,P,k]),Xe=(0,m.useCallback)(async()=>{if(!W.trim()||D)return;if(!I){ue("\u26A0\uFE0F No AI engine available.");return}je(!0),Se([]),ue("");let{runAgent:u}=await Promise.resolve().then(()=>(Wt(),Ft));await u(W,I,w=>{Se(G=>[...G,w.text])}),je(!1),ue("done")},[W,D,I]);(0,m.useEffect)(()=>{if(typeof window>"u")return;let w=setTimeout(async()=>{let G=window,jt=await Bn();Y(jt),O(!!(G.SpeechRecognition||G.webkitSpeechRecognition))},800);return()=>clearTimeout(w)},[]),(0,m.useEffect)(()=>{if(!(typeof window>"u"))try{let u=localStorage.getItem("yuktai-a11y-prefs");u&&d(w=>({...w,...JSON.parse(u)}))}catch{}},[]);let Qe=(0,m.useCallback)(async u=>{let w={enabled:!0,highContrast:u.highContrast,darkMode:u.darkMode,reduceMotion:u.reduceMotion,largeTargets:u.largeTargets,speechEnabled:u.speechEnabled,autoFix:u.autoFix,dyslexiaFont:u.dyslexiaFont,localFont:u.localFont,fontSizeMultiplier:u.fontScale/100,colorBlindMode:u.colorBlindMode,showAuditBadge:u.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:u.plainEnglish,summarisePage:u.summarisePage,translateLanguage:u.translateLanguage,voiceControl:u.voiceControl,smartLabels:u.smartLabels,...n};await M.execute(w),h(M.applyFixes(w)),q(!0)},[n]),Ot=(0,m.useCallback)(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(l))}catch{}await Qe(l),o(!1)},[l,Qe]),Dt=(0,m.useCallback)(()=>{d(Ge);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let u=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(w=>u.removeAttribute(w)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",h(null),q(!1)},[]),Gt=(0,m.useCallback)((u,w)=>{d(G=>({...G,[u]:w}))},[]);(0,m.useEffect)(()=>{let u=w=>{w.key==="Escape"&&(s&&o(!1),C&&L(!1),F&&V(!1))};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s,C,F]),(0,m.useEffect)(()=>{s&&$.current&&M.trapFocus($.current)},[s]);let Te=(u,w,G)=>({position:"fixed",bottom:`${u}px`,[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:w,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"}),Ee=u=>{u.currentTarget.style.transform="scale(1.08)"},Le=u=>{u.currentTarget.style.transform="scale(1)"},Ze=k==="gemini"?"Gemini Nano \xB7 On device":k==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",_t=k==="transformers"&&ne==="loading"?"Loading model...":"...";return(0,f.jsxs)(f.Fragment,{children:[t,i&&(0,f.jsx)("button",{style:Te(Ue,F?"#059669":"#10b981",F),"aria-label":"Open AI agent","aria-haspopup":"dialog","aria-expanded":F,title:"\u{1F916} AI Agent \u2014 guide me through this page",onClick:()=>{V(u=>!u),L(!1),o(!1)},onMouseEnter:Ee,onMouseLeave:Le,children:"\u{1F916}"}),i&&F&&(0,f.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"yuktai AI Agent","data-yuktai-panel":"true",style:{position:"fixed",bottom:`${Ue+64}px`,[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",maxHeight:"70vh",overflowY:"auto"},children:[(0,f.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"10px"},children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:600,color:"#0f172a"},children:"\u{1F916} AI Agent"}),(0,f.jsx)("p",{style:{margin:0,fontSize:"10px",color:"#10b981"},children:I==="gemini"?"Gemini Nano \xB7 On device":I==="transformers"?"Transformers.js \xB7 All devices":"Detecting..."})]}),(0,f.jsx)("button",{onClick:()=>V(!1),"aria-label":"Close agent panel",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",lineHeight:1,padding:"2px"},children:"\xD7"})]}),(0,f.jsx)("p",{style:{margin:"0 0 8px",fontSize:"11px",color:"#64748b"},children:"Tell me what you want to do on this page. I will guide you step by step."}),(0,f.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",marginBottom:"8px"},children:["Fill this form","Find contact info","What is this page?","Guide me to apply"].map(u=>(0,f.jsx)("button",{onClick:()=>oe(u),style:{padding:"3px 8px",borderRadius:"20px",fontSize:"10px",border:"1px solid #e2e8f0",background:"#f8fafc",color:"#64748b",cursor:"pointer"},children:u},u))}),(0,f.jsxs)("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[(0,f.jsx)("input",{type:"text",value:W,onChange:u=>oe(u.target.value),onKeyDown:u=>{u.key==="Enter"&&Xe()},placeholder:"e.g. Help me fill this form",disabled:D||!I,"aria-label":"Tell the agent what to do",style:{flex:1,padding:"8px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px",color:"#0f172a",background:I?"#fff":"#f8fafc",outline:"none",height:"36px"}}),(0,f.jsx)("button",{onClick:Xe,disabled:D||!W.trim()||!I,"aria-label":"Run agent",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:I&&W.trim()&&!D?"#10b981":"#e2e8f0",color:I&&W.trim()&&!D?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:I&&W.trim()&&!D?"pointer":"not-allowed",height:"36px",minWidth:"52px",transition:"background 0.2s"},children:D?"...":"Go"})]}),Ve.length>0&&(0,f.jsxs)("div",{style:{padding:"10px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:"8px",fontSize:"11px",color:"#166534",lineHeight:1.7},children:[Ve.map((u,w)=>(0,f.jsx)("p",{style:{margin:"0 0 2px"},children:u},w)),Bt==="done"&&(0,f.jsx)("button",{onClick:()=>{Se([]),oe(""),ue("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!I&&(0,f.jsx)("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano via chrome://flags for best results."})]}),a&&(0,f.jsx)("button",{style:Te(Ke,C?"#7c3aed":"#6d28d9",C),"aria-label":"Ask a question about this page","aria-haspopup":"dialog","aria-expanded":C,title:`\u{1F4AC} Ask this page \xB7 ${Ze}`,onClick:()=>{L(u=>!u),o(!1),V(!1)},onMouseEnter:Ee,onMouseLeave:Le,children:"\u{1F4AC}"}),a&&C&&(0,f.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":"Ask this page","data-yuktai-panel":"true",style:{position:"fixed",bottom:`${Ke+64}px`,[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,f.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"10px"},children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:600,color:"#0f172a"},children:"\u{1F4AC} Ask this page"}),(0,f.jsx)("p",{style:{margin:0,fontSize:"10px",color:"#7c3aed"},children:Ze}),k==="transformers"&&ne==="loading"&&(0,f.jsx)("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8"},children:"Downloading model \u2014 first time only"}),k==="transformers"&&ne==="ready"&&(0,f.jsx)("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#10b981"},children:"Model ready \u2705 \u2014 works offline"})]}),(0,f.jsx)("button",{onClick:()=>L(!1),"aria-label":"Close ask panel",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",lineHeight:1,padding:"2px"},children:"\xD7"})]}),(0,f.jsxs)("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[(0,f.jsx)("input",{type:"text",value:R,onChange:u=>y(u.target.value),onKeyDown:u=>{u.key==="Enter"&&Je()},placeholder:"e.g. What does this page do?",disabled:P||!k,"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:k?"#fff":"#f8fafc",outline:"none",height:"36px"}}),(0,f.jsx)("button",{onClick:Je,disabled:P||!R.trim()||!k,"aria-label":"Submit question",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:k&&R.trim()&&!P?"#7c3aed":"#e2e8f0",color:k&&R.trim()&&!P?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:k&&R.trim()&&!P?"pointer":"not-allowed",height:"36px",minWidth:"48px",transition:"background 0.2s"},children:P?_t:"Ask"})]}),ee&&(0,f.jsxs)("div",{style:{padding:"10px",background:"#f5f3ff",borderRadius:"8px",fontSize:"12px",color:"#4c1d95",lineHeight:1.6,maxHeight:"180px",overflowY:"auto"},children:[(0,f.jsx)("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#7c3aed"},children:"\u{1F4AC} Answer"}),ee,(0,f.jsx)("button",{onClick:()=>{B(""),y("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!k&&(0,f.jsx)("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Detecting AI engine..."})]}),(0,f.jsx)("button",{style:Te(qt,b?"#0d9488":"#1a73e8",s),"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":s,"data-yuktai-pref-toggle":"true",title:"\u267F Accessibility settings",onClick:()=>{o(u=>!u),L(!1),V(!1)},onMouseEnter:Ee,onMouseLeave:Le,children:"\u267F"}),s&&(0,f.jsx)(_e,{ref:$,position:e,settings:l,report:p,isActive:b,aiSupported:N,voiceSupported:A,set:Gt,onApply:Ot,onReset:Dt,onClose:()=>o(!1)})]})}g();var le={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};g();var ce={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};g();var j=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 a=this.use(t);if(!a)throw new Error(`Plugin not found: ${t}`);return await a.execute(n)}catch(a){throw console.error(`[YuktAI Runtime Error in ${t}]:`,a),a}}getPlugins(){return Array.from(this.plugins.keys())}};function qn(){if(typeof globalThis>"u")return new j;if(!globalThis.__yuktai_runtime__){let e=new j;e.register(M.name,M),e.register(le.name,le),e.register(ce.name,ce),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var Nt=typeof window<"u"?qn():new j,On={wcagPlugin:M,list(){return Nt.getPlugins()},use(e){return Nt.use(e)},fix(e){return M.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return M.scan()}};