@yuktishaalaa/yuktai 2.0.15 → 2.0.17

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.
@@ -1,34 +1,124 @@
1
- "use strict";var YuktAI=(()=>{var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var O=(t,i)=>{for(var n in i)E(t,n,{get:i[n],enumerable:!0})},K=(t,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of I(i))!j.call(t,a)&&a!==n&&E(t,a,{get:()=>i[a],enumerable:!(s=F(i,a))||s.enumerable});return t};var G=t=>K(E({},"__esModule",{value:!0}),t);var re={};O(re,{wcagPlugin:()=>ae});var w=null,C=null,A=null,$=null,T=null,b=null,m=null,h=null,S=null,g=null,k={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"},H=new Set(["h1","h2","h3","h4","h5","h6"]),q=new Set(["input","select","textarea"]),W=new Set(["button","a","input","select","textarea","details","summary"]),V=new Set(["video","audio"]),Y=new Set(["ul","ol","dl"]);var L={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function M(t,i="polite"){if(typeof window>"u"||!g?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(t);n.rate=1,n.pitch=1,n.volume=1;let s=window.speechSynthesis.getVoices();s.length>0&&(n.voice=s[0]),window.speechSynthesis.speak(n)}function R(t,i="info"){if(typeof document>"u")return;let s={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"}}[i];b||(b=document.createElement("div"),b.setAttribute("role","alert"),b.setAttribute("aria-live","assertive"),b.setAttribute("aria-atomic","true"),b.style.cssText=`
2
- position:fixed;top:80px;right:16px;z-index:999999;
3
- max-width:320px;width:calc(100% - 32px);
4
- border-radius:8px;padding:12px 16px;
5
- display:flex;align-items:center;gap:10px;
6
- font-family:system-ui,sans-serif;font-size:14px;
7
- box-shadow:0 4px 12px rgba(0,0,0,0.3);
8
- transition:transform 0.3s,opacity 0.3s;
9
- transform:translateX(120%);opacity:0;
10
- `,document.body.appendChild(b)),b.style.background=s.bg,b.style.border=`1px solid ${s.border}`,b.style.color="#fff",b.innerHTML=`
11
- <span style="font-size:18px;font-weight:700">${s.icon}</span>
12
- <span style="flex:1;line-height:1.4">${t}</span>
13
- <button onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
1
+ "use strict";var YuktAI=(()=>{var T=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var le=(e,t)=>{for(var i in t)T(e,i,{get:t[i],enumerable:!0})},ce=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of oe(t))!se.call(e,a)&&a!==i&&T(e,a,{get:()=>t[a],enumerable:!(n=ne(t,a))||n.enumerable});return e};var ue=e=>ce(T({},"__esModule",{value:!0}),e);var Re={};le(Re,{wcagPlugin:()=>He});async function S(){try{return window.ai?.rewriter?(await window.ai.rewriter.capabilities()).available!=="no":!1}catch{return!1}}async function de(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=await window.ai.rewriter.create({tone:"more-casual",format:"plain-text",length:"as-is"}),i=await t.rewrite(e,{context:"Rewrite this text in simple plain English. Use short sentences. Avoid jargon. Make it easy to understand for everyone."});return t.destroy(),{success:!0,original:e,rewritten:i.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function q(){if(!await S())return{fixed:0,error:"Chrome Built-in AI not available on this device. Chrome 127+ required."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),i=0;for(let n of t){let a=n.innerText?.trim();if(!a||a.length<20||n.closest("[data-yuktai-panel]"))continue;let o=await de(a);o.success&&o.rewritten!==a&&(n.dataset.yuktaiOriginal=a,n.innerText=o.rewritten,i++)}return{fixed:i}}function B(){let e=document.querySelectorAll("[data-yuktai-original]");for(let t of e){let i=t.dataset.yuktaiOriginal;i&&(t.innerText=i,delete t.dataset.yuktaiOriginal)}}var D="yuktai-summary-box";async function L(){try{return window.ai?.summarizer?(await window.ai.summarizer.capabilities()).available!=="no":!1}catch{return!1}}function me(){let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let i of e){if(i.closest("[data-yuktai-panel]"))continue;let n=window.getComputedStyle(i);if(n.display==="none"||n.visibility==="hidden")continue;let a=i.innerText?.trim();a&&a.length>10&&t.push(a)}return t.join(" ").slice(0,5e3)}async function N(){if(!await L())return{success:!1,summary:"",error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=me();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let i=await window.ai.summarizer.create({type:"tl;dr",format:"plain-text",length:"short"}),n=await i.summarize(t,{context:"Summarise this page in 2-3 simple sentences for a screen reader user who wants to know if this page is relevant to them."});return i.destroy(),pe(n.trim()),{success:!0,summary:n.trim()}}catch(i){return{success:!1,summary:"",error:i instanceof Error?i.message:"Summary failed"}}}function pe(e){h();let t=document.createElement("div");t.id=D,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ z-index: 9990;
7
+ background: #0d9488;
8
+ color: #ffffff;
9
+ font-family: system-ui, -apple-system, sans-serif;
10
+ font-size: 14px;
11
+ line-height: 1.6;
12
+ padding: 10px 20px;
13
+ display: flex;
14
+ align-items: flex-start;
15
+ justify-content: space-between;
16
+ gap: 12px;
17
+ box-shadow: 0 2px 8px rgba(0,0,0,0.15);
18
+ `;let i=document.createElement("p");i.style.cssText="margin: 0; flex: 1;",i.textContent=`\u{1F4CB} Page summary: ${e}`;let n=document.createElement("button");n.textContent="\xD7",n.setAttribute("aria-label","Close page summary"),n.style.cssText=`
19
+ background: none;
20
+ border: none;
21
+ color: #ffffff;
22
+ font-size: 20px;
23
+ cursor: pointer;
24
+ padding: 0 4px;
25
+ line-height: 1;
26
+ flex-shrink: 0;
27
+ `,n.addEventListener("click",h),t.appendChild(i),t.appendChild(n),document.body.prepend(t)}function h(){let e=document.getElementById(D);e&&e.remove()}var F=[{code:"en",label:"English"},{code:"hi",label:"Hindi"},{code:"es",label:"Spanish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"pt",label:"Portuguese"},{code:"nl",label:"Dutch"},{code:"pl",label:"Polish"},{code:"ru",label:"Russian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"zh",label:"Chinese"},{code:"ar",label:"Arabic"},{code:"tr",label:"Turkish"},{code:"vi",label:"Vietnamese"},{code:"bn",label:"Bengali"},{code:"id",label:"Indonesian"}],x="en";async function fe(e){try{return window.translation?await window.translation.canTranslate({sourceLanguage:"en",targetLanguage:e})!=="no":!1}catch{return!1}}async function I(e){if(e===x)return{success:!0,language:e,fixed:0};if(e==="en")return C(),x="en",{success:!0,language:"en",fixed:0};if(!await fe(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Chrome 127+ required.`};try{let i=await window.translation.createTranslator({sourceLanguage:"en",targetLanguage:e}),n=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),a=0;for(let o of n){if(o.closest("[data-yuktai-panel]")||o.children.length>0)continue;let r=o.innerText?.trim();if(!r||r.length<2)continue;o.dataset.yuktaiTranslationOriginal||(o.dataset.yuktaiTranslationOriginal=r);let s=await i.translate(r);s&&s!==r&&(o.innerText=s,a++)}return i.destroy(),x=e,{success:!0,language:e,fixed:a}}catch(i){return{success:!1,language:e,fixed:0,error:i instanceof Error?i.message:"Translation failed"}}}function C(){let e=document.querySelectorAll("[data-yuktai-translation-original]");for(let t of e){let i=t.dataset.yuktaiTranslationOriginal;i&&(t.innerText=i,delete t.dataset.yuktaiTranslationOriginal)}x="en"}var be=[{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,w=!1,f=null;function M(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function ge(e){let t=e.toLowerCase().trim();for(let i of be)for(let n of i.phrases)if(t.includes(n))return{action:i.action,label:i.label};return null}function ye(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=V(),i=t.indexOf(document.activeElement),n=t[i+1]||t[0];n&&n.focus();break}case"tab-back":{let t=V(),i=t.indexOf(document.activeElement),n=t[i-1]||t[t.length-1];n&&n.focus();break}case"stop-voice":{P();break}}}function V(){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 _(e){if(!M())return!1;if(w)return!0;e&&(f=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return m=new t,m.continuous=!0,m.interimResults=!1,m.lang="en-US",m.onresult=i=>{let n=i.results[i.results.length-1][0].transcript,a=ge(n);if(a){ye(a.action);let o={success:!0,command:n,action:a.label};if(f&&f(o),a.action==="stop-voice")return}},m.onend=()=>{w&&m?.start()},m.onerror=i=>{i.error!=="no-speech"&&f&&f({success:!1,command:"",action:"",error:`Voice error: ${i.error}`})},m.start(),w=!0,he(),!0}function P(){w=!1,m&&(m.stop(),m=null),f=null,G()}var W="yuktai-voice-indicator";function he(){G();let e=document.createElement("div");e.id=W,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
28
+ position: fixed;
29
+ bottom: 80px;
30
+ left: 50%;
31
+ transform: translateX(-50%);
32
+ z-index: 9995;
33
+ background: #0d9488;
34
+ color: #ffffff;
35
+ font-family: system-ui, -apple-system, sans-serif;
36
+ font-size: 13px;
37
+ font-weight: 500;
38
+ padding: 6px 14px;
39
+ border-radius: 99px;
40
+ display: flex;
41
+ align-items: center;
42
+ gap: 8px;
43
+ box-shadow: 0 2px 8px rgba(0,0,0,0.15);
44
+ pointer-events: none;
45
+ `;let t=document.createElement("span");if(t.style.cssText=`
46
+ width: 8px;
47
+ height: 8px;
48
+ border-radius: 50%;
49
+ background: #ffffff;
50
+ animation: yuktai-pulse 1.2s infinite;
51
+ flex-shrink: 0;
52
+ `,!document.getElementById("yuktai-pulse-style")){let n=document.createElement("style");n.id="yuktai-pulse-style",n.textContent=`
53
+ @keyframes yuktai-pulse {
54
+ 0%, 100% { opacity: 1; transform: scale(1); }
55
+ 50% { opacity: 0.4; transform: scale(0.7); }
56
+ }
57
+ `,document.head.appendChild(n)}let i=document.createElement("span");i.textContent="Listening for commands...",e.appendChild(t),e.appendChild(i),document.body.appendChild(e)}function G(){let e=document.getElementById(W);e&&e.remove()}var xe=["button:not([aria-label]):not([aria-labelledby])","a:not([aria-label]):not([aria-labelledby])","input:not([aria-label]):not([aria-labelledby]):not([id])","select:not([aria-label]):not([aria-labelledby])","textarea:not([aria-label]):not([aria-labelledby])","[role='button']:not([aria-label])","[role='link']:not([aria-label])","[role='checkbox']:not([aria-label])","[role='tab']:not([aria-label])"].join(", ");async function $(){try{return window.ai?.writer?(await window.ai.writer.capabilities()).available!=="no":!1}catch{return!1}}function we(e){let t=[],i=e.innerText?.trim();i&&t.push(`element text: "${i}"`);let n=e.placeholder?.trim();n&&t.push(`placeholder: "${n}"`);let a=e.getAttribute("name")?.trim();a&&t.push(`name: "${a}"`);let o=e.getAttribute("type")?.trim();o&&t.push(`type: "${o}"`);let r=e.id;if(r){let c=document.querySelector(`label[for="${r}"]`);c&&t.push(`label: "${c.innerText?.trim()}"`)}let s=e.parentElement?.innerText?.trim().slice(0,60);s&&t.push(`parent context: "${s}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let d=e.getAttribute("role");return d&&t.push(`role: ${d}`),t.join(". ")}async function ve(e,t){let i=`
58
+ Generate a short, clear aria-label for an HTML element.
59
+ The label must be 2-6 words maximum.
60
+ The label must describe what the element does or what it is.
61
+ Do not include punctuation.
62
+ Do not explain \u2014 just output the label text only.
63
+
64
+ Element details:
65
+ ${t}
66
+
67
+ Output only the label. Nothing else.
68
+ `.trim();return(await e.write(i)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function j(){if(!await $())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI not available. Chrome 127+ required."};let t=document.querySelectorAll(xe);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let i=await window.ai.writer.create({tone:"neutral",format:"plain-text",length:"short"}),n=0,a=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let r=window.getComputedStyle(o);if(r.display==="none"||r.visibility==="hidden")continue;let s=we(o),d=await ve(i,s);d&&d.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",d),n++,a.push({tag:o.tagName.toLowerCase(),label:d}))}return i.destroy(),{success:!0,fixed:n,elements:a}}catch(i){return{success:!1,fixed:0,elements:[],error:i instanceof Error?i.message:"Label generation failed"}}}function K(){let e=document.querySelectorAll("[data-yuktai-label-original]");for(let t of e){let i=t.dataset.yuktaiLabelOriginal;i?t.setAttribute("aria-label",i):t.removeAttribute("aria-label"),delete t.dataset.yuktaiLabelOriginal}}var A=null,U=null;var Y=null,H=null,u=null,b=null,v=null,R=null,g=null,k={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var J=new Set(["input","select","textarea"]);var z={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function O(e,t="polite"){if(typeof window>"u"||!g?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let i=new SpeechSynthesisUtterance(e);i.rate=1,i.pitch=1,i.volume=1;let n=window.speechSynthesis.getVoices();n.length>0&&(i.voice=n[0]),window.speechSynthesis.speak(i)}function re(e,t="info"){if(typeof document>"u")return;let n={success:{bg:"#0f9d58",border:"#0a7a44",icon:"\u2713"},error:{bg:"#d93025",border:"#b52a1c",icon:"\u2715"},warning:{bg:"#f29900",border:"#c67c00",icon:"\u26A0"},info:{bg:"#1a73e8",border:"#1557b0",icon:"\u2139"}}[t];u||(u=document.createElement("div"),u.setAttribute("role","alert"),u.setAttribute("aria-live","assertive"),u.setAttribute("aria-atomic","true"),u.style.cssText=`
69
+ position: fixed;
70
+ top: 80px;
71
+ right: 16px;
72
+ left: auto;
73
+ z-index: 999999;
74
+ max-width: 320px;
75
+ width: calc(100% - 32px);
76
+ border-radius: 8px;
77
+ padding: 12px 16px;
78
+ display: flex;
79
+ align-items: center;
80
+ gap: 10px;
81
+ font-family: system-ui, sans-serif;
82
+ font-size: 14px;
83
+ box-shadow: 0 4px 12px rgba(0,0,0,0.3);
84
+ transition: transform 0.3s, opacity 0.3s;
85
+ transform: translateX(120%);
86
+ opacity: 0;
87
+ `,document.body.appendChild(u)),u.style.background=n.bg,u.style.border=`1px solid ${n.border}`,u.style.color="#fff",u.innerHTML=`
88
+ <span style="font-size:18px;font-weight:700">${n.icon}</span>
89
+ <span style="flex:1;line-height:1.4">${e}</span>
90
+ <button
91
+ onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
14
92
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
15
93
  aria-label="Close notification">\xD7</button>
16
- `,requestAnimationFrame(()=>{b&&(b.style.transform="translateX(0)",b.style.opacity="1")}),setTimeout(()=>{b&&(b.style.transform="translateX(120%)",b.style.opacity="0")},5e3)}function c(t,i="info",n=!0){w&&(w.textContent=t),R(t,i),n&&M(t,i==="error"?"assertive":"polite")}function U(){if(typeof document>"u"||$)return;let t=[{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']"}],i=document.createElement("div");i.setAttribute("data-yuktai-skip-bar","true"),i.setAttribute("role","navigation"),i.setAttribute("aria-label","Skip links"),i.style.cssText=`
17
- position:fixed;top:0;left:0;right:0;z-index:999999;
18
- display:flex;gap:4px;padding:4px;
19
- background:#111;
20
- transform:translateY(-100%);
21
- transition:transform 0.2s ease;
22
- font-family:system-ui,sans-serif;
23
- `;let n=!1;if(t.forEach(({label:a,selector:l})=>{let e=document.querySelector(l);if(!e)return;n=!0,e.getAttribute("tabindex")||e.setAttribute("tabindex","-1");let r=document.createElement("a");r.href="#",r.textContent=a,r.style.cssText=`
24
- color:#fff;background:#1a73e8;
25
- padding:8px 14px;border-radius:4px;
26
- font-size:13px;font-weight:600;
27
- text-decoration:none;white-space:nowrap;
28
- border:2px solid transparent;
29
- transition:background 0.15s,border-color 0.15s;
30
- `,r.addEventListener("focus",()=>{i.style.transform="translateY(0)"}),r.addEventListener("blur",()=>{setTimeout(()=>{i.matches(":focus-within")||(i.style.transform="translateY(-100%)")},2e3)}),r.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),e.focus(),e.scrollIntoView({behavior:"smooth",block:"start"}),c(`Jumped to ${a.replace("Skip to ","")}`,"info"),i.style.transform="translateY(-100%)")}),r.addEventListener("click",p=>{p.preventDefault(),e.focus(),e.scrollIntoView({behavior:"smooth",block:"start"}),c(`Jumped to ${a.replace("Skip to ","")}`,"info"),i.style.transform="translateY(-100%)"}),r.addEventListener("mouseover",()=>{r.style.background="#1557b0",r.style.borderColor="#fff"}),r.addEventListener("mouseout",()=>{r.style.background="#1a73e8",r.style.borderColor="transparent"}),i.appendChild(r)}),!n)return;window.innerWidth<768&&(i.style.transform="translateY(0)",i.style.position="sticky"),document.body.insertBefore(i,document.body.firstChild),$=i}function J(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let t=document.createElement("style");t.setAttribute("data-yuktai-focus-style","true"),t.textContent=`
31
- /* WCAG 2.4.11 \u2014 minimum 2px solid focus indicator */
94
+ `,window.innerWidth<=480&&(u.style.right="8px",u.style.left="8px",u.style.maxWidth="none",u.style.width="auto"),requestAnimationFrame(()=>{u&&(u.style.transform="translateX(0)",u.style.opacity="1")}),setTimeout(()=>{u&&(u.style.transform="translateX(120%)",u.style.opacity="0")},5e3)}function l(e,t="info",i=!0){A&&(A.textContent=e),re(e,t),i&&O(e,t==="error"?"assertive":"polite")}function ke(){if(typeof document>"u"||Y)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
95
+ position: fixed;
96
+ top: 0;
97
+ left: 0;
98
+ right: 0;
99
+ z-index: 999999;
100
+ display: flex;
101
+ flex-wrap: wrap;
102
+ gap: 4px;
103
+ padding: 4px;
104
+ background: #111;
105
+ transform: translateY(-100%);
106
+ transition: transform 0.2s ease;
107
+ font-family: system-ui, sans-serif;
108
+ `;let i=!1;if(e.forEach(({label:a,selector:o})=>{let r=document.querySelector(o);if(!r)return;i=!0,r.getAttribute("tabindex")||r.setAttribute("tabindex","-1");let s=document.createElement("a");s.href="#",s.textContent=a,s.style.cssText=`
109
+ color: #fff;
110
+ background: #1a73e8;
111
+ padding: 8px 14px;
112
+ border-radius: 4px;
113
+ font-size: 13px;
114
+ font-weight: 600;
115
+ text-decoration: none;
116
+ white-space: nowrap;
117
+ border: 2px solid transparent;
118
+ transition: background 0.15s, border-color 0.15s;
119
+ `,s.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),s.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),s.addEventListener("click",d=>{d.preventDefault(),r.focus(),r.scrollIntoView({behavior:"smooth",block:"start"}),l(`Jumped to ${a.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(s)}),!i)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),Y=t}function Ae(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
120
+
121
+ /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
32
122
  [data-yuktai-a11y] *:focus-visible {
33
123
  outline: 3px solid #1a73e8 !important;
34
124
  outline-offset: 3px !important;
@@ -36,25 +126,25 @@
36
126
  box-shadow: 0 0 0 6px rgba(26,115,232,0.15) !important;
37
127
  }
38
128
 
39
- /* High contrast focus */
129
+ /* \u2500\u2500 High contrast focus \u2500\u2500 */
40
130
  [data-yuktai-high-contrast] *:focus-visible {
41
131
  outline: 3px solid #ffff00 !important;
42
132
  outline-offset: 3px !important;
43
133
  box-shadow: 0 0 0 6px rgba(255,255,0,0.2) !important;
44
134
  }
45
135
 
46
- /* Keyboard hint mode */
136
+ /* \u2500\u2500 Keyboard hint mode \u2500\u2500 */
47
137
  [data-yuktai-keyboard] *:focus {
48
138
  outline: 3px solid #ff6b35 !important;
49
139
  outline-offset: 3px !important;
50
140
  }
51
141
 
52
- /* Remove default outline \u2014 replaced by above */
142
+ /* \u2500\u2500 Remove default outline \u2014 replaced above \u2500\u2500 */
53
143
  [data-yuktai-a11y] *:focus:not(:focus-visible) {
54
144
  outline: none !important;
55
145
  }
56
146
 
57
- /* Large targets \u2014 WCAG 2.5.8 */
147
+ /* \u2500\u2500 Large targets \u2014 WCAG 2.5.8 \u2500\u2500 */
58
148
  [data-yuktai-large-targets] button,
59
149
  [data-yuktai-large-targets] a,
60
150
  [data-yuktai-large-targets] input,
@@ -64,7 +154,7 @@
64
154
  min-width: 44px !important;
65
155
  }
66
156
 
67
- /* Reduce motion \u2014 WCAG 2.3.3 */
157
+ /* \u2500\u2500 Reduce motion \u2014 WCAG 2.3.3 \u2500\u2500 */
68
158
  [data-yuktai-reduce-motion] *,
69
159
  [data-yuktai-reduce-motion] *::before,
70
160
  [data-yuktai-reduce-motion] *::after {
@@ -72,12 +162,12 @@
72
162
  transition-duration: 0.001ms !important;
73
163
  }
74
164
 
75
- /* High contrast mode */
165
+ /* \u2500\u2500 High contrast mode \u2500\u2500 */
76
166
  [data-yuktai-high-contrast] {
77
167
  filter: contrast(1.4) brightness(1.05) !important;
78
168
  }
79
169
 
80
- /* Dark mode */
170
+ /* \u2500\u2500 Dark mode \u2500\u2500 */
81
171
  [data-yuktai-dark] {
82
172
  filter: invert(1) hue-rotate(180deg) !important;
83
173
  }
@@ -87,7 +177,24 @@
87
177
  filter: invert(1) hue-rotate(180deg) !important;
88
178
  }
89
179
 
90
- /* Skip link bar responsive */
180
+ /* \u2500\u2500 Dyslexia font \u2500\u2500 */
181
+ [data-yuktai-dyslexia] * {
182
+ font-family: "Atkinson Hyperlegible", "Arial", sans-serif !important;
183
+ letter-spacing: 0.05em !important;
184
+ word-spacing: 0.1em !important;
185
+ line-height: 1.8 !important;
186
+ }
187
+
188
+ /* \u2500\u2500 Link underline enforcement \u2500\u2500 */
189
+ [data-yuktai-a11y] a:not([role]):not([class]) {
190
+ text-decoration: underline !important;
191
+ }
192
+
193
+ /* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
194
+ RESPONSIVE BREAKPOINTS
195
+ \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
196
+
197
+ /* Skip link bar \u2014 wrap on small screens */
91
198
  @media (max-width: 768px) {
92
199
  [data-yuktai-skip-bar] {
93
200
  flex-wrap: wrap;
@@ -98,173 +205,186 @@
98
205
  }
99
206
  }
100
207
 
101
- /* Preference panel responsive */
208
+ /* Preference panel \u2014 bottom sheet on mobile */
102
209
  @media (max-width: 480px) {
103
210
  [data-yuktai-panel] {
104
211
  width: 100% !important;
105
212
  right: 0 !important;
213
+ left: 0 !important;
106
214
  bottom: 0 !important;
107
215
  border-radius: 16px 16px 0 0 !important;
216
+ max-height: 85vh !important;
108
217
  }
109
218
  }
110
219
 
111
- /* Link underline enforcement */
112
- [data-yuktai-a11y] a:not([role]):not([class]) {
113
- text-decoration: underline !important;
220
+ /* FAB button \u2014 reposition on mobile */
221
+ @media (max-width: 480px) {
222
+ [data-yuktai-pref-toggle] {
223
+ bottom: 12px !important;
224
+ right: 12px !important;
225
+ width: 44px !important;
226
+ height: 44px !important;
227
+ }
228
+ }
229
+
230
+ /* Audit badge \u2014 reposition on mobile */
231
+ @media (max-width: 480px) {
232
+ [data-yuktai-badge] {
233
+ bottom: 12px !important;
234
+ left: 12px !important;
235
+ font-size: 11px !important;
236
+ padding: 4px 10px !important;
237
+ }
114
238
  }
115
- `,document.head.appendChild(t),document.documentElement.setAttribute("data-yuktai-a11y","true")}function X(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",t=>{let i=document.activeElement;if(!i)return;let n=i.getAttribute("role")||"";if(t.key==="Escape"){let s=i.closest("[role='dialog'],[role='alertdialog']");if(s){s.style.display="none";let l=s.getAttribute("data-yuktai-trigger");l&&document.querySelector(`[data-yuktai-id='${l}']`)?.focus(),c("Dialog closed","info");return}let a=i.closest("[role='menu'],[role='menubar']");a&&(a.style.display="none",c("Menu closed","info"))}if(n==="menuitem"||i.closest("[role='menu'],[role='menubar']")){let s=i.closest("[role='menu'],[role='menubar']");if(!s)return;let a=Array.from(s.querySelectorAll("[role='menuitem']:not([disabled])")),l=a.indexOf(i);t.key==="ArrowDown"||t.key==="ArrowRight"?(t.preventDefault(),a[(l+1)%a.length]?.focus()):t.key==="ArrowUp"||t.key==="ArrowLeft"?(t.preventDefault(),a[(l-1+a.length)%a.length]?.focus()):t.key==="Home"?(t.preventDefault(),a[0]?.focus()):t.key==="End"&&(t.preventDefault(),a[a.length-1]?.focus())}if(n==="tab"||i.closest("[role='tablist']")){let s=i.closest("[role='tablist']");if(!s)return;let a=Array.from(s.querySelectorAll("[role='tab']:not([disabled])")),l=a.indexOf(i);if(t.key==="ArrowRight"||t.key==="ArrowDown"){t.preventDefault();let e=a[(l+1)%a.length];e?.focus(),e?.click()}else if(t.key==="ArrowLeft"||t.key==="ArrowUp"){t.preventDefault();let e=a[(l-1+a.length)%a.length];e?.focus(),e?.click()}}if(n==="option"||i.closest("[role='listbox']")){let s=i.closest("[role='listbox']");if(!s)return;let a=Array.from(s.querySelectorAll("[role='option']:not([aria-disabled='true'])")),l=a.indexOf(i);t.key==="ArrowDown"?(t.preventDefault(),a[(l+1)%a.length]?.focus()):t.key==="ArrowUp"?(t.preventDefault(),a[(l-1+a.length)%a.length]?.focus()):(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),i.setAttribute("aria-selected","true"),a.forEach(e=>{e!==i&&e.setAttribute("aria-selected","false")}),c(`Selected: ${i.textContent?.trim()}`,"success"))}t.altKey&&t.key==="a"&&(t.preventDefault(),N()),t.key==="Tab"&&g?.speechEnabled&&setTimeout(()=>{let s=document.activeElement;if(!s)return;let a=s.getAttribute("aria-label")||s.getAttribute("title")||s.textContent?.trim()||s.tagName.toLowerCase(),l=s.getAttribute("role")||s.tagName.toLowerCase();M(`${a}, ${l}`)},100)}))}function y(t){let i=t.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(i.length===0)return;let n=i[0],s=i[i.length-1];n.focus(),t.addEventListener("keydown",a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===n&&(a.preventDefault(),s.focus()):document.activeElement===s&&(a.preventDefault(),n.focus()))})}function N(){if(typeof document>"u")return;if(m){m.remove(),m=null;return}let t=document.createElement("div");t.setAttribute("role","dialog"),t.setAttribute("aria-label","Keyboard shortcuts"),t.setAttribute("aria-modal","true"),t.style.cssText=`
116
- position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
117
- z-index:999999;background:#1a1a2e;color:#fff;
118
- border-radius:12px;padding:24px;width:320px;max-width:calc(100vw - 32px);
119
- box-shadow:0 20px 60px rgba(0,0,0,0.5);
120
- font-family:system-ui,sans-serif;
121
- `;let i=[["Alt + A","Open/close this menu"],["Tab","Next focusable element"],["Shift+Tab","Previous focusable element"],["Enter","Activate button or link"],["Space","Check checkbox / scroll"],["Arrow keys","Navigate lists and menus"],["Escape","Close dialog or menu"],["Home","First item in list"],["End","Last item in list"]];t.innerHTML=`
239
+
240
+ /* Keyboard cheatsheet \u2014 full width on mobile */
241
+ @media (max-width: 480px) {
242
+ [data-yuktai-cheatsheet] {
243
+ width: calc(100vw - 32px) !important;
244
+ max-height: 80vh !important;
245
+ overflow-y: auto !important;
246
+ }
247
+ }
248
+
249
+ /* Timeout warning \u2014 full width on mobile */
250
+ @media (max-width: 480px) {
251
+ [data-yuktai-timeout] {
252
+ width: calc(100vw - 32px) !important;
253
+ }
254
+ }
255
+
256
+ /* Visual alert \u2014 full width on mobile */
257
+ @media (max-width: 480px) {
258
+ [data-yuktai-alert] {
259
+ right: 8px !important;
260
+ left: 8px !important;
261
+ max-width: none !important;
262
+ width: auto !important;
263
+ }
264
+ }
265
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function Ee(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{let t=document.activeElement;if(!t)return;let i=t.getAttribute("role")||"";if(e.key==="Escape"){let n=t.closest("[role='dialog'],[role='alertdialog']");if(n){n.style.display="none",l("Dialog closed","info");return}let a=t.closest("[role='menu'],[role='menubar']");a&&(a.style.display="none",l("Menu closed","info"))}if(i==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let n=t.closest("[role='menu'],[role='menubar']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='menuitem']:not([disabled])")),o=a.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),a[(o+1)%a.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),a[(o-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(i==="tab"||t.closest("[role='tablist']")){let n=t.closest("[role='tablist']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='tab']:not([disabled])")),o=a.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let r=a[(o+1)%a.length];r?.focus(),r?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let r=a[(o-1+a.length)%a.length];r?.focus(),r?.click()}}if(i==="option"||t.closest("[role='listbox']")){let n=t.closest("[role='listbox']");if(!n)return;let a=Array.from(n.querySelectorAll("[role='option']:not([aria-disabled='true'])")),o=a.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),a[(o+1)%a.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),a[(o-1+a.length)%a.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),a.forEach(r=>{r!==t&&r.setAttribute("aria-selected","false")}),l(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Te()),e.key==="Tab"&&g?.speechEnabled&&setTimeout(()=>{let n=document.activeElement;if(!n)return;let a=n.getAttribute("aria-label")||n.getAttribute("title")||n.textContent?.trim()||n.tagName.toLowerCase(),o=n.getAttribute("role")||n.tagName.toLowerCase();O(`${a}, ${o}`)},100)}))}function E(e){let t=e.querySelectorAll('button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"]),[role="button"]');if(t.length===0)return;let i=t[0],n=t[t.length-1];i.focus(),e.addEventListener("keydown",a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===i&&(a.preventDefault(),n.focus()):document.activeElement===n&&(a.preventDefault(),i.focus()))})}function Te(){if(typeof document>"u")return;if(b){b.remove(),b=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
266
+ position: fixed;
267
+ top: 50%;
268
+ left: 50%;
269
+ transform: translate(-50%, -50%);
270
+ z-index: 999999;
271
+ background: #1a1a2e;
272
+ color: #fff;
273
+ border-radius: 12px;
274
+ padding: 24px;
275
+ width: min(320px, calc(100vw - 32px));
276
+ max-height: 80vh;
277
+ overflow-y: auto;
278
+ box-shadow: 0 20px 60px rgba(0,0,0,0.5);
279
+ font-family: system-ui, sans-serif;
280
+ `;let t=[["Alt + A","Open/close this menu"],["Tab","Next focusable element"],["Shift+Tab","Previous focusable element"],["Enter","Activate button or link"],["Space","Check checkbox / scroll"],["Arrow keys","Navigate lists and menus"],["Escape","Close dialog or menu"],["Home","First item in list"],["End","Last item in list"]];e.innerHTML=`
122
281
  <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:16px">
123
282
  <h2 style="margin:0;font-size:16px;font-weight:700;color:#74c0fc">
124
283
  \u2328 Keyboard shortcuts
125
284
  </h2>
126
- <button data-yuktai-close style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1" aria-label="Close shortcuts">\xD7</button>
285
+ <button data-yuktai-close
286
+ style="background:none;border:none;color:#aaa;cursor:pointer;font-size:20px;padding:0;line-height:1"
287
+ aria-label="Close shortcuts">\xD7</button>
127
288
  </div>
128
- ${i.map(([s,a])=>`
289
+ ${t.map(([n,a])=>`
129
290
  <div style="display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid #2a2a4a">
130
- <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${s}</kbd>
291
+ <kbd style="background:#2a2a4a;color:#74c0fc;padding:3px 8px;border-radius:4px;font-size:12px;font-family:monospace;border:1px solid #3a3a6a">${n}</kbd>
131
292
  <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${a}</span>
132
293
  </div>
133
294
  `).join("")}
134
- <p style="margin:12px 0 0;font-size:11px;color:#888;text-align:center">
135
- Powered by @yuktai/a11y \xB7 Press Escape to close
136
- </p>
137
- `,t.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{t.remove(),m=null}),t.addEventListener("keydown",s=>{s.key==="Escape"&&(t.remove(),m=null)}),document.body.appendChild(t),m=t,y(t),c("Keyboard shortcuts opened. Press Escape to close.","info")}function Z(t){if(typeof document>"u"||!g?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;T&&T.remove();let i=t.score,n=i>=90?"#0f9d58":i>=70?"#f29900":"#d93025",s=i>=90?"\u267F":i>=70?"\u26A0":"\u2715",a=document.createElement("button");a.setAttribute("aria-label",`Accessibility score: ${i} out of 100. Click for details.`),a.setAttribute("data-yuktai-badge","true"),a.style.cssText=`
138
- position:fixed;bottom:16px;left:16px;z-index:999998;
139
- background:${n};color:#fff;
140
- border:none;border-radius:20px;cursor:pointer;
141
- padding:6px 12px;font-size:12px;font-weight:700;
142
- font-family:system-ui,sans-serif;
143
- box-shadow:0 2px 8px rgba(0,0,0,0.3);
144
- display:flex;align-items:center;gap:6px;
145
- transition:transform 0.15s;
146
- `,a.innerHTML=`${s} ${i}/100 <span style="font-weight:400;opacity:0.85">${t.details.length} issues</span>`,a.addEventListener("mouseenter",()=>{a.style.transform="scale(1.05)"}),a.addEventListener("mouseleave",()=>{a.style.transform="scale(1)"}),a.addEventListener("click",()=>{Q(t)}),document.body.appendChild(a),T=a}function Q(t){let i=document.querySelector("[data-yuktai-audit-details]");if(i){i.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=`
147
- position:fixed;bottom:56px;left:16px;z-index:999999;
148
- background:#1a1a2e;color:#fff;border-radius:12px;
149
- padding:16px;width:340px;max-width:calc(100vw - 32px);
150
- max-height:60vh;overflow-y:auto;
151
- box-shadow:0 8px 32px rgba(0,0,0,0.5);
152
- font-family:system-ui,sans-serif;font-size:12px;
153
- `;let s={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};n.innerHTML=`
295
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),b=null}),e.addEventListener("keydown",n=>{n.key==="Escape"&&(e.remove(),b=null)}),document.body.appendChild(e),b=e,E(e),l("Keyboard shortcuts opened. Press Escape to close.","info")}function Se(e){if(typeof document>"u"||!g?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;H&&H.remove();let t=e.score,i=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",n=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",a=document.createElement("button");a.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),a.setAttribute("data-yuktai-badge","true"),a.style.cssText=`
296
+ position: fixed;
297
+ bottom: 16px;
298
+ left: 16px;
299
+ z-index: 999998;
300
+ background: ${i};
301
+ color: #fff;
302
+ border: none;
303
+ border-radius: 20px;
304
+ cursor: pointer;
305
+ padding: 6px 12px;
306
+ font-size: 12px;
307
+ font-weight: 700;
308
+ font-family: system-ui, sans-serif;
309
+ box-shadow: 0 2px 8px rgba(0,0,0,0.3);
310
+ display: flex;
311
+ align-items: center;
312
+ gap: 6px;
313
+ transition: transform 0.15s;
314
+ `,a.innerHTML=`${n} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,a.addEventListener("click",()=>Le(e)),document.body.appendChild(a),H=a}function Le(e){let t=document.querySelector("[data-yuktai-audit-details]");if(t){t.remove();return}let i=document.createElement("div");i.setAttribute("data-yuktai-audit-details","true"),i.setAttribute("role","dialog"),i.setAttribute("aria-label","Accessibility audit details"),i.style.cssText=`
315
+ position: fixed;
316
+ bottom: 56px;
317
+ left: 16px;
318
+ right: 16px;
319
+ z-index: 999999;
320
+ background: #1a1a2e;
321
+ color: #fff;
322
+ border-radius: 12px;
323
+ padding: 16px;
324
+ width: auto;
325
+ max-width: 340px;
326
+ max-height: 60vh;
327
+ overflow-y: auto;
328
+ box-shadow: 0 8px 32px rgba(0,0,0,0.5);
329
+ font-family: system-ui, sans-serif;
330
+ font-size: 12px;
331
+ `;let n={critical:"#d93025",serious:"#f29900",moderate:"#1a73e8",minor:"#0f9d58"};i.innerHTML=`
154
332
  <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px">
155
- <strong style="font-size:14px;color:#74c0fc">Audit Report</strong>
156
- <span style="color:#aaa">${t.fixed} fixed \xB7 ${t.renderTime}ms</span>
333
+ <strong style="font-size:14px;color:#74c0fc">Audit report</strong>
334
+ <span style="color:#aaa">${e.fixed} fixed \xB7 ${e.renderTime}ms</span>
157
335
  </div>
158
- ${t.details.slice(0,20).map(a=>`
336
+ ${e.details.slice(0,20).map(a=>`
159
337
  <div style="padding:6px 0;border-bottom:1px solid #2a2a4a">
160
338
  <div style="display:flex;gap:6px;align-items:center">
161
- <span style="background:${s[a.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${a.severity}</span>
339
+ <span style="background:${n[a.severity]};color:#fff;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:700;text-transform:uppercase">${a.severity}</span>
162
340
  <code style="color:#74c0fc">&lt;${a.tag}&gt;</code>
163
341
  </div>
164
342
  <div style="color:#ccc;margin-top:3px">${a.fix}</div>
165
343
  </div>
166
344
  `).join("")}
167
- ${t.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${t.details.length-20} more issues</div>`:""}
168
- `,n.addEventListener("keydown",a=>{a.key==="Escape"&&n.remove()}),document.body.appendChild(n),y(n)}function _(t){typeof document>"u"||(S&&clearTimeout(S),S=setTimeout(()=>{if(h)return;let i=document.createElement("div");i.setAttribute("role","alertdialog"),i.setAttribute("aria-label","Session timeout warning"),i.setAttribute("aria-modal","true"),i.setAttribute("data-yuktai-timeout","true"),i.style.cssText=`
169
- position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
170
- z-index:999999;background:#fff;color:#111;
171
- border-radius:12px;padding:24px;width:320px;max-width:calc(100vw - 32px);
172
- box-shadow:0 20px 60px rgba(0,0,0,0.4);
173
- font-family:system-ui,sans-serif;border:2px solid #d93025;
174
- `,i.innerHTML=`
345
+ ${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
346
+ `,i.addEventListener("keydown",a=>{a.key==="Escape"&&i.remove()}),document.body.appendChild(i),E(i)}function ae(e){typeof document>"u"||(R&&clearTimeout(R),R=setTimeout(()=>{if(v)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
347
+ position: fixed;
348
+ top: 50%;
349
+ left: 50%;
350
+ transform: translate(-50%, -50%);
351
+ z-index: 999999;
352
+ background: #fff;
353
+ color: #111;
354
+ border-radius: 12px;
355
+ padding: 24px;
356
+ width: min(320px, calc(100vw - 32px));
357
+ box-shadow: 0 20px 60px rgba(0,0,0,0.4);
358
+ font-family: system-ui, sans-serif;
359
+ border: 2px solid #d93025;
360
+ `,t.innerHTML=`
175
361
  <h2 style="margin:0 0 8px;font-size:18px;color:#d93025">\u23F1 Session timeout</h2>
176
362
  <p style="margin:0 0 16px;font-size:14px;line-height:1.5;color:#444">
177
363
  Your session will expire soon. Do you need more time?
178
364
  </p>
179
- <div style="display:flex;gap:8px">
180
- <button data-yuktai-extend style="flex:1;padding:10px;background:#1a73e8;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:14px;font-weight:600">
365
+ <div style="display:flex;gap:8px;flex-wrap:wrap">
366
+ <button data-yuktai-extend
367
+ style="flex:1;min-width:120px;padding:10px;background:#1a73e8;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:14px;font-weight:600">
181
368
  Yes, more time
182
369
  </button>
183
- <button data-yuktai-dismiss style="flex:1;padding:10px;background:#f1f3f4;color:#111;border:none;border-radius:8px;cursor:pointer;font-size:14px">
370
+ <button data-yuktai-dismiss
371
+ style="flex:1;min-width:120px;padding:10px;background:#f1f3f4;color:#111;border:none;border-radius:8px;cursor:pointer;font-size:14px">
184
372
  No, sign out
185
373
  </button>
186
374
  </div>
187
- `;let n=i.querySelector("[data-yuktai-extend]"),s=i.querySelector("[data-yuktai-dismiss]");n?.addEventListener("click",()=>{i.remove(),h=null,c("Session extended. You have more time.","success"),g?.timeoutWarning&&_(g.timeoutWarning)}),s?.addEventListener("click",()=>{i.remove(),h=null}),document.body.appendChild(i),h=i,y(i),c("Warning: Your session will expire soon. Do you need more time?","warning")},t*1e3))}function P(t){if(typeof document>"u"||A)return;try{let a=localStorage.getItem("yuktai-a11y-prefs");if(a){let l=JSON.parse(a);Object.assign(t,l),x(t)}}catch{}let i=document.createElement("button");i.setAttribute("aria-label","Accessibility preferences"),i.setAttribute("aria-haspopup","dialog"),i.setAttribute("data-yuktai-pref-toggle","true"),i.style.cssText=`
188
- position:fixed;bottom:16px;right:16px;z-index:999998;
189
- width:48px;height:48px;border-radius:50%;
190
- background:#1a73e8;color:#fff;border:none;
191
- cursor:pointer;font-size:22px;
192
- box-shadow:0 2px 12px rgba(0,0,0,0.3);
193
- display:flex;align-items:center;justify-content:center;
194
- transition:transform 0.15s,background 0.15s;
195
- `,i.innerHTML="\u267F",i.addEventListener("mouseenter",()=>{i.style.transform="scale(1.1)",i.style.background="#1557b0"}),i.addEventListener("mouseleave",()=>{i.style.transform="scale(1)",i.style.background="#1a73e8"});let n=document.createElement("div");n.setAttribute("role","dialog"),n.setAttribute("aria-label","Accessibility preferences"),n.setAttribute("aria-modal","true"),n.setAttribute("data-yuktai-panel","true"),n.style.cssText=`
196
- position:fixed;bottom:76px;right:16px;z-index:999999;
197
- width:300px;max-width:calc(100vw - 32px);
198
- background:#fff;border-radius:16px;
199
- box-shadow:0 8px 32px rgba(0,0,0,0.2);
200
- border:1px solid #e0e0e0;
201
- font-family:system-ui,sans-serif;
202
- overflow:hidden;display:none;
203
- `;let s=[{icon:"\u{1F441}",title:"Vision",options:[{key:"highContrast",label:"High contrast",type:"toggle"},{key:"darkMode",label:"Dark mode",type:"toggle"},{key:"largeTargets",label:"Large text & targets",type:"toggle"}]},{icon:"\u{1F3A8}",title:"Colour blindness",options:[{key:"colorBlind_none",label:"None",type:"radio",group:"cb"},{key:"colorBlind_deuteranopia",label:"Deuteranopia",type:"radio",group:"cb"},{key:"colorBlind_protanopia",label:"Protanopia",type:"radio",group:"cb"},{key:"colorBlind_tritanopia",label:"Tritanopia",type:"radio",group:"cb"},{key:"colorBlind_achromatopsia",label:"Greyscale",type:"radio",group:"cb"}]},{icon:"\u2328",title:"Motor",options:[{key:"reduceMotion",label:"Reduce motion",type:"toggle"},{key:"largeTargets",label:"Large click targets",type:"toggle"}]},{icon:"\u{1F50A}",title:"Audio",options:[{key:"speechEnabled",label:"Speak on focus",type:"toggle"}]}];n.innerHTML=`
204
- <div style="padding:16px 16px 8px;border-bottom:1px solid #f0f0f0;display:flex;justify-content:space-between;align-items:center">
205
- <strong style="font-size:15px;color:#111">\u267F Accessibility</strong>
206
- <button data-yuktai-panel-close style="background:none;border:none;cursor:pointer;font-size:20px;color:#666;padding:0;line-height:1" aria-label="Close preferences">\xD7</button>
207
- </div>
208
- <div style="padding:8px 0;max-height:60vh;overflow-y:auto">
209
- ${s.map(a=>`
210
- <div style="padding:8px 16px">
211
- <div style="font-size:11px;font-weight:700;color:#888;letter-spacing:0.5px;text-transform:uppercase;margin-bottom:8px">
212
- ${a.icon} ${a.title}
213
- </div>
214
- ${a.options.map(l=>`
215
- <label style="display:flex;align-items:center;justify-content:space-between;padding:6px 0;cursor:pointer;gap:8px">
216
- <span style="font-size:13px;color:#333">${l.label}</span>
217
- ${l.type==="toggle"?`
218
- <div data-yuktai-toggle="${l.key}" style="
219
- width:40px;height:22px;border-radius:11px;
220
- background:${v(t,l.key)?"#1a73e8":"#ccc"};
221
- position:relative;cursor:pointer;transition:background 0.2s;flex-shrink:0;
222
- ">
223
- <div style="
224
- position:absolute;top:2px;left:${v(t,l.key)?"20px":"2px"};
225
- width:18px;height:18px;border-radius:50%;background:#fff;
226
- transition:left 0.2s;box-shadow:0 1px 3px rgba(0,0,0,0.2);
227
- "></div>
228
- </div>
229
- `:`
230
- <input type="radio" name="yuktai-${l.group}" value="${l.key}"
231
- ${ee(t,l.key)?"checked":""}
232
- style="width:16px;height:16px;cursor:pointer;accent-color:#1a73e8"
233
- />
234
- `}
235
- </label>
236
- `).join("")}
237
- </div>
238
- `).join("")}
239
- <div style="padding:8px 16px 4px">
240
- <div style="font-size:11px;font-weight:700;color:#888;letter-spacing:0.5px;text-transform:uppercase;margin-bottom:8px">
241
- \u2328 Keyboard
242
- </div>
243
- <button data-yuktai-show-keys style="
244
- width:100%;padding:8px;background:#f8f9fa;border:1px solid #e0e0e0;
245
- border-radius:8px;cursor:pointer;font-size:13px;color:#333;
246
- display:flex;align-items:center;justify-content:center;gap:6px;
247
- ">
248
- Show keyboard shortcuts <kbd style="background:#e0e0e0;padding:1px 6px;border-radius:4px;font-size:11px">Alt+A</kbd>
249
- </button>
250
- </div>
251
- </div>
252
- <div style="padding:8px 16px 12px;border-top:1px solid #f0f0f0">
253
- <button data-yuktai-reset style="
254
- width:100%;padding:8px;background:#fff;border:1px solid #d93025;
255
- border-radius:8px;cursor:pointer;font-size:12px;color:#d93025;font-weight:600;
256
- ">Reset all preferences</button>
257
- </div>
258
- `,n.querySelectorAll("[data-yuktai-toggle]").forEach(a=>{a.addEventListener("click",()=>{let l=a.getAttribute("data-yuktai-toggle");t[l]=!v(t,l),B(t),x(t),z(t),c(`${l.replace(/([A-Z])/g," $1")} ${v(t,l)?"enabled":"disabled"}`,"info")})}),n.querySelectorAll("input[type='radio']").forEach(a=>{a.addEventListener("change",()=>{let l=a.value.replace("colorBlind_","");t.colorBlindMode=l,B(t),x(t),c(`Colour blind mode: ${l}`,"info")})}),n.querySelector("[data-yuktai-show-keys]")?.addEventListener("click",()=>{N()}),n.querySelector("[data-yuktai-reset]")?.addEventListener("click",()=>{localStorage.removeItem("yuktai-a11y-prefs"),t.highContrast=!1,t.darkMode=!1,t.reduceMotion=!1,t.largeTargets=!1,t.speechEnabled=!1,t.colorBlindMode="none",x(t),z(t),c("Preferences reset to default","info")}),n.querySelector("[data-yuktai-panel-close]")?.addEventListener("click",()=>{n.style.display="none",i.focus(),c("Preferences closed","info")}),n.addEventListener("keydown",a=>{a.key==="Escape"&&(n.style.display="none",i.focus())}),i.addEventListener("click",()=>{let a=n.style.display!=="none";n.style.display=a?"none":"block",i.setAttribute("aria-expanded",String(!a)),a||(y(n),c("Accessibility preferences opened","info"))}),document.body.appendChild(i),document.body.appendChild(n),A=n}function z(t){A&&(A.remove(),A=null),P(t)}function v(t,i){return!!t[i]}function ee(t,i){let n=i.replace("colorBlind_","");return t.colorBlindMode===n}function B(t){try{let i={highContrast:t.highContrast,darkMode:t.darkMode,reduceMotion:t.reduceMotion,largeTargets:t.largeTargets,speechEnabled:t.speechEnabled,colorBlindMode:t.colorBlindMode};localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(i))}catch{}}function x(t){if(typeof document>"u")return;let i=document.documentElement;i.toggleAttribute("data-yuktai-high-contrast",!!t.highContrast),i.toggleAttribute("data-yuktai-dark",!!t.darkMode),i.toggleAttribute("data-yuktai-reduce-motion",!!t.reduceMotion),i.toggleAttribute("data-yuktai-large-targets",!!t.largeTargets),i.toggleAttribute("data-yuktai-keyboard",!!t.keyboardHints);let n=document.body;if(t.colorBlindMode&&t.colorBlindMode!=="none"){let s=t.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${k[t.colorBlindMode]})`;n.style.filter=s}else n.style.filter=""}function te(){if(typeof document>"u"||w)return;let t=document.createElement("div");t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.setAttribute("aria-relevant","text"),t.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);",document.body.appendChild(t),w=t}function ie(){if(typeof document>"u"||C)return;let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("aria-hidden","true"),t.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",t.innerHTML=`
375
+ `;let i=t.querySelector("[data-yuktai-extend]"),n=t.querySelector("[data-yuktai-dismiss]");i?.addEventListener("click",()=>{t.remove(),v=null,l("Session extended. You have more time.","success"),g?.timeoutWarning&&ae(g.timeoutWarning)}),n?.addEventListener("click",()=>{t.remove(),v=null}),document.body.appendChild(t),v=t,E(t),l("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function Ce(e){if(typeof document>"u")return;let t=document.documentElement;if(t.toggleAttribute("data-yuktai-high-contrast",!!e.highContrast),t.toggleAttribute("data-yuktai-dark",!!e.darkMode),t.toggleAttribute("data-yuktai-reduce-motion",!!e.reduceMotion),t.toggleAttribute("data-yuktai-large-targets",!!e.largeTargets),t.toggleAttribute("data-yuktai-keyboard",!!e.keyboardHints),t.toggleAttribute("data-yuktai-dyslexia",!!e.dyslexiaFont),e.localFont?document.body.style.fontFamily=`"${e.localFont}", system-ui, sans-serif`:e.dyslexiaFont||(document.body.style.fontFamily=""),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1?document.documentElement.style.fontSize=`${e.fontSizeMultiplier*100}%`:document.documentElement.style.fontSize="",e.colorBlindMode&&e.colorBlindMode!=="none"){let i=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${k[e.colorBlindMode]})`;document.body.style.filter=i}else document.body.style.filter=""}function Me(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function X(e){if(e){if(!await S()){l("Plain English requires Chrome 127+","warning");return}l("Rewriting page in plain English...","info",!1);let i=await q();l(i.error?`Plain English failed: ${i.error}`:`${i.fixed} sections rewritten in plain English`,i.error?"error":"success",!1)}else B(),l("Original text restored","info",!1)}async function Q(e){if(e){if(!await L()){l("Page summariser requires Chrome 127+","warning");return}l("Generating page summary...","info",!1);let i=await N();l(i.error?`Summary failed: ${i.error}`:"Page summary added at top",i.error?"error":"success",!1)}else h(),l("Page summary removed","info",!1)}async function Z(e){if(e==="en"){C(),l("Page restored to English","info",!1);return}l(`Translating page to ${e}...`,"info",!1);let t=await I(e);l(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function ee(e){if(e){if(!M()){l("Voice control not supported in this browser","warning");return}_(t=>{t.success&&l(`Voice: ${t.action}`,"info",!1)}),l("Voice control started. Say a command.","success",!1)}else P(),l("Voice control stopped","info",!1)}async function te(e){if(e){if(!await $()){l("Smart labels requires Chrome 127+","warning");return}l("Generating smart labels...","info",!1);let i=await j();l(i.error?`Smart labels failed: ${i.error}`:`${i.fixed} elements labelled`,i.error?"error":"success",!1)}else K(),l("Smart labels removed","info",!1)}function Pe(){if(typeof document>"u"||A)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("aria-relevant","text"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);",document.body.appendChild(e),A=e}function $e(){if(typeof document>"u"||U)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=`
259
376
  <defs>
260
377
  <filter id="${k.deuteranopia}">
261
- <feColorMatrix type="matrix" 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"/>
378
+ <feColorMatrix type="matrix"
379
+ values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
262
380
  </filter>
263
381
  <filter id="${k.protanopia}">
264
- <feColorMatrix type="matrix" 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"/>
382
+ <feColorMatrix type="matrix"
383
+ values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
265
384
  </filter>
266
385
  <filter id="${k.tritanopia}">
267
- <feColorMatrix type="matrix" values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
386
+ <feColorMatrix type="matrix"
387
+ values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
268
388
  </filter>
269
389
  </defs>
270
- `,document.body.appendChild(t),C=t}function D(t){let i={critical:20,serious:10,moderate:5,minor:2},n=t.details.reduce((s,a)=>s+(i[a.severity]||0),0);return Math.max(0,Math.min(100,100-n))}var ae={name:"yuktai-a11y",version:"2.0.0",observer:null,async execute(t){if(!t.enabled)return this.stopObserver(),"yuktai-a11y: disabled.";g=t,te(),ie(),J(),X(),t.showSkipLinks!==!1&&U(),t.showPreferencePanel!==!1&&P(t),x(t);let i=this.applyFixes(t);i.score=D(i),t.showAuditBadge&&Z(i),t.timeoutWarning&&_(t.timeoutWarning),t.autoFix&&this.startObserver(t);let n=`${i.fixed} accessibility fixes applied. Score: ${i.score}/100.`;return c(n,i.score>=90?"success":"info",!1),`yuktai-a11y v2: ${n} Scanned ${i.scanned} elements in ${i.renderTime}ms.`},applyFixes(t){let i={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return i;let n=performance.now(),s=document.querySelectorAll("*");i.scanned=s.length;let a=(l,e,r,p)=>{i.details.push({tag:l,fix:e,severity:r,element:p.outerHTML.slice(0,100)}),i.fixed++};return s.forEach(l=>{let e=l,r=e.tagName.toLowerCase();if(r==="html"&&!e.getAttribute("lang")&&(e.setAttribute("lang","en"),a(r,'lang="en" added to <html>',"critical",e)),r==="head"&&!document.title&&(document.title=document.querySelector("h1")?.innerText?.trim()||"Page",a(r,`document.title set to "${document.title}"`,"serious",e)),r==="meta"){let o=e.getAttribute("name"),d=e.getAttribute("content")||"";o==="viewport"&&d.includes("user-scalable=no")&&(e.setAttribute("content",d.replace("user-scalable=no","user-scalable=yes")),a(r,"user-scalable=yes restored","serious",e)),o==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(d)&&(e.setAttribute("content",d.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(r,"maximum-scale=5 restored","serious",e))}if(r==="main"&&!e.getAttribute("tabindex")&&(e.setAttribute("tabindex","-1"),e.getAttribute("id")||e.setAttribute("id","main-content")),r==="body"&&document.querySelectorAll("video[autoplay]:not([muted])").forEach(o=>{o.muted=!0,a("video","autoplay video muted (deaf users)","serious",e)}),t.largeTargets&&(r==="button"||r==="a"||r==="input")){let o=e.getBoundingClientRect();o.width>0&&o.width<24&&(e.style.minWidth="44px",e.style.minHeight="44px",a(r,"min 44px touch target enforced","minor",e))}if(H.has(r)&&(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",`${r.toUpperCase()} section`),a(r,"aria-label added (empty heading)","moderate",e)),e.hasAttribute("onclick")&&!e.getAttribute("tabindex")&&(e.setAttribute("tabindex","0"),e.onkeydown||(e.onkeydown=o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),e.click())}),a(r,"tabindex=0 + keydown (clickable heading)","minor",e))),r==="img"&&(e.hasAttribute("alt")||(e.setAttribute("alt",""),e.setAttribute("aria-hidden","true"),a(r,'alt="" aria-hidden="true"',"serious",e)),e.getAttribute("role")==="presentation"&&e.getAttribute("alt")!==""&&(e.setAttribute("alt",""),a(r,'alt="" (role=presentation)',"minor",e))),r==="area"&&!e.getAttribute("alt")){let o=e.getAttribute("title")||e.getAttribute("href")||"map area";e.setAttribute("alt",o),a(r,`alt="${o}" on <area>`,"serious",e)}if(r==="svg"){if(!e.getAttribute("aria-hidden")&&!e.getAttribute("aria-label")&&!l.querySelector("title"))if(!e.getAttribute("role")||e.getAttribute("role")==="img"){let o=document.createElementNS("http://www.w3.org/2000/svg","title");o.textContent="graphic",e.prepend(o),e.setAttribute("role","img"),a(r,'role="img" + <title> injected',"moderate",e)}else e.setAttribute("aria-hidden","true"),a(r,'aria-hidden="true" (decorative svg)',"minor",e);e.getAttribute("focusable")||e.setAttribute("focusable","false")}if(r==="canvas"&&(e.getAttribute("role")||(e.setAttribute("role","img"),a(r,'role="img"',"serious",e)),e.getAttribute("aria-label")||(e.setAttribute("aria-label",e.getAttribute("title")||"canvas graphic"),a(r,"aria-label added to canvas","serious",e))),(r==="object"||r==="embed")&&!e.getAttribute("aria-label")&&!e.getAttribute("title")&&(e.setAttribute("aria-label",`embedded ${r} content`),a(r,`aria-label added to <${r}>`,"moderate",e)),r==="video"&&!l.querySelector("track")&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label",e.getAttribute("title")||"video player"),a(r,"aria-label added (no captions track)","serious",e)),r==="audio"&&!l.querySelector("track")&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label",e.getAttribute("title")||"audio player"),a(r,"aria-label added to audio","serious",e)),r==="iframe"&&!e.getAttribute("title")&&!e.getAttribute("aria-label")&&(e.setAttribute("title","embedded content"),e.setAttribute("aria-label","embedded content"),a(r,'title + aria-label="embedded content"',"serious",e)),r==="figure"&&!l.querySelector("figcaption")&&!e.getAttribute("aria-label")){let d=l.querySelector("img")?.getAttribute("alt");d&&(e.setAttribute("aria-label",d),a(r,"aria-label from inner img alt","minor",e))}if(r==="button"){if(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let o=e.getAttribute("title")||e.getAttribute("data-label")||"button";e.setAttribute("aria-label",o),a(r,`aria-label="${o}" (empty button)`,"critical",e)}e.hasAttribute("disabled")&&!e.getAttribute("aria-disabled")&&(e.setAttribute("aria-disabled","true"),i.fixed++),e.getAttribute("data-yuktai-announced")||(e.setAttribute("data-yuktai-announced","true"),e.addEventListener("click",()=>{let o=e.getAttribute("aria-label")||e.textContent?.trim()||"button";setTimeout(()=>{c(`${o} activated`,"success",!1)},100)}))}if(r==="a"){let o=e;if(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let d=e.getAttribute("title")||"link";e.setAttribute("aria-label",d),a(r,`aria-label="${d}" (empty link)`,"critical",e)}if(o.target==="_blank"){o.rel?.includes("noopener")||(o.rel="noopener noreferrer",i.fixed++);let d=o.getAttribute("aria-label")||o.innerText?.trim()||"link";d.includes("opens in new window")||(o.setAttribute("aria-label",`${d} (opens in new window)`),a(r,"aria-label: new-window warning","moderate",e))}!o.href&&!o.getAttribute("role")&&!o.getAttribute("tabindex")&&(o.setAttribute("role","button"),o.setAttribute("tabindex","0"),a(r,'role="button" tabindex=0 (href-less link)',"serious",e))}if((e.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(e).cursor==="pointer")&&!W.has(r)&&(e.getAttribute("role")||(e.setAttribute("role","button"),a(r,'role="button" (clickable non-interactive)',"serious",e)),e.tabIndex<0&&(e.tabIndex=0,i.fixed++),e.onkeydown||(e.onkeydown=o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),e.click())})),q.has(r)){let o=e;if(!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let d=e.getAttribute("placeholder")||e.getAttribute("name")||e.getAttribute("title")||r;e.setAttribute("aria-label",d),a(r,`aria-label="${d}"`,"serious",e)}if(e.hasAttribute("required")&&!e.getAttribute("aria-required")&&(e.setAttribute("aria-required","true"),i.fixed++),e.hasAttribute("disabled")&&!e.getAttribute("aria-disabled")&&(e.setAttribute("aria-disabled","true"),i.fixed++),e.hasAttribute("readonly")&&!e.getAttribute("aria-readonly")&&(e.setAttribute("aria-readonly","true"),i.fixed++),e.getAttribute("data-yuktai-validation")||(e.setAttribute("data-yuktai-validation","true"),e.addEventListener("invalid",()=>{let d=e.getAttribute("aria-label")||e.getAttribute("placeholder")||"Field",f=e.validationMessage||"is invalid";c(`Error: ${d} ${f}`,"error")}),e.addEventListener("change",()=>{if(e.validity?.valid){let d=e.getAttribute("aria-label")||e.getAttribute("placeholder")||"Field";c(`${d} looks good`,"success",!1)}})),r==="input"&&!o.autocomplete){let d=o.name||"";o.type==="email"||d.includes("email")?(o.autocomplete="email",i.fixed++):o.type==="tel"||d.includes("tel")?(o.autocomplete="tel",i.fixed++):o.type==="password"?(o.autocomplete="current-password",i.fixed++):d.includes("firstname")||d.includes("fname")?(o.autocomplete="given-name",i.fixed++):d.includes("lastname")||d.includes("lname")?(o.autocomplete="family-name",i.fixed++):d==="name"||d.includes("fullname")?(o.autocomplete="name",i.fixed++):d.includes("zip")||d.includes("postal")?(o.autocomplete="postal-code",i.fixed++):d.includes("city")?(o.autocomplete="address-level2",i.fixed++):d.includes("country")&&(o.autocomplete="country",i.fixed++)}r==="input"&&o.type==="image"&&!e.getAttribute("alt")&&(e.setAttribute("alt",e.getAttribute("value")||"submit"),a(r,"alt added to input[type=image]","serious",e)),r==="input"&&o.type==="range"&&(e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin",o.min||"0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax",o.max||"100"),e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow",o.value||"50"),i.fixed++)}if(r==="fieldset"&&!l.querySelector("legend")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","form group"),a(r,'aria-label="form group" (no legend)',"moderate",e)),r==="table"&&(!l.querySelector("th")&&!e.getAttribute("role")&&(e.setAttribute("role","grid"),a(r,'role="grid" (no <th>)',"serious",e)),!l.querySelector("caption")&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label","data table"),a(r,'aria-label="data table"',"moderate",e))),r==="th"&&!e.getAttribute("scope")){let o=e.closest("thead")!==null;e.setAttribute("scope",o?"col":"row"),a(r,`scope="${o?"col":"row"}"`,"moderate",e)}if(Y.has(r)&&(e.getAttribute("role")==="presentation"&&(l.querySelectorAll("li").forEach(o=>{o.getAttribute("role")||o.setAttribute("role","presentation")}),i.fixed++),(r==="ul"||r==="ol")&&!e.getAttribute("aria-label"))){let o=e.closest("nav");o&&(e.setAttribute("aria-label",o.getAttribute("aria-label")||"navigation list"),a(r,"aria-label from parent nav","minor",e))}if(L[r]&&!e.getAttribute("role")&&(e.setAttribute("role",L[r]),a(r,`role="${L[r]}"`,"minor",e)),["nav","section","article","aside"].includes(r)){let o=l.parentElement?.querySelectorAll(r);if(o&&o.length>1&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let f=l.querySelector("h1,h2,h3,h4,h5,h6")?.textContent?.trim();f&&(e.setAttribute("aria-label",f),a(r,"aria-label from inner heading","moderate",e))}}if(r==="details"&&!l.querySelector("summary")){let o=document.createElement("summary");o.textContent=e.getAttribute("aria-label")||"More details",e.prepend(o),a(r,"<summary> injected","moderate",e)}if(r==="summary"&&!e.innerText?.trim()&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label","Toggle details"),a(r,'aria-label="Toggle details"',"moderate",e)),r==="dialog"){let o=e.getAttribute("role");if(o&&o!=="dialog"&&o!=="alertdialog"&&(e.setAttribute("role","dialog"),a(r,'role corrected to "dialog"',"serious",e)),!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let f=l.querySelector("h1,h2,h3,h4,h5,h6")?.textContent?.trim()||"dialog";e.setAttribute("aria-label",f),a(r,"aria-label added to dialog","serious",e)}e.getAttribute("data-yuktai-trap")||(e.setAttribute("data-yuktai-trap","true"),new MutationObserver(()=>{e.style.display!=="none"&&e.style.visibility!=="hidden"&&y(e)}).observe(e,{attributes:!0,attributeFilter:["style","open"]}))}if(r==="abbr"&&!e.getAttribute("title")&&(e.setAttribute("title",e.innerText?.trim()||"abbreviation"),a(r,"title added to <abbr>","minor",e)),r==="time"&&!e.getAttribute("datetime")&&e.innerText?.trim()&&(e.setAttribute("datetime",e.innerText.trim()),a(r,`datetime="${e.innerText.trim()}" added`,"minor",e)),r==="meter"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",e.getAttribute("title")||"meter"),a(r,"aria-label added to <meter>","moderate",e)),r==="progress"){!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",e.getAttribute("title")||"progress"),a(r,"aria-label added to <progress>","moderate",e));let o=e;e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow",String(o.value)),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax",String(o.max||1)),i.fixed++}let u=e.getAttribute("role")||"";if(u==="tab"&&!e.getAttribute("aria-selected")&&(e.setAttribute("aria-selected","false"),i.fixed++),u==="tabpanel"&&(!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","tab panel"),a(r,'aria-label="tab panel"',"moderate",e)),e.getAttribute("tabindex")||(e.setAttribute("tabindex","0"),i.fixed++)),["alert","status","log","marquee"].includes(u)){if(!e.getAttribute("aria-live")){let o=u==="alert"?"assertive":"polite";e.setAttribute("aria-live",o),a(r,`aria-live="${o}" on role=${u}`,"moderate",e)}e.getAttribute("aria-atomic")||(e.setAttribute("aria-atomic","true"),i.fixed++)}u==="tooltip"&&!e.getAttribute("aria-live")&&(e.setAttribute("aria-live","polite"),i.fixed++),(u==="menu"||u==="menubar")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","menu"),a(r,'aria-label="menu"',"moderate",e)),u==="listbox"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","listbox"),a(r,'aria-label="listbox"',"moderate",e)),u==="option"&&!e.getAttribute("aria-selected")&&(e.setAttribute("aria-selected","false"),i.fixed++),u==="slider"&&(e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin","0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax","100"),e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow","50"),i.fixed++),(u==="checkbox"||u==="radio")&&!e.getAttribute("aria-checked")&&(e.setAttribute("aria-checked","false"),a(r,`aria-checked="false" on role=${u}`,"serious",e)),u==="combobox"&&(e.getAttribute("aria-expanded")||(e.setAttribute("aria-expanded","false"),a(r,'aria-expanded="false" on combobox',"serious",e)),e.getAttribute("aria-haspopup")||(e.setAttribute("aria-haspopup","listbox"),i.fixed++)),(u==="grid"||u==="treegrid")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","data grid"),a(r,'aria-label="data grid"',"moderate",e)),u==="tree"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","tree"),a(r,'aria-label="tree"',"moderate",e)),u==="spinbutton"&&(e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow","0"),e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin","0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax","100"),i.fixed++)}),i.renderTime=parseFloat((performance.now()-n).toFixed(2)),i},scan(){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let i=performance.now(),n=document.querySelectorAll("*");t.scanned=n.length;let s=(a,l,e,r)=>t.details.push({tag:a,fix:l,severity:e,element:r.outerHTML.slice(0,100)});return n.forEach(a=>{let l=a,e=l.tagName.toLowerCase();(e==="a"||e==="button")&&!l.innerText?.trim()&&!l.getAttribute("aria-label")&&s(e,"needs aria-label (empty)","critical",l),e==="img"&&!l.hasAttribute("alt")&&s(e,"needs alt text","serious",l),q.has(e)&&!l.getAttribute("aria-label")&&!l.getAttribute("aria-labelledby")&&s(e,"needs aria-label","serious",l),e==="iframe"&&!l.getAttribute("title")&&!l.getAttribute("aria-label")&&s(e,"iframe needs title","serious",l),V.has(e)&&!a.querySelector("track")&&!l.getAttribute("aria-label")&&s(e,"media needs captions/aria-label","serious",l),H.has(e)&&!l.innerText?.trim()&&!l.getAttribute("aria-label")&&s(e,"empty heading","moderate",l)}),t.fixed=t.details.length,t.score=D(t),t.renderTime=parseFloat((performance.now()-i).toFixed(2)),t},startObserver(t){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(t)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer?.disconnect(),this.observer=null},announce:c,speak:M,showVisualAlert:R,trapFocus:y};return G(re);})();
390
+ `,document.body.appendChild(e),U=e}function ie(e){let t={critical:20,serious:10,moderate:5,minor:2},i=e.details.reduce((n,a)=>n+(t[a.severity]||0),0);return Math.max(0,Math.min(100,100-i))}var He={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";g=e,Me(e),Pe(),$e(),Ae(),Ee(),e.showSkipLinks!==!1&&ke(),e.showPreferencePanel,Ce(e);let t=this.applyFixes(e);t.score=ie(t),e.showAuditBadge&&Se(t),e.timeoutWarning&&ae(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await X(!0),e.summarisePage&&await Q(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await Z(e.translateLanguage),e.voiceControl&&await ee(!0),e.smartLabels&&await te(!0);let i=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return l(i,t.score>=90?"success":"info",!1),`yuktai v4.0.0: ${i} Scanned ${t.scanned} elements in ${t.renderTime}ms.`},applyFixes(e){let t={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return t;let i=performance.now(),n=document.querySelectorAll("*");t.scanned=n.length;let a=(o,r,s,d)=>{t.details.push({tag:o,fix:r,severity:s,element:d.outerHTML.slice(0,100)}),t.fixed++};return n.forEach(o=>{let r=o,s=r.tagName.toLowerCase();if(s==="html"&&!r.getAttribute("lang")&&(r.setAttribute("lang","en"),a(s,'lang="en" added',"critical",r)),s==="meta"){let c=r.getAttribute("name"),p=r.getAttribute("content")||"";c==="viewport"&&p.includes("user-scalable=no")&&(r.setAttribute("content",p.replace("user-scalable=no","user-scalable=yes")),a(s,"user-scalable=yes restored","serious",r)),c==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(p)&&(r.setAttribute("content",p.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(s,"maximum-scale=5 restored","serious",r))}if(s==="main"&&!r.getAttribute("tabindex")&&(r.setAttribute("tabindex","-1"),r.getAttribute("id")||r.setAttribute("id","main-content")),s==="img"&&(r.hasAttribute("alt")||(r.setAttribute("alt",""),r.setAttribute("aria-hidden","true"),a(s,'alt="" aria-hidden="true"',"serious",r))),s==="svg"&&(!r.getAttribute("aria-hidden")&&!r.getAttribute("aria-label")&&!o.querySelector("title")&&(r.setAttribute("aria-hidden","true"),a(s,'aria-hidden="true" (decorative svg)',"minor",r)),r.getAttribute("focusable")||r.setAttribute("focusable","false")),s==="iframe"&&!r.getAttribute("title")&&!r.getAttribute("aria-label")&&(r.setAttribute("title","embedded content"),r.setAttribute("aria-label","embedded content"),a(s,"title + aria-label added","serious",r)),s==="button"){if(!r.innerText?.trim()&&!r.getAttribute("aria-label")){let c=r.getAttribute("title")||"button";r.setAttribute("aria-label",c),a(s,`aria-label="${c}" (empty button)`,"critical",r)}r.hasAttribute("disabled")&&!r.getAttribute("aria-disabled")&&(r.setAttribute("aria-disabled","true"),t.fixed++)}if(s==="a"){let c=r;!r.innerText?.trim()&&!r.getAttribute("aria-label")&&(r.setAttribute("aria-label",r.getAttribute("title")||"link"),a(s,"aria-label added (empty link)","critical",r)),c.target==="_blank"&&!c.rel?.includes("noopener")&&(c.rel="noopener noreferrer",t.fixed++)}if(J.has(s)){let c=r;if(!r.getAttribute("aria-label")&&!r.getAttribute("aria-labelledby")){let p=r.getAttribute("placeholder")||r.getAttribute("name")||s;r.setAttribute("aria-label",p),a(s,`aria-label="${p}"`,"serious",r)}if(r.hasAttribute("required")&&!r.getAttribute("aria-required")&&(r.setAttribute("aria-required","true"),t.fixed++),s==="input"&&!c.autocomplete){let p=c.name||"";c.type==="email"||p.includes("email")?c.autocomplete="email":c.type==="tel"||p.includes("tel")?c.autocomplete="tel":c.type==="password"&&(c.autocomplete="current-password"),t.fixed++}}s==="th"&&!r.getAttribute("scope")&&(r.setAttribute("scope",r.closest("thead")?"col":"row"),a(s,"scope added to <th>","moderate",r)),z[s]&&!r.getAttribute("role")&&(r.setAttribute("role",z[s]),a(s,`role="${z[s]}"`,"minor",r));let d=r.getAttribute("role")||"";d==="tab"&&!r.getAttribute("aria-selected")&&(r.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(d)&&!r.getAttribute("aria-live")&&(r.setAttribute("aria-live",d==="alert"?"assertive":"polite"),a(s,`aria-live added on role=${d}`,"moderate",r)),d==="combobox"&&!r.getAttribute("aria-expanded")&&(r.setAttribute("aria-expanded","false"),a(s,'aria-expanded="false" on combobox',"serious",r)),(d==="checkbox"||d==="radio")&&!r.getAttribute("aria-checked")&&(r.setAttribute("aria-checked","false"),a(s,`aria-checked="false" on role=${d}`,"serious",r))}),t.renderTime=parseFloat((performance.now()-i).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),i=document.querySelectorAll("*");e.scanned=i.length;let n=(a,o,r,s)=>e.details.push({tag:a,fix:o,severity:r,element:s.outerHTML.slice(0,100)});return i.forEach(a=>{let o=a,r=o.tagName.toLowerCase();(r==="a"||r==="button")&&!o.innerText?.trim()&&!o.getAttribute("aria-label")&&n(r,"needs aria-label (empty)","critical",o),r==="img"&&!o.hasAttribute("alt")&&n(r,"needs alt text","serious",o),J.has(r)&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")&&n(r,"needs aria-label","serious",o),r==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&n(r,"iframe needs title","serious",o)}),e.fixed=e.details.length,e.score=ie(e),e.renderTime=parseFloat((performance.now()-t).toFixed(2)),e},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer?.disconnect(),this.observer=null},announce:l,speak:O,showVisualAlert:re,trapFocus:E,handlePlainEnglish:X,handleSummarisePage:Q,handleTranslate:Z,handleVoiceControl:ee,handleSmartLabels:te,SUPPORTED_LANGUAGES:F};return ue(Re);})();