@yuktishaalaa/yuktai 5.3.2 → 5.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as Yi,E as Kr,Ea as Ki,F as Qr,Fa as Qi,G as Jr,Ga as Ji,H as Zr,Ha as Zi,I as Xr,Ia as Xi,J as ei,Ja as es,K as ti,Ka as ts,L as ni,La as ns,M as oi,Ma as os,N as ri,Na as rs,O as ii,Oa as is,P as si,Pa as ss,Q as ai,Qa as as,R as li,Ra as ls,S as ci,Sa as cs,T as ui,U as di,V as pi,W as gi,X as fi,Y as mi,Z as bi,_ as hi,a as We,aa as xi,b as Je,ba as wi,c as Ae,ca as ki,d as _,da as vi,e as qe,ea as Si,f as pe,fa as Ti,g as Ne,ga as Ai,h as Ie,ha as Ci,i as ln,ia as Ri,j as Mr,ja as Ii,k as cn,ka as $i,l as to,la as Ei,m as no,ma as Gi,n as ht,na as Fi,o as oo,oa as Li,p as Gt,pa as Pi,q as Nr,qa as Mi,r as zr,ra as Ni,s as Dr,sa as zi,t as Or,ta as Di,u as Wr,ua as Oi,va as Wi,w as Br,wa as Bi,x as Hr,xa as Hi,y as qr,ya as qi,z as _r,za as _i}from"./chunk-LV252EOY.mjs";import{a as Xn}from"./chunk-3VGU4YGK.mjs";import{a as eo,b as $t,c as Et}from"./chunk-XQMQZMAH.mjs";function ro(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function un(){try{let e=ro();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 us(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=ro();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"}),o=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:o.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function io(){if(!await un())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 o of t){let r=o.innerText?.trim();if(!r||r.length<20||o.closest("[data-yuktai-panel]"))continue;let s=await us(r);s.success&&s.rewritten!==r&&(o.dataset.yuktaiOriginal=r,o.innerText=s.rewritten,n++)}return{fixed:n}}function so(){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)}}var ao="yuktai-summary-box";function lo(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function dn(){try{let e=lo();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 ds(){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 o=window.getComputedStyle(n);if(o.display==="none"||o.visibility==="hidden")continue;let r=n.innerText?.trim();r&&r.length>10&&t.push(r)}return t.join(" ").slice(0,5e3)}async function co(){if(!await dn())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=ds();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let n=lo();if(!n)throw new Error("Summarizer API not available");let o=await n.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),r=await o.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 o.destroy(),ps(r.trim()),{success:!0,summary:r.trim()}}catch(n){return{success:!1,summary:"",error:n instanceof Error?n.message:"Summary failed"}}}function ps(e){Ft();let t=document.createElement("div");t.id=ao,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
1
+ import{$ as yi,$a as ya,$b as ys,A as Ur,Aa as Ui,Ab as Ua,B as jr,Ba as ji,Bb as ja,C as Vr,Ca as Vi,Cb as Va,D as Yr,Da as Yi,Db as Ya,E as Kr,Ea as Ki,Eb as Ka,F as Qr,Fa as Qi,Fb as Qa,G as Jr,Ga as Ji,Gb as Ja,H as Zr,Ha as Zi,Hb as Za,I as Xr,Ia as Xi,Ib as Xa,J as ei,Ja as ea,Jb as es,K as ti,Ka as ta,Kb as ts,L as ni,La as na,Lb as ns,M as oi,Ma as oa,Mb as os,N as ri,Na as ra,Nb as rs,O as ii,Oa as ia,Ob as is,P as ai,Pa as aa,Pb as as,Q as si,Qa as sa,Qb as ss,R as li,Ra as la,Rb as ls,S as ci,Sa as ca,Sb as cs,T as ui,Ta as ua,Tb as us,U as di,Ua as da,Ub as ds,V as pi,Va as pa,Vb as ps,W as gi,Wa as ga,Wb as gs,X as fi,Xa as fa,Xb as fs,Y as mi,Ya as ma,Yb as ms,Z as bi,Za as ba,Zb as bs,_ as hi,_a as ha,_b as hs,a as We,aa as xi,ab as xa,ac as xs,b as Je,ba as wi,bb as wa,bc as ws,c as Ae,ca as ki,cb as ka,cc as ks,d as _,da as vi,db as va,dc as vs,e as qe,ea as Si,eb as Sa,ec as Ss,f as pe,fa as Ti,fb as Ta,fc as Ts,g as Ne,ga as Ai,gb as Aa,gc as As,h as Ie,ha as Ci,hb as Ca,hc as Cs,i as ln,ia as Ri,ib as Ra,ic as Rs,j as Mr,ja as Ii,jb as Ia,jc as Is,k as cn,ka as $i,kb as $a,kc as $s,l as to,la as Ei,lb as Ea,lc as Es,m as no,ma as Fi,mb as Fa,mc as Fs,n as ht,na as Gi,nb as Ga,nc as Gs,o as oo,oa as Li,ob as La,oc as Ls,p as Ft,pa as Pi,pb as Pa,pc as Ps,q as Nr,qa as Mi,qb as Ma,qc as Ms,r as zr,ra as Ni,rb as Na,rc as Ns,s as Dr,sa as zi,sb as za,sc as zs,t as Or,ta as Di,tb as Da,tc as Ds,u as Wr,ua as Oi,ub as Oa,uc as Os,va as Wi,vb as Wa,vc as Ws,w as Br,wa as Bi,wb as Ba,wc as Bs,x as Hr,xa as Hi,xb as Ha,xc as Hs,y as qr,ya as qi,yb as qa,yc as qs,z as _r,za as _i,zb as _a,zc as _s}from"./chunk-7BGINZ5U.mjs";import{a as Xn}from"./chunk-3VGU4YGK.mjs";import{a as eo,b as $t,c as Et}from"./chunk-XQMQZMAH.mjs";function ro(){let e=window;return e.Rewriter||e.ai?.rewriter||null}async function un(){try{let e=ro();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 Us(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=ro();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"}),o=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:o.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function io(){if(!await un())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 o of t){let r=o.innerText?.trim();if(!r||r.length<20||o.closest("[data-yuktai-panel]"))continue;let a=await Us(r);a.success&&a.rewritten!==r&&(o.dataset.yuktaiOriginal=r,o.innerText=a.rewritten,n++)}return{fixed:n}}function ao(){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)}}var so="yuktai-summary-box";function lo(){let e=window;return e.Summarizer||e.ai?.summarizer||null}async function dn(){try{let e=lo();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 js(){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 o=window.getComputedStyle(n);if(o.display==="none"||o.visibility==="hidden")continue;let r=n.innerText?.trim();r&&r.length>10&&t.push(r)}return t.join(" ").slice(0,5e3)}async function co(){if(!await dn())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=js();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let n=lo();if(!n)throw new Error("Summarizer API not available");let o=await n.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),r=await o.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 o.destroy(),Vs(r.trim()),{success:!0,summary:r.trim()}}catch(n){return{success:!1,summary:"",error:n instanceof Error?n.message:"Summary failed"}}}function Vs(e){Gt();let t=document.createElement("div");t.id=so,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -19,7 +19,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
19
19
  background: none; border: none; color: #ffffff;
20
20
  font-size: 20px; cursor: pointer; padding: 0 4px;
21
21
  line-height: 1; flex-shrink: 0;
22
- `,o.addEventListener("click",Ft),t.appendChild(n),t.appendChild(o),document.body.prepend(t)}function Ft(){let e=document.getElementById(ao);e&&e.remove()}var Pt=[{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"}],Lt="en";function gs(){let e=window;return e.Translator||e.translation||null}async function fs(e){try{let t=window;if(!gs())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let o=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return o==="readily"||o==="available"||o==="downloadable"||o==="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 ms(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 uo(e){if(e===Lt)return{success:!0,language:e,fixed:0};if(e==="en")return pn(),Lt="en",{success:!0,language:"en",fixed:0};if(!await fs(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let n=await ms(e),o=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),r=0;for(let s of o){if(s.closest("[data-yuktai-panel]")||s.children.length>0)continue;let i=s.innerText?.trim();if(!i||i.length<2)continue;s.dataset.yuktaiTranslationOriginal||(s.dataset.yuktaiTranslationOriginal=i);let a=await n.translate(i);a&&a!==i&&(s.innerText=a,r++)}return typeof n.destroy=="function"&&n.destroy(),Lt=e,{success:!0,language:e,fixed:r}}catch(n){return{success:!1,language:e,fixed:0,error:n instanceof Error?n.message:"Translation failed"}}}function pn(){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)}Lt="en"}var bs=[{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"}],Ce=null,Mt=!1,it=null;function gn(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function hs(e){let t=e.toLowerCase().trim();for(let n of bs)for(let o of n.phrases)if(t.includes(o))return{action:n.action,label:n.label};return null}function ys(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=po(),n=t.indexOf(document.activeElement),o=t[n+1]||t[0];o&&o.focus();break}case"tab-back":{let t=po(),n=t.indexOf(document.activeElement),o=t[n-1]||t[t.length-1];o&&o.focus();break}case"stop-voice":{fn();break}}}function po(){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 go(e){if(!gn())return!1;if(Mt)return!0;e&&(it=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return Ce=new t,Ce.continuous=!0,Ce.interimResults=!1,Ce.lang="en-US",Ce.onresult=n=>{let o=n.results[n.results.length-1][0].transcript,r=hs(o);if(r){ys(r.action);let s={success:!0,command:o,action:r.label};if(it&&it(s),r.action==="stop-voice")return}},Ce.onend=()=>{Mt&&Ce?.start()},Ce.onerror=n=>{n.error!=="no-speech"&&it&&it({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},Ce.start(),Mt=!0,xs(),!0}function fn(){Mt=!1,Ce&&(Ce.stop(),Ce=null),it=null,mo()}var fo="yuktai-voice-indicator";function xs(){mo();let e=document.createElement("div");e.id=fo,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
22
+ `,o.addEventListener("click",Gt),t.appendChild(n),t.appendChild(o),document.body.prepend(t)}function Gt(){let e=document.getElementById(so);e&&e.remove()}var Pt=[{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"}],Lt="en";function Ys(){let e=window;return e.Translator||e.translation||null}async function Ks(e){try{let t=window;if(!Ys())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let o=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return o==="readily"||o==="available"||o==="downloadable"||o==="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 Qs(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 uo(e){if(e===Lt)return{success:!0,language:e,fixed:0};if(e==="en")return pn(),Lt="en",{success:!0,language:"en",fixed:0};if(!await Ks(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let n=await Qs(e),o=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),r=0;for(let a of o){if(a.closest("[data-yuktai-panel]")||a.children.length>0)continue;let i=a.innerText?.trim();if(!i||i.length<2)continue;a.dataset.yuktaiTranslationOriginal||(a.dataset.yuktaiTranslationOriginal=i);let s=await n.translate(i);s&&s!==i&&(a.innerText=s,r++)}return typeof n.destroy=="function"&&n.destroy(),Lt=e,{success:!0,language:e,fixed:r}}catch(n){return{success:!1,language:e,fixed:0,error:n instanceof Error?n.message:"Translation failed"}}}function pn(){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)}Lt="en"}var Js=[{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"}],Ce=null,Mt=!1,it=null;function gn(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function Zs(e){let t=e.toLowerCase().trim();for(let n of Js)for(let o of n.phrases)if(t.includes(o))return{action:n.action,label:n.label};return null}function Xs(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=po(),n=t.indexOf(document.activeElement),o=t[n+1]||t[0];o&&o.focus();break}case"tab-back":{let t=po(),n=t.indexOf(document.activeElement),o=t[n-1]||t[t.length-1];o&&o.focus();break}case"stop-voice":{fn();break}}}function po(){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 go(e){if(!gn())return!1;if(Mt)return!0;e&&(it=e);let t=window.SpeechRecognition||window.webkitSpeechRecognition;return Ce=new t,Ce.continuous=!0,Ce.interimResults=!1,Ce.lang="en-US",Ce.onresult=n=>{let o=n.results[n.results.length-1][0].transcript,r=Zs(o);if(r){Xs(r.action);let a={success:!0,command:o,action:r.label};if(it&&it(a),r.action==="stop-voice")return}},Ce.onend=()=>{Mt&&Ce?.start()},Ce.onerror=n=>{n.error!=="no-speech"&&it&&it({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},Ce.start(),Mt=!0,el(),!0}function fn(){Mt=!1,Ce&&(Ce.stop(),Ce=null),it=null,mo()}var fo="yuktai-voice-indicator";function el(){mo();let e=document.createElement("div");e.id=fo,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
23
23
  position: fixed;
24
24
  bottom: 80px;
25
25
  left: 50%;
@@ -49,7 +49,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
49
49
  0%, 100% { opacity: 1; transform: scale(1); }
50
50
  50% { opacity: 0.4; transform: scale(0.7); }
51
51
  }
52
- `,document.head.appendChild(o)}let n=document.createElement("span");n.textContent="Listening for commands...",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}function mo(){let e=document.getElementById(fo);e&&e.remove()}var ws=["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 bo(){let e=window;return e.Writer||e.ai?.writer||null}async function mn(){try{let e=bo();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 ks(e){let t=[],n=e.innerText?.trim();n&&t.push(`element text: "${n}"`);let o=e.placeholder?.trim();o&&t.push(`placeholder: "${o}"`);let r=e.getAttribute("name")?.trim();r&&t.push(`name: "${r}"`);let s=e.getAttribute("type")?.trim();s&&t.push(`type: "${s}"`);let i=e.id;if(i){let c=document.querySelector(`label[for="${i}"]`);c&&t.push(`label: "${c.innerText?.trim()}"`)}let a=e.parentElement?.innerText?.trim().slice(0,60);a&&t.push(`parent context: "${a}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let l=e.getAttribute("role");return l&&t.push(`role: ${l}`),t.join(". ")}async function vs(e,t){let n=`
52
+ `,document.head.appendChild(o)}let n=document.createElement("span");n.textContent="Listening for commands...",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}function mo(){let e=document.getElementById(fo);e&&e.remove()}var tl=["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 bo(){let e=window;return e.Writer||e.ai?.writer||null}async function mn(){try{let e=bo();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 nl(e){let t=[],n=e.innerText?.trim();n&&t.push(`element text: "${n}"`);let o=e.placeholder?.trim();o&&t.push(`placeholder: "${o}"`);let r=e.getAttribute("name")?.trim();r&&t.push(`name: "${r}"`);let a=e.getAttribute("type")?.trim();a&&t.push(`type: "${a}"`);let i=e.id;if(i){let c=document.querySelector(`label[for="${i}"]`);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 l=e.getAttribute("role");return l&&t.push(`role: ${l}`),t.join(". ")}async function ol(e,t){let n=`
53
53
  Generate a short, clear aria-label for an HTML element.
54
54
  The label must be 2-6 words maximum.
55
55
  The label must describe what the element does or what it is.
@@ -60,7 +60,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
60
60
  ${t}
61
61
 
62
62
  Output only the label. Nothing else.
63
- `.trim();return(await e.write(n)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function ho(){if(!await mn())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(ws);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let n=bo();if(!n)throw new Error("Writer API not available");let o=await n.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),r=0,s=[];for(let i of t){if(i.closest("[data-yuktai-panel]"))continue;let a=window.getComputedStyle(i);if(a.display==="none"||a.visibility==="hidden")continue;let l=ks(i),c=await vs(o,l);c&&c.length>0&&(i.dataset.yuktaiLabelOriginal=i.getAttribute("aria-label")||"",i.setAttribute("aria-label",c),r++,s.push({tag:i.tagName.toLowerCase(),label:c}))}return o.destroy(),{success:!0,fixed:r,elements:s}}catch(n){return{success:!1,fixed:0,elements:[],error:n instanceof Error?n.message:"Label generation failed"}}}function yo(){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 Dt=null,xo=null;var wo=null,bn=null,le=null,st=null,Nt=null,hn=null,at=null,zt={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var ko=new Set(["input","select","textarea"]);var yn={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function xn(e,t="polite"){if(typeof window>"u"||!at?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.rate=1,n.pitch=1,n.volume=1;let o=window.speechSynthesis.getVoices();o.length>0&&(n.voice=o[0]),window.speechSynthesis.speak(n)}function $o(e,t="info"){if(typeof document>"u")return;let o={success:{bg:"#0a7a44",border:"#075e34",icon:"\u2713"},error:{bg:"#b52a1c",border:"#8f2116",icon:"\u2715"},warning:{bg:"#a35f00",border:"#7a4700",icon:"\u26A0"},info:{bg:"#005A9C",border:"#003F6E",icon:"\u2139"}}[t];le||(le=document.createElement("div"),le.setAttribute("role","alert"),le.setAttribute("aria-live","assertive"),le.setAttribute("aria-atomic","true"),le.style.cssText=`
63
+ `.trim();return(await e.write(n)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function ho(){if(!await mn())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(tl);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let n=bo();if(!n)throw new Error("Writer API not available");let o=await n.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),r=0,a=[];for(let i of t){if(i.closest("[data-yuktai-panel]"))continue;let s=window.getComputedStyle(i);if(s.display==="none"||s.visibility==="hidden")continue;let l=nl(i),c=await ol(o,l);c&&c.length>0&&(i.dataset.yuktaiLabelOriginal=i.getAttribute("aria-label")||"",i.setAttribute("aria-label",c),r++,a.push({tag:i.tagName.toLowerCase(),label:c}))}return o.destroy(),{success:!0,fixed:r,elements:a}}catch(n){return{success:!1,fixed:0,elements:[],error:n instanceof Error?n.message:"Label generation failed"}}}function yo(){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 Dt=null,xo=null;var wo=null,bn=null,le=null,at=null,Nt=null,hn=null,st=null,zt={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var ko=new Set(["input","select","textarea"]);var yn={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function xn(e,t="polite"){if(typeof window>"u"||!st?.speechEnabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.rate=1,n.pitch=1,n.volume=1;let o=window.speechSynthesis.getVoices();o.length>0&&(n.voice=o[0]),window.speechSynthesis.speak(n)}function $o(e,t="info"){if(typeof document>"u")return;let o={success:{bg:"#0a7a44",border:"#075e34",icon:"\u2713"},error:{bg:"#b52a1c",border:"#8f2116",icon:"\u2715"},warning:{bg:"#a35f00",border:"#7a4700",icon:"\u26A0"},info:{bg:"#005A9C",border:"#003F6E",icon:"\u2139"}}[t];le||(le=document.createElement("div"),le.setAttribute("role","alert"),le.setAttribute("aria-live","assertive"),le.setAttribute("aria-atomic","true"),le.style.cssText=`
64
64
  position: fixed;
65
65
  top: 80px;
66
66
  right: 16px;
@@ -86,7 +86,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
86
86
  onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
87
87
  style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
88
88
  aria-label="Close notification">\xD7</button>
89
- `,window.innerWidth<=480&&(le.style.right="8px",le.style.left="8px",le.style.maxWidth="none",le.style.width="auto"),requestAnimationFrame(()=>{le&&(le.style.transform="translateX(0)",le.style.opacity="1")}),setTimeout(()=>{le&&(le.style.transform="translateX(120%)",le.style.opacity="0")},5e3)}function X(e,t="info",n=!0){Dt&&(Dt.textContent=e),$o(e,t),n&&xn(e,t==="error"?"assertive":"polite")}function Ss(){if(typeof document>"u"||wo)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
89
+ `,window.innerWidth<=480&&(le.style.right="8px",le.style.left="8px",le.style.maxWidth="none",le.style.width="auto"),requestAnimationFrame(()=>{le&&(le.style.transform="translateX(0)",le.style.opacity="1")}),setTimeout(()=>{le&&(le.style.transform="translateX(120%)",le.style.opacity="0")},5e3)}function X(e,t="info",n=!0){Dt&&(Dt.textContent=e),$o(e,t),n&&xn(e,t==="error"?"assertive":"polite")}function rl(){if(typeof document>"u"||wo)return;let e=[{label:"Skip to main content",selector:"main,[role='main'],#main,#main-content"},{label:"Skip to navigation",selector:"nav,[role='navigation'],#nav,#navigation"},{label:"Skip to search",selector:"[role='search'],#search,input[type='search']"}],t=document.createElement("div");t.setAttribute("data-yuktai-skip-bar","true"),t.setAttribute("role","navigation"),t.setAttribute("aria-label","Skip links"),t.style.cssText=`
90
90
  position: fixed;
91
91
  top: 0;
92
92
  left: 0;
@@ -100,7 +100,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
100
100
  transform: translateY(-100%);
101
101
  transition: transform 0.2s ease;
102
102
  font-family: system-ui, sans-serif;
103
- `;let n=!1;if(e.forEach(({label:r,selector:s})=>{let i=document.querySelector(s);if(!i)return;n=!0,i.getAttribute("tabindex")||i.setAttribute("tabindex","-1");let a=document.createElement("a");a.href="#",a.textContent=r,a.style.cssText=`
103
+ `;let n=!1;if(e.forEach(({label:r,selector:a})=>{let i=document.querySelector(a);if(!i)return;n=!0,i.getAttribute("tabindex")||i.setAttribute("tabindex","-1");let s=document.createElement("a");s.href="#",s.textContent=r,s.style.cssText=`
104
104
  color: #fff;
105
105
  background: #005A9C;
106
106
  padding: 8px 14px;
@@ -111,7 +111,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
111
111
  white-space: nowrap;
112
112
  border: 2px solid transparent;
113
113
  transition: background 0.15s, border-color 0.15s;
114
- `,a.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),a.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),a.addEventListener("click",l=>{l.preventDefault(),i.focus(),i.scrollIntoView({behavior:"smooth",block:"start"}),X(`Jumped to ${r.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(a)}),!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),wo=t}function Ts(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
114
+ `,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",l=>{l.preventDefault(),i.focus(),i.scrollIntoView({behavior:"smooth",block:"start"}),X(`Jumped to ${r.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(s)}),!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),wo=t}function il(){if(typeof document>"u"||document.querySelector("[data-yuktai-focus-style]"))return;let e=document.createElement("style");e.setAttribute("data-yuktai-focus-style","true"),e.textContent=`
115
115
 
116
116
  /* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
117
117
  [data-yuktai-a11y] *:focus-visible {
@@ -257,7 +257,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
257
257
  width: auto !important;
258
258
  }
259
259
  }
260
- `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function As(){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 o=t.closest("[role='dialog'],[role='alertdialog']");if(o){o.style.display="none",X("Dialog closed","info");return}let r=t.closest("[role='menu'],[role='menubar']");r&&(r.style.display="none",X("Menu closed","info"))}if(n==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let o=t.closest("[role='menu'],[role='menubar']");if(!o)return;let r=Array.from(o.querySelectorAll("[role='menuitem']:not([disabled])")),s=r.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),r[(s+1)%r.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),r[(s-1+r.length)%r.length]?.focus()):e.key==="Home"?(e.preventDefault(),r[0]?.focus()):e.key==="End"&&(e.preventDefault(),r[r.length-1]?.focus())}if(n==="tab"||t.closest("[role='tablist']")){let o=t.closest("[role='tablist']");if(!o)return;let r=Array.from(o.querySelectorAll("[role='tab']:not([disabled])")),s=r.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let i=r[(s+1)%r.length];i?.focus(),i?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let i=r[(s-1+r.length)%r.length];i?.focus(),i?.click()}}if(n==="option"||t.closest("[role='listbox']")){let o=t.closest("[role='listbox']");if(!o)return;let r=Array.from(o.querySelectorAll("[role='option']:not([aria-disabled='true'])")),s=r.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),r[(s+1)%r.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),r[(s-1+r.length)%r.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),r.forEach(i=>{i!==t&&i.setAttribute("aria-selected","false")}),X(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Cs()),e.key==="Tab"&&at?.speechEnabled&&setTimeout(()=>{let o=document.activeElement;if(!o)return;let r=o.getAttribute("aria-label")||o.getAttribute("title")||o.textContent?.trim()||o.tagName.toLowerCase(),s=o.getAttribute("role")||o.tagName.toLowerCase();xn(`${r}, ${s}`)},100)}))}function Ot(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],o=t[t.length-1];n.focus(),e.addEventListener("keydown",r=>{r.key==="Tab"&&(r.shiftKey?document.activeElement===n&&(r.preventDefault(),o.focus()):document.activeElement===o&&(r.preventDefault(),n.focus()))})}function Cs(){if(typeof document>"u")return;if(st){st.remove(),st=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
260
+ `,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function al(){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 o=t.closest("[role='dialog'],[role='alertdialog']");if(o){o.style.display="none",X("Dialog closed","info");return}let r=t.closest("[role='menu'],[role='menubar']");r&&(r.style.display="none",X("Menu closed","info"))}if(n==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let o=t.closest("[role='menu'],[role='menubar']");if(!o)return;let r=Array.from(o.querySelectorAll("[role='menuitem']:not([disabled])")),a=r.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),r[(a+1)%r.length]?.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),r[(a-1+r.length)%r.length]?.focus()):e.key==="Home"?(e.preventDefault(),r[0]?.focus()):e.key==="End"&&(e.preventDefault(),r[r.length-1]?.focus())}if(n==="tab"||t.closest("[role='tablist']")){let o=t.closest("[role='tablist']");if(!o)return;let r=Array.from(o.querySelectorAll("[role='tab']:not([disabled])")),a=r.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let i=r[(a+1)%r.length];i?.focus(),i?.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let i=r[(a-1+r.length)%r.length];i?.focus(),i?.click()}}if(n==="option"||t.closest("[role='listbox']")){let o=t.closest("[role='listbox']");if(!o)return;let r=Array.from(o.querySelectorAll("[role='option']:not([aria-disabled='true'])")),a=r.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),r[(a+1)%r.length]?.focus()):e.key==="ArrowUp"?(e.preventDefault(),r[(a-1+r.length)%r.length]?.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),r.forEach(i=>{i!==t&&i.setAttribute("aria-selected","false")}),X(`Selected: ${t.textContent?.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),sl()),e.key==="Tab"&&st?.speechEnabled&&setTimeout(()=>{let o=document.activeElement;if(!o)return;let r=o.getAttribute("aria-label")||o.getAttribute("title")||o.textContent?.trim()||o.tagName.toLowerCase(),a=o.getAttribute("role")||o.tagName.toLowerCase();xn(`${r}, ${a}`)},100)}))}function Ot(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],o=t[t.length-1];n.focus(),e.addEventListener("keydown",r=>{r.key==="Tab"&&(r.shiftKey?document.activeElement===n&&(r.preventDefault(),o.focus()):document.activeElement===o&&(r.preventDefault(),n.focus()))})}function sl(){if(typeof document>"u")return;if(at){at.remove(),at=null;return}let e=document.createElement("div");e.setAttribute("role","dialog"),e.setAttribute("aria-label","Keyboard shortcuts"),e.setAttribute("aria-modal","true"),e.setAttribute("data-yuktai-cheatsheet","true"),e.style.cssText=`
261
261
  position: fixed;
262
262
  top: 50%;
263
263
  left: 50%;
@@ -287,7 +287,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
287
287
  <span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${r}</span>
288
288
  </div>
289
289
  `).join("")}
290
- `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),st=null}),e.addEventListener("keydown",o=>{o.key==="Escape"&&(e.remove(),st=null)}),document.body.appendChild(e),st=e,Ot(e),X("Keyboard shortcuts opened. Press Escape to close.","info")}function Rs(e){if(typeof document>"u"||!at?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;bn&&bn.remove();let t=e.score,n=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",o=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",r=document.createElement("button");r.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),r.setAttribute("data-yuktai-badge","true"),r.style.cssText=`
290
+ `,e.querySelector("[data-yuktai-close]")?.addEventListener("click",()=>{e.remove(),at=null}),e.addEventListener("keydown",o=>{o.key==="Escape"&&(e.remove(),at=null)}),document.body.appendChild(e),at=e,Ot(e),X("Keyboard shortcuts opened. Press Escape to close.","info")}function ll(e){if(typeof document>"u"||!st?.showAuditBadge||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;bn&&bn.remove();let t=e.score,n=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",o=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",r=document.createElement("button");r.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),r.setAttribute("data-yuktai-badge","true"),r.style.cssText=`
291
291
  position: fixed;
292
292
  bottom: 16px;
293
293
  left: 16px;
@@ -306,7 +306,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
306
306
  align-items: center;
307
307
  gap: 6px;
308
308
  transition: transform 0.15s;
309
- `,r.innerHTML=`${o} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,r.addEventListener("click",()=>Is(e)),document.body.appendChild(r),bn=r}function Is(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=`
309
+ `,r.innerHTML=`${o} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,r.addEventListener("click",()=>cl(e)),document.body.appendChild(r),bn=r}function cl(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=`
310
310
  position: fixed;
311
311
  bottom: 56px;
312
312
  left: 16px;
@@ -367,7 +367,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
367
367
  No, sign out
368
368
  </button>
369
369
  </div>
370
- `;let n=t.querySelector("[data-yuktai-extend]"),o=t.querySelector("[data-yuktai-dismiss]");n?.addEventListener("click",()=>{t.remove(),Nt=null,X("Session extended. You have more time.","success"),at?.timeoutWarning&&Eo(at.timeoutWarning)}),o?.addEventListener("click",()=>{t.remove(),Nt=null}),document.body.appendChild(t),Nt=t,Ot(t),X("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function $s(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(#${zt[e.colorBlindMode]})`;document.body.style.filter=n}else document.body.style.filter=""}function Es(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function vo(e){if(e){if(!await un()){X("Plain English requires Chrome 127+","warning");return}X("Rewriting page in plain English...","info",!1);let n=await io();X(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else so(),X("Original text restored","info",!1)}async function So(e){if(e){if(!await dn()){X("Page summariser requires Chrome 127+","warning");return}X("Generating page summary...","info",!1);let n=await co();X(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else Ft(),X("Page summary removed","info",!1)}async function To(e){if(e==="en"){pn(),X("Page restored to English","info",!1);return}X(`Translating page to ${e}...`,"info",!1);let t=await uo(e);X(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Ao(e){if(e){if(!gn()){X("Voice control not supported in this browser","warning");return}go(t=>{t.success&&X(`Voice: ${t.action}`,"info",!1)}),X("Voice control started. Say a command.","success",!1)}else fn(),X("Voice control stopped","info",!1)}async function Co(e){if(e){if(!await mn()){X("Smart labels requires Chrome 127+","warning");return}X("Generating smart labels...","info",!1);let n=await ho();X(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else yo(),X("Smart labels removed","info",!1)}function Gs(){if(typeof document>"u"||Dt)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),Dt=e}function Fs(){if(typeof document>"u"||xo)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
370
+ `;let n=t.querySelector("[data-yuktai-extend]"),o=t.querySelector("[data-yuktai-dismiss]");n?.addEventListener("click",()=>{t.remove(),Nt=null,X("Session extended. You have more time.","success"),st?.timeoutWarning&&Eo(st.timeoutWarning)}),o?.addEventListener("click",()=>{t.remove(),Nt=null}),document.body.appendChild(t),Nt=t,Ot(t),X("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function ul(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(#${zt[e.colorBlindMode]})`;document.body.style.filter=n}else document.body.style.filter=""}function dl(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function vo(e){if(e){if(!await un()){X("Plain English requires Chrome 127+","warning");return}X("Rewriting page in plain English...","info",!1);let n=await io();X(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else ao(),X("Original text restored","info",!1)}async function So(e){if(e){if(!await dn()){X("Page summariser requires Chrome 127+","warning");return}X("Generating page summary...","info",!1);let n=await co();X(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else Gt(),X("Page summary removed","info",!1)}async function To(e){if(e==="en"){pn(),X("Page restored to English","info",!1);return}X(`Translating page to ${e}...`,"info",!1);let t=await uo(e);X(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function Ao(e){if(e){if(!gn()){X("Voice control not supported in this browser","warning");return}go(t=>{t.success&&X(`Voice: ${t.action}`,"info",!1)}),X("Voice control started. Say a command.","success",!1)}else fn(),X("Voice control stopped","info",!1)}async function Co(e){if(e){if(!await mn()){X("Smart labels requires Chrome 127+","warning");return}X("Generating smart labels...","info",!1);let n=await ho();X(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else yo(),X("Smart labels removed","info",!1)}function pl(){if(typeof document>"u"||Dt)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),Dt=e}function gl(){if(typeof document>"u"||xo)return;let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",e.innerHTML=`
371
371
  <defs>
372
372
  <filter id="${zt.deuteranopia}">
373
373
  <feColorMatrix type="matrix"
@@ -382,7 +382,7 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
382
382
  values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
383
383
  </filter>
384
384
  </defs>
385
- `,document.body.appendChild(e),xo=e}function Ro(e){return e.getAttribute("aria-label")?.trim()||e.getAttribute("aria-labelledby")||e.getAttribute("title")?.trim()||e.textContent?.trim()?!0:!!e.querySelector("img[alt]:not([alt='']), svg[aria-label], svg title, [aria-label]")}function Io(e){let t={critical:20,serious:10,moderate:5,minor:2},n=e.details.reduce((o,r)=>o+(t[r.severity]||0),0);return Math.max(0,Math.min(100,100-n))}var ke={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";at=e,Es(e),Gs(),Fs(),Ts(),As(),e.showSkipLinks!==!1&&Ss(),e.showPreferencePanel,$s(e);let t=this.applyFixes(e);t.score=Io(t),e.showAuditBadge&&Rs(t),e.timeoutWarning&&Eo(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await vo(!0),e.summarisePage&&await So(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await To(e.translateLanguage),e.voiceControl&&await Ao(!0),e.smartLabels&&await Co(!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(),o=document.querySelectorAll("*");t.scanned=o.length;let r=(s,i,a,l)=>{t.details.push({tag:s,fix:i,severity:a,element:l.outerHTML.slice(0,100)}),t.fixed++};return o.forEach(s=>{let i=s,a=i.tagName.toLowerCase();if(a==="html"&&!i.getAttribute("lang")&&(i.setAttribute("lang","en"),r(a,'lang="en" added',"critical",i)),a==="meta"){let u=i.getAttribute("name"),b=i.getAttribute("content")||"";u==="viewport"&&b.includes("user-scalable=no")&&(i.setAttribute("content",b.replace("user-scalable=no","user-scalable=yes")),r(a,"user-scalable=yes restored","serious",i)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(b)&&(i.setAttribute("content",b.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),r(a,"maximum-scale=5 restored","serious",i))}if(a==="main"&&!i.getAttribute("tabindex")&&(i.setAttribute("tabindex","-1"),i.getAttribute("id")||i.setAttribute("id","main-content")),a==="img"&&(i.hasAttribute("alt")||(i.setAttribute("alt",""),i.setAttribute("aria-hidden","true"),r(a,'alt="" aria-hidden="true"',"serious",i))),a==="svg"&&(!i.getAttribute("aria-hidden")&&!i.getAttribute("aria-label")&&!s.querySelector("title")&&(i.setAttribute("aria-hidden","true"),r(a,'aria-hidden="true" (decorative svg)',"minor",i)),i.getAttribute("focusable")||i.setAttribute("focusable","false")),a==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&(i.setAttribute("title","embedded content"),i.setAttribute("aria-label","embedded content"),r(a,"title + aria-label added","serious",i)),a==="button"){if(!Ro(i)){let u=i.getAttribute("title")||"button";i.setAttribute("aria-label",u),r(a,`aria-label="${u}" (empty button)`,"critical",i)}i.hasAttribute("disabled")&&!i.getAttribute("aria-disabled")&&(i.setAttribute("aria-disabled","true"),t.fixed++)}if(a==="a"){let u=i;Ro(i)||(i.setAttribute("aria-label",i.getAttribute("title")||"link"),r(a,"aria-label added (empty link)","critical",i)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(ko.has(a)){let u=i;if(!(!!(u.labels&&u.labels.length)||!!i.getAttribute("title")||u.type==="hidden"||u.type==="submit"||u.type==="button"||u.type==="reset")&&!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")){let p=i.getAttribute("placeholder")||i.getAttribute("name")||a;i.setAttribute("aria-label",p),r(a,`aria-label="${p}"`,"serious",i)}if(i.hasAttribute("required")&&!i.getAttribute("aria-required")&&(i.setAttribute("aria-required","true"),t.fixed++),a==="input"&&!u.autocomplete){let p=u.name||"",g=u.type==="email"||p.includes("email")?"email":u.type==="tel"||p.includes("tel")?"tel":u.type==="password"?"current-password":"";g&&(u.autocomplete=g,t.fixed++)}}a==="th"&&!i.getAttribute("scope")&&(i.setAttribute("scope",i.closest("thead")?"col":"row"),r(a,"scope added to <th>","moderate",i));let l=(a==="header"||a==="footer")&&!!i.parentElement?.closest("article,aside,main,nav,section,[role='dialog'],[role='region']");yn[a]&&!i.getAttribute("role")&&!l&&(i.setAttribute("role",yn[a]),r(a,`role="${yn[a]}"`,"minor",i));let c=i.getAttribute("role")||"";c==="tab"&&!i.getAttribute("aria-selected")&&(i.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(c)&&!i.getAttribute("aria-live")&&(i.setAttribute("aria-live",c==="alert"?"assertive":"polite"),r(a,`aria-live added on role=${c}`,"moderate",i)),c==="combobox"&&!i.getAttribute("aria-expanded")&&(i.setAttribute("aria-expanded","false"),r(a,'aria-expanded="false" on combobox',"serious",i)),(c==="checkbox"||c==="radio")&&!i.getAttribute("aria-checked")&&(i.setAttribute("aria-checked","false"),r(a,`aria-checked="false" on role=${c}`,"serious",i))}),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 o=(r,s,i,a)=>e.details.push({tag:r,fix:s,severity:i,element:a.outerHTML.slice(0,100)});return n.forEach(r=>{let s=r,i=s.tagName.toLowerCase();(i==="a"||i==="button")&&!s.innerText?.trim()&&!s.getAttribute("aria-label")&&o(i,"needs aria-label (empty)","critical",s),i==="img"&&!s.hasAttribute("alt")&&o(i,"needs alt text","serious",s),ko.has(i)&&!s.getAttribute("aria-label")&&!s.getAttribute("aria-labelledby")&&o(i,"needs aria-label","serious",s),i==="iframe"&&!s.getAttribute("title")&&!s.getAttribute("aria-label")&&o(i,"iframe needs title","serious",s)}),e.fixed=e.details.length,e.score=Io(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:xn,showVisualAlert:$o,trapFocus:Ot,handlePlainEnglish:vo,handleSummarisePage:So,handleTranslate:To,handleVoiceControl:Ao,handleSmartLabels:Co,SUPPORTED_LANGUAGES:Pt};import Xs,{useEffect as ut,useState as ce,useCallback as dt}from"react";import{forwardRef as Ls,useEffect as Wt,useState as Ze}from"react";import{jsx as R,jsxs as Q}from"react/jsx-runtime";var wn={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},lt=[80,90,100,110,120,130],Ps=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],Ms=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function Ns(){let[e,t]=Ze(typeof window<"u"?window.innerWidth:1024);return Wt(()=>{let n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function zs({checked:e,onChange:t,label:n,disabled:o=!1}){return Q("label",{"aria-label":n,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:o?"not-allowed":"pointer",flexShrink:0,opacity:o?.4:1},children:[R("input",{type:"checkbox",checked:e,disabled:o,onChange:r=>t(r.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),R("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),R("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function ct({label:e,color:t="#64748b",badge:n,concept:o}){return Q("div",{style:{margin:"10px 18px 4px"},children:[Q("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[R("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),n&&R("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:n})]}),o&&R("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8",fontStyle:"italic"},children:o})]})}function $e({icon:e,label:t,desc:n,checked:o,onChange:r,disabled:s=!1,disabledReason:i,tip:a}){return Q("div",{title:s?i:a,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[Q("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[R("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}),Q("div",{style:{minWidth:0},children:[R("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:s?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),R("p",{style:{margin:0,fontSize:"10px",color:"#94a3b8"},children:s?i:n})]})]}),R(zs,{checked:o,onChange:r,label:`Toggle ${t}`,disabled:s})]})}function he(){return R("div",{style:{height:"1px",background:"#f1f5f9"}})}function yt({steps:e}){return Q("div",{style:{margin:"0 18px 8px",padding:"8px 10px",background:"#f8fafc",borderRadius:"8px",border:"0.5px solid #e2e8f0"},children:[R("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)=>Q("p",{style:{margin:"0 0 2px",fontSize:"10px",color:"#475569"},children:[n+1,". ",t]},n))]})}var kn=Ls(({position:e,settings:t,report:n,isActive:o,aiSupported:r,voiceSupported:s,set:i,onApply:a,onReset:l,onClose:c},u)=>{let{isMobile:b,isTablet:p}=Ns(),[g,f]=Ze([]),[h,d]=Ze(""),[x,k]=Ze(""),[m,v]=Ze(!1),[w,A]=Ze(null),[C,F]=Ze("idle");Wt(()=>{let y=window;!!(y.LanguageModel||y.ai?.languageModel)&&r?A("gemini"):$t()&&A("transformers")},[r]),Wt(()=>{if(w!=="transformers")return;let y=setInterval(()=>{F(Et())},500);return()=>clearInterval(y)},[w]);let D=async()=>{if(!(!h.trim()||m)){if(!w){k("\u26A0\uFE0F No AI engine available on this device.");return}v(!0),k("");try{let y;w==="gemini"?y=await Xn(h):(F("loading"),y=await eo(h),F("ready")),k(y.success&&y.answer?y.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(y.error||"No answer found on this page"))}catch{k("\u26A0\uFE0F Failed to get answer. Please try again.")}v(!1)}};Wt(()=>{(async()=>{try{let q=window;if(!q.queryLocalFonts)return;let B=await q.queryLocalFonts(),U=[...new Set(B.map(oe=>oe.family))].sort();f(U.slice(0,50))}catch{}})()},[]);let M=w==="gemini"?"Gemini Nano":w==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",E=w==="transformers"&&C==="loading"?"Loading AI model... (first time only)":"...",I=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: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 Q("div",{ref:u,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:I,children:[Q("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:[Q("div",{children:[Q("div",{style:{display:"flex",alignItems:"center",gap:"7px",marginBottom:"4px",flexWrap:"wrap"},children:[R("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai"}),o&&R("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),R("p",{style:{margin:"0 0 1px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),R("p",{style:{margin:0,fontSize:"11px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost \xB7 All devices"})]}),R("button",{onClick:c,"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"})]}),R(ct,{label:"\u267F Core Accessibility",concept:"Rule-based engine \u2014 works on all browsers and devices"}),R(yt,{steps:["Toggle any feature on","Click Apply settings","Preferences saved automatically"]}),R($e,{icon:"\u{1F527}",label:"Auto-fix ARIA",desc:"Injects missing labels and roles automatically",checked:t.autoFix,onChange:y=>i("autoFix",y),tip:"Fixes aria-label, alt text, roles on every element"}),R(he,{}),R($e,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud as you tab",checked:t.speechEnabled,onChange:y=>i("speechEnabled",y),tip:"Uses browser SpeechSynthesis \u2014 no install needed"}),R(he,{}),R($e,{icon:"\u{1F399}\uFE0F",label:"Voice control",desc:"Say commands to navigate the page",checked:t.voiceControl,onChange:y=>i("voiceControl",y),disabled:!s,disabledReason:"Not supported in this browser",tip:'Say "scroll down", "go to main", "click"'}),R(he,{}),R(ct,{label:"\u{1F916} AI Features",color:"#7c3aed",badge:"Gemini Nano",concept:"Large Language Model running privately on your device \u2014 Chrome 127+ only"}),R("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:r?"#f0fdfa":"#f5f3ff",borderRadius:"8px",border:`0.5px solid ${r?"#99f6e4":"#c4b5fd"}`,fontSize:"10px",color:r?"#0f766e":"#7c3aed",lineHeight:1.5},children:r?"\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."}),!r&&Q("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[R("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} One-time setup \u2014 5 steps:"}),Q("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome \u2192 ",R("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),R("p",{style:{margin:"0 0 3px"},children:"2. Enable each flag:"}),R("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:Ms.map(y=>Q("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",y]},y))}),Q("p",{style:{margin:"0 0 3px"},children:["3. Click ",R("strong",{style:{color:"#0f172a"},children:"Relaunch"})]}),Q("p",{style:{margin:"0 0 3px"},children:["4. ",R("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"]}),R("p",{style:{margin:"0"},children:"5. Refresh \u2014 AI features unlock automatically \u2705"})]}),R($e,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Rewrites complex text in simple language",checked:t.plainEnglish,onChange:y=>i("plainEnglish",y),disabled:!r,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: LLM text rewriting"}),R(he,{}),R($e,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary appears at top",checked:t.summarisePage,onChange:y=>i("summarisePage",y),disabled:!r,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Abstractive summarisation"}),R(he,{}),R($e,{icon:"\u{1F3F7}\uFE0F",label:"Smart aria-labels",desc:"AI generates meaningful labels for elements",checked:t.smartLabels,onChange:y=>i("smartLabels",y),disabled:!r,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Context-aware label generation"}),R(he,{}),R(ct,{label:"\u{1F441}\uFE0F Visual",concept:"CSS filter-based \u2014 works on all browsers and devices"}),R(yt,{steps:["Toggle any visual mode","Changes apply instantly","Works on mobile and desktop"]}),R($e,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision users",checked:t.highContrast,onChange:y=>i("highContrast",y),tip:"CSS filter: contrast()"}),R(he,{}),R($e,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours \u2014 easy on eyes at night",checked:t.darkMode,onChange:y=>i("darkMode",y),tip:"CSS filter: invert + hue-rotate"}),R(he,{}),R($e,{icon:"\u23F8\uFE0F",label:"Reduce motion",desc:"Disables all animations",checked:t.reduceMotion,onChange:y=>i("reduceMotion",y),tip:"WCAG 2.3.3 \u2014 vestibular disorders"}),R(he,{}),R($e,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:y=>i("largeTargets",y),tip:"WCAG 2.5.8 \u2014 motor impaired users"}),R(he,{}),Q("div",{style:{padding:"10px 18px"},children:[R("p",{style:{margin:"0 0 2px",fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),R("p",{style:{margin:"0 0 8px",fontSize:"10px",color:"#94a3b8"},children:"SVG colour matrix filters \u2014 all devices"}),R("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Ps.map(y=>R("button",{onClick:()=>i("colorBlindMode",y.value),"aria-pressed":t.colorBlindMode===y.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===y.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===y.value?"#f0fdfa":"#fff",color:t.colorBlindMode===y.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:b?"36px":"auto"},children:y.label},y.value))})]}),R(he,{}),R(ct,{label:"\u{1F524} Font",concept:"Browser Font API + CSS \u2014 Chrome 103+"}),R(yt,{steps:["Toggle dyslexia font or pick from device","Adjust size with + / \u2212","Saved across visits"]}),R($e,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible \u2014 research-backed",checked:t.dyslexiaFont,onChange:y=>i("dyslexiaFont",y),tip:"By Braille Institute \u2014 free and open source"}),R(he,{}),Q("div",{style:{padding:"10px 18px"},children:[R("p",{style:{margin:"0 0 2px",fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F5A5}\uFE0F Local font"}),R("p",{style:{margin:"0 0 8px",fontSize:"10px",color:"#94a3b8"},children:"window.queryLocalFonts() \u2014 Chrome 103+"}),g.length>0?Q("select",{value:t.localFont,onChange:y=>i("localFont",y.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:[R("option",{value:"",children:"System default"}),g.map(y=>R("option",{value:y,style:{fontFamily:y},children:y},y))]}):R("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Allow font access when Chrome prompts you."})]}),R(he,{}),Q("div",{style:{padding:"10px 18px 14px"},children:[Q("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[Q("div",{children:[R("p",{style:{margin:0,fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F4CF} Text size"}),R("p",{style:{margin:0,fontSize:"10px",color:"#94a3b8"},children:"Scales all text on the page"})]}),Q("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),Q("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[R("button",{onClick:()=>{let y=lt.indexOf(t.fontScale);y>0&&i("fontScale",lt[y-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"}),R("div",{style:{flex:1,display:"flex",gap:"3px"},children:lt.map(y=>R("button",{onClick:()=>i("fontScale",y),"aria-label":`Set text size to ${y}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:y<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},y))}),R("button",{onClick:()=>{let y=lt.indexOf(t.fontScale);y<lt.length-1&&i("fontScale",lt[y+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:"+"})]})]}),R(he,{}),R(ct,{label:"\u{1F310} Translate",color:"#7c3aed",badge:"Gemini Nano",concept:"Chrome Translation API \u2014 on device, no internet after setup"}),R(yt,{steps:["Enable Gemini Nano first","Pick your language","Full page translates instantly"]}),Q("div",{style:{padding:"6px 18px 12px"},children:[R("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Pt.slice(0,b?8:18).map(y=>R("button",{onClick:()=>i("translateLanguage",y.code),"aria-pressed":t.translateLanguage===y.code,disabled:!r,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===y.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===y.code?"#f5f3ff":"#fff",color:t.translateLanguage===y.code?"#7c3aed":"#64748b",cursor:r?"pointer":"not-allowed",opacity:r?1:.5,minHeight:b?"36px":"auto"},children:y.label},y.code))}),!r&&R("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above."})]}),R(he,{}),R(ct,{label:"\u{1F4AC} Ask This Page",color:"#0d9488",badge:M,concept:"RAG \u2014 Retrieval Augmented Generation. Works on all devices including mobile."}),R(yt,{steps:["Type any question about this page","Press Ask or hit Enter",w==="transformers"?"Transformers.js answers \u2014 works on mobile, offline":"Gemini Nano reads page and answers privately","Zero cost. No data leaves your device."]}),Q("div",{style:{margin:"0 18px 8px",padding:"6px 10px",background:w==="gemini"?"#f0fdfa":w==="transformers"?"#f5f3ff":"#f8fafc",borderRadius:"8px",border:`0.5px solid ${w==="gemini"?"#99f6e4":w==="transformers"?"#c4b5fd":"#e2e8f0"}`,fontSize:"10px",color:w==="gemini"?"#0f766e":w==="transformers"?"#7c3aed":"#94a3b8"},children:[w==="gemini"&&"\u2705 Using Gemini Nano \u2014 on device, private, instant",w==="transformers"&&"\u2705 Using Transformers.js \u2014 works on mobile and all browsers",!w&&"\u23F3 Detecting AI engine...",w==="transformers"&&C==="loading"&&" \xB7 Loading model...",w==="transformers"&&C==="ready"&&" \xB7 Model ready \u2705"]}),Q("div",{style:{padding:"0 18px 14px"},children:[Q("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[R("input",{type:"text",value:h,onChange:y=>d(y.target.value),onKeyDown:y=>{y.key==="Enter"&&D()},placeholder:"e.g. What does this page do?",disabled:m||!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:b?"44px":"36px"}}),R("button",{onClick:D,disabled:m||!h.trim()||!w,"aria-label":"Ask question",style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:w&&h.trim()&&!m?"#0d9488":"#e2e8f0",color:w&&h.trim()&&!m?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:w&&h.trim()&&!m?"pointer":"not-allowed",flexShrink:0,height:b?"44px":"36px",minWidth:"52px",transition:"background 0.2s"},children:m?E:"Ask"})]}),x&&Q("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:[R("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#0d9488"},children:"\u{1F4AC} Answer"}),x,R("button",{onClick:()=>{k(""),d("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]})]}),n&&R("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`}),Q("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:[R("button",{onClick:l,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"}),R("button",{onClick:a,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"})]})]})});kn.displayName="WidgetPanel";import{useState as xt,useCallback as Fo}from"react";var Ds={hotel:["hotel","resort","motel","inn","accommodation","lodge","stay","room","booking","hospitality"],ecommerce:["shop","store","ecommerce","e-commerce","sell","product","cart","buy","marketplace","retail"],restaurant:["restaurant","food","cafe","cafeteria","menu","dining","eat","cuisine","bistro","takeaway","delivery"],portfolio:["portfolio","freelance","personal","designer","developer","creative","showcase","work","hire me"],blog:["blog","article","post","write","news","magazine","journal","content"],saas:["saas","dashboard","app","software","platform","tool","analytics","admin","manage","crm"],government:["government","govt","portal","citizen","scheme","welfare","municipal","public","official"],healthcare:["hospital","clinic","doctor","health","medical","patient","appointment","pharmacy"],education:["school","college","university","course","learn","education","student","lms","training"],realestate:["real estate","property","house","flat","apartment","rent","buy property","listing"],landing:["landing","startup","launch","product launch","coming soon","waitlist"],generic:[]},Os={hotel:["home","rooms","booking","about","contact"],ecommerce:["home","products","cart","checkout","about","contact"],restaurant:["home","menu","reservations","about","contact"],portfolio:["home","portfolio","about","contact"],blog:["home","blog","about","contact"],saas:["home","pricing","dashboard","auth","about","contact"],government:["home","services","about","contact","faq"],healthcare:["home","services","booking","team","about","contact"],education:["home","services","pricing","about","contact"],realestate:["home","products","about","contact"],landing:["home","pricing","about","contact"],generic:["home","about","services","contact"]},Ws={home:["home","homepage","main","landing"],about:["about","who we are","our story","company"],contact:["contact","reach us","get in touch","location"],services:["service","what we offer","solution","offering"],pricing:["pricing","price","plan","subscription","cost","fee"],blog:["blog","article","news","post"],auth:["login","register","signup","sign up","sign in","auth","account"],dashboard:["dashboard","admin","panel","manage","analytics"],gallery:["gallery","photo","image","portfolio"],products:["product","shop","store","item","catalogue"],cart:["cart","basket","shopping cart"],checkout:["checkout","payment","pay","order"],rooms:["room","suite","accommodation","stay"],booking:["booking","reserve","reservation","schedule","appointment"],menu:["menu","food","dish","cuisine"],reservations:["reservation","table booking","book table"],portfolio:["portfolio","work","project","case study"],team:["team","staff","member","people","who we are"],faq:["faq","question","answer","help","support"],terms:["terms","condition","legal"],privacy:["privacy","policy","gdpr","data"]},Bs={Authentication:["login","register","auth","signup","sign in","account"],Payment:["payment","stripe","pay","checkout","billing"],Search:["search","filter","find"],"Dark mode":["dark mode","dark theme","night mode"],"Multi-language":["multilingual","multi language","translation","i18n"],SEO:["seo","search engine","meta","google"],Analytics:["analytics","tracking","stats","dashboard"],Email:["email","newsletter","contact form","notification"],Map:["map","location","address","google maps"],"Social media":["social","instagram","facebook","twitter","share"],"Image gallery":["gallery","photo","image","carousel"],"Booking system":["booking","reservation","appointment","schedule"],"Shopping cart":["cart","basket","shop","ecommerce"],"Blog/CMS":["blog","cms","content","article","post"]},Hs={blue:["blue","navy","sky","ocean","corporate"],green:["green","nature","eco","environment","health","fresh"],purple:["purple","violet","luxury","creative","royal"],red:["red","bold","energy","passion","food"],orange:["orange","warm","friendly","fun"],teal:["teal","turquoise","modern","tech"],indigo:["indigo","professional","trust","finance","bank"],gray:["gray","minimal","clean","simple","neutral"]},qs={hotel:"indigo",ecommerce:"blue",restaurant:"red",portfolio:"purple",blog:"gray",saas:"teal",government:"blue",healthcare:"green",education:"indigo",realestate:"orange",landing:"purple",generic:"blue"};function _s(e){let t=[/(?:for|called|named|company|business|brand)\s+["']?([A-Z][a-zA-Z\s]{1,30})["']?/i,/["']([A-Z][a-zA-Z\s]{1,30})["']/,/^([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)?)/m];for(let n of t){let o=e.match(n);if(o?.[1]){let r=o[1].trim();if(r.length>2&&r.length<40)return r}}return"My Business"}function js(e){let t=e.toLowerCase(),n="generic",o=0;for(let[r,s]of Object.entries(Ds)){let i=0;for(let a of s)t.includes(a)&&i++;i>o&&(o=i,n=r)}return n}function Us(e,t){let n=e.toLowerCase(),o=new Set(Os[t]);for(let[r,s]of Object.entries(Ws))for(let i of s)if(n.includes(i)){o.add(r);break}return o.add("home"),o.add("contact"),Array.from(o)}function Vs(e){let t=e.toLowerCase(),n=[];for(let[o,r]of Object.entries(Bs))for(let s of r)if(t.includes(s)){n.push(o);break}return n}function Ys(e,t){let n=e.toLowerCase();for(let[o,r]of Object.entries(Hs))for(let s of r)if(n.includes(s))return o;return qs[t]}function Go(e){let t=js(e),n=Us(e,t),o=Vs(e),r=Ys(e,t);return{siteName:_s(e),websiteType:t,pages:n,features:o,theme:r,description:e.slice(0,200)}}import{Fragment as Zs,jsx as V,jsxs as re}from"react/jsx-runtime";var Ks=["Hotel booking website for Grand Palace Hotels with rooms, booking and payment","E-commerce store for organic food products with cart and checkout","Restaurant website for Spice Garden with menu and table reservations","Portfolio website for a freelance designer with gallery and contact","SaaS dashboard for project management with pricing and auth","Government portal for citizen services with FAQ and contact"],Qs={home:"\u{1F3E0}",about:"\u2139\uFE0F",contact:"\u{1F4EC}",services:"\u2699\uFE0F",pricing:"\u{1F4B0}",blog:"\u{1F4DD}",auth:"\u{1F510}",dashboard:"\u{1F4CA}",gallery:"\u{1F5BC}\uFE0F",products:"\u{1F6D2}",cart:"\u{1F6CD}\uFE0F",checkout:"\u{1F4B3}",rooms:"\u{1F6CF}\uFE0F",booking:"\u{1F4C5}",menu:"\u{1F37D}\uFE0F",reservations:"\u{1FA91}",portfolio:"\u{1F4BC}",team:"\u{1F465}",faq:"\u2753",terms:"\u{1F4C4}",privacy:"\u{1F512}"},Js={hotel:"\u{1F3E8}",ecommerce:"\u{1F6D2}",restaurant:"\u{1F37D}\uFE0F",portfolio:"\u{1F4BC}",blog:"\u{1F4DD}",saas:"\u26A1",government:"\u{1F3DB}\uFE0F",healthcare:"\u{1F3E5}",education:"\u{1F393}",realestate:"\u{1F3E0}",landing:"\u{1F680}",generic:"\u{1F310}"};function vn({position:e,onClose:t}){let[n,o]=xt("input"),[r,s]=xt(""),[i,a]=xt(null),[l,c]=xt(0),[u,b]=xt(""),p=Fo(()=>{if(!r.trim())return;let d=Go(r);a(d),o("preview")},[r]),g=Fo(async()=>{if(i){o("generating"),c(0),b("");try{let d=[{msg:"Parsing requirement...",pct:15},{msg:"Loading templates...",pct:30},{msg:"Generating pages...",pct:55},{msg:"Building components...",pct:70},{msg:"Creating styles...",pct:85},{msg:"Packaging ZIP...",pct:95}];for(let k of d)c(k.pct),await new Promise(m=>setTimeout(m,200));let{generateZip:x}=await import("./zip-generator-D5EXBBNS.mjs");await x(i),c(100),o("done")}catch(d){b(d instanceof Error?d.message:"Generation failed. Please try again."),o("preview")}}},[i]),f=()=>{o("input"),s(""),a(null),c(0),b("")},h={position:"fixed",bottom:"204px",[e]:"24px",zIndex:9999,width:"340px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.14)",fontFamily:"system-ui,-apple-system,sans-serif",maxHeight:"75vh",overflowY:"auto"};return re("div",{role:"dialog","aria-modal":"true","aria-label":"yuktai Vibe Coder","data-yuktai-panel":"true",style:h,children:[re("div",{style:{padding:"14px 16px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between",position:"sticky",top:0,background:"#fff",zIndex:1},children:[re("div",{children:[V("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:700,color:"#0f172a"},children:"\u26A1 Vibe Coder"}),V("p",{style:{margin:0,fontSize:"10px",color:"#64748b"},children:"Describe your website \u2192 Download Next.js ZIP"})]}),V("button",{onClick:t,"aria-label":"Close vibe coder",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",padding:"2px"},children:"\xD7"})]}),n==="input"&&re("div",{style:{padding:"14px 16px"},children:[V("p",{style:{margin:"0 0 10px",fontSize:"11px",color:"#64748b"},children:"Describe your business website in plain English. The plugin will generate a complete Next.js project for you."}),V("p",{style:{margin:"0 0 6px",fontSize:"10px",fontWeight:600,color:"#94a3b8",textTransform:"uppercase"},children:"Examples"}),V("div",{style:{display:"flex",flexDirection:"column",gap:"4px",marginBottom:"12px"},children:Ks.slice(0,3).map(d=>V("button",{onClick:()=>s(d),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#f8fafc",color:"#475569",fontSize:"10px",cursor:"pointer",textAlign:"left",lineHeight:1.4},children:d},d))}),V("textarea",{value:r,onChange:d=>s(d.target.value),placeholder:"e.g. I need a hotel booking website with rooms, search, and payment for Grand Palace Hotels",rows:4,"aria-label":"Describe your website",style:{width:"100%",padding:"10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px",color:"#0f172a",resize:"vertical",outline:"none",fontFamily:"inherit",lineHeight:1.5}}),V("button",{onClick:p,disabled:!r.trim(),style:{width:"100%",marginTop:"10px",padding:"10px",borderRadius:"8px",border:"none",background:r.trim()?"#f59e0b":"#e2e8f0",color:r.trim()?"#fff":"#94a3b8",fontSize:"13px",fontWeight:700,cursor:r.trim()?"pointer":"not-allowed",transition:"background 0.2s"},children:"Analyse Requirement \u2192"})]}),n==="preview"&&i&&re("div",{style:{padding:"14px 16px"},children:[u&&re("div",{style:{padding:"10px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:"8px",marginBottom:"12px",fontSize:"11px",color:"#dc2626"},children:["\u26A0\uFE0F ",u]}),re("div",{style:{background:"#f8fafc",borderRadius:"10px",padding:"12px",marginBottom:"12px"},children:[re("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[V("span",{style:{fontSize:"1.5rem"},children:Js[i.websiteType]||"\u{1F310}"}),re("div",{children:[V("p",{style:{margin:0,fontSize:"13px",fontWeight:700,color:"#0f172a"},children:i.siteName}),re("p",{style:{margin:0,fontSize:"10px",color:"#64748b",textTransform:"capitalize"},children:[i.websiteType," website \xB7 ",i.theme," theme"]})]})]}),re("p",{style:{margin:"8px 0 6px",fontSize:"10px",fontWeight:600,color:"#94a3b8",textTransform:"uppercase"},children:["Pages to generate (",i.pages.length,")"]}),V("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:i.pages.map(d=>re("span",{style:{padding:"2px 8px",borderRadius:"99px",background:"#f0fdf4",border:"1px solid #86efac",fontSize:"10px",color:"#166534",fontWeight:500},children:[Qs[d]||"\u{1F4C4}"," ",d]},d))}),i.features.length>0&&re(Zs,{children:[V("p",{style:{margin:"10px 0 6px",fontSize:"10px",fontWeight:600,color:"#94a3b8",textTransform:"uppercase"},children:"Detected features"}),V("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:i.features.map(d=>V("span",{style:{padding:"2px 8px",borderRadius:"99px",background:"#f5f3ff",border:"1px solid #c4b5fd",fontSize:"10px",color:"#7c3aed",fontWeight:500},children:d},d))})]})]}),re("div",{style:{margin:"0 0 12px",padding:"10px 12px",background:"#f0fdf4",borderRadius:"8px",border:"1px solid #86efac"},children:[V("p",{style:{margin:"0 0 4px",fontSize:"10px",fontWeight:700,color:"#166534"},children:"\u{1F4E6} What you get:"}),re("p",{style:{margin:0,fontSize:"10px",color:"#166534",lineHeight:1.6},children:["\u2705 Complete Next.js 16 project",V("br",{}),"\u2705 Tailwind CSS + CSS Modules",V("br",{}),"\u2705 TypeScript configured",V("br",{}),"\u2705 Navbar + Footer components",V("br",{}),"\u2705 All ",i.pages.length," pages ready",V("br",{}),"\u2705 Mobile responsive",V("br",{}),"\u2705 npm run dev \u2192 works immediately"]})]}),re("div",{style:{display:"flex",gap:"8px"},children:[V("button",{onClick:f,style:{flex:1,padding:"9px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"\u2190 Edit"}),V("button",{onClick:g,style:{flex:2,padding:"9px",borderRadius:"8px",border:"none",background:"#f59e0b",color:"#fff",fontSize:"13px",fontWeight:700,cursor:"pointer"},children:"\u2B07\uFE0F Generate & Download ZIP"})]})]}),n==="generating"&&re("div",{style:{padding:"2rem 16px",textAlign:"center"},children:[V("p",{style:{fontSize:"2rem",marginBottom:"1rem"},children:"\u26A1"}),V("p",{style:{fontSize:"13px",fontWeight:700,color:"#0f172a",marginBottom:"0.5rem"},children:"Generating your project..."}),V("p",{style:{fontSize:"11px",color:"#64748b",marginBottom:"1.5rem"},children:l<30?"Parsing requirement...":l<55?"Loading templates...":l<70?"Generating pages...":l<85?"Building components...":l<95?"Creating styles...":"Packaging ZIP..."}),V("div",{style:{height:"8px",background:"#e2e8f0",borderRadius:"99px",overflow:"hidden"},children:V("div",{style:{height:"100%",width:`${l}%`,background:"#f59e0b",borderRadius:"99px",transition:"width 0.3s ease"}})}),re("p",{style:{marginTop:"0.5rem",fontSize:"10px",color:"#94a3b8"},children:[l,"%"]})]}),n==="done"&&i&&re("div",{style:{padding:"2rem 16px",textAlign:"center"},children:[V("p",{style:{fontSize:"3rem",marginBottom:"0.75rem"},children:"\u2705"}),re("p",{style:{fontSize:"14px",fontWeight:700,color:"#0f172a",marginBottom:"0.5rem"},children:[i.siteName," downloaded!"]}),V("p",{style:{fontSize:"11px",color:"#64748b",marginBottom:"1.5rem",lineHeight:1.6},children:"Your ZIP is downloading. Unzip it and run:"}),["npm install","npm run dev"].map(d=>V("div",{style:{background:"#0f172a",borderRadius:"8px",padding:"8px 12px",marginBottom:"6px",textAlign:"left"},children:re("code",{style:{fontSize:"12px",color:"#a7f3d0",fontFamily:"monospace"},children:["$ ",d]})},d)),V("p",{style:{fontSize:"11px",color:"#10b981",margin:"1rem 0",fontWeight:600},children:"Then open http://localhost:3000 \u{1F680}"}),re("div",{style:{display:"flex",gap:"8px"},children:[V("button",{onClick:f,style:{flex:1,padding:"9px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"New Project"}),V("button",{onClick:g,style:{flex:1,padding:"9px",borderRadius:"8px",border:"none",background:"#f59e0b",color:"#fff",fontSize:"12px",fontWeight:700,cursor:"pointer"},children:"\u2B07\uFE0F Download Again"})]})]})]})}import{Fragment as ta,jsx as ee,jsxs as Ee}from"react/jsx-runtime";async function ea(){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 Sn({position:e="left",children:t,config:n={},showRag:o=!1,showAgent:r=!1}){let[s,i]=ce(!1),[a,l]=ce(wn),[c,u]=ce(null),[b,p]=ce(!1),[g,f]=ce(!1),[h,d]=ce(!1),x=Xs.useRef(null),[k,m]=ce(!1),[v,w]=ce(""),[A,C]=ce(""),[F,D]=ce(!1),[M,E]=ce(null),[I,y]=ce("idle"),[q,B]=ce(!1),[U,oe]=ce(""),[de,z]=ce(""),[H,T]=ce(!1),[P,J]=ce([]),[W,ae]=ce(null),fe=24,ve=84,De=o?144:84,jn=204,[Se,nt]=ce(!1);ut(()=>{if(typeof window>"u")return;let $=window;!!($.LanguageModel||$.ai?.languageModel)&&g?(E("gemini"),ae("gemini")):$t()&&(E("transformers"),ae("transformers"))},[g]),ut(()=>{if(M!=="transformers")return;let $=setInterval(()=>y(Et()),500);return()=>clearInterval($)},[M]);let mt=dt(async()=>{if(!(!v.trim()||F)){if(!M){C("\u26A0\uFE0F No AI engine available.");return}D(!0),C("");try{let $;if(M==="gemini"){let{askPage:ne}=await import("./rag-MKBAGH6J.mjs");$=await ne(v)}else{y("loading");let{askPageWithTransformers:ne}=await import("./transformers-rag-HW4QKA5T.mjs");$=await ne(v),y("ready")}C($.success&&$.answer?$.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+($.error||"No answer found."))}catch{C("\u26A0\uFE0F Something went wrong.")}D(!1)}},[v,F,M]),Ct=dt(async()=>{if(!U.trim()||H)return;if(!W){z("\u26A0\uFE0F No AI engine available.");return}T(!0),J([]),z("");let{runAgent:$}=await import("./agent-JGLAYQMX.mjs");await $(U,W,ne=>{J(Me=>[...Me,ne.text])}),T(!1),z("done")},[U,H,W]);ut(()=>{if(typeof window>"u")return;let ne=setTimeout(async()=>{let Me=window,rn=await ea();f(rn),d(!!(Me.SpeechRecognition||Me.webkitSpeechRecognition))},800);return()=>clearTimeout(ne)},[]),ut(()=>{if(!(typeof window>"u"))try{let $=localStorage.getItem("yuktai-a11y-prefs");$&&l(ne=>({...ne,...JSON.parse($)}))}catch{}},[]);let Be=dt(async $=>{let ne={enabled:!0,highContrast:$.highContrast,darkMode:$.darkMode,reduceMotion:$.reduceMotion,largeTargets:$.largeTargets,speechEnabled:$.speechEnabled,autoFix:$.autoFix,dyslexiaFont:$.dyslexiaFont,localFont:$.localFont,fontSizeMultiplier:$.fontScale/100,colorBlindMode:$.colorBlindMode,showAuditBadge:$.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:$.plainEnglish,summarisePage:$.summarisePage,translateLanguage:$.translateLanguage,voiceControl:$.voiceControl,smartLabels:$.smartLabels,...n};await ke.execute(ne),u(ke.applyFixes(ne)),p(!0)},[n]),we=dt(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(a))}catch{}await Be(a),i(!1)},[a,Be]),Oe=dt(()=>{l(wn);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let $=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(ne=>$.removeAttribute(ne)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",u(null),p(!1)},[]),bt=dt(($,ne)=>{l(Me=>({...Me,[$]:ne}))},[]);ut(()=>{let $=ne=>{ne.key==="Escape"&&(s&&i(!1),k&&m(!1),q&&B(!1),Se&&nt(!1))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[s,k,q]),ut(()=>{s&&x.current&&ke.trapFocus(x.current)},[s]);let Qe=($,ne,Me)=>({position:"fixed",bottom:`${$}px`,[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:ne,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"}),ot=$=>{$.currentTarget.style.transform="scale(1.08)"},He=$=>{$.currentTarget.style.transform="scale(1)"},rt=M==="gemini"?"Gemini Nano \xB7 On device":M==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",Rt=M==="transformers"&&I==="loading"?"Loading model...":"...";return Ee(ta,{children:[t,r&&ee("button",{style:Qe(204,Se?"#d97706":"#f59e0b",Se),"aria-label":"Open Vibe Coder",title:"\u26A1 Vibe Coder \u2014 Generate Next.js project",onClick:()=>{nt($=>!$),B(!1),m(!1),i(!1)},onMouseEnter:ot,onMouseLeave:He,children:"\u26A1"}),r&&Se&&ee(vn,{position:e,onClose:()=>nt(!1)}),r&&ee("button",{style:Qe(De,q?"#059669":"#10b981",q),"aria-label":"Open AI agent","aria-haspopup":"dialog","aria-expanded":q,title:"\u{1F916} AI Agent \u2014 guide me through this page",onClick:()=>{B($=>!$),m(!1),i(!1)},onMouseEnter:ot,onMouseLeave:He,children:"\u{1F916}"}),r&&q&&Ee("div",{role:"dialog","aria-modal":"true","aria-label":"yuktai AI Agent","data-yuktai-panel":"true",style:{position:"fixed",bottom:`${De+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:[Ee("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"10px"},children:[Ee("div",{children:[ee("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:600,color:"#0f172a"},children:"\u{1F916} AI Agent"}),ee("p",{style:{margin:0,fontSize:"10px",color:"#10b981"},children:W==="gemini"?"Gemini Nano \xB7 On device":W==="transformers"?"Transformers.js \xB7 All devices":"Detecting..."})]}),ee("button",{onClick:()=>B(!1),"aria-label":"Close agent panel",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",lineHeight:1,padding:"2px"},children:"\xD7"})]}),ee("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."}),ee("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($=>ee("button",{onClick:()=>oe($),style:{padding:"3px 8px",borderRadius:"20px",fontSize:"10px",border:"1px solid #e2e8f0",background:"#f8fafc",color:"#64748b",cursor:"pointer"},children:$},$))}),Ee("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[ee("input",{type:"text",value:U,onChange:$=>oe($.target.value),onKeyDown:$=>{$.key==="Enter"&&Ct()},placeholder:"e.g. Help me fill this form",disabled:H||!W,"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:W?"#fff":"#f8fafc",outline:"none",height:"36px"}}),ee("button",{onClick:Ct,disabled:H||!U.trim()||!W,"aria-label":"Run agent",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:W&&U.trim()&&!H?"#10b981":"#e2e8f0",color:W&&U.trim()&&!H?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:W&&U.trim()&&!H?"pointer":"not-allowed",height:"36px",minWidth:"52px",transition:"background 0.2s"},children:H?"...":"Go"})]}),P.length>0&&Ee("div",{style:{padding:"10px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:"8px",fontSize:"11px",color:"#166534",lineHeight:1.7},children:[P.map(($,ne)=>ee("p",{style:{margin:"0 0 2px"},children:$},ne)),de==="done"&&ee("button",{onClick:()=>{J([]),oe(""),z("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!W&&ee("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano via chrome://flags for best results."})]}),o&&ee("button",{style:Qe(ve,k?"#7c3aed":"#6d28d9",k),"aria-label":"Ask a question about this page","aria-haspopup":"dialog","aria-expanded":k,title:`\u{1F4AC} Ask this page \xB7 ${rt}`,onClick:()=>{m($=>!$),i(!1),B(!1)},onMouseEnter:ot,onMouseLeave:He,children:"\u{1F4AC}"}),o&&k&&Ee("div",{role:"dialog","aria-modal":"true","aria-label":"Ask this page","data-yuktai-panel":"true",style:{position:"fixed",bottom:`${ve+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:[Ee("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"10px"},children:[Ee("div",{children:[ee("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:600,color:"#0f172a"},children:"\u{1F4AC} Ask this page"}),ee("p",{style:{margin:0,fontSize:"10px",color:"#7c3aed"},children:rt}),M==="transformers"&&I==="loading"&&ee("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8"},children:"Downloading model \u2014 first time only"}),M==="transformers"&&I==="ready"&&ee("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#10b981"},children:"Model ready \u2705 \u2014 works offline"})]}),ee("button",{onClick:()=>m(!1),"aria-label":"Close ask panel",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",lineHeight:1,padding:"2px"},children:"\xD7"})]}),Ee("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[ee("input",{type:"text",value:v,onChange:$=>w($.target.value),onKeyDown:$=>{$.key==="Enter"&&mt()},placeholder:"e.g. What does this page do?",disabled:F||!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:"36px"}}),ee("button",{onClick:mt,disabled:F||!v.trim()||!M,"aria-label":"Submit question",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:M&&v.trim()&&!F?"#7c3aed":"#e2e8f0",color:M&&v.trim()&&!F?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:M&&v.trim()&&!F?"pointer":"not-allowed",height:"36px",minWidth:"48px",transition:"background 0.2s"},children:F?Rt:"Ask"})]}),A&&Ee("div",{style:{padding:"10px",background:"#f5f3ff",borderRadius:"8px",fontSize:"12px",color:"#4c1d95",lineHeight:1.6,maxHeight:"180px",overflowY:"auto"},children:[ee("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#7c3aed"},children:"\u{1F4AC} Answer"}),A,ee("button",{onClick:()=>{C(""),w("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!M&&ee("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Detecting AI engine..."})]}),ee("button",{style:Qe(fe,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:()=>{i($=>!$),m(!1),B(!1)},onMouseEnter:ot,onMouseLeave:He,children:"\u267F"}),s&&ee(kn,{ref:x,position:e,settings:a,report:c,isActive:b,aiSupported:g,voiceSupported:h,set:bt,onApply:we,onReset:Oe,onClose:()=>i(!1)})]})}var Bt={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var Ht={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var Xe=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 o=this.use(t);if(!o)throw new Error(`Plugin not found: ${t}`);return await o.execute(n)}catch(o){throw console.error(`[YuktAI Runtime Error in ${t}]:`,o),o}}getPlugins(){return Array.from(this.plugins.keys())}};import{useCallback as $n,useEffect as Qt,useMemo as pt,useState as Ve}from"react";import{useCallback as Tn,useEffect as wt,useMemo as Lo,useRef as Po,useState as _e}from"react";import{Fragment as da,jsx as L,jsxs as ye}from"react/jsx-runtime";var Mo={"en-US":{title:"Grid AI Assistant",subtitle:"Ask about your data",ask:"Ask",placeholder:"Ask or type a command...",listening:"Listening...",send:"Send",close:"Close",open:"Open AI assistant",inputLanguage:"Input language",speakNow:"Speak your question",working:"Working on it\u2026",english:"English",telugu:"\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41",searchStarted:e=>`Searching for "${e}".`,sortedAscending:e=>`Sorted by ${e} in ascending order.`,sortedDescending:e=>`Sorted by ${e} in descending order.`,count:e=>`There are ${e} rows in the grid.`,highest:(e,t,n)=>`The highest ${e} is ${t}, held by ${n}.`,lowest:(e,t,n)=>`The lowest ${e} is ${t}, held by ${n}.`,average:(e,t)=>`The average ${e} is ${t}.`,total:(e,t)=>`The total ${e} is ${t}.`,noData:"There is no data to analyze.",noColumn:"I could not find a column to analyze.",noNumericData:e=>`There is no numeric data in ${e}.`,notFound:e=>`I could not find anything matching "${e}".`,needName:"Please provide a value to look up.",fallback:"I can search, sort, count, and analyze the grid data.",unsupportedVoice:"Voice input is not supported in this browser."},"te-IN":{title:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D AI \u0C38\u0C39\u0C3E\u0C2F\u0C15\u0C41\u0C21\u0C41",subtitle:"\u0C2E\u0C40 \u0C21\u0C47\u0C1F\u0C3E \u0C17\u0C41\u0C30\u0C3F\u0C02\u0C1A\u0C3F \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F",ask:"\u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F",placeholder:"\u0C2A\u0C4D\u0C30\u0C36\u0C4D\u0C28 \u0C32\u0C47\u0C26\u0C3E \u0C06\u0C26\u0C47\u0C36\u0C02 \u0C1F\u0C48\u0C2A\u0C4D \u0C1A\u0C47\u0C2F\u0C02\u0C21\u0C3F...",listening:"\u0C35\u0C3F\u0C02\u0C1F\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41...",send:"\u0C2A\u0C02\u0C2A\u0C02\u0C21\u0C3F",close:"\u0C2E\u0C42\u0C38\u0C3F\u0C35\u0C47\u0C2F\u0C02\u0C21\u0C3F",open:"AI \u0C38\u0C39\u0C3E\u0C2F\u0C15\u0C41\u0C21\u0C3F\u0C28\u0C3F \u0C24\u0C46\u0C30\u0C35\u0C02\u0C21\u0C3F",inputLanguage:"\u0C07\u0C28\u0C4D\u200C\u0C2A\u0C41\u0C1F\u0C4D \u0C2D\u0C3E\u0C37",speakNow:"\u0C2E\u0C40 \u0C2A\u0C4D\u0C30\u0C36\u0C4D\u0C28 \u0C1A\u0C46\u0C2A\u0C4D\u0C2A\u0C02\u0C21\u0C3F",working:"\u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41\u2026",english:"English",telugu:"\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41",searchStarted:e=>`\u201C${e}\u201D \u0C15\u0C4B\u0C38\u0C02 \u0C36\u0C4B\u0C27\u0C3F\u0C38\u0C4D\u0C24\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41.`,sortedAscending:e=>`${e}\u0C28\u0C41 \u0C06\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u0C32\u0C4B \u0C05\u0C2E\u0C30\u0C4D\u0C1A\u0C3E\u0C28\u0C41.`,sortedDescending:e=>`${e}\u0C28\u0C41 \u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u0C32\u0C4B \u0C05\u0C2E\u0C30\u0C4D\u0C1A\u0C3E\u0C28\u0C41.`,count:e=>`\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C32\u0C4B \u0C2E\u0C4A\u0C24\u0C4D\u0C24\u0C02 ${e} \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C09\u0C28\u0C4D\u0C28\u0C3E\u0C2F\u0C3F.`,highest:(e,t,n)=>`\u0C05\u0C24\u0C4D\u0C2F\u0C27\u0C3F\u0C15 ${e} \u0C35\u0C3F\u0C32\u0C41\u0C35 ${t}. \u0C07\u0C26\u0C3F ${n}\u0C15\u0C41 \u0C38\u0C02\u0C2C\u0C02\u0C27\u0C3F\u0C02\u0C1A\u0C3F\u0C28\u0C26\u0C3F.`,lowest:(e,t,n)=>`\u0C05\u0C24\u0C4D\u0C2F\u0C32\u0C4D\u0C2A ${e} \u0C35\u0C3F\u0C32\u0C41\u0C35 ${t}. \u0C07\u0C26\u0C3F ${n}\u0C15\u0C41 \u0C38\u0C02\u0C2C\u0C02\u0C27\u0C3F\u0C02\u0C1A\u0C3F\u0C28\u0C26\u0C3F.`,average:(e,t)=>`${e} \u0C38\u0C17\u0C1F\u0C41 \u0C35\u0C3F\u0C32\u0C41\u0C35 ${t}.`,total:(e,t)=>`${e} \u0C2E\u0C4A\u0C24\u0C4D\u0C24\u0C02 \u0C35\u0C3F\u0C32\u0C41\u0C35 ${t}.`,noData:"\u0C35\u0C3F\u0C36\u0C4D\u0C32\u0C47\u0C37\u0C3F\u0C02\u0C1A\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C21\u0C47\u0C1F\u0C3E \u0C32\u0C47\u0C26\u0C41.",noColumn:"\u0C35\u0C3F\u0C36\u0C4D\u0C32\u0C47\u0C37\u0C3F\u0C02\u0C1A\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C24\u0C17\u0C3F\u0C28 \u0C15\u0C3E\u0C32\u0C2E\u0C4D \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.",noNumericData:e=>`${e}\u0C32\u0C4B \u0C38\u0C02\u0C16\u0C4D\u0C2F\u0C3E \u0C38\u0C2E\u0C3E\u0C1A\u0C3E\u0C30\u0C02 \u0C32\u0C47\u0C26\u0C41.`,notFound:e=>`\u201C${e}\u201D\u0C15\u0C41 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C32\u0C47 \u0C38\u0C2E\u0C3E\u0C1A\u0C3E\u0C30\u0C02 \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.`,needName:"\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C12\u0C15 \u0C35\u0C3F\u0C32\u0C41\u0C35 \u0C07\u0C35\u0C4D\u0C35\u0C02\u0C21\u0C3F.",fallback:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C32\u0C4B \u0C36\u0C4B\u0C27\u0C28, \u0C15\u0C4D\u0C30\u0C2E\u0C2C\u0C26\u0C4D\u0C27\u0C40\u0C15\u0C30\u0C23, \u0C32\u0C46\u0C15\u0C4D\u0C15\u0C3F\u0C02\u0C2A\u0C41 \u0C2E\u0C30\u0C3F\u0C2F\u0C41 \u0C21\u0C47\u0C1F\u0C3E \u0C35\u0C3F\u0C36\u0C4D\u0C32\u0C47\u0C37\u0C23 \u0C1A\u0C47\u0C2F\u0C17\u0C32\u0C28\u0C41.",unsupportedVoice:"\u0C08 \u0C2C\u0C4D\u0C30\u0C4C\u0C1C\u0C30\u0C4D\u200C\u0C32\u0C4B \u0C35\u0C3E\u0C2F\u0C3F\u0C38\u0C4D \u0C07\u0C28\u0C4D\u200C\u0C2A\u0C41\u0C1F\u0C4D\u200C\u0C15\u0C41 \u0C2E\u0C26\u0C4D\u0C26\u0C24\u0C41 \u0C32\u0C47\u0C26\u0C41."}};function Ge(e){return e.toLowerCase().trim().replace(/\s+/g," ")}function na(e,t){let n=Ge(e);if(t==="te-IN")return/^(శోధించు|శోధించండి|వెతుకు|వెతకండి|చూపించు|చూపించండి|ఫిల్టర్)/.test(n)?{type:"search",payload:n.replace(/^(శోధించు|శోధించండి|వెతుకు|వెతకండి|చూపించు|చూపించండి|ఫిల్టర్)\s*/u,"").trim()||e}:/క్రమబద్ధీకర|అమర్చ|సార్ట్/.test(n)?{type:"sort",payload:{key:void 0,dir:/అవరోహణ|పెద్ద|అధిక|చివర/.test(n)?"desc":"asc"}}:/ఎన్ని|ఎంతమంది|లెక్క|మొత్తం వరుస|వరుసలు/.test(n)?{type:"question",payload:e}:/అత్యధిక|గరిష్ఠ|పెద్ద|ఎక్కువ/.test(n)?{type:"question",payload:e}:/అత్యల్ప|కనిష్ఠ|చిన్న|తక్కువ/.test(n)?{type:"question",payload:e}:/సగటు|సగటు విలువ/.test(n)?{type:"question",payload:e}:/మొత్తం|కలిపి/.test(n)?{type:"question",payload:e}:{type:"search",payload:e};if(/^(search|find|show|filter)/.test(n))return{type:"search",payload:n.replace(/^(search|find|show|filter)\s+(for\s+|by\s+)?/,"").trim()||e};if(/sort/.test(n)){let o=/desc|descending|high|higher|large|largest|top/.test(n);return{type:"sort",payload:{key:n.match(/(?:by|on)\s+([a-z0-9_-]+)/)?.[1],dir:o?"desc":"asc"}}}return/how many|count|highest|maximum|max|top|largest|lowest|minimum|min|smallest|bottom|average|avg|mean|sum|total|who|which|where|whose/.test(n)?{type:"question",payload:e}:{type:"search",payload:e}}function No(e,t){let n=Ge(e);return t.find(o=>{let r=Ge(o.key),s=Ge(o.label);return n.includes(r)||n.includes(s)})}function qt(e,t){return e.toLocaleString(t==="te-IN"?"te-IN":"en-IN")}function oa(e,t,n,o){let r=Mo[o];if(t.length===0)return r.noData;let s=Ge(e),i=n.filter(k=>k.type==="number"),a=No(e,n),l=a?.type==="number"?a:i[0],c=/how many|count|rows|ఎన్ని|ఎంతమంది|లెక్క|వరుసలు/.test(s);if(c)return r.count(t.length);if(/highest|maximum|max|top|largest|అత్యధిక|గరిష్ఠ|పెద్ద|ఎక్కువ/.test(s)){let k=a??l;if(!k)return r.noColumn;let m=t.map(C=>({row:C,value:Number(C[k.key])})).filter(C=>!Number.isNaN(C.value)).sort((C,F)=>F.value-C.value);if(m.length===0)return r.noNumericData(k.label);let v=m[0],w=n.find(C=>C.key==="name"||Ge(C.label)==="name"),A=w?String(v.row[w.key]??""):o==="te-IN"?"\u0C08 \u0C35\u0C30\u0C41\u0C38":"this row";return r.highest(k.label,qt(v.value,o),A)}if(/lowest|minimum|min|smallest|bottom|అత్యల్ప|కనిష్ఠ|చిన్న|తక్కువ/.test(s)){let k=a??l;if(!k)return r.noColumn;let m=t.map(C=>({row:C,value:Number(C[k.key])})).filter(C=>!Number.isNaN(C.value)).sort((C,F)=>C.value-F.value);if(m.length===0)return r.noNumericData(k.label);let v=m[0],w=n.find(C=>C.key==="name"||Ge(C.label)==="name"),A=w?String(v.row[w.key]??""):o==="te-IN"?"\u0C08 \u0C35\u0C30\u0C41\u0C38":"this row";return r.lowest(k.label,qt(v.value,o),A)}if(/average|avg|mean|సగటు/.test(s)){let k=a??l;if(!k)return r.noColumn;let m=t.map(w=>Number(w[k.key])).filter(w=>!Number.isNaN(w));if(m.length===0)return r.noNumericData(k.label);let v=m.reduce((w,A)=>w+A,0)/m.length;return r.average(k.label,qt(Math.round(v*100)/100,o))}if(/sum|total|మొత్తం|కలిపి/.test(s)&&!c){let k=a??l;if(!k)return r.noColumn;let m=t.map(w=>Number(w[k.key])).filter(w=>!Number.isNaN(w));if(m.length===0)return r.noNumericData(k.label);let v=m.reduce((w,A)=>w+A,0);return r.total(k.label,qt(v,o))}let f=s.match(/[\p{L}\p{N}_-]+/gu)??[],h=new Set(["who","what","which","where","whose","is","the","has","have","show","find","search","for","by","about"]),x=f.filter(k=>!h.has(k)).join(" ").trim();if(x){let k=t.find(m=>Object.values(m).some(v=>String(v??"").toLowerCase().includes(x.toLowerCase())));return k?n.map(m=>`${m.label}: ${String(k[m.key]??"")}`).join(o==="te-IN"?" \xB7 ":", "):r.notFound(x)}return r.fallback}function ra(e,t){if(typeof window>"u"||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.lang=t,n.rate=1,n.pitch=1,window.speechSynthesis.speak(n)}function ia(e){let[t,n]=_e(!1),[o,r]=_e(""),[s,i]=_e(!0),a=Po(null);wt(()=>{if(typeof window>"u")return;let u=window.SpeechRecognition||window.webkitSpeechRecognition;if(!u){i(!1),a.current=null;return}let b=new u;return b.continuous=!1,b.interimResults=!1,b.lang=e,b.onresult=p=>{let g=p?.results?.[0]?.[0]?.transcript??"";r(g),n(!1)},b.onerror=()=>{n(!1)},b.onend=()=>{n(!1)},a.current=b,()=>{try{b.stop()}catch{}a.current=null}},[e]);let l=Tn(()=>{if(a.current){r(""),n(!0);try{a.current.start()}catch{n(!1)}}},[]),c=Tn(()=>{try{a.current?.stop()}catch{}n(!1)},[]);return{listening:t,transcript:o,supported:s,start:l,stop:c}}function sa(){return ye("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[L("circle",{cx:"11",cy:"11",r:"6.5"}),L("path",{d:"m16 16 5 5"})]})}function aa(){return ye("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[L("rect",{x:"8",y:"3",width:"8",height:"12",rx:"4"}),L("path",{d:"M5 11a7 7 0 0 0 14 0"}),L("path",{d:"M12 18v3"}),L("path",{d:"M8 21h8"})]})}function la(){return ye("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[L("path",{d:"m4 4 16 8-16 8 4-8-4-8Z"}),L("path",{d:"M8 12h12"})]})}function ca(){return ye("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[L("path",{d:"m6 6 12 12"}),L("path",{d:"m18 6-12 12"})]})}function ua({data:e,columns:t,onSearch:n,onSort:o,theme:r="light",language:s="en-US",inputLanguage:i="en-US",embedded:a=!1,agent:l,onInputLanguageChange:c}){let u=Mo[s],[b,p]=_e(i);wt(()=>{p(i)},[i]);let[g,f]=_e(!1),h=r==="dark",[d,x]=_e(a),[k,m]=_e(""),[v,w]=_e([]),A=Po(null),{listening:C,transcript:F,supported:D,start:M,stop:E}=ia(b),I=Lo(()=>({bg:h?"#0F172A":"#FFFFFF",surface:h?"#1E293B":"#F8FAFC",border:h?"#334155":"#E2E8F0",text:h?"#F1F5F9":"#0F172A",muted:h?"#94A3B8":"#64748B",accent:"#10B981",userMsg:h?"#334155":"#DBEAFE",aiMsg:h?"#1E293B":"#F0FDF4"}),[h]),y=Lo(()=>({role:"ai",text:s==="te-IN"?"\u0C2E\u0C40 \u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D \u0C21\u0C47\u0C1F\u0C3E \u0C17\u0C41\u0C30\u0C3F\u0C02\u0C1A\u0C3F \u0C2A\u0C4D\u0C30\u0C36\u0C4D\u0C28 \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F.":"Ask me about your grid data.",time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),[s]);wt(()=>{w(z=>z.length>0?z:[y])},[y]),wt(()=>{A.current?.scrollIntoView({behavior:"smooth"})},[v]);let q=()=>new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),B=Tn(async z=>{let H=z.trim();if(!H)return;w(P=>[...P,{role:"user",text:H,time:q()}]),m("");let T="";if(l){f(!0);try{T=(await l.ask(H)).message}catch{T=u.fallback}finally{f(!1)}}else{let P=na(H,s);if(P.type==="question")T=oa(P.payload??H,e,t,s);else if(P.type==="search"){let J=String(P.payload??H);n?.(J),T=u.searchStarted(J)}else if(P.type==="sort"){let J=P.payload?.key,W=J?t.find(ae=>Ge(ae.key)===Ge(J)||Ge(ae.label)===Ge(J)):void 0;if(W||(W=No(H,t)),W&&o){let ae=P.payload?.dir==="desc"?"desc":"asc";o(String(W.key),ae),T=ae==="asc"?u.sortedAscending(W.label):u.sortedDescending(W.label)}else T=u.noColumn}}T||(T=u.fallback),w(P=>[...P,{role:"ai",text:T,time:q()}]),ra(T,s)},[l,t,e,s,n,o,u]);wt(()=>{F&&B(F)},[F,B]);let U=()=>{B(k)},oe=s==="te-IN"?["\u0C0E\u0C28\u0C4D\u0C28\u0C3F \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41","\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F","\u0C15\u0C4D\u0C30\u0C2E\u0C02"]:["how many rows","search","sort"],de=ye("div",{style:{width:a?"100%":360,maxWidth:a?"100%":"calc(100vw - 48px)",height:a?390:480,maxHeight:"70vh",background:I.bg,border:`1px solid ${I.border}`,borderRadius:a?12:16,boxShadow:a?"none":"0 20px 40px rgba(0,0,0,0.15)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[ye("div",{style:{padding:"12px 14px",background:I.accent,color:"#FFFFFF",display:"flex",alignItems:"center",gap:10},children:[L("div",{style:{width:34,height:34,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.18)",fontSize:17},children:"AI"}),ye("div",{style:{flex:1,minWidth:0},children:[L("div",{style:{fontWeight:700,fontSize:14},children:u.title}),L("div",{style:{fontSize:11,opacity:.9},children:u.subtitle})]}),!a&&L("button",{type:"button",onClick:()=>x(!1),"aria-label":u.close,title:u.close,style:{width:32,height:32,border:"none",borderRadius:8,background:"rgba(255,255,255,0.12)",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:L(ca,{})})]}),ye("div",{style:{padding:"8px 10px",borderBottom:`1px solid ${I.border}`,display:"flex",alignItems:"center",gap:8,background:I.surface},children:[L("span",{style:{fontSize:11,color:I.muted},children:u.inputLanguage}),ye("select",{value:b,onChange:z=>{let H=z.target.value;p(H),c?.(H)},disabled:C,"aria-label":u.inputLanguage,style:{padding:"5px 8px",borderRadius:7,border:`1px solid ${I.border}`,background:I.bg,color:I.text,fontSize:11},children:[L("option",{value:"en-US",children:"English (US)"}),L("option",{value:"en-IN",children:"English (India)"}),L("option",{value:"as-IN",children:"Assamese"}),L("option",{value:"bn-IN",children:"Bengali"}),L("option",{value:"brx-IN",children:"Bodo"}),L("option",{value:"doi-IN",children:"Dogri"}),L("option",{value:"gu-IN",children:"Gujarati"}),L("option",{value:"hi-IN",children:"Hindi"}),L("option",{value:"kn-IN",children:"Kannada"}),L("option",{value:"ks-IN",children:"Kashmiri"}),L("option",{value:"kok-IN",children:"Konkani"}),L("option",{value:"mai-IN",children:"Maithili"}),L("option",{value:"ml-IN",children:"Malayalam"}),L("option",{value:"mni-IN",children:"Manipuri"}),L("option",{value:"mr-IN",children:"Marathi"}),L("option",{value:"ne-IN",children:"Nepali"}),L("option",{value:"or-IN",children:"Odia"}),L("option",{value:"pa-IN",children:"Punjabi"}),L("option",{value:"sa-IN",children:"Sanskrit"}),L("option",{value:"sat-IN",children:"Santali"}),L("option",{value:"sd-IN",children:"Sindhi"}),L("option",{value:"ta-IN",children:"Tamil"}),L("option",{value:"te-IN",children:"Telugu"}),L("option",{value:"ur-IN",children:"Urdu"})]})]}),ye("div",{style:{flex:1,overflowY:"auto",padding:10,display:"flex",flexDirection:"column",gap:8},children:[v.map((z,H)=>ye("div",{style:{alignSelf:z.role==="user"?"flex-end":"flex-start",maxWidth:"88%",padding:"8px 11px",borderRadius:11,background:z.role==="user"?I.userMsg:I.aiMsg,color:I.text,fontSize:13,lineHeight:1.5},children:[L("div",{children:z.text}),L("div",{style:{marginTop:3,fontSize:10,opacity:.55,textAlign:"right"},children:z.time})]},`${z.time}-${H}`)),C&&L("div",{style:{alignSelf:"flex-end",padding:"8px 11px",borderRadius:11,background:h?"#3F1D2E":"#FEE2E2",color:h?"#FCA5A5":"#991B1B",fontSize:13},children:u.listening}),(g||l?.loading)&&L("div",{role:"status","aria-live":"polite",style:{alignSelf:"flex-start",padding:"8px 11px",borderRadius:11,background:I.aiMsg,color:I.muted,fontSize:13},children:u.working}),L("div",{ref:A})]}),L("div",{style:{padding:"7px 10px",borderTop:`1px solid ${I.border}`,display:"flex",gap:6,overflowX:"auto",flexShrink:0},children:oe.map(z=>L("button",{type:"button",onClick:()=>B(z),style:{padding:"5px 9px",borderRadius:12,border:`1px solid ${I.border}`,background:I.surface,color:I.text,fontSize:10.5,cursor:"pointer",whiteSpace:"nowrap"},children:z},z))}),ye("div",{style:{padding:9,display:"flex",gap:6,borderTop:`1px solid ${I.border}`,background:I.surface},children:[ye("div",{style:{position:"relative",flex:1},children:[L(sa,{}),L("input",{type:"text",value:k,onChange:z=>m(z.target.value),onKeyDown:z=>{z.key==="Enter"&&U()},placeholder:u.placeholder,"aria-label":u.ask,style:{width:"100%",boxSizing:"border-box",padding:"9px 10px 9px 34px",borderRadius:8,border:`1px solid ${I.border}`,background:I.bg,color:I.text,fontSize:12,outline:"none"}})]}),D?L("button",{type:"button",onClick:C?E:M,"aria-label":C?u.listening:u.speakNow,title:C?u.listening:u.speakNow,style:{width:38,height:38,border:"none",borderRadius:8,background:C?"#EF4444":I.accent,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},children:L(aa,{})}):null,L("button",{type:"button",onClick:U,disabled:!k.trim(),"aria-label":u.send,title:u.send,style:{width:38,height:38,border:"none",borderRadius:8,background:k.trim()?I.accent:I.muted,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:k.trim()?"pointer":"not-allowed",opacity:k.trim()?1:.6,flexShrink:0},children:L(la,{})})]})]});return a?L("div",{style:{width:"100%",minWidth:0},children:d?de:ye("button",{type:"button",onClick:()=>x(!0),"aria-label":u.open,style:{minHeight:40,padding:"8px 13px",borderRadius:9,border:"1px solid #10B981",background:h?"#064E3B":"#ECFDF5",color:h?"#A7F3D0":"#047857",display:"inline-flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12,fontWeight:600},children:[L("span",{"aria-hidden":"true",children:"AI"}),u.ask]})}):ye(da,{children:[!d&&L("button",{type:"button",onClick:()=>x(!0),"aria-label":u.open,title:u.title,style:{position:"fixed",bottom:24,right:24,zIndex:9998,width:56,height:56,borderRadius:28,background:I.accent,color:"#FFFFFF",border:"none",cursor:"pointer",boxShadow:"0 8px 20px rgba(16,185,129,0.3)",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:14},children:"AI"}),d&&L("div",{style:{position:"fixed",bottom:90,right:24,zIndex:9997},children:de}),L("style",{children:`
385
+ `,document.body.appendChild(e),xo=e}function Ro(e){return e.getAttribute("aria-label")?.trim()||e.getAttribute("aria-labelledby")||e.getAttribute("title")?.trim()||e.textContent?.trim()?!0:!!e.querySelector("img[alt]:not([alt='']), svg[aria-label], svg title, [aria-label]")}function Io(e){let t={critical:20,serious:10,moderate:5,minor:2},n=e.details.reduce((o,r)=>o+(t[r.severity]||0),0);return Math.max(0,Math.min(100,100-n))}var ke={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";st=e,dl(e),pl(),gl(),il(),al(),e.showSkipLinks!==!1&&rl(),e.showPreferencePanel,ul(e);let t=this.applyFixes(e);t.score=Io(t),e.showAuditBadge&&ll(t),e.timeoutWarning&&Eo(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await vo(!0),e.summarisePage&&await So(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await To(e.translateLanguage),e.voiceControl&&await Ao(!0),e.smartLabels&&await Co(!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(),o=document.querySelectorAll("*");t.scanned=o.length;let r=(a,i,s,l)=>{t.details.push({tag:a,fix:i,severity:s,element:l.outerHTML.slice(0,100)}),t.fixed++};return o.forEach(a=>{let i=a,s=i.tagName.toLowerCase();if(s==="html"&&!i.getAttribute("lang")&&(i.setAttribute("lang","en"),r(s,'lang="en" added',"critical",i)),s==="meta"){let u=i.getAttribute("name"),b=i.getAttribute("content")||"";u==="viewport"&&b.includes("user-scalable=no")&&(i.setAttribute("content",b.replace("user-scalable=no","user-scalable=yes")),r(s,"user-scalable=yes restored","serious",i)),u==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(b)&&(i.setAttribute("content",b.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),r(s,"maximum-scale=5 restored","serious",i))}if(s==="main"&&!i.getAttribute("tabindex")&&(i.setAttribute("tabindex","-1"),i.getAttribute("id")||i.setAttribute("id","main-content")),s==="img"&&(i.hasAttribute("alt")||(i.setAttribute("alt",""),i.setAttribute("aria-hidden","true"),r(s,'alt="" aria-hidden="true"',"serious",i))),s==="svg"&&(!i.getAttribute("aria-hidden")&&!i.getAttribute("aria-label")&&!a.querySelector("title")&&(i.setAttribute("aria-hidden","true"),r(s,'aria-hidden="true" (decorative svg)',"minor",i)),i.getAttribute("focusable")||i.setAttribute("focusable","false")),s==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&(i.setAttribute("title","embedded content"),i.setAttribute("aria-label","embedded content"),r(s,"title + aria-label added","serious",i)),s==="button"){if(!Ro(i)){let u=i.getAttribute("title")||"button";i.setAttribute("aria-label",u),r(s,`aria-label="${u}" (empty button)`,"critical",i)}i.hasAttribute("disabled")&&!i.getAttribute("aria-disabled")&&(i.setAttribute("aria-disabled","true"),t.fixed++)}if(s==="a"){let u=i;Ro(i)||(i.setAttribute("aria-label",i.getAttribute("title")||"link"),r(s,"aria-label added (empty link)","critical",i)),u.target==="_blank"&&!u.rel?.includes("noopener")&&(u.rel="noopener noreferrer",t.fixed++)}if(ko.has(s)){let u=i;if(!(!!(u.labels&&u.labels.length)||!!i.getAttribute("title")||u.type==="hidden"||u.type==="submit"||u.type==="button"||u.type==="reset")&&!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")){let p=i.getAttribute("placeholder")||i.getAttribute("name")||s;i.setAttribute("aria-label",p),r(s,`aria-label="${p}"`,"serious",i)}if(i.hasAttribute("required")&&!i.getAttribute("aria-required")&&(i.setAttribute("aria-required","true"),t.fixed++),s==="input"&&!u.autocomplete){let p=u.name||"",g=u.type==="email"||p.includes("email")?"email":u.type==="tel"||p.includes("tel")?"tel":u.type==="password"?"current-password":"";g&&(u.autocomplete=g,t.fixed++)}}s==="th"&&!i.getAttribute("scope")&&(i.setAttribute("scope",i.closest("thead")?"col":"row"),r(s,"scope added to <th>","moderate",i));let l=(s==="header"||s==="footer")&&!!i.parentElement?.closest("article,aside,main,nav,section,[role='dialog'],[role='region']");yn[s]&&!i.getAttribute("role")&&!l&&(i.setAttribute("role",yn[s]),r(s,`role="${yn[s]}"`,"minor",i));let c=i.getAttribute("role")||"";c==="tab"&&!i.getAttribute("aria-selected")&&(i.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(c)&&!i.getAttribute("aria-live")&&(i.setAttribute("aria-live",c==="alert"?"assertive":"polite"),r(s,`aria-live added on role=${c}`,"moderate",i)),c==="combobox"&&!i.getAttribute("aria-expanded")&&(i.setAttribute("aria-expanded","false"),r(s,'aria-expanded="false" on combobox',"serious",i)),(c==="checkbox"||c==="radio")&&!i.getAttribute("aria-checked")&&(i.setAttribute("aria-checked","false"),r(s,`aria-checked="false" on role=${c}`,"serious",i))}),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 o=(r,a,i,s)=>e.details.push({tag:r,fix:a,severity:i,element:s.outerHTML.slice(0,100)});return n.forEach(r=>{let a=r,i=a.tagName.toLowerCase();(i==="a"||i==="button")&&!a.innerText?.trim()&&!a.getAttribute("aria-label")&&o(i,"needs aria-label (empty)","critical",a),i==="img"&&!a.hasAttribute("alt")&&o(i,"needs alt text","serious",a),ko.has(i)&&!a.getAttribute("aria-label")&&!a.getAttribute("aria-labelledby")&&o(i,"needs aria-label","serious",a),i==="iframe"&&!a.getAttribute("title")&&!a.getAttribute("aria-label")&&o(i,"iframe needs title","serious",a)}),e.fixed=e.details.length,e.score=Io(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:xn,showVisualAlert:$o,trapFocus:Ot,handlePlainEnglish:vo,handleSummarisePage:So,handleTranslate:To,handleVoiceControl:Ao,handleSmartLabels:Co,SUPPORTED_LANGUAGES:Pt};import Pl,{useEffect as ut,useState as ce,useCallback as dt}from"react";import{forwardRef as fl,useEffect as Wt,useState as Ze}from"react";import{jsx as R,jsxs as Q}from"react/jsx-runtime";var wn={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},lt=[80,90,100,110,120,130],ml=[{value:"none",label:"None"},{value:"deuteranopia",label:"Deuteranopia"},{value:"protanopia",label:"Protanopia"},{value:"tritanopia",label:"Tritanopia"},{value:"achromatopsia",label:"Greyscale"}],bl=["Prompt API for Gemini Nano","Summarization API for Gemini Nano","Writer API for Gemini Nano","Rewriter API for Gemini Nano","Translation API"];function hl(){let[e,t]=Ze(typeof window<"u"?window.innerWidth:1024);return Wt(()=>{let n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),{isMobile:e<=480,isTablet:e>480&&e<=768}}function yl({checked:e,onChange:t,label:n,disabled:o=!1}){return Q("label",{"aria-label":n,style:{position:"relative",display:"inline-flex",width:"40px",height:"24px",cursor:o?"not-allowed":"pointer",flexShrink:0,opacity:o?.4:1},children:[R("input",{type:"checkbox",checked:e,disabled:o,onChange:r=>t(r.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),R("span",{style:{position:"absolute",inset:0,borderRadius:"99px",background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),R("span",{style:{position:"absolute",top:"3px",left:e?"19px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function ct({label:e,color:t="#64748b",badge:n,concept:o}){return Q("div",{style:{margin:"10px 18px 4px"},children:[Q("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[R("p",{style:{margin:0,fontSize:"10px",fontWeight:600,color:t,letterSpacing:"0.06em",textTransform:"uppercase"},children:e}),n&&R("span",{style:{fontSize:"9px",fontWeight:500,padding:"1px 7px",borderRadius:"99px",background:"#f5f3ff",color:"#7c3aed",border:"0.5px solid #c4b5fd",whiteSpace:"nowrap"},children:n})]}),o&&R("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8",fontStyle:"italic"},children:o})]})}function $e({icon:e,label:t,desc:n,checked:o,onChange:r,disabled:a=!1,disabledReason:i,tip:s}){return Q("div",{title:a?i:s,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:"12px"},children:[Q("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[R("span",{"aria-hidden":"true",style:{width:"32px",height:"32px",borderRadius:"8px",background:a?"#f1f5f9":"#f0fdfa",color:a?"#94a3b8":"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"15px",flexShrink:0,fontWeight:700},children:e}),Q("div",{style:{minWidth:0},children:[R("p",{style:{margin:0,fontSize:"13px",fontWeight:500,color:a?"#94a3b8":"#0f172a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),R("p",{style:{margin:0,fontSize:"10px",color:"#94a3b8"},children:a?i:n})]})]}),R(yl,{checked:o,onChange:r,label:`Toggle ${t}`,disabled:a})]})}function he(){return R("div",{style:{height:"1px",background:"#f1f5f9"}})}function yt({steps:e}){return Q("div",{style:{margin:"0 18px 8px",padding:"8px 10px",background:"#f8fafc",borderRadius:"8px",border:"0.5px solid #e2e8f0"},children:[R("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)=>Q("p",{style:{margin:"0 0 2px",fontSize:"10px",color:"#475569"},children:[n+1,". ",t]},n))]})}var kn=fl(({position:e,settings:t,report:n,isActive:o,aiSupported:r,voiceSupported:a,set:i,onApply:s,onReset:l,onClose:c},u)=>{let{isMobile:b,isTablet:p}=hl(),[g,f]=Ze([]),[h,d]=Ze(""),[x,k]=Ze(""),[m,v]=Ze(!1),[w,A]=Ze(null),[C,G]=Ze("idle");Wt(()=>{let y=window;!!(y.LanguageModel||y.ai?.languageModel)&&r?A("gemini"):$t()&&A("transformers")},[r]),Wt(()=>{if(w!=="transformers")return;let y=setInterval(()=>{G(Et())},500);return()=>clearInterval(y)},[w]);let D=async()=>{if(!(!h.trim()||m)){if(!w){k("\u26A0\uFE0F No AI engine available on this device.");return}v(!0),k("");try{let y;w==="gemini"?y=await Xn(h):(G("loading"),y=await eo(h),G("ready")),k(y.success&&y.answer?y.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+(y.error||"No answer found on this page"))}catch{k("\u26A0\uFE0F Failed to get answer. Please try again.")}v(!1)}};Wt(()=>{(async()=>{try{let q=window;if(!q.queryLocalFonts)return;let B=await q.queryLocalFonts(),j=[...new Set(B.map(oe=>oe.family))].sort();f(j.slice(0,50))}catch{}})()},[]);let M=w==="gemini"?"Gemini Nano":w==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",E=w==="transformers"&&C==="loading"?"Loading AI model... (first time only)":"...",I=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: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 Q("div",{ref:u,role:"dialog","aria-modal":"true","aria-label":"yuktai accessibility preferences","data-yuktai-panel":"true",style:I,children:[Q("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:[Q("div",{children:[Q("div",{style:{display:"flex",alignItems:"center",gap:"7px",marginBottom:"4px",flexWrap:"wrap"},children:[R("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai"}),o&&R("span",{style:{fontSize:"10px",fontWeight:700,padding:"2px 7px",borderRadius:"99px",background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),R("p",{style:{margin:"0 0 1px",fontSize:"15px",fontWeight:600,color:"#0f172a"},children:"Accessibility"}),R("p",{style:{margin:0,fontSize:"11px",color:"#64748b"},children:"WCAG 2.2 \xB7 Open source \xB7 Zero cost \xB7 All devices"})]}),R("button",{onClick:c,"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"})]}),R(ct,{label:"\u267F Core Accessibility",concept:"Rule-based engine \u2014 works on all browsers and devices"}),R(yt,{steps:["Toggle any feature on","Click Apply settings","Preferences saved automatically"]}),R($e,{icon:"\u{1F527}",label:"Auto-fix ARIA",desc:"Injects missing labels and roles automatically",checked:t.autoFix,onChange:y=>i("autoFix",y),tip:"Fixes aria-label, alt text, roles on every element"}),R(he,{}),R($e,{icon:"\u{1F50A}",label:"Speak on focus",desc:"Browser reads elements aloud as you tab",checked:t.speechEnabled,onChange:y=>i("speechEnabled",y),tip:"Uses browser SpeechSynthesis \u2014 no install needed"}),R(he,{}),R($e,{icon:"\u{1F399}\uFE0F",label:"Voice control",desc:"Say commands to navigate the page",checked:t.voiceControl,onChange:y=>i("voiceControl",y),disabled:!a,disabledReason:"Not supported in this browser",tip:'Say "scroll down", "go to main", "click"'}),R(he,{}),R(ct,{label:"\u{1F916} AI Features",color:"#7c3aed",badge:"Gemini Nano",concept:"Large Language Model running privately on your device \u2014 Chrome 127+ only"}),R("div",{style:{margin:"4px 18px 6px",padding:"8px 10px",background:r?"#f0fdfa":"#f5f3ff",borderRadius:"8px",border:`0.5px solid ${r?"#99f6e4":"#c4b5fd"}`,fontSize:"10px",color:r?"#0f766e":"#7c3aed",lineHeight:1.5},children:r?"\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."}),!r&&Q("div",{style:{margin:"0 18px 8px",padding:"10px 12px",background:"#fafafa",borderRadius:"8px",border:"0.5px solid #e2e8f0",fontSize:"11px",color:"#475569",lineHeight:1.7},children:[R("p",{style:{margin:"0 0 6px",fontWeight:600,color:"#0f172a",fontSize:"11px"},children:"\u{1F6E0} One-time setup \u2014 5 steps:"}),Q("p",{style:{margin:"0 0 3px"},children:["1. Open Chrome \u2192 ",R("code",{style:{background:"#f1f5f9",padding:"1px 5px",borderRadius:"4px",fontSize:"10px",color:"#0d9488",fontFamily:"monospace"},children:"chrome://flags"})]}),R("p",{style:{margin:"0 0 3px"},children:"2. Enable each flag:"}),R("div",{style:{display:"flex",flexDirection:"column",gap:"2px",margin:"4px 0 6px 10px"},children:bl.map(y=>Q("span",{style:{fontSize:"10px",color:"#7c3aed",fontFamily:"monospace"},children:["\u2192 ",y]},y))}),Q("p",{style:{margin:"0 0 3px"},children:["3. Click ",R("strong",{style:{color:"#0f172a"},children:"Relaunch"})]}),Q("p",{style:{margin:"0 0 3px"},children:["4. ",R("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"]}),R("p",{style:{margin:"0"},children:"5. Refresh \u2014 AI features unlock automatically \u2705"})]}),R($e,{icon:"\u{1F4DD}",label:"Plain English mode",desc:"Rewrites complex text in simple language",checked:t.plainEnglish,onChange:y=>i("plainEnglish",y),disabled:!r,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: LLM text rewriting"}),R(he,{}),R($e,{icon:"\u{1F4CB}",label:"Summarise page",desc:"3-sentence summary appears at top",checked:t.summarisePage,onChange:y=>i("summarisePage",y),disabled:!r,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Abstractive summarisation"}),R(he,{}),R($e,{icon:"\u{1F3F7}\uFE0F",label:"Smart aria-labels",desc:"AI generates meaningful labels for elements",checked:t.smartLabels,onChange:y=>i("smartLabels",y),disabled:!r,disabledReason:"Enable Gemini Nano \u2014 see setup above",tip:"AI concept: Context-aware label generation"}),R(he,{}),R(ct,{label:"\u{1F441}\uFE0F Visual",concept:"CSS filter-based \u2014 works on all browsers and devices"}),R(yt,{steps:["Toggle any visual mode","Changes apply instantly","Works on mobile and desktop"]}),R($e,{icon:"\u25D1",label:"High contrast",desc:"Boosts contrast for low vision users",checked:t.highContrast,onChange:y=>i("highContrast",y),tip:"CSS filter: contrast()"}),R(he,{}),R($e,{icon:"\u{1F319}",label:"Dark mode",desc:"Inverts colours \u2014 easy on eyes at night",checked:t.darkMode,onChange:y=>i("darkMode",y),tip:"CSS filter: invert + hue-rotate"}),R(he,{}),R($e,{icon:"\u23F8\uFE0F",label:"Reduce motion",desc:"Disables all animations",checked:t.reduceMotion,onChange:y=>i("reduceMotion",y),tip:"WCAG 2.3.3 \u2014 vestibular disorders"}),R(he,{}),R($e,{icon:"\u{1F446}",label:"Large targets",desc:"44\xD744px minimum touch targets",checked:t.largeTargets,onChange:y=>i("largeTargets",y),tip:"WCAG 2.5.8 \u2014 motor impaired users"}),R(he,{}),Q("div",{style:{padding:"10px 18px"},children:[R("p",{style:{margin:"0 0 2px",fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F3A8} Colour blindness"}),R("p",{style:{margin:"0 0 8px",fontSize:"10px",color:"#94a3b8"},children:"SVG colour matrix filters \u2014 all devices"}),R("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ml.map(y=>R("button",{onClick:()=>i("colorBlindMode",y.value),"aria-pressed":t.colorBlindMode===y.value,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.colorBlindMode===y.value?"#0d9488":"#e2e8f0"}`,background:t.colorBlindMode===y.value?"#f0fdfa":"#fff",color:t.colorBlindMode===y.value?"#0d9488":"#64748b",cursor:"pointer",minHeight:b?"36px":"auto"},children:y.label},y.value))})]}),R(he,{}),R(ct,{label:"\u{1F524} Font",concept:"Browser Font API + CSS \u2014 Chrome 103+"}),R(yt,{steps:["Toggle dyslexia font or pick from device","Adjust size with + / \u2212","Saved across visits"]}),R($e,{icon:"Aa",label:"Dyslexia-friendly font",desc:"Atkinson Hyperlegible \u2014 research-backed",checked:t.dyslexiaFont,onChange:y=>i("dyslexiaFont",y),tip:"By Braille Institute \u2014 free and open source"}),R(he,{}),Q("div",{style:{padding:"10px 18px"},children:[R("p",{style:{margin:"0 0 2px",fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F5A5}\uFE0F Local font"}),R("p",{style:{margin:"0 0 8px",fontSize:"10px",color:"#94a3b8"},children:"window.queryLocalFonts() \u2014 Chrome 103+"}),g.length>0?Q("select",{value:t.localFont,onChange:y=>i("localFont",y.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:[R("option",{value:"",children:"System default"}),g.map(y=>R("option",{value:y,style:{fontFamily:y},children:y},y))]}):R("p",{style:{margin:0,fontSize:"11px",color:"#94a3b8"},children:"Allow font access when Chrome prompts you."})]}),R(he,{}),Q("div",{style:{padding:"10px 18px 14px"},children:[Q("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},children:[Q("div",{children:[R("p",{style:{margin:0,fontSize:"12px",fontWeight:500,color:"#0f172a"},children:"\u{1F4CF} Text size"}),R("p",{style:{margin:0,fontSize:"10px",color:"#94a3b8"},children:"Scales all text on the page"})]}),Q("span",{style:{fontSize:"12px",fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:"99px"},children:[t.fontScale,"%"]})]}),Q("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[R("button",{onClick:()=>{let y=lt.indexOf(t.fontScale);y>0&&i("fontScale",lt[y-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"}),R("div",{style:{flex:1,display:"flex",gap:"3px"},children:lt.map(y=>R("button",{onClick:()=>i("fontScale",y),"aria-label":`Set text size to ${y}%`,style:{flex:1,height:"6px",borderRadius:"99px",border:"none",cursor:"pointer",padding:0,background:y<=t.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},y))}),R("button",{onClick:()=>{let y=lt.indexOf(t.fontScale);y<lt.length-1&&i("fontScale",lt[y+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:"+"})]})]}),R(he,{}),R(ct,{label:"\u{1F310} Translate",color:"#7c3aed",badge:"Gemini Nano",concept:"Chrome Translation API \u2014 on device, no internet after setup"}),R(yt,{steps:["Enable Gemini Nano first","Pick your language","Full page translates instantly"]}),Q("div",{style:{padding:"6px 18px 12px"},children:[R("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Pt.slice(0,b?8:18).map(y=>R("button",{onClick:()=>i("translateLanguage",y.code),"aria-pressed":t.translateLanguage===y.code,disabled:!r,style:{padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:500,border:`1px solid ${t.translateLanguage===y.code?"#7c3aed":"#e2e8f0"}`,background:t.translateLanguage===y.code?"#f5f3ff":"#fff",color:t.translateLanguage===y.code?"#7c3aed":"#64748b",cursor:r?"pointer":"not-allowed",opacity:r?1:.5,minHeight:b?"36px":"auto"},children:y.label},y.code))}),!r&&R("p",{style:{margin:"6px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano using the setup guide above."})]}),R(he,{}),R(ct,{label:"\u{1F4AC} Ask This Page",color:"#0d9488",badge:M,concept:"RAG \u2014 Retrieval Augmented Generation. Works on all devices including mobile."}),R(yt,{steps:["Type any question about this page","Press Ask or hit Enter",w==="transformers"?"Transformers.js answers \u2014 works on mobile, offline":"Gemini Nano reads page and answers privately","Zero cost. No data leaves your device."]}),Q("div",{style:{margin:"0 18px 8px",padding:"6px 10px",background:w==="gemini"?"#f0fdfa":w==="transformers"?"#f5f3ff":"#f8fafc",borderRadius:"8px",border:`0.5px solid ${w==="gemini"?"#99f6e4":w==="transformers"?"#c4b5fd":"#e2e8f0"}`,fontSize:"10px",color:w==="gemini"?"#0f766e":w==="transformers"?"#7c3aed":"#94a3b8"},children:[w==="gemini"&&"\u2705 Using Gemini Nano \u2014 on device, private, instant",w==="transformers"&&"\u2705 Using Transformers.js \u2014 works on mobile and all browsers",!w&&"\u23F3 Detecting AI engine...",w==="transformers"&&C==="loading"&&" \xB7 Loading model...",w==="transformers"&&C==="ready"&&" \xB7 Model ready \u2705"]}),Q("div",{style:{padding:"0 18px 14px"},children:[Q("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[R("input",{type:"text",value:h,onChange:y=>d(y.target.value),onKeyDown:y=>{y.key==="Enter"&&D()},placeholder:"e.g. What does this page do?",disabled:m||!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:b?"44px":"36px"}}),R("button",{onClick:D,disabled:m||!h.trim()||!w,"aria-label":"Ask question",style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:w&&h.trim()&&!m?"#0d9488":"#e2e8f0",color:w&&h.trim()&&!m?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:w&&h.trim()&&!m?"pointer":"not-allowed",flexShrink:0,height:b?"44px":"36px",minWidth:"52px",transition:"background 0.2s"},children:m?E:"Ask"})]}),x&&Q("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:[R("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#0d9488"},children:"\u{1F4AC} Answer"}),x,R("button",{onClick:()=>{k(""),d("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]})]}),n&&R("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`}),Q("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:[R("button",{onClick:l,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"}),R("button",{onClick:s,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"})]})]})});kn.displayName="WidgetPanel";import{useState as xt,useCallback as Go}from"react";var xl={hotel:["hotel","resort","motel","inn","accommodation","lodge","stay","room","booking","hospitality"],ecommerce:["shop","store","ecommerce","e-commerce","sell","product","cart","buy","marketplace","retail"],restaurant:["restaurant","food","cafe","cafeteria","menu","dining","eat","cuisine","bistro","takeaway","delivery"],portfolio:["portfolio","freelance","personal","designer","developer","creative","showcase","work","hire me"],blog:["blog","article","post","write","news","magazine","journal","content"],saas:["saas","dashboard","app","software","platform","tool","analytics","admin","manage","crm"],government:["government","govt","portal","citizen","scheme","welfare","municipal","public","official"],healthcare:["hospital","clinic","doctor","health","medical","patient","appointment","pharmacy"],education:["school","college","university","course","learn","education","student","lms","training"],realestate:["real estate","property","house","flat","apartment","rent","buy property","listing"],landing:["landing","startup","launch","product launch","coming soon","waitlist"],generic:[]},wl={hotel:["home","rooms","booking","about","contact"],ecommerce:["home","products","cart","checkout","about","contact"],restaurant:["home","menu","reservations","about","contact"],portfolio:["home","portfolio","about","contact"],blog:["home","blog","about","contact"],saas:["home","pricing","dashboard","auth","about","contact"],government:["home","services","about","contact","faq"],healthcare:["home","services","booking","team","about","contact"],education:["home","services","pricing","about","contact"],realestate:["home","products","about","contact"],landing:["home","pricing","about","contact"],generic:["home","about","services","contact"]},kl={home:["home","homepage","main","landing"],about:["about","who we are","our story","company"],contact:["contact","reach us","get in touch","location"],services:["service","what we offer","solution","offering"],pricing:["pricing","price","plan","subscription","cost","fee"],blog:["blog","article","news","post"],auth:["login","register","signup","sign up","sign in","auth","account"],dashboard:["dashboard","admin","panel","manage","analytics"],gallery:["gallery","photo","image","portfolio"],products:["product","shop","store","item","catalogue"],cart:["cart","basket","shopping cart"],checkout:["checkout","payment","pay","order"],rooms:["room","suite","accommodation","stay"],booking:["booking","reserve","reservation","schedule","appointment"],menu:["menu","food","dish","cuisine"],reservations:["reservation","table booking","book table"],portfolio:["portfolio","work","project","case study"],team:["team","staff","member","people","who we are"],faq:["faq","question","answer","help","support"],terms:["terms","condition","legal"],privacy:["privacy","policy","gdpr","data"]},vl={Authentication:["login","register","auth","signup","sign in","account"],Payment:["payment","stripe","pay","checkout","billing"],Search:["search","filter","find"],"Dark mode":["dark mode","dark theme","night mode"],"Multi-language":["multilingual","multi language","translation","i18n"],SEO:["seo","search engine","meta","google"],Analytics:["analytics","tracking","stats","dashboard"],Email:["email","newsletter","contact form","notification"],Map:["map","location","address","google maps"],"Social media":["social","instagram","facebook","twitter","share"],"Image gallery":["gallery","photo","image","carousel"],"Booking system":["booking","reservation","appointment","schedule"],"Shopping cart":["cart","basket","shop","ecommerce"],"Blog/CMS":["blog","cms","content","article","post"]},Sl={blue:["blue","navy","sky","ocean","corporate"],green:["green","nature","eco","environment","health","fresh"],purple:["purple","violet","luxury","creative","royal"],red:["red","bold","energy","passion","food"],orange:["orange","warm","friendly","fun"],teal:["teal","turquoise","modern","tech"],indigo:["indigo","professional","trust","finance","bank"],gray:["gray","minimal","clean","simple","neutral"]},Tl={hotel:"indigo",ecommerce:"blue",restaurant:"red",portfolio:"purple",blog:"gray",saas:"teal",government:"blue",healthcare:"green",education:"indigo",realestate:"orange",landing:"purple",generic:"blue"};function Al(e){let t=[/(?:for|called|named|company|business|brand)\s+["']?([A-Z][a-zA-Z\s]{1,30})["']?/i,/["']([A-Z][a-zA-Z\s]{1,30})["']/,/^([A-Z][a-zA-Z]+(?:\s[A-Z][a-zA-Z]+)?)/m];for(let n of t){let o=e.match(n);if(o?.[1]){let r=o[1].trim();if(r.length>2&&r.length<40)return r}}return"My Business"}function Cl(e){let t=e.toLowerCase(),n="generic",o=0;for(let[r,a]of Object.entries(xl)){let i=0;for(let s of a)t.includes(s)&&i++;i>o&&(o=i,n=r)}return n}function Rl(e,t){let n=e.toLowerCase(),o=new Set(wl[t]);for(let[r,a]of Object.entries(kl))for(let i of a)if(n.includes(i)){o.add(r);break}return o.add("home"),o.add("contact"),Array.from(o)}function Il(e){let t=e.toLowerCase(),n=[];for(let[o,r]of Object.entries(vl))for(let a of r)if(t.includes(a)){n.push(o);break}return n}function $l(e,t){let n=e.toLowerCase();for(let[o,r]of Object.entries(Sl))for(let a of r)if(n.includes(a))return o;return Tl[t]}function Fo(e){let t=Cl(e),n=Rl(e,t),o=Il(e),r=$l(e,t);return{siteName:Al(e),websiteType:t,pages:n,features:o,theme:r,description:e.slice(0,200)}}import{Fragment as Ll,jsx as V,jsxs as re}from"react/jsx-runtime";var El=["Hotel booking website for Grand Palace Hotels with rooms, booking and payment","E-commerce store for organic food products with cart and checkout","Restaurant website for Spice Garden with menu and table reservations","Portfolio website for a freelance designer with gallery and contact","SaaS dashboard for project management with pricing and auth","Government portal for citizen services with FAQ and contact"],Fl={home:"\u{1F3E0}",about:"\u2139\uFE0F",contact:"\u{1F4EC}",services:"\u2699\uFE0F",pricing:"\u{1F4B0}",blog:"\u{1F4DD}",auth:"\u{1F510}",dashboard:"\u{1F4CA}",gallery:"\u{1F5BC}\uFE0F",products:"\u{1F6D2}",cart:"\u{1F6CD}\uFE0F",checkout:"\u{1F4B3}",rooms:"\u{1F6CF}\uFE0F",booking:"\u{1F4C5}",menu:"\u{1F37D}\uFE0F",reservations:"\u{1FA91}",portfolio:"\u{1F4BC}",team:"\u{1F465}",faq:"\u2753",terms:"\u{1F4C4}",privacy:"\u{1F512}"},Gl={hotel:"\u{1F3E8}",ecommerce:"\u{1F6D2}",restaurant:"\u{1F37D}\uFE0F",portfolio:"\u{1F4BC}",blog:"\u{1F4DD}",saas:"\u26A1",government:"\u{1F3DB}\uFE0F",healthcare:"\u{1F3E5}",education:"\u{1F393}",realestate:"\u{1F3E0}",landing:"\u{1F680}",generic:"\u{1F310}"};function vn({position:e,onClose:t}){let[n,o]=xt("input"),[r,a]=xt(""),[i,s]=xt(null),[l,c]=xt(0),[u,b]=xt(""),p=Go(()=>{if(!r.trim())return;let d=Fo(r);s(d),o("preview")},[r]),g=Go(async()=>{if(i){o("generating"),c(0),b("");try{let d=[{msg:"Parsing requirement...",pct:15},{msg:"Loading templates...",pct:30},{msg:"Generating pages...",pct:55},{msg:"Building components...",pct:70},{msg:"Creating styles...",pct:85},{msg:"Packaging ZIP...",pct:95}];for(let k of d)c(k.pct),await new Promise(m=>setTimeout(m,200));let{generateZip:x}=await import("./zip-generator-D5EXBBNS.mjs");await x(i),c(100),o("done")}catch(d){b(d instanceof Error?d.message:"Generation failed. Please try again."),o("preview")}}},[i]),f=()=>{o("input"),a(""),s(null),c(0),b("")},h={position:"fixed",bottom:"204px",[e]:"24px",zIndex:9999,width:"340px",maxWidth:"calc(100vw - 48px)",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0,0,0,0.14)",fontFamily:"system-ui,-apple-system,sans-serif",maxHeight:"75vh",overflowY:"auto"};return re("div",{role:"dialog","aria-modal":"true","aria-label":"yuktai Vibe Coder","data-yuktai-panel":"true",style:h,children:[re("div",{style:{padding:"14px 16px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between",position:"sticky",top:0,background:"#fff",zIndex:1},children:[re("div",{children:[V("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:700,color:"#0f172a"},children:"\u26A1 Vibe Coder"}),V("p",{style:{margin:0,fontSize:"10px",color:"#64748b"},children:"Describe your website \u2192 Download Next.js ZIP"})]}),V("button",{onClick:t,"aria-label":"Close vibe coder",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",padding:"2px"},children:"\xD7"})]}),n==="input"&&re("div",{style:{padding:"14px 16px"},children:[V("p",{style:{margin:"0 0 10px",fontSize:"11px",color:"#64748b"},children:"Describe your business website in plain English. The plugin will generate a complete Next.js project for you."}),V("p",{style:{margin:"0 0 6px",fontSize:"10px",fontWeight:600,color:"#94a3b8",textTransform:"uppercase"},children:"Examples"}),V("div",{style:{display:"flex",flexDirection:"column",gap:"4px",marginBottom:"12px"},children:El.slice(0,3).map(d=>V("button",{onClick:()=>a(d),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#f8fafc",color:"#475569",fontSize:"10px",cursor:"pointer",textAlign:"left",lineHeight:1.4},children:d},d))}),V("textarea",{value:r,onChange:d=>a(d.target.value),placeholder:"e.g. I need a hotel booking website with rooms, search, and payment for Grand Palace Hotels",rows:4,"aria-label":"Describe your website",style:{width:"100%",padding:"10px",borderRadius:"8px",border:"1px solid #e2e8f0",fontSize:"12px",color:"#0f172a",resize:"vertical",outline:"none",fontFamily:"inherit",lineHeight:1.5}}),V("button",{onClick:p,disabled:!r.trim(),style:{width:"100%",marginTop:"10px",padding:"10px",borderRadius:"8px",border:"none",background:r.trim()?"#f59e0b":"#e2e8f0",color:r.trim()?"#fff":"#94a3b8",fontSize:"13px",fontWeight:700,cursor:r.trim()?"pointer":"not-allowed",transition:"background 0.2s"},children:"Analyse Requirement \u2192"})]}),n==="preview"&&i&&re("div",{style:{padding:"14px 16px"},children:[u&&re("div",{style:{padding:"10px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:"8px",marginBottom:"12px",fontSize:"11px",color:"#dc2626"},children:["\u26A0\uFE0F ",u]}),re("div",{style:{background:"#f8fafc",borderRadius:"10px",padding:"12px",marginBottom:"12px"},children:[re("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[V("span",{style:{fontSize:"1.5rem"},children:Gl[i.websiteType]||"\u{1F310}"}),re("div",{children:[V("p",{style:{margin:0,fontSize:"13px",fontWeight:700,color:"#0f172a"},children:i.siteName}),re("p",{style:{margin:0,fontSize:"10px",color:"#64748b",textTransform:"capitalize"},children:[i.websiteType," website \xB7 ",i.theme," theme"]})]})]}),re("p",{style:{margin:"8px 0 6px",fontSize:"10px",fontWeight:600,color:"#94a3b8",textTransform:"uppercase"},children:["Pages to generate (",i.pages.length,")"]}),V("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:i.pages.map(d=>re("span",{style:{padding:"2px 8px",borderRadius:"99px",background:"#f0fdf4",border:"1px solid #86efac",fontSize:"10px",color:"#166534",fontWeight:500},children:[Fl[d]||"\u{1F4C4}"," ",d]},d))}),i.features.length>0&&re(Ll,{children:[V("p",{style:{margin:"10px 0 6px",fontSize:"10px",fontWeight:600,color:"#94a3b8",textTransform:"uppercase"},children:"Detected features"}),V("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:i.features.map(d=>V("span",{style:{padding:"2px 8px",borderRadius:"99px",background:"#f5f3ff",border:"1px solid #c4b5fd",fontSize:"10px",color:"#7c3aed",fontWeight:500},children:d},d))})]})]}),re("div",{style:{margin:"0 0 12px",padding:"10px 12px",background:"#f0fdf4",borderRadius:"8px",border:"1px solid #86efac"},children:[V("p",{style:{margin:"0 0 4px",fontSize:"10px",fontWeight:700,color:"#166534"},children:"\u{1F4E6} What you get:"}),re("p",{style:{margin:0,fontSize:"10px",color:"#166534",lineHeight:1.6},children:["\u2705 Complete Next.js 16 project",V("br",{}),"\u2705 Tailwind CSS + CSS Modules",V("br",{}),"\u2705 TypeScript configured",V("br",{}),"\u2705 Navbar + Footer components",V("br",{}),"\u2705 All ",i.pages.length," pages ready",V("br",{}),"\u2705 Mobile responsive",V("br",{}),"\u2705 npm run dev \u2192 works immediately"]})]}),re("div",{style:{display:"flex",gap:"8px"},children:[V("button",{onClick:f,style:{flex:1,padding:"9px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"\u2190 Edit"}),V("button",{onClick:g,style:{flex:2,padding:"9px",borderRadius:"8px",border:"none",background:"#f59e0b",color:"#fff",fontSize:"13px",fontWeight:700,cursor:"pointer"},children:"\u2B07\uFE0F Generate & Download ZIP"})]})]}),n==="generating"&&re("div",{style:{padding:"2rem 16px",textAlign:"center"},children:[V("p",{style:{fontSize:"2rem",marginBottom:"1rem"},children:"\u26A1"}),V("p",{style:{fontSize:"13px",fontWeight:700,color:"#0f172a",marginBottom:"0.5rem"},children:"Generating your project..."}),V("p",{style:{fontSize:"11px",color:"#64748b",marginBottom:"1.5rem"},children:l<30?"Parsing requirement...":l<55?"Loading templates...":l<70?"Generating pages...":l<85?"Building components...":l<95?"Creating styles...":"Packaging ZIP..."}),V("div",{style:{height:"8px",background:"#e2e8f0",borderRadius:"99px",overflow:"hidden"},children:V("div",{style:{height:"100%",width:`${l}%`,background:"#f59e0b",borderRadius:"99px",transition:"width 0.3s ease"}})}),re("p",{style:{marginTop:"0.5rem",fontSize:"10px",color:"#94a3b8"},children:[l,"%"]})]}),n==="done"&&i&&re("div",{style:{padding:"2rem 16px",textAlign:"center"},children:[V("p",{style:{fontSize:"3rem",marginBottom:"0.75rem"},children:"\u2705"}),re("p",{style:{fontSize:"14px",fontWeight:700,color:"#0f172a",marginBottom:"0.5rem"},children:[i.siteName," downloaded!"]}),V("p",{style:{fontSize:"11px",color:"#64748b",marginBottom:"1.5rem",lineHeight:1.6},children:"Your ZIP is downloading. Unzip it and run:"}),["npm install","npm run dev"].map(d=>V("div",{style:{background:"#0f172a",borderRadius:"8px",padding:"8px 12px",marginBottom:"6px",textAlign:"left"},children:re("code",{style:{fontSize:"12px",color:"#a7f3d0",fontFamily:"monospace"},children:["$ ",d]})},d)),V("p",{style:{fontSize:"11px",color:"#10b981",margin:"1rem 0",fontWeight:600},children:"Then open http://localhost:3000 \u{1F680}"}),re("div",{style:{display:"flex",gap:"8px"},children:[V("button",{onClick:f,style:{flex:1,padding:"9px",borderRadius:"8px",border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",fontSize:"12px",fontWeight:600,cursor:"pointer"},children:"New Project"}),V("button",{onClick:g,style:{flex:1,padding:"9px",borderRadius:"8px",border:"none",background:"#f59e0b",color:"#fff",fontSize:"12px",fontWeight:700,cursor:"pointer"},children:"\u2B07\uFE0F Download Again"})]})]})]})}import{Fragment as Nl,jsx as ee,jsxs as Ee}from"react/jsx-runtime";async function Ml(){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 Sn({position:e="left",children:t,config:n={},showRag:o=!1,showAgent:r=!1}){let[a,i]=ce(!1),[s,l]=ce(wn),[c,u]=ce(null),[b,p]=ce(!1),[g,f]=ce(!1),[h,d]=ce(!1),x=Pl.useRef(null),[k,m]=ce(!1),[v,w]=ce(""),[A,C]=ce(""),[G,D]=ce(!1),[M,E]=ce(null),[I,y]=ce("idle"),[q,B]=ce(!1),[j,oe]=ce(""),[de,z]=ce(""),[H,T]=ce(!1),[P,J]=ce([]),[W,se]=ce(null),fe=24,ve=84,De=o?144:84,Un=204,[Se,nt]=ce(!1);ut(()=>{if(typeof window>"u")return;let $=window;!!($.LanguageModel||$.ai?.languageModel)&&g?(E("gemini"),se("gemini")):$t()&&(E("transformers"),se("transformers"))},[g]),ut(()=>{if(M!=="transformers")return;let $=setInterval(()=>y(Et()),500);return()=>clearInterval($)},[M]);let mt=dt(async()=>{if(!(!v.trim()||G)){if(!M){C("\u26A0\uFE0F No AI engine available.");return}D(!0),C("");try{let $;if(M==="gemini"){let{askPage:ne}=await import("./rag-MKBAGH6J.mjs");$=await ne(v)}else{y("loading");let{askPageWithTransformers:ne}=await import("./transformers-rag-HW4QKA5T.mjs");$=await ne(v),y("ready")}C($.success&&$.answer?$.answer.replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/#+\s/g,"").trim():"\u26A0\uFE0F "+($.error||"No answer found."))}catch{C("\u26A0\uFE0F Something went wrong.")}D(!1)}},[v,G,M]),Ct=dt(async()=>{if(!j.trim()||H)return;if(!W){z("\u26A0\uFE0F No AI engine available.");return}T(!0),J([]),z("");let{runAgent:$}=await import("./agent-JGLAYQMX.mjs");await $(j,W,ne=>{J(Me=>[...Me,ne.text])}),T(!1),z("done")},[j,H,W]);ut(()=>{if(typeof window>"u")return;let ne=setTimeout(async()=>{let Me=window,rn=await Ml();f(rn),d(!!(Me.SpeechRecognition||Me.webkitSpeechRecognition))},800);return()=>clearTimeout(ne)},[]),ut(()=>{if(!(typeof window>"u"))try{let $=localStorage.getItem("yuktai-a11y-prefs");$&&l(ne=>({...ne,...JSON.parse($)}))}catch{}},[]);let Be=dt(async $=>{let ne={enabled:!0,highContrast:$.highContrast,darkMode:$.darkMode,reduceMotion:$.reduceMotion,largeTargets:$.largeTargets,speechEnabled:$.speechEnabled,autoFix:$.autoFix,dyslexiaFont:$.dyslexiaFont,localFont:$.localFont,fontSizeMultiplier:$.fontScale/100,colorBlindMode:$.colorBlindMode,showAuditBadge:$.showAuditBadge,showSkipLinks:!0,showPreferencePanel:!1,plainEnglish:$.plainEnglish,summarisePage:$.summarisePage,translateLanguage:$.translateLanguage,voiceControl:$.voiceControl,smartLabels:$.smartLabels,...n};await ke.execute(ne),u(ke.applyFixes(ne)),p(!0)},[n]),we=dt(async()=>{try{localStorage.setItem("yuktai-a11y-prefs",JSON.stringify(s))}catch{}await Be(s),i(!1)},[s,Be]),Oe=dt(()=>{l(wn);try{localStorage.removeItem("yuktai-a11y-prefs")}catch{}let $=document.documentElement;["data-yuktai-high-contrast","data-yuktai-dark","data-yuktai-reduce-motion","data-yuktai-large-targets","data-yuktai-keyboard","data-yuktai-dyslexia"].forEach(ne=>$.removeAttribute(ne)),document.body.style.filter="",document.body.style.fontFamily="",document.documentElement.style.fontSize="",u(null),p(!1)},[]),bt=dt(($,ne)=>{l(Me=>({...Me,[$]:ne}))},[]);ut(()=>{let $=ne=>{ne.key==="Escape"&&(a&&i(!1),k&&m(!1),q&&B(!1),Se&&nt(!1))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,k,q]),ut(()=>{a&&x.current&&ke.trapFocus(x.current)},[a]);let Qe=($,ne,Me)=>({position:"fixed",bottom:`${$}px`,[e]:"24px",zIndex:9998,width:"52px",height:"52px",borderRadius:"50%",background:ne,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"}),ot=$=>{$.currentTarget.style.transform="scale(1.08)"},He=$=>{$.currentTarget.style.transform="scale(1)"},rt=M==="gemini"?"Gemini Nano \xB7 On device":M==="transformers"?"Transformers.js \xB7 All devices":"Detecting...",Rt=M==="transformers"&&I==="loading"?"Loading model...":"...";return Ee(Nl,{children:[t,r&&ee("button",{style:Qe(204,Se?"#d97706":"#f59e0b",Se),"aria-label":"Open Vibe Coder",title:"\u26A1 Vibe Coder \u2014 Generate Next.js project",onClick:()=>{nt($=>!$),B(!1),m(!1),i(!1)},onMouseEnter:ot,onMouseLeave:He,children:"\u26A1"}),r&&Se&&ee(vn,{position:e,onClose:()=>nt(!1)}),r&&ee("button",{style:Qe(De,q?"#059669":"#10b981",q),"aria-label":"Open AI agent","aria-haspopup":"dialog","aria-expanded":q,title:"\u{1F916} AI Agent \u2014 guide me through this page",onClick:()=>{B($=>!$),m(!1),i(!1)},onMouseEnter:ot,onMouseLeave:He,children:"\u{1F916}"}),r&&q&&Ee("div",{role:"dialog","aria-modal":"true","aria-label":"yuktai AI Agent","data-yuktai-panel":"true",style:{position:"fixed",bottom:`${De+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:[Ee("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"10px"},children:[Ee("div",{children:[ee("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:600,color:"#0f172a"},children:"\u{1F916} AI Agent"}),ee("p",{style:{margin:0,fontSize:"10px",color:"#10b981"},children:W==="gemini"?"Gemini Nano \xB7 On device":W==="transformers"?"Transformers.js \xB7 All devices":"Detecting..."})]}),ee("button",{onClick:()=>B(!1),"aria-label":"Close agent panel",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",lineHeight:1,padding:"2px"},children:"\xD7"})]}),ee("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."}),ee("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($=>ee("button",{onClick:()=>oe($),style:{padding:"3px 8px",borderRadius:"20px",fontSize:"10px",border:"1px solid #e2e8f0",background:"#f8fafc",color:"#64748b",cursor:"pointer"},children:$},$))}),Ee("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[ee("input",{type:"text",value:j,onChange:$=>oe($.target.value),onKeyDown:$=>{$.key==="Enter"&&Ct()},placeholder:"e.g. Help me fill this form",disabled:H||!W,"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:W?"#fff":"#f8fafc",outline:"none",height:"36px"}}),ee("button",{onClick:Ct,disabled:H||!j.trim()||!W,"aria-label":"Run agent",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:W&&j.trim()&&!H?"#10b981":"#e2e8f0",color:W&&j.trim()&&!H?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:W&&j.trim()&&!H?"pointer":"not-allowed",height:"36px",minWidth:"52px",transition:"background 0.2s"},children:H?"...":"Go"})]}),P.length>0&&Ee("div",{style:{padding:"10px 12px",background:"#f0fdf4",border:"1px solid #86efac",borderRadius:"8px",fontSize:"11px",color:"#166534",lineHeight:1.7},children:[P.map(($,ne)=>ee("p",{style:{margin:"0 0 2px"},children:$},ne)),de==="done"&&ee("button",{onClick:()=>{J([]),oe(""),z("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!W&&ee("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Enable Gemini Nano via chrome://flags for best results."})]}),o&&ee("button",{style:Qe(ve,k?"#7c3aed":"#6d28d9",k),"aria-label":"Ask a question about this page","aria-haspopup":"dialog","aria-expanded":k,title:`\u{1F4AC} Ask this page \xB7 ${rt}`,onClick:()=>{m($=>!$),i(!1),B(!1)},onMouseEnter:ot,onMouseLeave:He,children:"\u{1F4AC}"}),o&&k&&Ee("div",{role:"dialog","aria-modal":"true","aria-label":"Ask this page","data-yuktai-panel":"true",style:{position:"fixed",bottom:`${ve+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:[Ee("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"10px"},children:[Ee("div",{children:[ee("p",{style:{margin:"0 0 2px",fontSize:"13px",fontWeight:600,color:"#0f172a"},children:"\u{1F4AC} Ask this page"}),ee("p",{style:{margin:0,fontSize:"10px",color:"#7c3aed"},children:rt}),M==="transformers"&&I==="loading"&&ee("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#94a3b8"},children:"Downloading model \u2014 first time only"}),M==="transformers"&&I==="ready"&&ee("p",{style:{margin:"2px 0 0",fontSize:"9px",color:"#10b981"},children:"Model ready \u2705 \u2014 works offline"})]}),ee("button",{onClick:()=>m(!1),"aria-label":"Close ask panel",style:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",fontSize:"18px",lineHeight:1,padding:"2px"},children:"\xD7"})]}),Ee("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:[ee("input",{type:"text",value:v,onChange:$=>w($.target.value),onKeyDown:$=>{$.key==="Enter"&&mt()},placeholder:"e.g. What does this page do?",disabled:G||!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:"36px"}}),ee("button",{onClick:mt,disabled:G||!v.trim()||!M,"aria-label":"Submit question",style:{padding:"8px 12px",borderRadius:"8px",border:"none",background:M&&v.trim()&&!G?"#7c3aed":"#e2e8f0",color:M&&v.trim()&&!G?"#fff":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:M&&v.trim()&&!G?"pointer":"not-allowed",height:"36px",minWidth:"48px",transition:"background 0.2s"},children:G?Rt:"Ask"})]}),A&&Ee("div",{style:{padding:"10px",background:"#f5f3ff",borderRadius:"8px",fontSize:"12px",color:"#4c1d95",lineHeight:1.6,maxHeight:"180px",overflowY:"auto"},children:[ee("strong",{style:{display:"block",marginBottom:"4px",fontSize:"11px",color:"#7c3aed"},children:"\u{1F4AC} Answer"}),A,ee("button",{onClick:()=>{C(""),w("")},style:{display:"block",marginTop:"6px",background:"none",border:"none",color:"#94a3b8",fontSize:"10px",cursor:"pointer",padding:0},children:"Clear"})]}),!M&&ee("p",{style:{margin:"4px 0 0",fontSize:"10px",color:"#94a3b8"},children:"Detecting AI engine..."})]}),ee("button",{style:Qe(fe,b?"#0d9488":"#1a73e8",a),"aria-label":"Open accessibility preferences","aria-haspopup":"dialog","aria-expanded":a,"data-yuktai-pref-toggle":"true",title:"\u267F Accessibility settings",onClick:()=>{i($=>!$),m(!1),B(!1)},onMouseEnter:ot,onMouseLeave:He,children:"\u267F"}),a&&ee(kn,{ref:x,position:e,settings:s,report:c,isActive:b,aiSupported:g,voiceSupported:h,set:bt,onApply:we,onReset:Oe,onClose:()=>i(!1)})]})}var Bt={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var Ht={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var Xe=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 o=this.use(t);if(!o)throw new Error(`Plugin not found: ${t}`);return await o.execute(n)}catch(o){throw console.error(`[YuktAI Runtime Error in ${t}]:`,o),o}}getPlugins(){return Array.from(this.plugins.keys())}};import{useCallback as $n,useEffect as Qt,useMemo as pt,useState as Ve}from"react";import{useCallback as Tn,useEffect as wt,useMemo as Lo,useRef as Po,useState as _e}from"react";import{Fragment as jl,jsx as L,jsxs as ye}from"react/jsx-runtime";var Mo={"en-US":{title:"Grid AI Assistant",subtitle:"Ask about your data",ask:"Ask",placeholder:"Ask or type a command...",listening:"Listening...",send:"Send",close:"Close",open:"Open AI assistant",inputLanguage:"Input language",speakNow:"Speak your question",working:"Working on it\u2026",english:"English",telugu:"\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41",searchStarted:e=>`Searching for "${e}".`,sortedAscending:e=>`Sorted by ${e} in ascending order.`,sortedDescending:e=>`Sorted by ${e} in descending order.`,count:e=>`There are ${e} rows in the grid.`,highest:(e,t,n)=>`The highest ${e} is ${t}, held by ${n}.`,lowest:(e,t,n)=>`The lowest ${e} is ${t}, held by ${n}.`,average:(e,t)=>`The average ${e} is ${t}.`,total:(e,t)=>`The total ${e} is ${t}.`,noData:"There is no data to analyze.",noColumn:"I could not find a column to analyze.",noNumericData:e=>`There is no numeric data in ${e}.`,notFound:e=>`I could not find anything matching "${e}".`,needName:"Please provide a value to look up.",fallback:"I can search, sort, count, and analyze the grid data.",unsupportedVoice:"Voice input is not supported in this browser."},"te-IN":{title:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D AI \u0C38\u0C39\u0C3E\u0C2F\u0C15\u0C41\u0C21\u0C41",subtitle:"\u0C2E\u0C40 \u0C21\u0C47\u0C1F\u0C3E \u0C17\u0C41\u0C30\u0C3F\u0C02\u0C1A\u0C3F \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F",ask:"\u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F",placeholder:"\u0C2A\u0C4D\u0C30\u0C36\u0C4D\u0C28 \u0C32\u0C47\u0C26\u0C3E \u0C06\u0C26\u0C47\u0C36\u0C02 \u0C1F\u0C48\u0C2A\u0C4D \u0C1A\u0C47\u0C2F\u0C02\u0C21\u0C3F...",listening:"\u0C35\u0C3F\u0C02\u0C1F\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41...",send:"\u0C2A\u0C02\u0C2A\u0C02\u0C21\u0C3F",close:"\u0C2E\u0C42\u0C38\u0C3F\u0C35\u0C47\u0C2F\u0C02\u0C21\u0C3F",open:"AI \u0C38\u0C39\u0C3E\u0C2F\u0C15\u0C41\u0C21\u0C3F\u0C28\u0C3F \u0C24\u0C46\u0C30\u0C35\u0C02\u0C21\u0C3F",inputLanguage:"\u0C07\u0C28\u0C4D\u200C\u0C2A\u0C41\u0C1F\u0C4D \u0C2D\u0C3E\u0C37",speakNow:"\u0C2E\u0C40 \u0C2A\u0C4D\u0C30\u0C36\u0C4D\u0C28 \u0C1A\u0C46\u0C2A\u0C4D\u0C2A\u0C02\u0C21\u0C3F",working:"\u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41\u2026",english:"English",telugu:"\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41",searchStarted:e=>`\u201C${e}\u201D \u0C15\u0C4B\u0C38\u0C02 \u0C36\u0C4B\u0C27\u0C3F\u0C38\u0C4D\u0C24\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41.`,sortedAscending:e=>`${e}\u0C28\u0C41 \u0C06\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u0C32\u0C4B \u0C05\u0C2E\u0C30\u0C4D\u0C1A\u0C3E\u0C28\u0C41.`,sortedDescending:e=>`${e}\u0C28\u0C41 \u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u0C32\u0C4B \u0C05\u0C2E\u0C30\u0C4D\u0C1A\u0C3E\u0C28\u0C41.`,count:e=>`\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C32\u0C4B \u0C2E\u0C4A\u0C24\u0C4D\u0C24\u0C02 ${e} \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C09\u0C28\u0C4D\u0C28\u0C3E\u0C2F\u0C3F.`,highest:(e,t,n)=>`\u0C05\u0C24\u0C4D\u0C2F\u0C27\u0C3F\u0C15 ${e} \u0C35\u0C3F\u0C32\u0C41\u0C35 ${t}. \u0C07\u0C26\u0C3F ${n}\u0C15\u0C41 \u0C38\u0C02\u0C2C\u0C02\u0C27\u0C3F\u0C02\u0C1A\u0C3F\u0C28\u0C26\u0C3F.`,lowest:(e,t,n)=>`\u0C05\u0C24\u0C4D\u0C2F\u0C32\u0C4D\u0C2A ${e} \u0C35\u0C3F\u0C32\u0C41\u0C35 ${t}. \u0C07\u0C26\u0C3F ${n}\u0C15\u0C41 \u0C38\u0C02\u0C2C\u0C02\u0C27\u0C3F\u0C02\u0C1A\u0C3F\u0C28\u0C26\u0C3F.`,average:(e,t)=>`${e} \u0C38\u0C17\u0C1F\u0C41 \u0C35\u0C3F\u0C32\u0C41\u0C35 ${t}.`,total:(e,t)=>`${e} \u0C2E\u0C4A\u0C24\u0C4D\u0C24\u0C02 \u0C35\u0C3F\u0C32\u0C41\u0C35 ${t}.`,noData:"\u0C35\u0C3F\u0C36\u0C4D\u0C32\u0C47\u0C37\u0C3F\u0C02\u0C1A\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C21\u0C47\u0C1F\u0C3E \u0C32\u0C47\u0C26\u0C41.",noColumn:"\u0C35\u0C3F\u0C36\u0C4D\u0C32\u0C47\u0C37\u0C3F\u0C02\u0C1A\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C24\u0C17\u0C3F\u0C28 \u0C15\u0C3E\u0C32\u0C2E\u0C4D \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.",noNumericData:e=>`${e}\u0C32\u0C4B \u0C38\u0C02\u0C16\u0C4D\u0C2F\u0C3E \u0C38\u0C2E\u0C3E\u0C1A\u0C3E\u0C30\u0C02 \u0C32\u0C47\u0C26\u0C41.`,notFound:e=>`\u201C${e}\u201D\u0C15\u0C41 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C32\u0C47 \u0C38\u0C2E\u0C3E\u0C1A\u0C3E\u0C30\u0C02 \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.`,needName:"\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C12\u0C15 \u0C35\u0C3F\u0C32\u0C41\u0C35 \u0C07\u0C35\u0C4D\u0C35\u0C02\u0C21\u0C3F.",fallback:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C32\u0C4B \u0C36\u0C4B\u0C27\u0C28, \u0C15\u0C4D\u0C30\u0C2E\u0C2C\u0C26\u0C4D\u0C27\u0C40\u0C15\u0C30\u0C23, \u0C32\u0C46\u0C15\u0C4D\u0C15\u0C3F\u0C02\u0C2A\u0C41 \u0C2E\u0C30\u0C3F\u0C2F\u0C41 \u0C21\u0C47\u0C1F\u0C3E \u0C35\u0C3F\u0C36\u0C4D\u0C32\u0C47\u0C37\u0C23 \u0C1A\u0C47\u0C2F\u0C17\u0C32\u0C28\u0C41.",unsupportedVoice:"\u0C08 \u0C2C\u0C4D\u0C30\u0C4C\u0C1C\u0C30\u0C4D\u200C\u0C32\u0C4B \u0C35\u0C3E\u0C2F\u0C3F\u0C38\u0C4D \u0C07\u0C28\u0C4D\u200C\u0C2A\u0C41\u0C1F\u0C4D\u200C\u0C15\u0C41 \u0C2E\u0C26\u0C4D\u0C26\u0C24\u0C41 \u0C32\u0C47\u0C26\u0C41."}};function Fe(e){return e.toLowerCase().trim().replace(/\s+/g," ")}function zl(e,t){let n=Fe(e);if(t==="te-IN")return/^(శోధించు|శోధించండి|వెతుకు|వెతకండి|చూపించు|చూపించండి|ఫిల్టర్)/.test(n)?{type:"search",payload:n.replace(/^(శోధించు|శోధించండి|వెతుకు|వెతకండి|చూపించు|చూపించండి|ఫిల్టర్)\s*/u,"").trim()||e}:/క్రమబద్ధీకర|అమర్చ|సార్ట్/.test(n)?{type:"sort",payload:{key:void 0,dir:/అవరోహణ|పెద్ద|అధిక|చివర/.test(n)?"desc":"asc"}}:/ఎన్ని|ఎంతమంది|లెక్క|మొత్తం వరుస|వరుసలు/.test(n)?{type:"question",payload:e}:/అత్యధిక|గరిష్ఠ|పెద్ద|ఎక్కువ/.test(n)?{type:"question",payload:e}:/అత్యల్ప|కనిష్ఠ|చిన్న|తక్కువ/.test(n)?{type:"question",payload:e}:/సగటు|సగటు విలువ/.test(n)?{type:"question",payload:e}:/మొత్తం|కలిపి/.test(n)?{type:"question",payload:e}:{type:"search",payload:e};if(/^(search|find|show|filter)/.test(n))return{type:"search",payload:n.replace(/^(search|find|show|filter)\s+(for\s+|by\s+)?/,"").trim()||e};if(/sort/.test(n)){let o=/desc|descending|high|higher|large|largest|top/.test(n);return{type:"sort",payload:{key:n.match(/(?:by|on)\s+([a-z0-9_-]+)/)?.[1],dir:o?"desc":"asc"}}}return/how many|count|highest|maximum|max|top|largest|lowest|minimum|min|smallest|bottom|average|avg|mean|sum|total|who|which|where|whose/.test(n)?{type:"question",payload:e}:{type:"search",payload:e}}function No(e,t){let n=Fe(e);return t.find(o=>{let r=Fe(o.key),a=Fe(o.label);return n.includes(r)||n.includes(a)})}function qt(e,t){return e.toLocaleString(t==="te-IN"?"te-IN":"en-IN")}function Dl(e,t,n,o){let r=Mo[o];if(t.length===0)return r.noData;let a=Fe(e),i=n.filter(k=>k.type==="number"),s=No(e,n),l=s?.type==="number"?s:i[0],c=/how many|count|rows|ఎన్ని|ఎంతమంది|లెక్క|వరుసలు/.test(a);if(c)return r.count(t.length);if(/highest|maximum|max|top|largest|అత్యధిక|గరిష్ఠ|పెద్ద|ఎక్కువ/.test(a)){let k=s??l;if(!k)return r.noColumn;let m=t.map(C=>({row:C,value:Number(C[k.key])})).filter(C=>!Number.isNaN(C.value)).sort((C,G)=>G.value-C.value);if(m.length===0)return r.noNumericData(k.label);let v=m[0],w=n.find(C=>C.key==="name"||Fe(C.label)==="name"),A=w?String(v.row[w.key]??""):o==="te-IN"?"\u0C08 \u0C35\u0C30\u0C41\u0C38":"this row";return r.highest(k.label,qt(v.value,o),A)}if(/lowest|minimum|min|smallest|bottom|అత్యల్ప|కనిష్ఠ|చిన్న|తక్కువ/.test(a)){let k=s??l;if(!k)return r.noColumn;let m=t.map(C=>({row:C,value:Number(C[k.key])})).filter(C=>!Number.isNaN(C.value)).sort((C,G)=>C.value-G.value);if(m.length===0)return r.noNumericData(k.label);let v=m[0],w=n.find(C=>C.key==="name"||Fe(C.label)==="name"),A=w?String(v.row[w.key]??""):o==="te-IN"?"\u0C08 \u0C35\u0C30\u0C41\u0C38":"this row";return r.lowest(k.label,qt(v.value,o),A)}if(/average|avg|mean|సగటు/.test(a)){let k=s??l;if(!k)return r.noColumn;let m=t.map(w=>Number(w[k.key])).filter(w=>!Number.isNaN(w));if(m.length===0)return r.noNumericData(k.label);let v=m.reduce((w,A)=>w+A,0)/m.length;return r.average(k.label,qt(Math.round(v*100)/100,o))}if(/sum|total|మొత్తం|కలిపి/.test(a)&&!c){let k=s??l;if(!k)return r.noColumn;let m=t.map(w=>Number(w[k.key])).filter(w=>!Number.isNaN(w));if(m.length===0)return r.noNumericData(k.label);let v=m.reduce((w,A)=>w+A,0);return r.total(k.label,qt(v,o))}let f=a.match(/[\p{L}\p{N}_-]+/gu)??[],h=new Set(["who","what","which","where","whose","is","the","has","have","show","find","search","for","by","about"]),x=f.filter(k=>!h.has(k)).join(" ").trim();if(x){let k=t.find(m=>Object.values(m).some(v=>String(v??"").toLowerCase().includes(x.toLowerCase())));return k?n.map(m=>`${m.label}: ${String(k[m.key]??"")}`).join(o==="te-IN"?" \xB7 ":", "):r.notFound(x)}return r.fallback}function Ol(e,t){if(typeof window>"u"||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.lang=t,n.rate=1,n.pitch=1,window.speechSynthesis.speak(n)}function Wl(e){let[t,n]=_e(!1),[o,r]=_e(""),[a,i]=_e(!0),s=Po(null);wt(()=>{if(typeof window>"u")return;let u=window.SpeechRecognition||window.webkitSpeechRecognition;if(!u){i(!1),s.current=null;return}let b=new u;return b.continuous=!1,b.interimResults=!1,b.lang=e,b.onresult=p=>{let g=p?.results?.[0]?.[0]?.transcript??"";r(g),n(!1)},b.onerror=()=>{n(!1)},b.onend=()=>{n(!1)},s.current=b,()=>{try{b.stop()}catch{}s.current=null}},[e]);let l=Tn(()=>{if(s.current){r(""),n(!0);try{s.current.start()}catch{n(!1)}}},[]),c=Tn(()=>{try{s.current?.stop()}catch{}n(!1)},[]);return{listening:t,transcript:o,supported:a,start:l,stop:c}}function Bl(){return ye("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[L("circle",{cx:"11",cy:"11",r:"6.5"}),L("path",{d:"m16 16 5 5"})]})}function Hl(){return ye("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[L("rect",{x:"8",y:"3",width:"8",height:"12",rx:"4"}),L("path",{d:"M5 11a7 7 0 0 0 14 0"}),L("path",{d:"M12 18v3"}),L("path",{d:"M8 21h8"})]})}function ql(){return ye("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[L("path",{d:"m4 4 16 8-16 8 4-8-4-8Z"}),L("path",{d:"M8 12h12"})]})}function _l(){return ye("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[L("path",{d:"m6 6 12 12"}),L("path",{d:"m18 6-12 12"})]})}function Ul({data:e,columns:t,onSearch:n,onSort:o,theme:r="light",language:a="en-US",inputLanguage:i="en-US",embedded:s=!1,agent:l,onInputLanguageChange:c}){let u=Mo[a],[b,p]=_e(i);wt(()=>{p(i)},[i]);let[g,f]=_e(!1),h=r==="dark",[d,x]=_e(s),[k,m]=_e(""),[v,w]=_e([]),A=Po(null),{listening:C,transcript:G,supported:D,start:M,stop:E}=Wl(b),I=Lo(()=>({bg:h?"#0F172A":"#FFFFFF",surface:h?"#1E293B":"#F8FAFC",border:h?"#334155":"#E2E8F0",text:h?"#F1F5F9":"#0F172A",muted:h?"#94A3B8":"#64748B",accent:"#10B981",userMsg:h?"#334155":"#DBEAFE",aiMsg:h?"#1E293B":"#F0FDF4"}),[h]),y=Lo(()=>({role:"ai",text:a==="te-IN"?"\u0C2E\u0C40 \u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D \u0C21\u0C47\u0C1F\u0C3E \u0C17\u0C41\u0C30\u0C3F\u0C02\u0C1A\u0C3F \u0C2A\u0C4D\u0C30\u0C36\u0C4D\u0C28 \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F.":"Ask me about your grid data.",time:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),[a]);wt(()=>{w(z=>z.length>0?z:[y])},[y]),wt(()=>{A.current?.scrollIntoView({behavior:"smooth"})},[v]);let q=()=>new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),B=Tn(async z=>{let H=z.trim();if(!H)return;w(P=>[...P,{role:"user",text:H,time:q()}]),m("");let T="";if(l){f(!0);try{T=(await l.ask(H)).message}catch{T=u.fallback}finally{f(!1)}}else{let P=zl(H,a);if(P.type==="question")T=Dl(P.payload??H,e,t,a);else if(P.type==="search"){let J=String(P.payload??H);n?.(J),T=u.searchStarted(J)}else if(P.type==="sort"){let J=P.payload?.key,W=J?t.find(se=>Fe(se.key)===Fe(J)||Fe(se.label)===Fe(J)):void 0;if(W||(W=No(H,t)),W&&o){let se=P.payload?.dir==="desc"?"desc":"asc";o(String(W.key),se),T=se==="asc"?u.sortedAscending(W.label):u.sortedDescending(W.label)}else T=u.noColumn}}T||(T=u.fallback),w(P=>[...P,{role:"ai",text:T,time:q()}]),Ol(T,a)},[l,t,e,a,n,o,u]);wt(()=>{G&&B(G)},[G,B]);let j=()=>{B(k)},oe=a==="te-IN"?["\u0C0E\u0C28\u0C4D\u0C28\u0C3F \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41","\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F","\u0C15\u0C4D\u0C30\u0C2E\u0C02"]:["how many rows","search","sort"],de=ye("div",{style:{width:s?"100%":360,maxWidth:s?"100%":"calc(100vw - 48px)",height:s?390:480,maxHeight:"70vh",background:I.bg,border:`1px solid ${I.border}`,borderRadius:s?12:16,boxShadow:s?"none":"0 20px 40px rgba(0,0,0,0.15)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[ye("div",{style:{padding:"12px 14px",background:I.accent,color:"#FFFFFF",display:"flex",alignItems:"center",gap:10},children:[L("div",{style:{width:34,height:34,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.18)",fontSize:17},children:"AI"}),ye("div",{style:{flex:1,minWidth:0},children:[L("div",{style:{fontWeight:700,fontSize:14},children:u.title}),L("div",{style:{fontSize:11,opacity:.9},children:u.subtitle})]}),!s&&L("button",{type:"button",onClick:()=>x(!1),"aria-label":u.close,title:u.close,style:{width:32,height:32,border:"none",borderRadius:8,background:"rgba(255,255,255,0.12)",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:L(_l,{})})]}),ye("div",{style:{padding:"8px 10px",borderBottom:`1px solid ${I.border}`,display:"flex",alignItems:"center",gap:8,background:I.surface},children:[L("span",{style:{fontSize:11,color:I.muted},children:u.inputLanguage}),ye("select",{value:b,onChange:z=>{let H=z.target.value;p(H),c?.(H)},disabled:C,"aria-label":u.inputLanguage,style:{padding:"5px 8px",borderRadius:7,border:`1px solid ${I.border}`,background:I.bg,color:I.text,fontSize:11},children:[L("option",{value:"en-US",children:"English (US)"}),L("option",{value:"en-IN",children:"English (India)"}),L("option",{value:"as-IN",children:"Assamese"}),L("option",{value:"bn-IN",children:"Bengali"}),L("option",{value:"brx-IN",children:"Bodo"}),L("option",{value:"doi-IN",children:"Dogri"}),L("option",{value:"gu-IN",children:"Gujarati"}),L("option",{value:"hi-IN",children:"Hindi"}),L("option",{value:"kn-IN",children:"Kannada"}),L("option",{value:"ks-IN",children:"Kashmiri"}),L("option",{value:"kok-IN",children:"Konkani"}),L("option",{value:"mai-IN",children:"Maithili"}),L("option",{value:"ml-IN",children:"Malayalam"}),L("option",{value:"mni-IN",children:"Manipuri"}),L("option",{value:"mr-IN",children:"Marathi"}),L("option",{value:"ne-IN",children:"Nepali"}),L("option",{value:"or-IN",children:"Odia"}),L("option",{value:"pa-IN",children:"Punjabi"}),L("option",{value:"sa-IN",children:"Sanskrit"}),L("option",{value:"sat-IN",children:"Santali"}),L("option",{value:"sd-IN",children:"Sindhi"}),L("option",{value:"ta-IN",children:"Tamil"}),L("option",{value:"te-IN",children:"Telugu"}),L("option",{value:"ur-IN",children:"Urdu"})]})]}),ye("div",{style:{flex:1,overflowY:"auto",padding:10,display:"flex",flexDirection:"column",gap:8},children:[v.map((z,H)=>ye("div",{style:{alignSelf:z.role==="user"?"flex-end":"flex-start",maxWidth:"88%",padding:"8px 11px",borderRadius:11,background:z.role==="user"?I.userMsg:I.aiMsg,color:I.text,fontSize:13,lineHeight:1.5},children:[L("div",{children:z.text}),L("div",{style:{marginTop:3,fontSize:10,opacity:.55,textAlign:"right"},children:z.time})]},`${z.time}-${H}`)),C&&L("div",{style:{alignSelf:"flex-end",padding:"8px 11px",borderRadius:11,background:h?"#3F1D2E":"#FEE2E2",color:h?"#FCA5A5":"#991B1B",fontSize:13},children:u.listening}),(g||l?.loading)&&L("div",{role:"status","aria-live":"polite",style:{alignSelf:"flex-start",padding:"8px 11px",borderRadius:11,background:I.aiMsg,color:I.muted,fontSize:13},children:u.working}),L("div",{ref:A})]}),L("div",{style:{padding:"7px 10px",borderTop:`1px solid ${I.border}`,display:"flex",gap:6,overflowX:"auto",flexShrink:0},children:oe.map(z=>L("button",{type:"button",onClick:()=>B(z),style:{padding:"5px 9px",borderRadius:12,border:`1px solid ${I.border}`,background:I.surface,color:I.text,fontSize:10.5,cursor:"pointer",whiteSpace:"nowrap"},children:z},z))}),ye("div",{style:{padding:9,display:"flex",gap:6,borderTop:`1px solid ${I.border}`,background:I.surface},children:[ye("div",{style:{position:"relative",flex:1},children:[L(Bl,{}),L("input",{type:"text",value:k,onChange:z=>m(z.target.value),onKeyDown:z=>{z.key==="Enter"&&j()},placeholder:u.placeholder,"aria-label":u.ask,style:{width:"100%",boxSizing:"border-box",padding:"9px 10px 9px 34px",borderRadius:8,border:`1px solid ${I.border}`,background:I.bg,color:I.text,fontSize:12,outline:"none"}})]}),D?L("button",{type:"button",onClick:C?E:M,"aria-label":C?u.listening:u.speakNow,title:C?u.listening:u.speakNow,style:{width:38,height:38,border:"none",borderRadius:8,background:C?"#EF4444":I.accent,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},children:L(Hl,{})}):null,L("button",{type:"button",onClick:j,disabled:!k.trim(),"aria-label":u.send,title:u.send,style:{width:38,height:38,border:"none",borderRadius:8,background:k.trim()?I.accent:I.muted,color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:k.trim()?"pointer":"not-allowed",opacity:k.trim()?1:.6,flexShrink:0},children:L(ql,{})})]})]});return s?L("div",{style:{width:"100%",minWidth:0},children:d?de:ye("button",{type:"button",onClick:()=>x(!0),"aria-label":u.open,style:{minHeight:40,padding:"8px 13px",borderRadius:9,border:"1px solid #10B981",background:h?"#064E3B":"#ECFDF5",color:h?"#A7F3D0":"#047857",display:"inline-flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:12,fontWeight:600},children:[L("span",{"aria-hidden":"true",children:"AI"}),u.ask]})}):ye(jl,{children:[!d&&L("button",{type:"button",onClick:()=>x(!0),"aria-label":u.open,title:u.title,style:{position:"fixed",bottom:24,right:24,zIndex:9998,width:56,height:56,borderRadius:28,background:I.accent,color:"#FFFFFF",border:"none",cursor:"pointer",boxShadow:"0 8px 20px rgba(16,185,129,0.3)",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:14},children:"AI"}),d&&L("div",{style:{position:"fixed",bottom:90,right:24,zIndex:9997},children:de}),L("style",{children:`
386
386
  @keyframes yuktai-ai-pulse {
387
387
  0%, 100% {
388
388
  transform: scale(1);
@@ -392,16 +392,16 @@ import{$ as yi,A as jr,Aa as ji,B as Ur,Ba as Ui,C as Vr,Ca as Vi,D as Yr,Da as
392
392
  transform: scale(1.05);
393
393
  }
394
394
  }
395
- `})]})}var An=ua;import{useCallback as St,useEffect as ya,useRef as Rn,useState as Vt}from"react";var pa={en:{found:e=>`${e} row(s) found.`,count:e=>`${e} row(s).`,columns:"Grid columns retrieved.",rowFound:"Row found.",notFound:e=>`Row "${e}" not found.`,noneFound:"None of the given rows were found.",highlighted:e=>`${e} row(s) highlighted.`,selected:e=>`Row "${e}" selected.`,opened:e=>`Row "${e}" opened.`,notSupported:e=>`This grid does not support "${e}".`,emptyQuery:"Please enter something to search.",noIds:"No row IDs were given.",unknownColumn:e=>`Unknown column "${e}".`,badOperator:e=>`Unknown filter operator "${e}".`,badValue:"The filter value is not valid for this column.",filtered:e=>`Filter applied: ${e} row(s) match.`,filtersCleared:"All filters cleared.",sorted:(e,t)=>`Sorted by ${e} (${t==="asc"?"ascending":"descending"}).`,sortCleared:"Sorting cleared.",internal:"Something went wrong while running this action."},te:{found:e=>`${e} \u0C35\u0C30\u0C41\u0C38(\u0C32\u0C41) \u0C26\u0C4A\u0C30\u0C3F\u0C15\u0C3E\u0C2F\u0C3F.`,count:e=>`\u0C2E\u0C4A\u0C24\u0C4D\u0C24\u0C02 ${e} \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41.`,columns:"\u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C32 \u0C35\u0C3F\u0C35\u0C30\u0C3E\u0C32\u0C41.",rowFound:"\u0C35\u0C30\u0C41\u0C38 \u0C26\u0C4A\u0C30\u0C3F\u0C15\u0C3F\u0C02\u0C26\u0C3F.",notFound:e=>`"${e}" \u0C35\u0C30\u0C41\u0C38 \u0C26\u0C4A\u0C30\u0C15\u0C32\u0C47\u0C26\u0C41.`,noneFound:"\u0C07\u0C1A\u0C4D\u0C1A\u0C3F\u0C28 \u0C35\u0C30\u0C41\u0C38\u0C32\u0C47\u0C35\u0C40 \u0C26\u0C4A\u0C30\u0C15\u0C32\u0C47\u0C26\u0C41.",highlighted:e=>`${e} \u0C35\u0C30\u0C41\u0C38(\u0C32\u0C41) \u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D \u0C1A\u0C47\u0C36\u0C3E\u0C28\u0C41.`,selected:e=>`"${e}" \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41.`,opened:e=>`"${e}" \u0C24\u0C46\u0C30\u0C3F\u0C1A\u0C3E\u0C28\u0C41.`,notSupported:e=>`\u0C08 \u0C2A\u0C1F\u0C4D\u0C1F\u0C3F\u0C15\u0C32\u0C4B "${e}" \u0C38\u0C4C\u0C15\u0C30\u0C4D\u0C2F\u0C02 \u0C32\u0C47\u0C26\u0C41.`,emptyQuery:"\u0C35\u0C46\u0C24\u0C15\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C0F\u0C26\u0C48\u0C28\u0C3E \u0C30\u0C3E\u0C2F\u0C02\u0C21\u0C3F.",noIds:"\u0C35\u0C30\u0C41\u0C38 ID\u0C32\u0C41 \u0C07\u0C35\u0C4D\u0C35\u0C32\u0C47\u0C26\u0C41.",unknownColumn:e=>`"${e}" \u0C05\u0C28\u0C47 \u0C15\u0C3E\u0C32\u0C2E\u0C4D \u0C32\u0C47\u0C26\u0C41.`,badOperator:e=>`"${e}" \u0C05\u0C28\u0C47 \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C3F\u0C27\u0C3E\u0C28\u0C02 \u0C32\u0C47\u0C26\u0C41.`,badValue:"\u0C08 \u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C15\u0C3F \u0C08 \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C3F\u0C32\u0C41\u0C35 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C26\u0C41.",filtered:e=>`\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C47\u0C36\u0C3E\u0C28\u0C41: ${e} \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C2F\u0C3E\u0C2F\u0C3F.`,filtersCleared:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C28\u0C4D\u0C28\u0C40 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C28\u0C41.",sorted:(e,t)=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C15\u0C4D\u0C30\u0C2E\u0C02 (${t==="asc"?"\u0C06\u0C30\u0C4B\u0C39\u0C23":"\u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23"}).`,sortCleared:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C28\u0C41.",internal:"\u0C08 \u0C2A\u0C28\u0C3F \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C41\u0C02\u0C21\u0C17\u0C3E \u0C38\u0C2E\u0C38\u0C4D\u0C2F \u0C35\u0C1A\u0C4D\u0C1A\u0C3F\u0C02\u0C26\u0C3F."}};function Re(e){return pa[e.locale??"en"]}function Fe(e,t){return{success:!0,message:e,data:t}}function ie(e,t){return{success:!1,message:t,error:{code:e}}}var Do=["contains","equals","startsWith","endsWith","greaterThan","lessThan","between"];function me(e,t="id"){let n=e?.[t];return n==null?"":String(n)}function et(e){return String(e??"").normalize("NFC").toLowerCase().trim()}function Oo(e){if(typeof e=="number")return Number.isFinite(e)?e:null;let t=String(e??"").trim();if(t==="")return null;let n=Number(t);return Number.isFinite(n)?n:null}function Wo(e){if(e instanceof Date)return e.getTime();let t=new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null}function Bo(e){return(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>String(n).trim()).filter(Boolean)}function Cn(e,t){let n=et(t);return e.columns.find(o=>et(o.key)===n||et(o.label)===n)}function _t(e,t){return e.data.find(n=>me(n,e.rowKey)===t)}function ga(e,t){return e[t]}function fa(e,t,n){let o=ga(e,n.key),r=n.type??"text";if(r==="number"||r==="date"){let a=r==="number"?Oo:Wo,l=a(o);if(l===null)return!1;if(t.operator==="between"){let[u,b]=t.value,p=a(u),g=a(b);return p!==null&&g!==null&&l>=Math.min(p,g)&&l<=Math.max(p,g)}let c=a(t.value);if(c===null)return!1;switch(t.operator){case"equals":return l===c;case"greaterThan":return l>c;case"lessThan":return l<c;default:break}}let s=et(o),i=et(t.value);switch(t.operator){case"equals":return s===i;case"startsWith":return s.startsWith(i);case"endsWith":return s.endsWith(i);case"contains":return s.includes(i);default:return!1}}function ma(e,t){let n=t.type??"text",o=n==="date"?Wo:Oo;return e.operator==="between"?n==="text"||!Array.isArray(e.value)||e.value.length!==2?!1:o(e.value[0])!==null&&o(e.value[1])!==null:e.operator==="greaterThan"||e.operator==="lessThan"?n!=="text"&&o(e.value)!==null:!Array.isArray(e.value)&&String(e.value).trim()!==""}function je(e,t,n){return n.length?Ho({data:e,columns:t},n):e}function tt(e){return e.map(t=>({key:String(t.key),label:t.label,type:t.type==="number"?"number":t.type==="date"?"date":"text"}))}function Ho(e,t){return e.data.filter(n=>t.every(o=>{let r=Cn(e,o.key);return r?fa(n,o,r):!0}))}function qo(e,t){let n=Re(e),o=et(t);if(!o)return ie("INVALID_INPUT",n.emptyQuery);let r=e.data.filter(i=>e.columns.some(a=>et(i[a.key]).includes(o))),s=r.map(i=>me(i,e.rowKey)).filter(Boolean);return e.onHighlightRows?.(s),Fe(n.found(r.length),r)}function _o(e){return Fe(Re(e).count(e.data.length),e.data.length)}function jo(e){return Fe(Re(e).columns,e.columns)}function Uo(e,t){let n=Re(e),o=String(t??"").trim();if(!o)return ie("INVALID_INPUT",n.noIds);let r=_t(e,o);return r?Fe(n.rowFound,r):ie("NOT_FOUND",n.notFound(o))}function kt(e,t){let n=Re(e),o=Bo(t);if(o.length===0)return ie("INVALID_INPUT",n.noIds);if(!e.onHighlightRows)return ie("NOT_SUPPORTED",n.notSupported("highlight"));let r=o.filter(s=>_t(e,s)!==void 0);return r.length===0?ie("NOT_FOUND",n.noneFound):(e.onHighlightRows(r),Fe(n.highlighted(r.length),r))}function jt(e,t){let n=Re(e),o=String(t??"").trim();return o?e.onSelectRow?_t(e,o)?(e.onSelectRow(o),Fe(n.selected(o),o)):ie("NOT_FOUND",n.notFound(o)):ie("NOT_SUPPORTED",n.notSupported("select")):ie("INVALID_INPUT",n.noIds)}function Ut(e,t){let n=Re(e),o=String(t??"").trim();return o?e.onOpenRow?_t(e,o)?(e.onOpenRow(o),Fe(n.opened(o),o)):ie("NOT_FOUND",n.notFound(o)):ie("NOT_SUPPORTED",n.notSupported("open")):ie("INVALID_INPUT",n.noIds)}function Vo(e,t){let n=Re(e),o=Cn(e,t?.key??"");if(!o)return ie("INVALID_INPUT",n.unknownColumn(String(t?.key??"")));if(!Do.includes(t.operator))return ie("INVALID_INPUT",n.badOperator(String(t.operator)));let r={...t,key:o.key};if(!ma(r,o))return ie("INVALID_INPUT",n.badValue);if(!e.onFiltersChange)return ie("NOT_SUPPORTED",n.notSupported("filter"));let s=[...(e.filters??[]).filter(a=>a.key!==o.key),r],i=Ho(e,s).length;return e.onFiltersChange(s),Fe(n.filtered(i),{filters:s,count:i})}function Yo(e){let t=Re(e);return e.onFiltersChange?(e.onFiltersChange([]),Fe(t.filtersCleared,[])):ie("NOT_SUPPORTED",t.notSupported("clear filters"))}function Ko(e,t,n="asc"){let o=Re(e),r=Cn(e,t);if(!r)return ie("INVALID_INPUT",o.unknownColumn(String(t)));if(n!=="asc"&&n!=="desc")return ie("INVALID_INPUT",o.badValue);if(!e.onSortChange)return ie("NOT_SUPPORTED",o.notSupported("sort"));let s={key:r.key,direction:n};return e.onSortChange(s),Fe(o.sorted(r.label,n),s)}function Qo(e){let t=Re(e);return e.onSortChange?(e.onSortChange(null),Fe(t.sortCleared,null)):ie("NOT_SUPPORTED",t.notSupported("clear sort"))}var ba={search:"Search all columns for text. Matching rows are highlighted.",count:"Count the rows currently in the grid.",columns:"List the grid's columns with their keys, labels and types.",get_row:"Get one row by its ID.",highlight:"Highlight one or more rows by ID without filtering the grid.",select:"Select one row by ID.",open:"Open one row by ID to show its full details.",filter:"Filter the grid by one column. Replaces any existing filter on that column.",clear_filters:"Remove all filters.",sort:"Sort the grid by one column, ascending or descending.",clear_sort:"Remove sorting."},zo={en:{search:"Search",count:"Count",columns:"Columns",get_row:"Get row",highlight:"Highlight",select:"Select",open:"Open",filter:"Filter",clear_filters:"Clear filters",sort:"Sort",clear_sort:"Clear sort"},te:{search:"\u0C35\u0C46\u0C24\u0C41\u0C15\u0C41",count:"\u0C32\u0C46\u0C15\u0C4D\u0C15",columns:"\u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C32\u0C41",get_row:"\u0C35\u0C30\u0C41\u0C38 \u0C1A\u0C42\u0C2A\u0C41",highlight:"\u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D",select:"\u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B",open:"\u0C24\u0C46\u0C30\u0C41\u0C35\u0C41",filter:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D",clear_filters:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F",sort:"\u0C15\u0C4D\u0C30\u0C2E\u0C02",clear_sort:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F"}};async function ha(e,t){try{return t()}catch{return ie("INTERNAL",Re(e).internal)}}function vt(e,t={}){let n=t.name??"yuktai_grid",o=zo[e.locale??"en"],r=l=>t.descriptions?.[l]??ba[l],s={id:{type:"string",description:"Row ID"}},i=e.columns.map(l=>l.key);return[{id:"search",available:!0,schema:{type:"object",properties:{query:{type:"string"}},required:["query"]},run:l=>qo(e,String(l.query??""))},{id:"count",available:!0,schema:{type:"object",properties:{}},run:()=>_o(e)},{id:"columns",available:!0,schema:{type:"object",properties:{}},run:()=>jo(e)},{id:"get_row",available:!0,schema:{type:"object",properties:s,required:["id"]},run:l=>Uo(e,String(l.id??""))},{id:"highlight",available:!!e.onHighlightRows,schema:{type:"object",properties:{ids:{type:"array",items:{type:"string"},description:"Row IDs"}},required:["ids"]},run:l=>kt(e,Bo(l.ids))},{id:"select",available:!!e.onSelectRow,schema:{type:"object",properties:s,required:["id"]},run:l=>jt(e,String(l.id??""))},{id:"open",available:!!e.onOpenRow,schema:{type:"object",properties:s,required:["id"]},run:l=>Ut(e,String(l.id??""))},{id:"filter",available:!!e.onFiltersChange,schema:{type:"object",properties:{key:{type:"string",enum:i},operator:{type:"string",enum:Do},value:{description:"Text or number; for 'between' an array of two numbers or dates"}},required:["key","operator","value"]},run:l=>Vo(e,{key:String(l.key??""),operator:String(l.operator??""),value:l.value})},{id:"clear_filters",available:!!e.onFiltersChange,schema:{type:"object",properties:{}},run:()=>Yo(e)},{id:"sort",available:!!e.onSortChange,schema:{type:"object",properties:{key:{type:"string",enum:i},direction:{type:"string",enum:["asc","desc"]}},required:["key"]},run:l=>Ko(e,String(l.key??""),l.direction==="desc"?"desc":"asc")},{id:"clear_sort",available:!!e.onSortChange,schema:{type:"object",properties:{}},run:()=>Qo(e)}].filter(l=>l.available).map(l=>({name:`${n}_${l.id}`,title:zo.en[l.id],description:r(l.id),label:o[l.id],inputSchema:l.schema,execute:c=>ha(e,()=>l.run(c??{}))}))}var xa={en:{done:"Done.",toolMissing:e=>`The action "${e}" is not available here.`,missingInput:e=>`Missing: ${e}.`,notUnderstood:"Sorry, I didn't understand. Try: a word to search, \u201Csort by <column>\u201D, or \u201Cclear filters\u201D.",noMatch:e=>`Nothing matched "${e}".`,failed:"Something went wrong while running this action."},te:{done:"\u0C2A\u0C42\u0C30\u0C4D\u0C24\u0C2F\u0C3F\u0C02\u0C26\u0C3F.",toolMissing:e=>`"${e}" \u0C38\u0C4C\u0C15\u0C30\u0C4D\u0C2F\u0C02 \u0C07\u0C15\u0C4D\u0C15\u0C21 \u0C05\u0C02\u0C26\u0C41\u0C2C\u0C3E\u0C1F\u0C41\u0C32\u0C4B \u0C32\u0C47\u0C26\u0C41.`,missingInput:e=>`\u0C07\u0C35\u0C3F \u0C15\u0C3E\u0C35\u0C3E\u0C32\u0C3F: ${e}.`,notUnderstood:"\u0C15\u0C4D\u0C37\u0C2E\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F, \u0C05\u0C30\u0C4D\u0C25\u0C02 \u0C15\u0C3E\u0C32\u0C47\u0C26\u0C41. \u0C07\u0C32\u0C3E \u0C2A\u0C4D\u0C30\u0C2F\u0C24\u0C4D\u0C28\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F: \u0C35\u0C46\u0C24\u0C15\u0C3E\u0C32\u0C4D\u0C38\u0C3F\u0C28 \u0C2A\u0C26\u0C02, \u201C<\u0C15\u0C3E\u0C32\u0C2E\u0C4D> \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u201D, \u0C32\u0C47\u0C26\u0C3E \u201C\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F\u201D.",noMatch:e=>`"${e}" \u0C15\u0C3F \u0C0F\u0C2E\u0C40 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C32\u0C47\u0C26\u0C41.`,failed:"\u0C08 \u0C2A\u0C28\u0C3F \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C41\u0C02\u0C21\u0C17\u0C3E \u0C38\u0C2E\u0C38\u0C4D\u0C2F \u0C35\u0C1A\u0C4D\u0C1A\u0C3F\u0C02\u0C26\u0C3F."}},Jo=e=>e.normalize("NFC").toLowerCase().trim(),Ue={clearFilters:/\b(clear|remove|reset)\b.*\bfilters?\b|ఫిల్టర్.*(తీసే|తొలగ)/i,clearSort:/\b(clear|remove|reset)\b.*\bsort(ing)?\b|క్రమం.*(తీసే|తొలగ)/i,count:/^\s*(how many|count)\b|ఎన్ని|లెక్క/i,sort:/\bsort\b|\border by\b|క్రమ|అమర్చ|సార్ట్/i,desc:/\b(desc|descending|z\s*-\s*a|highest|largest|most)\b|అవరోహణ|తగ్గే|పెద్ద|అధిక|చివర|ఎక్కువ నుండి/i,openEn:/^\s*open\s+(.+?)\s*$/i,openTe:/^\s*(.+?)\s*(తెరువు|తెరవండి|తెరవు)\s*$/,searchFiller:/^\s*(search(\s+for)?|find|show(\s+me)?|filter(\s+by)?|look\s+for|వెతుకు|వెతకండి|శోధించు|శోధించండి|చూపించు|చూపించండి)\s+|\s+(వెతుకు|వెతకండి|శోధించు|శోధించండి|చూపించు|చూపించండి)\s*$/gi};function wa(e,t){let n=Jo(e),o=null;for(let r of t)for(let s of[r.label,r.key]){let i=Jo(s);i&&n.includes(i)&&(!o||i.length>o.len)&&(o={key:r.key,len:i.length})}return o?.key??null}function Xo(e,t){let n=(e??"").trim();if(!n)return null;if(Ue.clearFilters.test(n))return{kind:"tool",tool:"clear_filters",input:{}};if(Ue.clearSort.test(n))return{kind:"tool",tool:"clear_sort",input:{}};if(Ue.count.test(n))return{kind:"tool",tool:"count",input:{}};if(Ue.sort.test(n)){let s=wa(n,t.columns);return s?{kind:"tool",tool:"sort",input:{key:s,direction:Ue.desc.test(n)?"desc":"asc"}}:null}let o=n.match(Ue.openEn)??n.match(Ue.openTe);if(o?.[1])return{kind:"open",text:o[1].trim()};let r=n.replace(Ue.searchFiller,"").trim();return r?{kind:"tool",tool:"search",input:{query:r}}:null}function ka(e){return!!e&&typeof e=="object"&&typeof e.success=="boolean"&&typeof e.message=="string"}function va(e,t){let n=e.inputSchema?.required;return Array.isArray(n)?n.map(String).filter(o=>t[o]===void 0||t[o]===null||String(t[o]).trim()===""):[]}function Sa(e,t){let n=e.find(r=>r.name===t);if(n)return n;let o=e.filter(r=>r.name.endsWith(`_${t}`)).sort((r,s)=>r.name.length-s.name.length);if(o.length!==0&&!(o.length>1&&o[0].name.length===o[1].name.length))return o[0]}function Zo(e){return e.normalize("NFC").trim().toLocaleLowerCase()}function Ta(e,t){let n=Zo(e);return t.find(o=>o.phrases.some(r=>{let s=Zo(r);return s.length>0&&n.includes(s)}))}function Yt({tools:e,data:t=[],onResult:n,onError:o,locale:r="en",columns:s=[],rowKey:i="id",parseIntent:a,customRules:l=[],historyLimit:c=20}){let u=xa[r],[b,p]=Vt(0),[g,f]=Vt(null),[h,d]=Vt(null),[x,k]=Vt([]),m=Rn({tools:e,data:t,onResult:n,onError:o,columns:s,rowKey:i,parseIntent:a,customRules:l,historyLimit:c,m:u,locale:r});m.current={tools:e,data:t,onResult:n,onError:o,columns:s,rowKey:i,parseIntent:a,customRules:l,historyLimit:c,m:u,locale:r};let v=Rn(!0),w=Rn(0);ya(()=>(v.current=!0,()=>{v.current=!1}),[]);let A=St((E,I,y,q,B)=>{v.current&&(B===w.current&&f(y),k(U=>[...U,{id:B,tool:E,input:I,result:y,source:q,at:Date.now()}].slice(-m.current.historyLimit)))},[]),C=St(async(E,I,y)=>{let{tools:q,onResult:B,onError:U,m:oe}=m.current,de=++w.current,z=Sa(q,E);if(!z){let T={success:!1,message:oe.toolMissing(E),error:{code:"NOT_SUPPORTED"}},P=new Error(T.message);return v.current&&d(P),U?.(P),A(E,I,T,y,de),T}let H=va(z,I);if(H.length){let T={success:!1,message:oe.missingInput(H.join(", ")),error:{code:"INVALID_INPUT"},tool:z.name};return A(z.name,I,T,y,de),B?.(T),T}v.current&&p(T=>T+1);try{let T=await z.execute(I),P=ka(T)?{...T,tool:z.name}:{success:!0,message:oe.done,data:T,tool:z.name};return v.current&&P.success&&d(null),A(z.name,I,P,y,de),B?.(P),P}catch(T){let P=T instanceof Error?T:new Error(String(T)),J={success:!1,message:oe.failed,error:{code:"INTERNAL"},tool:z.name};return v.current&&d(P),U?.(P),A(z.name,I,J,y,de),J}finally{v.current&&p(T=>Math.max(0,T-1))}},[A]),F=St((E,I={})=>C(E,I??{},"tool"),[C]),D=St(async E=>{let{columns:I,locale:y,parseIntent:q,customRules:B,data:U,m:oe,rowKey:de}=m.current,z=Ta(E,B??[]);if(z){let W={input:E,data:U,columns:I,executeTool:F};try{let fe={success:!0,message:await z.execute(W),tool:`rule:${z.name}`};return A(`rule:${z.name}`,{text:E},fe,"ask",++w.current),m.current.onResult?.(fe),fe}catch(ae){let fe=ae instanceof Error?ae:new Error(String(ae)),ve={success:!1,message:oe.failed,error:{code:"INTERNAL"},tool:`rule:${z.name}`};return v.current&&d(fe),m.current.onError?.(fe),A(`rule:${z.name}`,{text:E},ve,"ask",++w.current),ve}}let T=(q??Xo)(E,{columns:I,locale:y});if(!T){let W={success:!1,message:oe.notUnderstood,error:{code:"NOT_UNDERSTOOD"}};return A("ask",{text:E},W,"ask",++w.current),W}if(T.kind==="tool")return C(T.tool,T.input,"ask");let P=await C("search",{query:T.text},"ask"),J=Array.isArray(P.data)?P.data:[];if(!P.success)return P;if(J.length===0){let W={success:!1,message:oe.noMatch(T.text),error:{code:"NOT_FOUND"},tool:P.tool};return A("open",{text:T.text},W,"ask",++w.current),W}return C("open",{id:me(J[0],de)},"ask")},[F,A,C]),M=St(()=>{k([]),f(null),d(null)},[]);return{loading:b>0,tools:e,executeTool:F,ask:D,lastResult:g,lastError:h,history:x,clearHistory:M}}var Aa=Yt;import{useEffect as Ca,useMemo as Ra,useRef as In}from"react";function Ia(e){return JSON.stringify(e.map(t=>[t.name,t.title,t.description,t.inputSchema]))}function $a({tools:e,data:t=[],columns:n=[],rowKey:o,locale:r,onSelectRow:s,onHighlightRows:i,onOpenRow:a,name:l="yuktai_grid",descriptions:c,onStatusChange:u}){let b=Ra(()=>e||vt({data:t,columns:n,rowKey:o,locale:r,onSelectRow:s,onHighlightRows:i,onOpenRow:a},{name:l,descriptions:c}),[e,t,n,o,r,s,i,a,l,c]),p=In(b);p.current=b;let g=In(u);g.current=u;let f=In(Promise.resolve()),h=Ia(b);return Ca(()=>{let d=w=>g.current?.(w),x=typeof document<"u"?document.modelContext:void 0;if(!x?.registerTool){d({state:"unsupported",registered:[],errors:[]});return}let k=new AbortController,m=p.current,v=f.current.then(async()=>{if(k.signal.aborted)return;d({state:"registering",registered:[],errors:[]});let w=[],A=[];for(let C of m){if(k.signal.aborted)return;try{await x.registerTool({name:C.name,title:C.title,description:C.description,inputSchema:C.inputSchema,execute:F=>{let D=p.current.find(M=>M.name===C.name);return D?D.execute(F??{}):{success:!1,message:`Tool "${C.name}" is no longer available.`,error:{code:"NOT_SUPPORTED"}}}},{signal:k.signal}),w.push(C.name)}catch(F){A.push({tool:C.name,message:F instanceof Error?F.message:String(F)})}}k.signal.aborted||d({state:A.length===0?"ready":w.length>0?"partial":"error",registered:w,errors:A})});return f.current=v.catch(()=>{}),()=>k.abort()},[h]),null}var Kt=$a;import{jsx as O,jsxs as ge}from"react/jsx-runtime";var Ea={"en-US":{search:"Search...",searchAria:"Search grid",rows:"rows",row:"row",loading:"Loading...",noData:"No data found.",selectRow:"Select row",pageSize:"Page size",page:"Page",of:"of",previous:"Previous",next:"Next",yes:"Yes",no:"No",sortAscending:"Sort ascending",sortDescending:"Sort descending",filtersActive:e=>`${e} filter(s) applied`,clearFilters:"Clear filters"},"te-IN":{search:"\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F...",searchAria:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C32\u0C4B \u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F",rows:"\u0C35\u0C30\u0C41\u0C38\u0C32\u0C41",row:"\u0C35\u0C30\u0C41\u0C38",loading:"\u0C32\u0C4B\u0C21\u0C4D \u0C05\u0C35\u0C41\u0C24\u0C4B\u0C02\u0C26\u0C3F...",noData:"\u0C21\u0C47\u0C1F\u0C3E \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.",selectRow:"\u0C35\u0C30\u0C41\u0C38\u0C28\u0C41 \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B\u0C02\u0C21\u0C3F",pageSize:"\u0C2A\u0C47\u0C1C\u0C40 \u0C2A\u0C30\u0C3F\u0C2E\u0C3E\u0C23\u0C02",page:"\u0C2A\u0C47\u0C1C\u0C40",of:"\u0C32\u0C4B",previous:"\u0C35\u0C46\u0C28\u0C41\u0C15\u0C15\u0C41",next:"\u0C2E\u0C41\u0C02\u0C26\u0C41\u0C15\u0C41",yes:"\u0C05\u0C35\u0C41\u0C28\u0C41",no:"\u0C15\u0C3E\u0C26\u0C41",sortAscending:"\u0C06\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u0C32\u0C4B \u0C05\u0C2E\u0C30\u0C4D\u0C1A\u0C02\u0C21\u0C3F",sortDescending:"\u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u0C32\u0C4B \u0C05\u0C2E\u0C30\u0C4D\u0C1A\u0C02\u0C21\u0C3F",filtersActive:e=>`${e} \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D(\u0C32\u0C41) \u0C35\u0C47\u0C36\u0C3E\u0C30\u0C41`,clearFilters:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C02\u0C21\u0C3F"}};function Ga({size:e=20,color:t="currentColor",strokeWidth:n=2.4}){return ge("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[O("circle",{cx:"11",cy:"11",r:"6.5"}),O("path",{d:"m16 16 5 5"})]})}function Fa({size:e=18,color:t="currentColor",strokeWidth:n=2.4,label:o}){return ge("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":o?void 0:!0,"aria-label":o,role:o?"img":void 0,children:[o?O("title",{children:o}):null,O("path",{d:"m6 15 6-6 6 6"})]})}function La({size:e=18,color:t="currentColor",strokeWidth:n=2.4,label:o}){return ge("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":o?void 0:!0,"aria-label":o,role:o?"img":void 0,children:[o?O("title",{children:o}):null,O("path",{d:"m6 9 6 6 6-6"})]})}function Pa({size:e=20,color:t="currentColor",strokeWidth:n=2.4}){return O("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:O("path",{d:"m15 18-6-6 6-6"})})}function Ma({size:e=20,color:t="currentColor",strokeWidth:n=2.4}){return O("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:O("path",{d:"m9 18 6-6-6-6"})})}function er({size:e=18,color:t="currentColor",strokeWidth:n=2.4}){return O("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:O("path",{d:"m5 12 4 4L19 6"})})}function Na({data:e,columns:t,rowKey:n="id",view:o="auto",mobileBreakpoint:r=768,theme:s="default",locale:i="en-US",ai:a=!1,search:l=!0,selectable:c=!1,selectedKeys:u=[],onSelectionChange:b,pagination:p,loading:g=!1,highlightIds:f=[],highlightColor:h="#fff3a3",autoScrollToHighlight:d=!1,onRowClick:x,onSortChange:k,empty:m,className:v="",inputLanguage:w,toolName:A="yuktai_grid",toolDescriptions:C,webmcp:F=!1,onWebMCPStatusChange:D,onAgentResult:M,customRules:E=[]}){let I=i==="te-IN"?"te-IN":"en-US",y=Ea[I],q=a===!0||typeof a=="object"&&a!==null,B=p!==!1&&p!==void 0,U=typeof p=="object"?p.pageSize??20:20,oe=typeof p=="object"&&p.sizeOptions&&p.sizeOptions.length>0?p.sizeOptions:[10,20,50,100],[de,z]=Ve(""),[H,T]=Ve(1),[P,J]=Ve(U),[W,ae]=Ve(),[fe,ve]=Ve("asc"),[De,jn]=Ve(!1),[Se,nt]=Ve([]),[mt,Ct]=Ve([]),Be=pt(()=>tt(t.map(S=>({key:String(S.key),label:S.label,type:S.type}))),[t]);Qt(()=>{J(U),T(1)},[U]),Qt(()=>{let S=()=>{jn(window.innerWidth<=r)};return S(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}},[r]);let we=pt(()=>{let S=[...e];if(de.trim()){let N=de.trim().toLowerCase();S=S.filter(Y=>t.some(j=>String(Y[j.key]??"").toLowerCase().includes(N)))}return Se.length&&(S=je(S,Be,Se)),W&&S.sort((N,Y)=>{let j=N[W],Te=Y[W];if(j==null&&Te==null)return 0;if(j==null)return 1;if(Te==null)return-1;if(typeof j=="number"&&typeof Te=="number")return fe==="asc"?j-Te:Te-j;let be=String(j).localeCompare(String(Te),i,{numeric:!0,sensitivity:"base"});return fe==="asc"?be:-be}),S},[e,t,de,Se,Be,W,fe,i]),Oe=B?Math.max(1,Math.ceil(we.length/P)):1;Qt(()=>{H>Oe&&T(Oe)},[H,Oe]);let bt=pt(()=>{let S=[...f.map(String),...mt];return Array.from(new Set(S))},[f,mt]);Qt(()=>{if(!d)return;let S=bt[0];if(S==null)return;let N=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(String(S)):String(S).replace(/["\\]/g,"\\$&");document.querySelector(`[data-yuktai-row-id="${N}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},[bt,d,H]);let Qe=pt(()=>{if(!B)return we;let S=(H-1)*P;return we.slice(S,S+P)},[we,B,H,P]),ot=o==="card"||o==="auto"&&De,He=S=>String(S[n]??""),rt=S=>u.some(N=>String(N)===S),Rt=S=>bt.some(N=>String(N)===S),$=S=>{if(!c)return;let N=He(S),Y=rt(N)?u.filter(j=>String(j)!==N):[...u,N];b?.(Y)},ne=S=>{if(S.sortable===!1)return;let N=String(S.key),Y=W===N&&fe==="asc"?"desc":"asc";ae(N),ve(Y),T(1),k?.({key:N,direction:Y})},Me=S=>{z(S),T(1)},rn=(S,N)=>{let Y=t.find(j=>String(j.key)===S||j.label.toLowerCase()===S.toLowerCase());Y&&(ae(String(Y.key)),ve(N),T(1),k?.({key:String(Y.key),direction:N}))},sn=I==="te-IN"?"te":"en",Un=$n(S=>{S?(ae(S.key),ve(S.direction)):(ae(void 0),ve("asc")),T(1),k?.(S)},[k]),Vn=$n(S=>{nt(S),T(1)},[]),Yn=$n(S=>{if(Ct(S),B&&S.length){let N=we.findIndex(Y=>String(Y[n]??"")===S[0]);N>=0&&T(Math.floor(N/P)+1)}},[B,we,n,P]),an=pt(()=>vt({data:e,columns:Be,rowKey:String(n),locale:sn,filters:Se,onHighlightRows:Yn,onFiltersChange:Vn,onSortChange:Un,onOpenRow:x?S=>{let N=we.findIndex(j=>String(j[n]??"")===S),Y=N>=0?we[N]:e.find(j=>String(j[n]??"")===S);Y&&x(Y,Math.max(N,0))}:void 0,onSelectRow:c&&b?S=>{u.some(N=>String(N)===S)||b([...u.map(String),S])}:void 0},{name:A,descriptions:C}),[e,Be,n,sn,Se,Yn,Vn,Un,x,we,c,b,u,A,C]),It=Yt({tools:an,data:e,locale:sn,columns:Be,rowKey:String(n),customRules:E,onResult:M}),Kn=pt(()=>an.map(S=>({...S,execute:N=>It.executeTool(S.name,N)})),[an,It.executeTool]),Fr=()=>{nt([]),T(1)},Qn=(S,N,Y)=>{if(N.render)return N.render(S[N.key],S,Y);let j=S[N.key];if(j==null)return"";if(N.type==="date"){let Te=new Date(String(j));if(!Number.isNaN(Te.getTime()))return Te.toLocaleDateString(i)}return N.type==="boolean"?j?y.yes:y.no:String(j)},Z=s==="dark",Jn={width:"100%",overflow:"hidden",border:s==="high-contrast"?"2px solid #000000":Z?"1px solid #334155":"1px solid #e2e8f0",borderRadius:12,background:Z?"#0f172a":"#ffffff",color:Z?"#f8fafc":"#0f172a",fontFamily:s==="dyslexia"?"Arial, sans-serif":void 0},Lr={padding:12,display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0"},Zn=S=>({width:40,height:40,minWidth:40,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,borderRadius:8,border:Z?"1px solid #475569":"1px solid #cbd5e1",background:S?Z?"#1e293b":"#f8fafc":Z?"#1e293b":"#ffffff",color:S?"#94a3b8":Z?"#f8fafc":"#0f172a",cursor:S?"not-allowed":"pointer",opacity:S?.55:1});if(g)return ge("div",{className:v,style:Jn,children:[F&&O(Kt,{tools:Kn,onStatusChange:D}),O("div",{style:{padding:32,textAlign:"center"},children:y.loading})]});let Pr=t.map(S=>({key:String(S.key),label:S.label,type:S.type==="number"?"number":S.type==="date"?"date":"text"}));return ge("div",{className:v,style:Jn,children:[F&&O(Kt,{tools:Kn,onStatusChange:D}),(l||q||Se.length>0)&&ge("div",{style:Lr,children:[l&&ge("div",{style:{position:"relative",width:"100%",maxWidth:420},children:[O("div",{style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",color:Z?"#cbd5e1":"#64748b",pointerEvents:"none"},children:O(Ga,{size:19})}),O("input",{value:de,onChange:S=>{z(S.target.value),T(1)},placeholder:y.search,"aria-label":y.searchAria,style:{width:"100%",padding:"10px 12px 10px 40px",borderRadius:8,border:Z?"1px solid #475569":"1px solid #cbd5e1",background:Z?"#1e293b":"#ffffff",color:Z?"#ffffff":"#0f172a",outline:"none",boxSizing:"border-box"}})]}),Se.length>0&&ge("button",{type:"button",onClick:Fr,title:y.clearFilters,style:{padding:"6px 10px",borderRadius:999,border:Z?"1px solid #475569":"1px solid #cbd5e1",background:Z?"#1e293b":"#f1f5f9",color:"inherit",fontSize:12,cursor:"pointer"},children:[y.filtersActive(Se.length)," \u2715"]}),ge("div",{style:{marginLeft:"auto",fontSize:13,opacity:.7,whiteSpace:"nowrap"},children:[we.length," ",we.length===1?y.row:y.rows]}),q&&O(An,{data:e,columns:Pr,onSearch:Me,onSort:rn,theme:Z?"dark":"light",language:I,inputLanguage:w??I,agent:{ask:It.ask,loading:It.loading},embedded:!0})]}),we.length===0?O("div",{style:{padding:40,textAlign:"center",opacity:.7},children:m??y.noData}):ot?O("div",{style:{display:"grid",gap:12,padding:12},children:Qe.map((S,N)=>{let Y=He(S),j=rt(Y),Te=Rt(Y);return ge("div",{"data-yuktai-row-id":Y,onClick:()=>x?.(S,N),style:{padding:14,borderRadius:10,border:Z?"1px solid #334155":"1px solid #e2e8f0",background:Te?h:j?Z?"#1e3a5f":"#eff6ff":Z?"#1e293b":"#ffffff",cursor:x?"pointer":"default"},children:[c&&O("button",{type:"button",onClick:be=>{be.stopPropagation(),$(S)},"aria-label":`${y.selectRow} ${Y}`,"aria-pressed":j,style:{width:32,height:32,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,marginBottom:10,borderRadius:7,border:j?"1px solid #2563eb":"1px solid #cbd5e1",background:j?"#2563eb":"transparent",color:j?"#ffffff":"currentColor",cursor:"pointer"},children:j&&O(er,{size:17})}),t.map(be=>ge("div",{style:{display:"flex",gap:8,padding:"5px 0",alignItems:"flex-start"},children:[O("strong",{style:{minWidth:100,opacity:.7},children:be.label}),O("span",{children:Qn(S,be,N)})]},String(be.key)))]},Y)})}):O("div",{style:{width:"100%",overflowX:"auto"},children:ge("table",{style:{width:"100%",borderCollapse:"collapse"},children:[O("thead",{children:ge("tr",{children:[c&&O("th",{style:{padding:10,borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0",width:52}}),t.filter(S=>!(De&&S.hiddenOnMobile)).map(S=>{let N=W===String(S.key);return O("th",{onClick:()=>ne(S),style:{padding:10,textAlign:S.align??"left",borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0",whiteSpace:"nowrap",cursor:S.sortable===!1?"default":"pointer",width:S.width,userSelect:"none"},children:ge("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[S.label,N&&(fe==="asc"?O(Fa,{size:17,label:y.sortAscending}):O(La,{size:17,label:y.sortDescending}))]})},String(S.key))})]})}),O("tbody",{children:Qe.map((S,N)=>{let Y=He(S),j=rt(Y),Te=Rt(Y);return ge("tr",{"data-yuktai-row-id":Y,onClick:()=>x?.(S,N),style:{background:Te?h:j?Z?"#1e3a5f":"#eff6ff":"transparent",cursor:x?"pointer":"default"},children:[c&&O("td",{style:{padding:10,borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0"},children:O("button",{type:"button",onClick:be=>{be.stopPropagation(),$(S)},"aria-label":`${y.selectRow} ${Y}`,"aria-pressed":j,style:{width:28,height:28,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,borderRadius:6,border:j?"1px solid #2563eb":Z?"1px solid #64748b":"1px solid #cbd5e1",background:j?"#2563eb":"transparent",color:j?"#ffffff":"currentColor",cursor:"pointer"},children:j&&O(er,{size:16})})}),t.filter(be=>!(De&&be.hiddenOnMobile)).map(be=>O("td",{style:{padding:10,textAlign:be.align??"left",borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0"},children:Qn(S,be,N)},String(be.key)))]},Y)})})]})}),B&&ge("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap",padding:12,borderTop:Z?"1px solid #334155":"1px solid #e2e8f0"},children:[ge("span",{style:{fontSize:13,opacity:.7},children:[y.page," ",H," ",y.of," ",Oe]}),ge("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[typeof p=="object"&&p.showSizeChanger&&O("select",{value:P,onChange:S=>{let N=Number(S.target.value);!Number.isFinite(N)||N<=0||(J(N),T(1))},"aria-label":y.pageSize,style:{minHeight:40,padding:"7px 10px",borderRadius:8,border:Z?"1px solid #475569":"1px solid #cbd5e1",background:Z?"#1e293b":"#ffffff",color:Z?"#ffffff":"#0f172a"},children:oe.map(S=>O("option",{value:S,children:S},S))}),O("button",{type:"button",disabled:H<=1,onClick:()=>T(S=>Math.max(1,S-1)),"aria-label":y.previous,title:y.previous,style:Zn(H<=1),children:O(Pa,{size:20})}),O("button",{type:"button",disabled:H>=Oe,onClick:()=>T(S=>Math.min(Oe,S+1)),"aria-label":y.next,title:y.next,style:Zn(H>=Oe),children:O(Ma,{size:20})})]})]})]})}import{useState as gt,useMemo as Tt,useCallback as Le,useEffect as En}from"react";function tr(e){return e===!1?Number.MAX_SAFE_INTEGER:e===!0||e===void 0?10:e.pageSize??10}function nr(e){return String(e??"").normalize("NFC").toLowerCase().trim()}function or(e){return e==null||typeof e=="string"&&e.trim()===""}function rr(e){if(typeof e=="number")return Number.isFinite(e)?e:null;let t=String(e??"").trim();if(t==="")return null;let n=Number(t);return Number.isFinite(n)?n:null}function ir(e){let t=e instanceof Date?e.getTime():new Date(String(e)).getTime();return Number.isFinite(t)?t:null}function za(e,t,n,o){if(n==="number"||typeof e=="number"&&typeof t=="number"){let r=rr(e),s=rr(t);if(r!==null&&s!==null)return r-s}if(n==="date"||e instanceof Date&&t instanceof Date){let r=ir(e),s=ir(t);if(r!==null&&s!==null)return r-s}return typeof e=="boolean"&&typeof t=="boolean"?e===t?0:e?1:-1:String(e).localeCompare(String(t),o,{sensitivity:"base",numeric:!0})}function Da(e){let{data:t,columns:n,pagination:o=!0,mobileBreakpoint:r=768,locale:s,initialFilters:i=[]}=e,[a,l]=gt(null),[c,u]=gt(""),[b,p]=gt(i),[g,f]=gt(1),[h,d]=gt(tr(o)),[x,k]=gt(!1),m=tr(o);En(()=>{d(m),f(1)},[m]),En(()=>{if(typeof window>"u")return;let T=()=>{k(window.innerWidth<=r)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[r]);let v=Tt(()=>tt(n.map(T=>({key:String(T.key),label:T.label,type:T.type}))),[n]),w=Le(T=>{l(P=>!P||P.key!==T?{key:T,direction:"asc"}:P.direction==="asc"?{key:T,direction:"desc"}:null),f(1)},[]),A=Le(T=>{l(T&&T.direction?T:null),f(1)},[]),C=Le(()=>{l(null),f(1)},[]),F=Le(T=>{u(T),f(1)},[]),D=Le(T=>{p(T),f(1)},[]),M=Le(T=>{p(P=>[...P.filter(J=>J.key!==T.key),T]),f(1)},[]),E=Le(T=>{p(P=>P.filter(J=>J.key!==T)),f(1)},[]),I=Le(()=>{p([]),f(1)},[]),y=Le(T=>{d(Math.max(1,Math.floor(T)||1)),f(1)},[]),q=Tt(()=>{let T=nr(c);return T?t.filter(P=>n.some(J=>{let W=P[J.key];return W==null?!1:nr(W).includes(T)})):t},[t,c,n]),B=Tt(()=>je(q,v,b),[q,v,b]),U=Tt(()=>{if(!a||!a.direction)return B;let T=n.find(J=>String(J.key)===a.key),P=a.direction==="desc"?-1:1;return[...B].sort((J,W)=>{let ae=J[a.key],fe=W[a.key],ve=or(ae),De=or(fe);return ve&&De?0:ve?1:De?-1:P*za(ae,fe,T?.type,s)})},[B,a,n,s]),oe=Math.max(1,Math.ceil(U.length/h)),de=Tt(()=>{if(o===!1)return U;let T=(g-1)*h;return U.slice(T,T+h)},[U,g,h,o]);En(()=>{g>oe&&f(oe)},[g,oe]);let z=Le(T=>f(Math.min(Math.max(1,Math.floor(T)||1),oe)),[oe]),H=Le(()=>{l(null),u(""),p([]),f(1)},[]);return{displayedData:de,rows:U,totalCount:t.length,filteredCount:U.length,sort:a,toggleSort:w,setSort:A,clearSort:C,searchQuery:c,setSearchQuery:F,filters:b,setFilters:D,setFilter:M,removeFilter:E,clearFilters:I,page:g,pageSize:h,totalPages:oe,setPage:z,setPageSize:y,isMobile:x,reset:H}}var Jt={"html-lang":{title:"Page language is set",wcag:"3.1.1",severity:"serious",why:"Screen readers pick their voice and pronunciation from the page language. Without it, Telugu or Hindi text may be read with English rules."},"page-title":{title:"Page has a title",wcag:"2.4.2",severity:"serious",why:"The title is the first thing announced and the name shown on browser tabs and bookmarks."},"image-alt":{title:"Images have alternative text",wcag:"1.1.1",severity:"critical",why:'People who cannot see the image get no information from it unless alt text describes it (or alt="" marks it as decorative).'},"heading-order":{title:"Headings follow a logical order",wcag:"1.3.1",severity:"moderate",why:"Many screen-reader users jump between headings. Skipped levels make the page outline confusing."},"single-h1":{title:"Page has one main heading",wcag:"best practice",severity:"minor",why:"A single h1 tells everyone what the page is about."},"landmark-main":{title:"Main content landmark exists",wcag:"1.3.1 / 2.4.1",severity:"moderate",why:"A <main> region lets keyboard and screen-reader users skip straight past menus to the content."},"form-label":{title:"Form fields have labels",wcag:"1.3.1 / 4.1.2",severity:"critical",why:'Without a label, a screen reader just says "edit text" and the user has to guess what to type.'},"button-name":{title:"Buttons have names",wcag:"4.1.2",severity:"critical",why:'An icon-only button with no name is announced as just "button", so its purpose is unknown.'},"link-name":{title:"Links have names",wcag:"2.4.4",severity:"serious",why:"Links are often read out of context in a list. An empty link gives no clue where it goes."},"color-contrast":{title:"Text has enough contrast",wcag:"1.4.3",severity:"serious",why:"Low-contrast text is hard to read for older users, people with low vision, and anyone outdoors on a phone."},"positive-tabindex":{title:"No positive tabindex",wcag:"2.4.3",severity:"moderate",why:"tabindex greater than 0 forces a custom keyboard order that usually doesn't match the visual order."},"keyboard-access":{title:"Clickable things work with a keyboard",wcag:"2.1.1",severity:"critical",why:"A div or span with a click handler can't be reached or activated with Tab and Enter, locking out keyboard users."},"duplicate-id":{title:"IDs are unique",wcag:"best practice",severity:"minor",why:"Labels and ARIA references point at ids. Duplicates make them point at the wrong element."},"form-error":{title:"Errors are linked to their fields",wcag:"3.3.1",severity:"serious",why:"When a field is marked invalid, the error message must be connected to it so it's announced together with the field."},"target-size":{title:"Touch targets are large enough",wcag:"2.5.8",severity:"moderate",why:"Small targets are hard to tap for people with tremors, seniors and everyone on mobile."}},Oa={critical:10,serious:5,moderate:2,minor:1};function Ye(e={}){let t=Ae(e.root),n=new Set(e.skip??[]),o=[],r={},s=t?Je(t)?t:t.ownerDocument:null,i=(a,l,c,u,b=!1)=>{if(n.has(a))return;let p=Jt[a],g=r[a]=(r[a]??0)+1;o.push({id:`${a}-${g}`,rule:a,severity:p.severity,wcag:p.wcag,message:c,why:p.why,fix:u,selector:l?Ne(l):"document",snippet:l?pe(l.outerHTML,120):"",autoFixable:b,element:l??void 0})};if(t&&s){s.documentElement.getAttribute("lang")||i("html-lang",s.documentElement,"The <html> element has no lang attribute.",'Add lang to <html>, e.g. <html lang="te"> or "en".',!0),s.title.trim()||i("page-title",null,"The page has no <title>.","Add a short, descriptive <title> that names this page.");for(let d of _(t,"img"))if(!(d.getAttribute("role")==="presentation"||d.getAttribute("role")==="none")&&!d.hasAttribute("alt")&&!d.getAttribute("aria-label")&&!d.getAttribute("aria-labelledby")){let x=d.getAttribute("title");i("image-alt",d,`Image has no alt text${d.getAttribute("src")?` (${pe(d.getAttribute("src")??"",40)})`:""}.`,x?`Use the title as alt: alt="${pe(x,40)}".`:'Describe the image in alt, or use alt="" if it is purely decorative.',!!x)}let a=_(t,"h1,h2,h3,h4,h5,h6"),l=0;for(let d of a){let x=Number(d.tagName[1]);l>0&&x>l+1&&i("heading-order",d,`Heading jumps from h${l} to h${x}: "${pe(d.textContent??"",40)}".`,`Change it to h${l+1}, or add the missing level above it.`),l=x}let c=a.filter(d=>d.tagName==="H1");c.length===0?i("single-h1",null,"The page has no h1.","Add one h1 that names the page."):c.length>1&&i("single-h1",c[1],`The page has ${c.length} h1 headings.`,"Keep one h1; turn the others into h2."),t.querySelectorAll("main,[role='main']").length===0&&i("landmark-main",null,"No <main> landmark found.","Wrap the primary content in <main>.");let u=_(t,"input,select,textarea").filter(d=>{let x=(d.getAttribute("type")??"text").toLowerCase();return!["hidden","submit","button","reset","image"].includes(x)});for(let d of u){if(!Ie(d)){let x=d.getAttribute("placeholder")||d.getAttribute("name");i("form-label",d,`Form field has no label${x?` (placeholder/name: "${pe(x,30)}")`:""}.`,x?`Add a visible <label>. Quick fix: aria-label="${pe(x,30)}".`:"Add a visible <label for=\u2026> describing what to enter.",!!x)}d.getAttribute("aria-invalid")==="true"&&(d.getAttribute("aria-describedby")||d.getAttribute("aria-errormessage")||i("form-error",d,"Field is marked invalid but no error message is linked to it.","Put the error text in an element with an id and point aria-describedby at it."))}for(let d of _(t,"button,[role='button'],input[type='submit'],input[type='button']"))if(!Ie(d)){let x=d.getAttribute("title");i("button-name",d,"Button has no accessible name.",x?`Use the title as the name: aria-label="${x}".`:"Add visible text or an aria-label that says what the button does.",!!x)}for(let d of _(t,"a[href]"))if(!Ie(d)){let x=d.getAttribute("title");i("link-name",d,`Link has no text (${pe(d.getAttribute("href")??"",40)}).`,x?`Use the title as the name: aria-label="${x}".`:"Add link text that says where it goes.",!!x)}for(let d of _(t,"[tabindex]"))Number(d.getAttribute("tabindex"))>0&&i("positive-tabindex",d,`tabindex="${d.getAttribute("tabindex")}" overrides the natural tab order.`,'Use tabindex="0" and fix the order in the HTML instead.',!0);let b="a[href],button,input,select,textarea,summary";for(let d of _(t,"[onclick],[role='button'],[role='link']"))d.matches(b)||d.hasAttribute("tabindex")||i("keyboard-access",d,`<${d.tagName.toLowerCase()}> is clickable but can't be reached with the keyboard.`,'Use a real <button>, or add tabindex="0", a role and Enter/Space key handling.',!0);let p=new Map;for(let d of Array.from(t.querySelectorAll("[id]")))d.closest("[data-yuktai-panel]")||p.set(d.id,(p.get(d.id)??0)+1);for(let[d,x]of p)x>1&&i("duplicate-id",t.querySelector(`[id="${d.replace(/"/g,'\\"')}"]`),`id="${d}" is used ${x} times.`,"Give each element a unique id.");let g=e.maxContrastChecks??600,f=0;for(let d of _(t,"body *")){if(f>=g)break;if(!ht(d)||["SCRIPT","STYLE","NOSCRIPT","OPTION"].includes(d.tagName))continue;f++;let x=ln(window.getComputedStyle(d).color),k=to(d);if(!x||!k)continue;let m=cn(x,k),v=no(d)?3:4.5;m<v&&i("color-contrast",d,`Contrast ${m}:1 is below ${v}:1 for "${pe(d.textContent??"",30)}".`,`Darken the text or lighten the background until the ratio is at least ${v}:1.`)}let h=e.minTargetSize??24;for(let d of _(t,Gt)){let x=d.getBoundingClientRect();x.width===0&&x.height===0||d.tagName==="A"&&d.closest("p,li,td")||(x.width<h||x.height<h)&&i("target-size",d,`Target is ${Math.round(x.width)}\xD7${Math.round(x.height)}px (minimum ${h}\xD7${h}).`,`Increase padding so it's at least ${h}\xD7${h}px (44\xD744 is better for seniors).`)}}return Wa(o,s,n)}function Wa(e,t,n){let o=Object.keys(Jt).filter(l=>!n.has(l)).map(l=>{let c=e.filter(u=>u.rule===l).length;return{rule:l,title:Jt[l].title,passed:c===0,issueCount:c}}),r=0;for(let l of o){let c=Oa[Jt[l.rule].severity];r+=Math.min(25,l.issueCount*c)}let s=Math.max(0,100-r),i=o.filter(l=>!l.passed),a=e.filter(l=>l.severity==="critical").length;return{url:t?.location?.href??"",title:t?.title??"",generatedAt:new Date().toISOString(),score:s,passed:a===0&&s>=80,checks:o,issues:e,summary:e.length===0?`All ${o.length} checks passed.`:`${o.length-i.length} of ${o.length} checks passed. ${e.length} issue(s) found, ${a} critical. Score ${s}/100.`}}function sr(e){let t=["# Accessibility QA report","",`- Page: ${e.title||"(untitled)"} ${e.url}`,`- Generated: ${e.generatedAt}`,`- Score: **${e.score}/100** \u2014 ${e.passed?"PASS":"FAIL"}`,"",e.summary,"","## Checks","","| Check | Result | Issues |","|---|---|---|",...e.checks.map(n=>`| ${n.title} | ${n.passed?"\u2705 Pass":"\u274C Fail"} | ${n.issueCount} |`)];if(e.issues.length){t.push("","## Issues","");for(let n of e.issues)t.push(`### ${n.id} \xB7 ${n.severity} \xB7 WCAG ${n.wcag}`,"",`- **Problem:** ${n.message}`,`- **Why it matters:** ${n.why}`,`- **Fix:** ${n.fix}`,`- **Where:** \`${n.selector}\``,"")}return t.join(`
396
- `)}function ar(e){return JSON.stringify({...e,issues:e.issues.map(({element:t,...n})=>n)},null,2)}function lr(e={}){let t=null,n=null,o=null,r=!1,s=[],i=()=>({report:t,watching:n!==null,appliedFixes:s.length}),a=()=>e.onUpdate?.(i()),l=p=>t?.issues.find(g=>g.id===p),c=(p,g,f)=>{s.push({element:p,attribute:g,previous:p.getAttribute(g)}),p.setAttribute(g,f)};function u(p){let g=p.element,f=(h,d)=>({issueId:p.id,applied:h,message:d});if(!p.autoFixable||!g)return f(!1,"This needs a human decision \u2014 see the suggested fix.");switch(p.rule){case"html-lang":{let h=e.defaultLang||(We()?navigator.language:"")||"en";return c(g,"lang",h),f(!0,`Set lang="${h}" on <html>.`)}case"image-alt":{let h=g.getAttribute("title");if(!h)break;return c(g,"alt",h),f(!0,`Used the image title as alt text: "${h}".`)}case"form-label":{let h=g.getAttribute("placeholder")||g.getAttribute("name");if(!h)break;let d=h.replace(/[_-]+/g," ").trim();return c(g,"aria-label",d),f(!0,`Added aria-label="${d}". A visible <label> is still better.`)}case"button-name":case"link-name":{let h=g.getAttribute("title");if(!h)break;return c(g,"aria-label",h),f(!0,`Added aria-label="${h}".`)}case"positive-tabindex":return c(g,"tabindex","0"),f(!0,"Changed tabindex to 0 so the natural order applies.");case"keyboard-access":{c(g,"tabindex","0"),g.getAttribute("role")||c(g,"role","button");let h=d=>{let x=d.key;(x==="Enter"||x===" ")&&(d.preventDefault(),g.click())};return g.addEventListener("keydown",h),s.push({element:g,attribute:"",previous:null,listener:h}),f(!0,"Made it focusable and added Enter/Space support.")}default:break}return f(!1,"No safe automatic fix for this one \u2014 see the suggested fix.")}function b(){if(t=Ye(e),e.autoApply){r=!0;let p=t.issues.filter(g=>g.autoFixable).map(u);r=!1,p.some(g=>g.applied)&&(t=Ye(e))}return a(),t}return{start(){if(!We()||n)return;let p=Ae(e.root),g=Je(p)?p.body:p;g&&(n=new MutationObserver(f=>{r||!f.some(d=>!d.target.closest?.("[data-yuktai-panel]"))||(o&&clearTimeout(o),o=setTimeout(b,e.debounceMs??600))}),n.observe(g,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["alt","aria-label","aria-invalid","tabindex","lang","title"]}),b())},stop(){n?.disconnect(),n=null,o&&clearTimeout(o),o=null,a()},scan:b,explain(p){let g=l(p);return g?[`${g.message}`,`Why it matters: ${g.why}`,`How to fix: ${g.fix}`,`Standard: WCAG ${g.wcag} (${g.severity}).`,g.autoFixable?"I can apply a safe fix for this in the browser.":"This one needs a change in your code."].join(`
397
- `):`No issue "${p}" in the current report. Run a scan first.`},applyFix(p){let g=l(p);if(!g)return{issueId:p,applied:!1,message:"Issue not found. Run a scan first."};r=!0;let f=u(g);return r=!1,f.applied&&b(),f},applyAllFixes(){t||b(),r=!0;let p=(t?.issues??[]).filter(g=>g.autoFixable).map(u);return r=!1,b(),p},undoAll(){let p=s.length;for(r=!0;s.length;){let g=s.pop();g.listener?g.element.removeEventListener("keydown",g.listener):g.previous===null?g.element.removeAttribute(g.attribute):g.element.setAttribute(g.attribute,g.previous)}return r=!1,b(),p},getState:i}}var Ba=/^(field|input|value|text|enter|details?|info|data|\*|:)$/i,Ha=/^(go|ok|submit|send|click here|>|→|next)$/i,qa=[[/e-?mail/i,"email","email"],[/phone|mobile|tel/i,"tel","tel"],[/^(full)?name$|full.?name/i,"name"],[/first.?name|given/i,"given-name"],[/last.?name|surname|family/i,"family-name"],[/address|street/i,"street-address"],[/zip|postal|pin.?code|pincode/i,"postal-code"],[/city|town/i,"address-level2"],[/country/i,"country-name"],[/password/i,"current-password","password"],[/dob|birth/i,"bday"]];function _a(e){let t=e.getAttribute("id");return t&&e.ownerDocument.querySelector(`label[for="${t.replace(/"/g,'\\"')}"]`)?!0:!!e.closest("label")}function ja(e){return _(e,"input,select,textarea").filter(t=>!["hidden","submit","button","reset","image"].includes((t.getAttribute("type")??"text").toLowerCase())).map(t=>({label:Ie(t),type:t.tagName==="INPUT"?(t.getAttribute("type")??"text").toLowerCase():t.tagName.toLowerCase(),name:t.getAttribute("name")??t.getAttribute("id")??"",required:t.hasAttribute("required")||t.getAttribute("aria-required")==="true",hasVisibleLabel:_a(t),selector:Ne(t),element:t}))}function Ua(e,t={}){let n=t.seniorFriendly!==!1,o=t.maxFieldsPerStep??8,r=ja(e),s=[],i=(p,g,f,h)=>s.push({level:p,message:g,suggestion:f,field:h?.label||h?.name,selector:h?.selector});for(let p of r){let g=p.element,f=p.label||p.name||p.type,h=g.getAttribute("placeholder");!p.label&&h?i("problem",`"${h}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts and aren't read by every screen reader. Add a visible label above the field.",p):p.label?!p.hasVisibleLabel&&h&&!g.getAttribute("aria-label")?i("problem",`"${f}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts. Add a visible label above the field.",p):Ba.test(p.label)&&i("improvement",`The label "${p.label}" is unclear.`,'Say exactly what is needed, e.g. "Mobile number (10 digits)".',p):i("problem",`A ${p.type} field${p.name?` ("${p.name}")`:""} has no label.`,"Add a visible <label> that says exactly what to enter.",p),p.required&&p.label&&!/\*|required|mandatory|తప్పనిసరి|आवश्यक/i.test(p.label)&&i("improvement",`"${f}" is required but the label doesn't say so.`,'Add "(required)" to the label so everyone knows before submitting.',p);let d=`${p.name} ${p.label}`;for(let[x,k,m]of qa)if(x.test(d)){g.getAttribute("autocomplete")||i("improvement",`"${f}" has no autocomplete hint.`,`Add autocomplete="${k}" so browsers can fill it in (WCAG 1.3.5).`,p),m&&p.type==="text"&&i("improvement",`"${f}" uses type="text".`,`Use type="${m}" for the right mobile keyboard and validation.`,p);break}if(g.getAttribute("aria-invalid")==="true"&&!g.getAttribute("aria-describedby")&&!g.getAttribute("aria-errormessage")&&i("problem",`"${f}" shows an error that isn't connected to the field.`,"Link the error text with aria-describedby and explain how to fix it.",p),n){let x=parseFloat(window.getComputedStyle(g).fontSize)||16;x<16&&i("improvement",`"${f}" text is ${x}px.`,"Use at least 16px in inputs; it is easier to read and stops mobile browsers from zooming.",p)}}r.length>o&&i("improvement",`This form has ${r.length} fields on one screen.`,`Split it into steps of about ${o} fields with a progress indicator.`);let a=_(e,"button,input[type='submit'],input[type='button']");if(a.length===0)i("problem","No submit button found.",'Add a clear <button type="submit"> so the form can be completed with the keyboard.');else if(n){let p=qe(Ie(a[a.length-1]));Ha.test(p)&&i("improvement",`The button says "${p}".`,'Name the result, e.g. "Send message" or "Book appointment".')}!_(e,"[role='alert'],[aria-live]",{includeHidden:!0}).length&&r.some(p=>p.required)&&i("improvement","No live region for error messages.",'Add an element with role="alert" so errors are announced when the form is submitted.');let l=s.filter(p=>p.level==="problem").length,c=s.length-l,u=Math.max(0,100-l*15-c*4),b=e.getAttribute("aria-label")||qe(e.querySelector("legend,h1,h2,h3")?.textContent)||e.getAttribute("name")||e.getAttribute("id")||"Form";return{name:pe(b,50),selector:Ne(e),fields:r,findings:s,score:u,summary:s.length===0?`"${pe(b,40)}" looks clear: ${r.length} labelled field(s), nothing to fix.`:`"${pe(b,40)}" has ${r.length} field(s): ${l} problem(s) and ${c} suggestion(s). Score ${u}/100.`}}function Zt(e={}){let t=Ae(e.root);return t?_(t,"form,[role='form']").map(n=>Ua(n,e)):[]}function Va(e){let t=Ae(e),n={title:"",description:"",language:"",headings:[],landmarks:{},counts:{links:0,buttons:0,images:0,forms:0,tables:0,fields:0},unlabeledFields:[],imagesWithoutAlt:[],purpose:""};if(!t)return n;let o=Je(t)?t:t.ownerDocument,r=_(t,"h1,h2,h3,h4,h5,h6").map(u=>({level:Number(u.tagName[1]),text:pe(u.textContent??"",80)})),s={};for(let[u,b]of Object.entries({header:"header,[role='banner']",navigation:"nav,[role='navigation']",main:"main,[role='main']",search:"search,[role='search']",footer:"footer,[role='contentinfo']"}))s[u]=_(t,b).length;let i=_(t,"input,select,textarea").filter(u=>!["hidden","submit","button","reset","image"].includes((u.getAttribute("type")??"text").toLowerCase())),a=i.filter(u=>!Ie(u)).map(u=>({type:u.tagName==="INPUT"?u.getAttribute("type")??"text":u.tagName.toLowerCase(),hint:u.getAttribute("placeholder")||u.getAttribute("name")||"",selector:Ne(u)})),l=_(t,"img:not([alt])").map(u=>({src:u.getAttribute("src")??"",selector:Ne(u)})),c={title:o.title,description:qe(o.querySelector('meta[name="description"]')?.getAttribute("content")),language:o.documentElement.getAttribute("lang")??"",headings:r,landmarks:s,counts:{links:_(t,"a[href]").length,buttons:_(t,"button,[role='button'],input[type='submit']").length,images:_(t,"img").length,forms:_(t,"form,[role='form']").length,tables:_(t,"table,[role='grid'],[role='table']").length,fields:i.length},unlabeledFields:a,imagesWithoutAlt:l,purpose:""};return c.purpose=Ya(c,i),c}function Ya(e,t){let n=e.headings.find(i=>i.level===1)?.text||e.title||"This page",o=t.map(i=>`${i.getAttribute("type")} ${i.getAttribute("name")} ${Ie(i)}`).join(" ").toLowerCase(),r=[];/password/.test(o)?r.push("sign in or create an account"):(/search|query|వెతుకు/.test(o)||e.landmarks.search)&&r.push("search"),/message|comment|feedback|contact|enquiry/.test(o)&&r.push("send a message"),/card|payment|upi|amount/.test(o)&&r.push("make a payment"),e.counts.tables&&r.push(`browse ${e.counts.tables} table(s) of data`),!r.length&&e.counts.forms&&r.push(`fill in ${e.counts.forms} form(s)`),r.length||r.push("read content");let s=e.headings.filter(i=>i.level===2).slice(0,5).map(i=>i.text);return[`"${n}" lets you ${r.join(", ")}.`,e.description?`It describes itself as: ${pe(e.description,140)}`:"",s.length?`Main sections: ${s.join(" \xB7 ")}.`:""].filter(Boolean).join(" ")}var Ka=[["missing-labels",/label|unlabel|లేబుల్/i],["images",/image|alt text|picture|photo|చిత్ర/i],["structure",/heading|structure|outline|section|landmark|శీర్షిక/i],["forms",/form|field|input|ఫారం/i],["links",/link|లింక్/i],["counts",/how many|count|ఎన్ని/i],["purpose",/what (does|is)|purpose|about|summar|explain|ఏమి|గురించి/i]];function Qa(e){for(let[t,n]of Ka)if(n.test(e))return t;return"unknown"}async function cr(e,t={}){let n=Va(t.root),o=Qa(e);switch(o){case"missing-labels":return n.unlabeledFields.length?{intent:o,answer:`${n.unlabeledFields.length} of ${n.counts.fields} field(s) have no label: ${n.unlabeledFields.map(r=>`${r.type}${r.hint?` ("${r.hint}")`:""}`).join(", ")}.`,targets:n.unlabeledFields.map(r=>r.selector),suggestions:["Add a visible <label for=\u2026> to each field.","Run the Accessibility Copilot to add aria-labels from placeholders as a quick fix."]}:{intent:o,answer:`All ${n.counts.fields} form field(s) have labels.`,targets:[],suggestions:[]};case"images":return{intent:o,answer:n.imagesWithoutAlt.length?`${n.imagesWithoutAlt.length} of ${n.counts.images} image(s) have no alt text.`:`All ${n.counts.images} image(s) have alt text.`,targets:n.imagesWithoutAlt.map(r=>r.selector),suggestions:n.imagesWithoutAlt.length?['Describe meaningful images in alt; use alt="" for decorative ones.']:[]};case"structure":{let r=n.headings.slice(0,15).map(i=>`${" ".repeat(i.level-1)}h${i.level} ${i.text}`).join(`
398
- `),s=Object.entries(n.landmarks).filter(([,i])=>i===0).map(([i])=>i);return{intent:o,answer:`${n.headings.length} heading(s).
399
- ${r}${s.length?`
400
- Missing landmarks: ${s.join(", ")}.`:""}`,targets:[],suggestions:s.includes("main")?["Wrap the primary content in <main>."]:[]}}case"forms":{let r=Zt({root:t.root});return{intent:o,answer:r.length?r.map(s=>s.summary).join(`
401
- `):"There are no forms on this page.",targets:r.flatMap(s=>s.findings.map(i=>i.selector).filter(i=>!!i)),suggestions:r.flatMap(s=>s.findings.slice(0,3).map(i=>i.suggestion))}}case"links":case"counts":{let r=n.counts;return{intent:o,answer:`${r.links} links, ${r.buttons} buttons, ${r.fields} form fields in ${r.forms} form(s), ${r.images} images, ${r.tables} tables.`,targets:[],suggestions:[]}}case"purpose":case"unknown":{let r=n.purpose;if(t.summarize)try{let i=Ae(t.root),a=qe((i&&Je(i)?i.body:i)?.textContent).slice(0,4e3);r=await t.summarize(a)||r}catch{}let s=[];return n.unlabeledFields.length&&s.push(`${n.unlabeledFields.length} form field(s) need labels.`),n.imagesWithoutAlt.length&&s.push(`${n.imagesWithoutAlt.length} image(s) need alt text.`),{intent:o,answer:r,targets:[],suggestions:s}}}}var ze=e=>String(e??"").normalize("NFC").toLowerCase().replace(/\s+/g," ").trim(),Ja=new Set("show me find list get give which who what all the a an rows row records record entries with where that are is have has having and or of for in on to please display only those whose any".split(" "));function Gn(e){let t=ze(e).replace(/(₹|rs\.?|inr|\$|usd|€|£)/g," ").match(/(-?\d[\d,]*(?:\.\d+)?|-?\.\d+)\s*(k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion)?(?![\p{L}])/u);if(!t)return null;let n=Number(t[1].replace(/,/g,""));if(!Number.isFinite(n))return null;let o=t[2]??"",r=/^k|thousand/.test(o)?1e3:/^la/.test(o)?1e5:/^(crore|cr)/.test(o)?1e7:/^(m|mn|million)$/.test(o)?1e6:/^(bn|billion)$/.test(o)?1e9:1;return n*r}function pr(e){let t=new Set([ze(e.label),ze(e.key),ze(e.key.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2"))]);for(let n of Array.from(t))n.endsWith("s")?t.add(n.slice(0,-1)):t.add(`${n}s`);return Array.from(t).filter(n=>n.length>1)}function Pe(e,t,n){let o=` ${ze(e)} `,r;for(let s of t)if(!(n&&(s.type??"text")!==n))for(let i of pr(s)){let a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${a}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(o)&&(!r||i.length>r.length)&&(r={column:s,length:i.length})}return r?.column}var Za=/amount|balance|total|price|salary|value|due|revenue|cost|fee|sales|outstanding|paid/i;function Fn(e){let t=e.filter(n=>n.type==="number");return t.find(n=>Za.test(`${n.key} ${n.label}`))??t[0]}var Xt=/(>=|=>|>|\bover\b|\babove\b|\bmore than\b|\bgreater than\b|\bexceeds?\b|\bexceeding\b|\bhigher than\b|\bat least\b|\bminimum\b|\bmin\b|కంటే ఎక్కువ)/,Ln=/(<=|=<|<|\bunder\b|\bbelow\b|\bless than\b|\blower than\b|\bat most\b|\bmaximum\b|\bmax\b|\bup to\b|కంటే తక్కువ)/,ur=/\b(after|since|from)\b/,Xa=/\b(before|until|till)\b/,el="(?:\\s*(?:k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion))?",Pn=`(?:\u20B9|rs\\.?\\s*|\\$)?\\s*-?\\d[\\d,]*(?:\\.\\d+)?${el}`;function ft(e,t,n={}){let o={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""},r=ze(e).replace(/[?!]+/g," ").replace(/\.(?!\d)/g," ").trim(),s=[],i=r.match(/\b(top|first|bottom|last|lowest|highest)\s+(\d+)\b/);i&&(o.limit=Number(i[2]),r=r.replace(i[0],` ${i[1]} `));let a=r.match(/\b(?:sort(?:ed)?|order(?:ed)?)\s+by\s+([\p{L}\p{M}\p{N} _]+?)(?:\s+(asc|ascending|desc|descending))?(?=$|,|\band\b|\bthen\b)/u),l=r.match(/\b(top|highest|largest|biggest|most|bottom|lowest|smallest|least)\b(?:\s+\d+)?\s+(?:by\s+)?([\p{L}\p{M}\p{N} _]+)/u);if(a){let f=Pe(a[1],t);f&&(o.sort={key:f.key,direction:/^desc/.test(a[2]??"")?"desc":"asc"},r=r.replace(a[0]," "))}else if(l){let f=Pe(l[2],t,"number")??Pe(l[2],t)??Fn(t);if(f){let h=/top|highest|largest|biggest|most/.test(l[1]);o.sort={key:f.key,direction:h?"desc":"asc"},r=r.replace(new RegExp(`\\b${l[1]}\\b`)," "),!i&&/top|bottom/.test(l[1])&&(o.limit=10)}}let c=new RegExp(`\\bbetween\\s+(${Pn}|\\d{4}-\\d{2}-\\d{2})\\s+(?:and|to|-)\\s+(${Pn}|\\d{4}-\\d{2}-\\d{2})`,"u"),u;for(;u=r.match(c);){let f=r.slice(Math.max(0,(u.index??0)-40),u.index??0),h=/\d{4}-\d{2}-\d{2}/.test(u[1]),d=h?Pe(f,t,"date")??t.find(m=>m.type==="date"):Pe(f,t,"number")??Fn(t),x=h?u[1]:Gn(u[1]),k=h?u[2]:Gn(u[2]);d&&x!==null&&k!==null&&(o.filters.push({key:d.key,operator:"between",value:[x,k]}),s.push(`${d.label} between ${u[1]} and ${u[2]}`)),r=r.replace(u[0]," ")}let b=r.split(/\s*(?:(?<!\d),|,(?!\d)|;|\band\b|(?<!(?:starts?|starting|ends?|ending|begins?|beginning)\s)\bwith\b|\bwhere\b|\bwho\b|\bthat\b|&|మరియు)\s*/u).map(f=>f.trim()).filter(Boolean),p=t.filter(f=>(f.type??"text")==="text"),g=new Map;for(let f of p){let h=new Set;for(let d of(n.data??[]).slice(0,5e3)){let x=ze(d[f.key]);if(x&&x.length<=40&&h.add(x),h.size>300)break}h.size&&h.size<=300&&g.set(f.key,h)}for(let f of b){let h=o.filters.length,d=Pe(f,t),x=f.match(new RegExp(Pn,"u")),k=f.match(/\d{4}-\d{2}-\d{2}/);if(k&&(ur.test(f)||Xa.test(f)||Xt.test(f)||Ln.test(f))){let m=(d?.type==="date"?d:void 0)??t.find(v=>v.type==="date");if(m){let v=ur.test(f)||Xt.test(f);o.filters.push({key:m.key,operator:v?"greaterThan":"lessThan",value:k[0]}),s.push(`${m.label} ${v?"after":"before"} ${k[0]}`)}}else if(x&&(Xt.test(f)||Ln.test(f)||d?.type==="number"&&/\b(is|equals?)\b|=/.test(f))){let m=d?.type==="number"?d:void 0;m||(m=Fn(t),m&&o.notes.push(`Assumed "${f}" refers to ${m.label}.`));let v=Gn(x[0]);if(m&&v!==null){let w=/at least|minimum|\bmin\b|>=|=>|at most|maximum|\bmax\b|up to|<=|=</.test(f);Xt.test(f)?(o.filters.push({key:m.key,operator:"greaterThan",value:w?v-1e-9:v}),s.push(`${m.label} ${w?"\u2265":">"} ${v.toLocaleString("en-IN")}`)):Ln.test(f)?(o.filters.push({key:m.key,operator:"lessThan",value:w?v+1e-9:v}),s.push(`${m.label} ${w?"\u2264":"<"} ${v.toLocaleString("en-IN")}`)):(o.filters.push({key:m.key,operator:"equals",value:v}),s.push(`${m.label} = ${v.toLocaleString("en-IN")}`))}}else{let m=f.match(/\b(?:starts?|starting|begins?|beginning)\s+with\s+(.+)$/),v=f.match(/\b(?:ends?|ending)\s+with\s+(.+)$/),w=f.match(/\b(?:contains?|containing|including|includes?|mentions?)\s+(.+)$/),A=f.match(/\b(?:is|equals?|=|:)\s+(.+)$/),C=m??v??w??A;if(C){let F=d??p[0],D=C[1].replace(/^["'“‘]|["'”’]$/g,"").trim();if(F&&D){let M=m?"startsWith":v?"endsWith":w?"contains":"equals";o.filters.push({key:F.key,operator:M,value:D}),s.push(`${F.label} ${M==="equals"?"is":M==="contains"?"contains":M==="startsWith"?"starts with":"ends with"} "${D}"`),d||o.notes.push(`Assumed "${f}" refers to ${F.label}.`)}}}if(o.filters.length===h)for(let[m,v]of g){let w="";for(let A of v){if(A.length<2||A.length<=w.length)continue;let C=A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${C}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(f)&&(w=A)}if(w){let A=t.find(C=>C.key===m);o.filters.push({key:m,operator:"equals",value:w}),s.push(`${A.label} is "${w}"`)}}if(o.filters.length===h){let m=f.split(/\s+/).filter(w=>!Ja.has(w)&&!/^(top|first|bottom|last|lowest|highest|by|desc|asc|sort(ed)?)$/.test(w)),v=m.length>0&&m.every(w=>t.some(A=>pr(A).includes(w)));if(m.length&&!v&&!(d&&m.length===1)){let w=m.join(" ");/^(customers?|users?|people|items?|entries|poems?|orders?|products?|employees?|students?|members?)$/.test(w)||(o.search.push(w),s.push(`any column contains "${w}"`))}}}if(o.sort){let f=t.find(h=>h.key===o.sort.key)?.label??o.sort.key;s.push(`sorted by ${f} ${o.sort.direction==="desc"?"high \u2192 low":"low \u2192 high"}`)}return o.limit&&s.push(`first ${o.limit}`),o.explanation=s.length?`Showing rows where ${s.join(", ")}.`:"No conditions understood \u2014 showing all rows.",o}function tl(e,t,n){return n==="number"?(Number(e)||0)-(Number(t)||0):n==="date"?(new Date(String(e)).getTime()||0)-(new Date(String(t)).getTime()||0):String(e??"").localeCompare(String(t??""),void 0,{numeric:!0})}function Ke(e,t,n){let o=je(e,t,n.filters);for(let r of n.search)o=o.filter(s=>t.some(i=>ze(s[i.key]).includes(r)));if(n.sort){let r=t.find(i=>i.key===n.sort.key),s=n.sort.direction==="desc"?-1:1;o=[...o].sort((i,a)=>s*tl(i[n.sort.key],a[n.sort.key],r?.type))}return n.limit&&(o=o.slice(0,n.limit)),o}function nl(e,t,n={}){let o=ft(e,t.columns,{data:t.data}),r=Ke(t.data,t.columns,o),s=r.map(a=>me(a,t.rowKey)).filter(Boolean);n.apply!==!1&&(o.filters.length&&t.onFiltersChange?.(o.filters),o.sort&&t.onSortChange?.(o.sort),s.length&&t.onHighlightRows?.(s));let i=r.length?`${r.length} row(s) found. ${o.explanation}${o.notes.length?` (${o.notes.join(" ")})`:""}`:`No rows match. ${o.explanation}`;return{rows:r,ids:s,parsed:o,message:i}}function dr(e,t){let n=(e.length-1)*t,o=Math.floor(n),r=n-o;return e[o+1]!==void 0?e[o]+r*(e[o+1]-e[o]):e[o]}function Mn(e,t,n={}){let o=n.factor??1.5,r=[],s=t.filter(c=>c.type==="number"&&(!n.columns||n.columns.includes(c.key))),i=c=>c.toLocaleString("en-IN",{maximumFractionDigits:2});for(let c of s){let u=e.map(x=>Number(x[c.key])).filter(x=>Number.isFinite(x));if(u.length<5)continue;let b=[...u].sort((x,k)=>x-k),p=dr(b,.25),g=dr(b,.75),f=g-p;if(f===0)continue;let h=p-o*f,d=g+o*f;for(let x of e){let k=Number(x[c.key]);!Number.isFinite(k)||k>=h&&k<=d||r.push({rowId:me(x,n.rowKey),column:c.key,label:c.label,value:k,kind:k>d?"high":"low",reason:`${c.label} ${i(k)} is far ${k>d?"above":"below"} the typical range (${i(p)}\u2013${i(g)}).`})}}let a=n.rowKey??"id",l=new Map;for(let c of e){let u=JSON.stringify(t.filter(g=>g.key!==a).map(g=>ze(c[g.key]))),b=me(c,n.rowKey),p=l.get(u);p!==void 0?r.push({rowId:b,column:a,label:"Row",value:b,kind:"duplicate",reason:`Row ${b} has the same values as row ${p}.`}):l.set(u,b)}return r}function Nn(e,t){if(!e.length)return"No rows to summarise.";let n=[`${e.length} row(s).`],o=r=>r.toLocaleString("en-IN",{maximumFractionDigits:2});for(let r of t){let s=e.map(i=>i[r.key]);if(r.type==="number"){let i=s.map(Number).filter(Number.isFinite);if(!i.length)continue;let a=i.reduce((l,c)=>l+c,0);n.push(`${r.label}: total ${o(a)}, average ${o(a/i.length)}, range ${o(Math.min(...i))}\u2013${o(Math.max(...i))}.`)}else if(r.type==="date"){let i=s.map(l=>new Date(String(l)).getTime()).filter(Number.isFinite);if(!i.length)continue;let a=l=>new Date(l).toISOString().slice(0,10);n.push(`${r.label}: from ${a(Math.min(...i))} to ${a(Math.max(...i))}.`)}else{let i=new Map;for(let l of s){let c=String(l??"").trim();c&&i.set(c,(i.get(c)??0)+1)}if(i.size===0||i.size>Math.max(8,e.length/3))continue;let a=Array.from(i.entries()).sort((l,c)=>c[1]-l[1]).slice(0,4);n.push(`${r.label}: ${a.map(([l,c])=>`${l} (${c})`).join(", ")}.`)}}return n.join(`
402
- `)}function gr(e,t){let n=ze(e);if(/unusual|anomal|outlier|odd|strange|suspicious|duplicate|అసాధారణ/.test(n)){let r=Mn(t.data,t.columns,{rowKey:t.rowKey}),s=Array.from(new Set(r.map(a=>a.rowId)));s.length&&t.onHighlightRows?.(s);let i=new Set(s);return{kind:"anomalies",message:r.length?`${s.length} unusual row(s):
403
- ${r.slice(0,10).map(a=>`\u2022 ${a.reason}`).join(`
404
- `)}`:"Nothing unusual found.",ids:s,rows:t.data.filter(a=>i.has(me(a,t.rowKey))),anomalies:r}}if(/summar|overview|describe|సారాంశం/.test(n)){let r=je(t.data,t.columns,t.filters??[]);return{kind:"summary",message:Nn(r,t.columns),ids:[],rows:r}}let o=nl(e,t);return{kind:"query",message:o.message,ids:o.ids,rows:o.rows}}var ol=/\b(off|disable|stop|remove|no more|turn off|switch off|deactivate)\b|ఆఫ్|ఆపు|తీసివేయి|बंद/i,rl=[{pattern:/high contrast|contrast|హై కాంట్రాస్ట్|కాంట్రాస్ట్/i,key:"highContrast",name:"High contrast"},{pattern:/dark mode|dark theme|night mode|డార్క్ మోడ్|చీకటి/i,key:"darkMode",name:"Dark mode"},{pattern:/reduce motion|less motion|stop animation|animations?|కదలికలు/i,key:"reduceMotion",name:"Reduced motion"},{pattern:/large targets?|bigger buttons?|big buttons?|larger buttons?|పెద్ద బటన్/i,key:"largeTargets",name:"Large targets"},{pattern:/dyslexia|readable font|easy font/i,key:"dyslexiaFont",name:"Dyslexia-friendly font"},{pattern:/speak on focus|read aloud|read out|screen reader|speech|చదివి వినిపించు/i,key:"speechEnabled",name:"Speak on focus"},{pattern:/skip links?/i,key:"showSkipLinks",name:"Skip links"}],il=[[/deuteranop|green.?blind/i,"deuteranopia"],[/protanop|red.?blind/i,"protanopia"],[/tritanop|blue.?blind/i,"tritanopia"],[/grey ?scale|gray ?scale|achromat|black and white/i,"achromatopsia"]],fr=.1,sl=.8,al=1.3;function ll(e,t={}){let n=e.trim().toLowerCase();if(!n)return null;if(/\b(next|down)\s+(row|line|record|item)\b|తర్వాతి (వరుస|అంశం)/.test(n))return{type:"grid",action:"next-row",say:"Next row."};if(/\b(previous|prev|back|up)\s+(row|line|record|item)\b|ముందరి (వరుస|అంశం)|వెనుక (వరుస|అంశం)/.test(n))return{type:"grid",action:"previous-row",say:"Previous row."};if(/\bfirst\s+(row|record|item)\b|మొదటి (వరుస|అంశం)/.test(n))return{type:"grid",action:"first-row",say:"First row."};if(/\blast\s+(row|record|item)\b|చివరి (వరుస|అంశం)/.test(n))return{type:"grid",action:"last-row",say:"Last row."};if(/\b(open|expand|read)\s+(this\s+)?(row|record|item)\b|ఈ (వరుస|అంశం) తెరువు/.test(n))return{type:"grid",action:"open-row",say:"Opening row."};if(/\b(reset|default|restore)\b.*\b(settings?|accessibility|everything|all)\b|^reset$|రీసెట్/.test(n))return{type:"reset",say:"Accessibility settings reset."};let o=t.fontSizeMultiplier??1,r=i=>Math.round(Math.min(al,Math.max(sl,i))*100)/100;if(/\b(bigger|larger|increase|zoom in)\b.*\b(text|font|letters?)\b|\b(text|font)\b.*\b(bigger|larger|up)\b|పెద్ద అక్షరాలు|అక్షరాలు పెద్ద/.test(n)){let i=r(o+fr);return{type:"setting",patch:{fontSizeMultiplier:i},say:`Text size ${Math.round(i*100)}%.`}}if(/\b(smaller|decrease|reduce|zoom out)\b.*\b(text|font|letters?)\b|\b(text|font)\b.*\b(smaller|down)\b|చిన్న అక్షరాలు|అక్షరాలు చిన్న/.test(n)){let i=r(o-fr);return{type:"setting",patch:{fontSizeMultiplier:i},say:`Text size ${Math.round(i*100)}%.`}}if(/\b(normal|default|reset)\b.*\b(text|font)\s*(size)?\b/.test(n))return{type:"setting",patch:{fontSizeMultiplier:1},say:"Text size 100%."};let s=ol.test(n);for(let[i,a]of il)if(i.test(n))return s?{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."}:{type:"setting",patch:{colorBlindMode:a},say:`${a} filter on.`};if(/colou?r.?blind/.test(n)&&s)return{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."};for(let i of rl){if(!i.pattern.test(n))continue;let a=/\btoggle\b/.test(n)?!t[i.key]:!s;return i.key==="reduceMotion"&&!/reduce motion|less motion|కదలికలు తగ్గించు/.test(n)&&/animations?/.test(n)&&(a=s||/\bno\b/.test(n)),{type:"setting",patch:{[i.key]:a},say:`${i.name} ${a?"on":"off"}.`}}return null}var mr={highContrast:!1,darkMode:!1,reduceMotion:!1,largeTargets:!1,dyslexiaFont:!1,speechEnabled:!1,colorBlindMode:"none",fontSizeMultiplier:1};function cl(e,t={}){if(!We())return null;let n=t.root??document,o=t.rowSelector??"[data-yuktai-row-id], [role='row']",r=Array.from(n.querySelectorAll(o)).filter(c=>!c.querySelector("th,[role='columnheader']"));if(!r.length)return null;let s=document.activeElement?.closest(o),i=s?r.indexOf(s):-1;if(e==="open-row"){let c=i>=0?r[i]:r[0];return c.click(),c}let a=e==="first-row"?0:e==="last-row"?r.length-1:e==="next-row"?Math.min(r.length-1,i+1):Math.max(0,i-1),l=r[a];return l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1"),l.focus(),l.scrollIntoView?.({block:"nearest"}),l}function br(e={}){let t={enabled:!0,...mr,...e.initial},n=null,o=!1,r=async c=>e.apply?e.apply(c):ke.execute(c),s=c=>{if(e.speak===!1||!We()||!("speechSynthesis"in window))return;let u=new SpeechSynthesisUtterance(c);u.lang=e.lang??"en-IN",window.speechSynthesis.cancel(),window.speechSynthesis.speak(u)};async function i(c){let u=ll(c,t);if(e.onTranscript?.(c,u),!u)return null;if(u.type==="grid"){let b=cl(u.action,{root:e.gridRoot});return s(b?u.say:"No table rows found."),u}return t=u.type==="reset"?{...t,...mr}:{...t,...u.patch},await r(t),s(u.say),u}function a(){if(!We()||o)return o;let c=window,u=c.SpeechRecognition??c.webkitSpeechRecognition;return u?(n=new u,n.lang=e.lang??"en-IN",n.continuous=!0,n.interimResults=!1,n.onresult=b=>{let p=b.results,g=p[p.length-1];g?.[0]?.transcript&&i(g[0].transcript)},n.onend=()=>{o&&n?.start()},n.onerror=b=>{(b.error==="not-allowed"||b.error==="service-not-allowed")&&(o=!1)},o=!0,n.start(),!0):!1}function l(){o=!1,n?.stop(),n=null}return{start:a,stop:l,handle:i,isListening:()=>o,getConfig:()=>({...t})}}var ul=new Set("a an the is are was were be to of and or in on at for with what which who whom how why when where does do did this that these those it its from by as about any all please tell me show give".split(" "));function en(e){return(e.normalize("NFC").toLowerCase().match(/[\p{L}\p{M}\p{N}]+/gu)??[]).filter(t=>t.length>1&&!ul.has(t))}function dl(e,t=600){let n=Ae(e);if(!n)return[];let o=[],r="",s="",i=()=>{s.trim()&&o.push({id:`page-${o.length+1}`,source:"page",text:s.trim(),ref:r||void 0}),s=""};for(let a of _(n,"h1,h2,h3,h4,p,li,td,th,dt,dd,blockquote,figcaption,label,summary")){if(a.querySelector("p,li,h1,h2,h3,h4"))continue;let l=qe(a.textContent);if(l){if(/^H[1-4]$/.test(a.tagName)){i(),r=l,s=`${l}. `;continue}s.length+l.length>t&&i(),s+=`${l} `}}return i(),o}function pl(e,t,n="id"){return e.map((o,r)=>{let s=o,i=String(s[n]??r+1);return{id:`grid-${i}`,source:"grid",ref:i,text:t.map(a=>`${a.label}: ${String(s[a.key]??"")}`).join(". ")}})}function hr(e={}){let t=[],n=[],o=new Map,r=0;function s(){t=[...e.includePage===!1?[]:dl(e.root),...e.rows&&e.columns?pl(e.rows,e.columns,e.rowKey):[],...(e.documents??[]).map(l=>({id:l.id,source:"custom",text:l.text}))],n=t.map(l=>en(l.text)),o=new Map;for(let l of n)for(let c of new Set(l))o.set(c,(o.get(c)??0)+1);r=n.reduce((l,c)=>l+c.length,0)/Math.max(1,n.length)}s();function i(l,c=5){let u=en(l);if(!u.length)return[];let b=n.length;return n.map((g,f)=>{let h=0;for(let d of u){let x=0;for(let m of g)(m===d||d.length>=4&&m.startsWith(d)||m.length>=4&&d.startsWith(m))&&x++;if(!x)continue;let k=Math.log(1+(b-(o.get(d)??1)+.5)/((o.get(d)??1)+.5));h+=k*(x*2.2/(x+1.2*(.25+.75*(g.length/(r||1)))))}return{...t[f],score:h}}).filter(g=>g.score>0).sort((g,f)=>f.score-g.score).slice(0,c)}async function a(l,c={}){let u=i(l,c.k??4);if(!u.length)return{answer:"I couldn't find anything about that on this page or in the data.",hits:u,generated:!1};if(c.generate)try{let f=u.map((d,x)=>`[${x+1}] ${d.text}`).join(`
395
+ `})]})}var An=Ul;import{useCallback as St,useEffect as Xl,useRef as Rn,useState as Vt}from"react";var Vl={en:{found:e=>`${e} row(s) found.`,count:e=>`${e} row(s).`,columns:"Grid columns retrieved.",rowFound:"Row found.",notFound:e=>`Row "${e}" not found.`,noneFound:"None of the given rows were found.",highlighted:e=>`${e} row(s) highlighted.`,selected:e=>`Row "${e}" selected.`,opened:e=>`Row "${e}" opened.`,notSupported:e=>`This grid does not support "${e}".`,emptyQuery:"Please enter something to search.",noIds:"No row IDs were given.",unknownColumn:e=>`Unknown column "${e}".`,badOperator:e=>`Unknown filter operator "${e}".`,badValue:"The filter value is not valid for this column.",filtered:e=>`Filter applied: ${e} row(s) match.`,filtersCleared:"All filters cleared.",sorted:(e,t)=>`Sorted by ${e} (${t==="asc"?"ascending":"descending"}).`,sortCleared:"Sorting cleared.",internal:"Something went wrong while running this action."},te:{found:e=>`${e} \u0C35\u0C30\u0C41\u0C38(\u0C32\u0C41) \u0C26\u0C4A\u0C30\u0C3F\u0C15\u0C3E\u0C2F\u0C3F.`,count:e=>`\u0C2E\u0C4A\u0C24\u0C4D\u0C24\u0C02 ${e} \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41.`,columns:"\u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C32 \u0C35\u0C3F\u0C35\u0C30\u0C3E\u0C32\u0C41.",rowFound:"\u0C35\u0C30\u0C41\u0C38 \u0C26\u0C4A\u0C30\u0C3F\u0C15\u0C3F\u0C02\u0C26\u0C3F.",notFound:e=>`"${e}" \u0C35\u0C30\u0C41\u0C38 \u0C26\u0C4A\u0C30\u0C15\u0C32\u0C47\u0C26\u0C41.`,noneFound:"\u0C07\u0C1A\u0C4D\u0C1A\u0C3F\u0C28 \u0C35\u0C30\u0C41\u0C38\u0C32\u0C47\u0C35\u0C40 \u0C26\u0C4A\u0C30\u0C15\u0C32\u0C47\u0C26\u0C41.",highlighted:e=>`${e} \u0C35\u0C30\u0C41\u0C38(\u0C32\u0C41) \u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D \u0C1A\u0C47\u0C36\u0C3E\u0C28\u0C41.`,selected:e=>`"${e}" \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41.`,opened:e=>`"${e}" \u0C24\u0C46\u0C30\u0C3F\u0C1A\u0C3E\u0C28\u0C41.`,notSupported:e=>`\u0C08 \u0C2A\u0C1F\u0C4D\u0C1F\u0C3F\u0C15\u0C32\u0C4B "${e}" \u0C38\u0C4C\u0C15\u0C30\u0C4D\u0C2F\u0C02 \u0C32\u0C47\u0C26\u0C41.`,emptyQuery:"\u0C35\u0C46\u0C24\u0C15\u0C21\u0C3E\u0C28\u0C3F\u0C15\u0C3F \u0C0F\u0C26\u0C48\u0C28\u0C3E \u0C30\u0C3E\u0C2F\u0C02\u0C21\u0C3F.",noIds:"\u0C35\u0C30\u0C41\u0C38 ID\u0C32\u0C41 \u0C07\u0C35\u0C4D\u0C35\u0C32\u0C47\u0C26\u0C41.",unknownColumn:e=>`"${e}" \u0C05\u0C28\u0C47 \u0C15\u0C3E\u0C32\u0C2E\u0C4D \u0C32\u0C47\u0C26\u0C41.`,badOperator:e=>`"${e}" \u0C05\u0C28\u0C47 \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C3F\u0C27\u0C3E\u0C28\u0C02 \u0C32\u0C47\u0C26\u0C41.`,badValue:"\u0C08 \u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C15\u0C3F \u0C08 \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C3F\u0C32\u0C41\u0C35 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C26\u0C41.",filtered:e=>`\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C35\u0C47\u0C36\u0C3E\u0C28\u0C41: ${e} \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C2F\u0C3E\u0C2F\u0C3F.`,filtersCleared:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C28\u0C4D\u0C28\u0C40 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C28\u0C41.",sorted:(e,t)=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C15\u0C4D\u0C30\u0C2E\u0C02 (${t==="asc"?"\u0C06\u0C30\u0C4B\u0C39\u0C23":"\u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23"}).`,sortCleared:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C28\u0C41.",internal:"\u0C08 \u0C2A\u0C28\u0C3F \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C41\u0C02\u0C21\u0C17\u0C3E \u0C38\u0C2E\u0C38\u0C4D\u0C2F \u0C35\u0C1A\u0C4D\u0C1A\u0C3F\u0C02\u0C26\u0C3F."}};function Re(e){return Vl[e.locale??"en"]}function Ge(e,t){return{success:!0,message:e,data:t}}function ie(e,t){return{success:!1,message:t,error:{code:e}}}var Do=["contains","equals","startsWith","endsWith","greaterThan","lessThan","between"];function me(e,t="id"){let n=e?.[t];return n==null?"":String(n)}function et(e){return String(e??"").normalize("NFC").toLowerCase().trim()}function Oo(e){if(typeof e=="number")return Number.isFinite(e)?e:null;let t=String(e??"").trim();if(t==="")return null;let n=Number(t);return Number.isFinite(n)?n:null}function Wo(e){if(e instanceof Date)return e.getTime();let t=new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null}function Bo(e){return(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>String(n).trim()).filter(Boolean)}function Cn(e,t){let n=et(t);return e.columns.find(o=>et(o.key)===n||et(o.label)===n)}function _t(e,t){return e.data.find(n=>me(n,e.rowKey)===t)}function Yl(e,t){return e[t]}function Kl(e,t,n){let o=Yl(e,n.key),r=n.type??"text";if(r==="number"||r==="date"){let s=r==="number"?Oo:Wo,l=s(o);if(l===null)return!1;if(t.operator==="between"){let[u,b]=t.value,p=s(u),g=s(b);return p!==null&&g!==null&&l>=Math.min(p,g)&&l<=Math.max(p,g)}let c=s(t.value);if(c===null)return!1;switch(t.operator){case"equals":return l===c;case"greaterThan":return l>c;case"lessThan":return l<c;default:break}}let a=et(o),i=et(t.value);switch(t.operator){case"equals":return a===i;case"startsWith":return a.startsWith(i);case"endsWith":return a.endsWith(i);case"contains":return a.includes(i);default:return!1}}function Ql(e,t){let n=t.type??"text",o=n==="date"?Wo:Oo;return e.operator==="between"?n==="text"||!Array.isArray(e.value)||e.value.length!==2?!1:o(e.value[0])!==null&&o(e.value[1])!==null:e.operator==="greaterThan"||e.operator==="lessThan"?n!=="text"&&o(e.value)!==null:!Array.isArray(e.value)&&String(e.value).trim()!==""}function Ue(e,t,n){return n.length?Ho({data:e,columns:t},n):e}function tt(e){return e.map(t=>({key:String(t.key),label:t.label,type:t.type==="number"?"number":t.type==="date"?"date":"text"}))}function Ho(e,t){return e.data.filter(n=>t.every(o=>{let r=Cn(e,o.key);return r?Kl(n,o,r):!0}))}function qo(e,t){let n=Re(e),o=et(t);if(!o)return ie("INVALID_INPUT",n.emptyQuery);let r=e.data.filter(i=>e.columns.some(s=>et(i[s.key]).includes(o))),a=r.map(i=>me(i,e.rowKey)).filter(Boolean);return e.onHighlightRows?.(a),Ge(n.found(r.length),r)}function _o(e){return Ge(Re(e).count(e.data.length),e.data.length)}function Uo(e){return Ge(Re(e).columns,e.columns)}function jo(e,t){let n=Re(e),o=String(t??"").trim();if(!o)return ie("INVALID_INPUT",n.noIds);let r=_t(e,o);return r?Ge(n.rowFound,r):ie("NOT_FOUND",n.notFound(o))}function kt(e,t){let n=Re(e),o=Bo(t);if(o.length===0)return ie("INVALID_INPUT",n.noIds);if(!e.onHighlightRows)return ie("NOT_SUPPORTED",n.notSupported("highlight"));let r=o.filter(a=>_t(e,a)!==void 0);return r.length===0?ie("NOT_FOUND",n.noneFound):(e.onHighlightRows(r),Ge(n.highlighted(r.length),r))}function Ut(e,t){let n=Re(e),o=String(t??"").trim();return o?e.onSelectRow?_t(e,o)?(e.onSelectRow(o),Ge(n.selected(o),o)):ie("NOT_FOUND",n.notFound(o)):ie("NOT_SUPPORTED",n.notSupported("select")):ie("INVALID_INPUT",n.noIds)}function jt(e,t){let n=Re(e),o=String(t??"").trim();return o?e.onOpenRow?_t(e,o)?(e.onOpenRow(o),Ge(n.opened(o),o)):ie("NOT_FOUND",n.notFound(o)):ie("NOT_SUPPORTED",n.notSupported("open")):ie("INVALID_INPUT",n.noIds)}function Vo(e,t){let n=Re(e),o=Cn(e,t?.key??"");if(!o)return ie("INVALID_INPUT",n.unknownColumn(String(t?.key??"")));if(!Do.includes(t.operator))return ie("INVALID_INPUT",n.badOperator(String(t.operator)));let r={...t,key:o.key};if(!Ql(r,o))return ie("INVALID_INPUT",n.badValue);if(!e.onFiltersChange)return ie("NOT_SUPPORTED",n.notSupported("filter"));let a=[...(e.filters??[]).filter(s=>s.key!==o.key),r],i=Ho(e,a).length;return e.onFiltersChange(a),Ge(n.filtered(i),{filters:a,count:i})}function Yo(e){let t=Re(e);return e.onFiltersChange?(e.onFiltersChange([]),Ge(t.filtersCleared,[])):ie("NOT_SUPPORTED",t.notSupported("clear filters"))}function Ko(e,t,n="asc"){let o=Re(e),r=Cn(e,t);if(!r)return ie("INVALID_INPUT",o.unknownColumn(String(t)));if(n!=="asc"&&n!=="desc")return ie("INVALID_INPUT",o.badValue);if(!e.onSortChange)return ie("NOT_SUPPORTED",o.notSupported("sort"));let a={key:r.key,direction:n};return e.onSortChange(a),Ge(o.sorted(r.label,n),a)}function Qo(e){let t=Re(e);return e.onSortChange?(e.onSortChange(null),Ge(t.sortCleared,null)):ie("NOT_SUPPORTED",t.notSupported("clear sort"))}var Jl={search:"Search all columns for text. Matching rows are highlighted.",count:"Count the rows currently in the grid.",columns:"List the grid's columns with their keys, labels and types.",get_row:"Get one row by its ID.",highlight:"Highlight one or more rows by ID without filtering the grid.",select:"Select one row by ID.",open:"Open one row by ID to show its full details.",filter:"Filter the grid by one column. Replaces any existing filter on that column.",clear_filters:"Remove all filters.",sort:"Sort the grid by one column, ascending or descending.",clear_sort:"Remove sorting."},zo={en:{search:"Search",count:"Count",columns:"Columns",get_row:"Get row",highlight:"Highlight",select:"Select",open:"Open",filter:"Filter",clear_filters:"Clear filters",sort:"Sort",clear_sort:"Clear sort"},te:{search:"\u0C35\u0C46\u0C24\u0C41\u0C15\u0C41",count:"\u0C32\u0C46\u0C15\u0C4D\u0C15",columns:"\u0C15\u0C3E\u0C32\u0C2E\u0C4D\u200C\u0C32\u0C41",get_row:"\u0C35\u0C30\u0C41\u0C38 \u0C1A\u0C42\u0C2A\u0C41",highlight:"\u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D",select:"\u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B",open:"\u0C24\u0C46\u0C30\u0C41\u0C35\u0C41",filter:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D",clear_filters:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F",sort:"\u0C15\u0C4D\u0C30\u0C2E\u0C02",clear_sort:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F"}};async function Zl(e,t){try{return t()}catch{return ie("INTERNAL",Re(e).internal)}}function vt(e,t={}){let n=t.name??"yuktai_grid",o=zo[e.locale??"en"],r=l=>t.descriptions?.[l]??Jl[l],a={id:{type:"string",description:"Row ID"}},i=e.columns.map(l=>l.key);return[{id:"search",available:!0,schema:{type:"object",properties:{query:{type:"string"}},required:["query"]},run:l=>qo(e,String(l.query??""))},{id:"count",available:!0,schema:{type:"object",properties:{}},run:()=>_o(e)},{id:"columns",available:!0,schema:{type:"object",properties:{}},run:()=>Uo(e)},{id:"get_row",available:!0,schema:{type:"object",properties:a,required:["id"]},run:l=>jo(e,String(l.id??""))},{id:"highlight",available:!!e.onHighlightRows,schema:{type:"object",properties:{ids:{type:"array",items:{type:"string"},description:"Row IDs"}},required:["ids"]},run:l=>kt(e,Bo(l.ids))},{id:"select",available:!!e.onSelectRow,schema:{type:"object",properties:a,required:["id"]},run:l=>Ut(e,String(l.id??""))},{id:"open",available:!!e.onOpenRow,schema:{type:"object",properties:a,required:["id"]},run:l=>jt(e,String(l.id??""))},{id:"filter",available:!!e.onFiltersChange,schema:{type:"object",properties:{key:{type:"string",enum:i},operator:{type:"string",enum:Do},value:{description:"Text or number; for 'between' an array of two numbers or dates"}},required:["key","operator","value"]},run:l=>Vo(e,{key:String(l.key??""),operator:String(l.operator??""),value:l.value})},{id:"clear_filters",available:!!e.onFiltersChange,schema:{type:"object",properties:{}},run:()=>Yo(e)},{id:"sort",available:!!e.onSortChange,schema:{type:"object",properties:{key:{type:"string",enum:i},direction:{type:"string",enum:["asc","desc"]}},required:["key"]},run:l=>Ko(e,String(l.key??""),l.direction==="desc"?"desc":"asc")},{id:"clear_sort",available:!!e.onSortChange,schema:{type:"object",properties:{}},run:()=>Qo(e)}].filter(l=>l.available).map(l=>({name:`${n}_${l.id}`,title:zo.en[l.id],description:r(l.id),label:o[l.id],inputSchema:l.schema,execute:c=>Zl(e,()=>l.run(c??{}))}))}var ec={en:{done:"Done.",toolMissing:e=>`The action "${e}" is not available here.`,missingInput:e=>`Missing: ${e}.`,notUnderstood:"Sorry, I didn't understand. Try: a word to search, \u201Csort by <column>\u201D, or \u201Cclear filters\u201D.",noMatch:e=>`Nothing matched "${e}".`,failed:"Something went wrong while running this action."},te:{done:"\u0C2A\u0C42\u0C30\u0C4D\u0C24\u0C2F\u0C3F\u0C02\u0C26\u0C3F.",toolMissing:e=>`"${e}" \u0C38\u0C4C\u0C15\u0C30\u0C4D\u0C2F\u0C02 \u0C07\u0C15\u0C4D\u0C15\u0C21 \u0C05\u0C02\u0C26\u0C41\u0C2C\u0C3E\u0C1F\u0C41\u0C32\u0C4B \u0C32\u0C47\u0C26\u0C41.`,missingInput:e=>`\u0C07\u0C35\u0C3F \u0C15\u0C3E\u0C35\u0C3E\u0C32\u0C3F: ${e}.`,notUnderstood:"\u0C15\u0C4D\u0C37\u0C2E\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F, \u0C05\u0C30\u0C4D\u0C25\u0C02 \u0C15\u0C3E\u0C32\u0C47\u0C26\u0C41. \u0C07\u0C32\u0C3E \u0C2A\u0C4D\u0C30\u0C2F\u0C24\u0C4D\u0C28\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F: \u0C35\u0C46\u0C24\u0C15\u0C3E\u0C32\u0C4D\u0C38\u0C3F\u0C28 \u0C2A\u0C26\u0C02, \u201C<\u0C15\u0C3E\u0C32\u0C2E\u0C4D> \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u201D, \u0C32\u0C47\u0C26\u0C3E \u201C\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F\u201D.",noMatch:e=>`"${e}" \u0C15\u0C3F \u0C0F\u0C2E\u0C40 \u0C38\u0C30\u0C3F\u0C2A\u0C4B\u0C32\u0C47\u0C26\u0C41.`,failed:"\u0C08 \u0C2A\u0C28\u0C3F \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C41\u0C02\u0C21\u0C17\u0C3E \u0C38\u0C2E\u0C38\u0C4D\u0C2F \u0C35\u0C1A\u0C4D\u0C1A\u0C3F\u0C02\u0C26\u0C3F."}},Jo=e=>e.normalize("NFC").toLowerCase().trim(),je={clearFilters:/\b(clear|remove|reset)\b.*\bfilters?\b|ఫిల్టర్.*(తీసే|తొలగ)/i,clearSort:/\b(clear|remove|reset)\b.*\bsort(ing)?\b|క్రమం.*(తీసే|తొలగ)/i,count:/^\s*(how many|count)\b|ఎన్ని|లెక్క/i,sort:/\bsort\b|\border by\b|క్రమ|అమర్చ|సార్ట్/i,desc:/\b(desc|descending|z\s*-\s*a|highest|largest|most)\b|అవరోహణ|తగ్గే|పెద్ద|అధిక|చివర|ఎక్కువ నుండి/i,openEn:/^\s*open\s+(.+?)\s*$/i,openTe:/^\s*(.+?)\s*(తెరువు|తెరవండి|తెరవు)\s*$/,searchFiller:/^\s*(search(\s+for)?|find|show(\s+me)?|filter(\s+by)?|look\s+for|వెతుకు|వెతకండి|శోధించు|శోధించండి|చూపించు|చూపించండి)\s+|\s+(వెతుకు|వెతకండి|శోధించు|శోధించండి|చూపించు|చూపించండి)\s*$/gi};function tc(e,t){let n=Jo(e),o=null;for(let r of t)for(let a of[r.label,r.key]){let i=Jo(a);i&&n.includes(i)&&(!o||i.length>o.len)&&(o={key:r.key,len:i.length})}return o?.key??null}function Xo(e,t){let n=(e??"").trim();if(!n)return null;if(je.clearFilters.test(n))return{kind:"tool",tool:"clear_filters",input:{}};if(je.clearSort.test(n))return{kind:"tool",tool:"clear_sort",input:{}};if(je.count.test(n))return{kind:"tool",tool:"count",input:{}};if(je.sort.test(n)){let a=tc(n,t.columns);return a?{kind:"tool",tool:"sort",input:{key:a,direction:je.desc.test(n)?"desc":"asc"}}:null}let o=n.match(je.openEn)??n.match(je.openTe);if(o?.[1])return{kind:"open",text:o[1].trim()};let r=n.replace(je.searchFiller,"").trim();return r?{kind:"tool",tool:"search",input:{query:r}}:null}function nc(e){return!!e&&typeof e=="object"&&typeof e.success=="boolean"&&typeof e.message=="string"}function oc(e,t){let n=e.inputSchema?.required;return Array.isArray(n)?n.map(String).filter(o=>t[o]===void 0||t[o]===null||String(t[o]).trim()===""):[]}function rc(e,t){let n=e.find(r=>r.name===t);if(n)return n;let o=e.filter(r=>r.name.endsWith(`_${t}`)).sort((r,a)=>r.name.length-a.name.length);if(o.length!==0&&!(o.length>1&&o[0].name.length===o[1].name.length))return o[0]}function Zo(e){return e.normalize("NFC").trim().toLocaleLowerCase()}function ic(e,t){let n=Zo(e);return t.find(o=>o.phrases.some(r=>{let a=Zo(r);return a.length>0&&n.includes(a)}))}function Yt({tools:e,data:t=[],onResult:n,onError:o,locale:r="en",columns:a=[],rowKey:i="id",parseIntent:s,customRules:l=[],historyLimit:c=20}){let u=ec[r],[b,p]=Vt(0),[g,f]=Vt(null),[h,d]=Vt(null),[x,k]=Vt([]),m=Rn({tools:e,data:t,onResult:n,onError:o,columns:a,rowKey:i,parseIntent:s,customRules:l,historyLimit:c,m:u,locale:r});m.current={tools:e,data:t,onResult:n,onError:o,columns:a,rowKey:i,parseIntent:s,customRules:l,historyLimit:c,m:u,locale:r};let v=Rn(!0),w=Rn(0);Xl(()=>(v.current=!0,()=>{v.current=!1}),[]);let A=St((E,I,y,q,B)=>{v.current&&(B===w.current&&f(y),k(j=>[...j,{id:B,tool:E,input:I,result:y,source:q,at:Date.now()}].slice(-m.current.historyLimit)))},[]),C=St(async(E,I,y)=>{let{tools:q,onResult:B,onError:j,m:oe}=m.current,de=++w.current,z=rc(q,E);if(!z){let T={success:!1,message:oe.toolMissing(E),error:{code:"NOT_SUPPORTED"}},P=new Error(T.message);return v.current&&d(P),j?.(P),A(E,I,T,y,de),T}let H=oc(z,I);if(H.length){let T={success:!1,message:oe.missingInput(H.join(", ")),error:{code:"INVALID_INPUT"},tool:z.name};return A(z.name,I,T,y,de),B?.(T),T}v.current&&p(T=>T+1);try{let T=await z.execute(I),P=nc(T)?{...T,tool:z.name}:{success:!0,message:oe.done,data:T,tool:z.name};return v.current&&P.success&&d(null),A(z.name,I,P,y,de),B?.(P),P}catch(T){let P=T instanceof Error?T:new Error(String(T)),J={success:!1,message:oe.failed,error:{code:"INTERNAL"},tool:z.name};return v.current&&d(P),j?.(P),A(z.name,I,J,y,de),J}finally{v.current&&p(T=>Math.max(0,T-1))}},[A]),G=St((E,I={})=>C(E,I??{},"tool"),[C]),D=St(async E=>{let{columns:I,locale:y,parseIntent:q,customRules:B,data:j,m:oe,rowKey:de}=m.current,z=ic(E,B??[]);if(z){let W={input:E,data:j,columns:I,executeTool:G};try{let fe={success:!0,message:await z.execute(W),tool:`rule:${z.name}`};return A(`rule:${z.name}`,{text:E},fe,"ask",++w.current),m.current.onResult?.(fe),fe}catch(se){let fe=se instanceof Error?se:new Error(String(se)),ve={success:!1,message:oe.failed,error:{code:"INTERNAL"},tool:`rule:${z.name}`};return v.current&&d(fe),m.current.onError?.(fe),A(`rule:${z.name}`,{text:E},ve,"ask",++w.current),ve}}let T=(q??Xo)(E,{columns:I,locale:y});if(!T){let W={success:!1,message:oe.notUnderstood,error:{code:"NOT_UNDERSTOOD"}};return A("ask",{text:E},W,"ask",++w.current),W}if(T.kind==="tool")return C(T.tool,T.input,"ask");let P=await C("search",{query:T.text},"ask"),J=Array.isArray(P.data)?P.data:[];if(!P.success)return P;if(J.length===0){let W={success:!1,message:oe.noMatch(T.text),error:{code:"NOT_FOUND"},tool:P.tool};return A("open",{text:T.text},W,"ask",++w.current),W}return C("open",{id:me(J[0],de)},"ask")},[G,A,C]),M=St(()=>{k([]),f(null),d(null)},[]);return{loading:b>0,tools:e,executeTool:G,ask:D,lastResult:g,lastError:h,history:x,clearHistory:M}}var ac=Yt;import{useEffect as sc,useMemo as lc,useRef as In}from"react";function cc(e){return JSON.stringify(e.map(t=>[t.name,t.title,t.description,t.inputSchema]))}function uc({tools:e,data:t=[],columns:n=[],rowKey:o,locale:r,onSelectRow:a,onHighlightRows:i,onOpenRow:s,name:l="yuktai_grid",descriptions:c,onStatusChange:u}){let b=lc(()=>e||vt({data:t,columns:n,rowKey:o,locale:r,onSelectRow:a,onHighlightRows:i,onOpenRow:s},{name:l,descriptions:c}),[e,t,n,o,r,a,i,s,l,c]),p=In(b);p.current=b;let g=In(u);g.current=u;let f=In(Promise.resolve()),h=cc(b);return sc(()=>{let d=w=>g.current?.(w),x=typeof document<"u"?document.modelContext:void 0;if(!x?.registerTool){d({state:"unsupported",registered:[],errors:[]});return}let k=new AbortController,m=p.current,v=f.current.then(async()=>{if(k.signal.aborted)return;d({state:"registering",registered:[],errors:[]});let w=[],A=[];for(let C of m){if(k.signal.aborted)return;try{await x.registerTool({name:C.name,title:C.title,description:C.description,inputSchema:C.inputSchema,execute:G=>{let D=p.current.find(M=>M.name===C.name);return D?D.execute(G??{}):{success:!1,message:`Tool "${C.name}" is no longer available.`,error:{code:"NOT_SUPPORTED"}}}},{signal:k.signal}),w.push(C.name)}catch(G){A.push({tool:C.name,message:G instanceof Error?G.message:String(G)})}}k.signal.aborted||d({state:A.length===0?"ready":w.length>0?"partial":"error",registered:w,errors:A})});return f.current=v.catch(()=>{}),()=>k.abort()},[h]),null}var Kt=uc;import{jsx as O,jsxs as ge}from"react/jsx-runtime";var dc={"en-US":{search:"Search...",searchAria:"Search grid",rows:"rows",row:"row",loading:"Loading...",noData:"No data found.",selectRow:"Select row",pageSize:"Page size",page:"Page",of:"of",previous:"Previous",next:"Next",yes:"Yes",no:"No",sortAscending:"Sort ascending",sortDescending:"Sort descending",filtersActive:e=>`${e} filter(s) applied`,clearFilters:"Clear filters"},"te-IN":{search:"\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F...",searchAria:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C32\u0C4B \u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F",rows:"\u0C35\u0C30\u0C41\u0C38\u0C32\u0C41",row:"\u0C35\u0C30\u0C41\u0C38",loading:"\u0C32\u0C4B\u0C21\u0C4D \u0C05\u0C35\u0C41\u0C24\u0C4B\u0C02\u0C26\u0C3F...",noData:"\u0C21\u0C47\u0C1F\u0C3E \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.",selectRow:"\u0C35\u0C30\u0C41\u0C38\u0C28\u0C41 \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B\u0C02\u0C21\u0C3F",pageSize:"\u0C2A\u0C47\u0C1C\u0C40 \u0C2A\u0C30\u0C3F\u0C2E\u0C3E\u0C23\u0C02",page:"\u0C2A\u0C47\u0C1C\u0C40",of:"\u0C32\u0C4B",previous:"\u0C35\u0C46\u0C28\u0C41\u0C15\u0C15\u0C41",next:"\u0C2E\u0C41\u0C02\u0C26\u0C41\u0C15\u0C41",yes:"\u0C05\u0C35\u0C41\u0C28\u0C41",no:"\u0C15\u0C3E\u0C26\u0C41",sortAscending:"\u0C06\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u0C32\u0C4B \u0C05\u0C2E\u0C30\u0C4D\u0C1A\u0C02\u0C21\u0C3F",sortDescending:"\u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02\u0C32\u0C4B \u0C05\u0C2E\u0C30\u0C4D\u0C1A\u0C02\u0C21\u0C3F",filtersActive:e=>`${e} \u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D(\u0C32\u0C41) \u0C35\u0C47\u0C36\u0C3E\u0C30\u0C41`,clearFilters:"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C02\u0C21\u0C3F"}};function pc({size:e=20,color:t="currentColor",strokeWidth:n=2.4}){return ge("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[O("circle",{cx:"11",cy:"11",r:"6.5"}),O("path",{d:"m16 16 5 5"})]})}function gc({size:e=18,color:t="currentColor",strokeWidth:n=2.4,label:o}){return ge("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":o?void 0:!0,"aria-label":o,role:o?"img":void 0,children:[o?O("title",{children:o}):null,O("path",{d:"m6 15 6-6 6 6"})]})}function fc({size:e=18,color:t="currentColor",strokeWidth:n=2.4,label:o}){return ge("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":o?void 0:!0,"aria-label":o,role:o?"img":void 0,children:[o?O("title",{children:o}):null,O("path",{d:"m6 9 6 6 6-6"})]})}function mc({size:e=20,color:t="currentColor",strokeWidth:n=2.4}){return O("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:O("path",{d:"m15 18-6-6 6-6"})})}function bc({size:e=20,color:t="currentColor",strokeWidth:n=2.4}){return O("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:O("path",{d:"m9 18 6-6-6-6"})})}function er({size:e=18,color:t="currentColor",strokeWidth:n=2.4}){return O("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:O("path",{d:"m5 12 4 4L19 6"})})}function hc({data:e,columns:t,rowKey:n="id",view:o="auto",mobileBreakpoint:r=768,theme:a="default",locale:i="en-US",ai:s=!1,search:l=!0,selectable:c=!1,selectedKeys:u=[],onSelectionChange:b,pagination:p,loading:g=!1,highlightIds:f=[],highlightColor:h="#fff3a3",autoScrollToHighlight:d=!1,onRowClick:x,onSortChange:k,empty:m,className:v="",inputLanguage:w,toolName:A="yuktai_grid",toolDescriptions:C,webmcp:G=!1,onWebMCPStatusChange:D,onAgentResult:M,customRules:E=[]}){let I=i==="te-IN"?"te-IN":"en-US",y=dc[I],q=s===!0||typeof s=="object"&&s!==null,B=p!==!1&&p!==void 0,j=typeof p=="object"?p.pageSize??20:20,oe=typeof p=="object"&&p.sizeOptions&&p.sizeOptions.length>0?p.sizeOptions:[10,20,50,100],[de,z]=Ve(""),[H,T]=Ve(1),[P,J]=Ve(j),[W,se]=Ve(),[fe,ve]=Ve("asc"),[De,Un]=Ve(!1),[Se,nt]=Ve([]),[mt,Ct]=Ve([]),Be=pt(()=>tt(t.map(S=>({key:String(S.key),label:S.label,type:S.type}))),[t]);Qt(()=>{J(j),T(1)},[j]),Qt(()=>{let S=()=>{Un(window.innerWidth<=r)};return S(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}},[r]);let we=pt(()=>{let S=[...e];if(de.trim()){let N=de.trim().toLowerCase();S=S.filter(Y=>t.some(U=>String(Y[U.key]??"").toLowerCase().includes(N)))}return Se.length&&(S=Ue(S,Be,Se)),W&&S.sort((N,Y)=>{let U=N[W],Te=Y[W];if(U==null&&Te==null)return 0;if(U==null)return 1;if(Te==null)return-1;if(typeof U=="number"&&typeof Te=="number")return fe==="asc"?U-Te:Te-U;let be=String(U).localeCompare(String(Te),i,{numeric:!0,sensitivity:"base"});return fe==="asc"?be:-be}),S},[e,t,de,Se,Be,W,fe,i]),Oe=B?Math.max(1,Math.ceil(we.length/P)):1;Qt(()=>{H>Oe&&T(Oe)},[H,Oe]);let bt=pt(()=>{let S=[...f.map(String),...mt];return Array.from(new Set(S))},[f,mt]);Qt(()=>{if(!d)return;let S=bt[0];if(S==null)return;let N=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(String(S)):String(S).replace(/["\\]/g,"\\$&");document.querySelector(`[data-yuktai-row-id="${N}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},[bt,d,H]);let Qe=pt(()=>{if(!B)return we;let S=(H-1)*P;return we.slice(S,S+P)},[we,B,H,P]),ot=o==="card"||o==="auto"&&De,He=S=>String(S[n]??""),rt=S=>u.some(N=>String(N)===S),Rt=S=>bt.some(N=>String(N)===S),$=S=>{if(!c)return;let N=He(S),Y=rt(N)?u.filter(U=>String(U)!==N):[...u,N];b?.(Y)},ne=S=>{if(S.sortable===!1)return;let N=String(S.key),Y=W===N&&fe==="asc"?"desc":"asc";se(N),ve(Y),T(1),k?.({key:N,direction:Y})},Me=S=>{z(S),T(1)},rn=(S,N)=>{let Y=t.find(U=>String(U.key)===S||U.label.toLowerCase()===S.toLowerCase());Y&&(se(String(Y.key)),ve(N),T(1),k?.({key:String(Y.key),direction:N}))},an=I==="te-IN"?"te":"en",jn=$n(S=>{S?(se(S.key),ve(S.direction)):(se(void 0),ve("asc")),T(1),k?.(S)},[k]),Vn=$n(S=>{nt(S),T(1)},[]),Yn=$n(S=>{if(Ct(S),B&&S.length){let N=we.findIndex(Y=>String(Y[n]??"")===S[0]);N>=0&&T(Math.floor(N/P)+1)}},[B,we,n,P]),sn=pt(()=>vt({data:e,columns:Be,rowKey:String(n),locale:an,filters:Se,onHighlightRows:Yn,onFiltersChange:Vn,onSortChange:jn,onOpenRow:x?S=>{let N=we.findIndex(U=>String(U[n]??"")===S),Y=N>=0?we[N]:e.find(U=>String(U[n]??"")===S);Y&&x(Y,Math.max(N,0))}:void 0,onSelectRow:c&&b?S=>{u.some(N=>String(N)===S)||b([...u.map(String),S])}:void 0},{name:A,descriptions:C}),[e,Be,n,an,Se,Yn,Vn,jn,x,we,c,b,u,A,C]),It=Yt({tools:sn,data:e,locale:an,columns:Be,rowKey:String(n),customRules:E,onResult:M}),Kn=pt(()=>sn.map(S=>({...S,execute:N=>It.executeTool(S.name,N)})),[sn,It.executeTool]),Gr=()=>{nt([]),T(1)},Qn=(S,N,Y)=>{if(N.render)return N.render(S[N.key],S,Y);let U=S[N.key];if(U==null)return"";if(N.type==="date"){let Te=new Date(String(U));if(!Number.isNaN(Te.getTime()))return Te.toLocaleDateString(i)}return N.type==="boolean"?U?y.yes:y.no:String(U)},Z=a==="dark",Jn={width:"100%",overflow:"hidden",border:a==="high-contrast"?"2px solid #000000":Z?"1px solid #334155":"1px solid #e2e8f0",borderRadius:12,background:Z?"#0f172a":"#ffffff",color:Z?"#f8fafc":"#0f172a",fontFamily:a==="dyslexia"?"Arial, sans-serif":void 0},Lr={padding:12,display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0"},Zn=S=>({width:40,height:40,minWidth:40,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,borderRadius:8,border:Z?"1px solid #475569":"1px solid #cbd5e1",background:S?Z?"#1e293b":"#f8fafc":Z?"#1e293b":"#ffffff",color:S?"#94a3b8":Z?"#f8fafc":"#0f172a",cursor:S?"not-allowed":"pointer",opacity:S?.55:1});if(g)return ge("div",{className:v,style:Jn,children:[G&&O(Kt,{tools:Kn,onStatusChange:D}),O("div",{style:{padding:32,textAlign:"center"},children:y.loading})]});let Pr=t.map(S=>({key:String(S.key),label:S.label,type:S.type==="number"?"number":S.type==="date"?"date":"text"}));return ge("div",{className:v,style:Jn,children:[G&&O(Kt,{tools:Kn,onStatusChange:D}),(l||q||Se.length>0)&&ge("div",{style:Lr,children:[l&&ge("div",{style:{position:"relative",width:"100%",maxWidth:420},children:[O("div",{style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",color:Z?"#cbd5e1":"#64748b",pointerEvents:"none"},children:O(pc,{size:19})}),O("input",{value:de,onChange:S=>{z(S.target.value),T(1)},placeholder:y.search,"aria-label":y.searchAria,style:{width:"100%",padding:"10px 12px 10px 40px",borderRadius:8,border:Z?"1px solid #475569":"1px solid #cbd5e1",background:Z?"#1e293b":"#ffffff",color:Z?"#ffffff":"#0f172a",outline:"none",boxSizing:"border-box"}})]}),Se.length>0&&ge("button",{type:"button",onClick:Gr,title:y.clearFilters,style:{padding:"6px 10px",borderRadius:999,border:Z?"1px solid #475569":"1px solid #cbd5e1",background:Z?"#1e293b":"#f1f5f9",color:"inherit",fontSize:12,cursor:"pointer"},children:[y.filtersActive(Se.length)," \u2715"]}),ge("div",{style:{marginLeft:"auto",fontSize:13,opacity:.7,whiteSpace:"nowrap"},children:[we.length," ",we.length===1?y.row:y.rows]}),q&&O(An,{data:e,columns:Pr,onSearch:Me,onSort:rn,theme:Z?"dark":"light",language:I,inputLanguage:w??I,agent:{ask:It.ask,loading:It.loading},embedded:!0})]}),we.length===0?O("div",{style:{padding:40,textAlign:"center",opacity:.7},children:m??y.noData}):ot?O("div",{style:{display:"grid",gap:12,padding:12},children:Qe.map((S,N)=>{let Y=He(S),U=rt(Y),Te=Rt(Y);return ge("div",{"data-yuktai-row-id":Y,onClick:()=>x?.(S,N),style:{padding:14,borderRadius:10,border:Z?"1px solid #334155":"1px solid #e2e8f0",background:Te?h:U?Z?"#1e3a5f":"#eff6ff":Z?"#1e293b":"#ffffff",cursor:x?"pointer":"default"},children:[c&&O("button",{type:"button",onClick:be=>{be.stopPropagation(),$(S)},"aria-label":`${y.selectRow} ${Y}`,"aria-pressed":U,style:{width:32,height:32,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,marginBottom:10,borderRadius:7,border:U?"1px solid #2563eb":"1px solid #cbd5e1",background:U?"#2563eb":"transparent",color:U?"#ffffff":"currentColor",cursor:"pointer"},children:U&&O(er,{size:17})}),t.map(be=>ge("div",{style:{display:"flex",gap:8,padding:"5px 0",alignItems:"flex-start"},children:[O("strong",{style:{minWidth:100,opacity:.7},children:be.label}),O("span",{children:Qn(S,be,N)})]},String(be.key)))]},Y)})}):O("div",{style:{width:"100%",overflowX:"auto"},children:ge("table",{style:{width:"100%",borderCollapse:"collapse"},children:[O("thead",{children:ge("tr",{children:[c&&O("th",{style:{padding:10,borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0",width:52}}),t.filter(S=>!(De&&S.hiddenOnMobile)).map(S=>{let N=W===String(S.key);return O("th",{onClick:()=>ne(S),style:{padding:10,textAlign:S.align??"left",borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0",whiteSpace:"nowrap",cursor:S.sortable===!1?"default":"pointer",width:S.width,userSelect:"none"},children:ge("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[S.label,N&&(fe==="asc"?O(gc,{size:17,label:y.sortAscending}):O(fc,{size:17,label:y.sortDescending}))]})},String(S.key))})]})}),O("tbody",{children:Qe.map((S,N)=>{let Y=He(S),U=rt(Y),Te=Rt(Y);return ge("tr",{"data-yuktai-row-id":Y,onClick:()=>x?.(S,N),style:{background:Te?h:U?Z?"#1e3a5f":"#eff6ff":"transparent",cursor:x?"pointer":"default"},children:[c&&O("td",{style:{padding:10,borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0"},children:O("button",{type:"button",onClick:be=>{be.stopPropagation(),$(S)},"aria-label":`${y.selectRow} ${Y}`,"aria-pressed":U,style:{width:28,height:28,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,borderRadius:6,border:U?"1px solid #2563eb":Z?"1px solid #64748b":"1px solid #cbd5e1",background:U?"#2563eb":"transparent",color:U?"#ffffff":"currentColor",cursor:"pointer"},children:U&&O(er,{size:16})})}),t.filter(be=>!(De&&be.hiddenOnMobile)).map(be=>O("td",{style:{padding:10,textAlign:be.align??"left",borderBottom:Z?"1px solid #334155":"1px solid #e2e8f0"},children:Qn(S,be,N)},String(be.key)))]},Y)})})]})}),B&&ge("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap",padding:12,borderTop:Z?"1px solid #334155":"1px solid #e2e8f0"},children:[ge("span",{style:{fontSize:13,opacity:.7},children:[y.page," ",H," ",y.of," ",Oe]}),ge("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[typeof p=="object"&&p.showSizeChanger&&O("select",{value:P,onChange:S=>{let N=Number(S.target.value);!Number.isFinite(N)||N<=0||(J(N),T(1))},"aria-label":y.pageSize,style:{minHeight:40,padding:"7px 10px",borderRadius:8,border:Z?"1px solid #475569":"1px solid #cbd5e1",background:Z?"#1e293b":"#ffffff",color:Z?"#ffffff":"#0f172a"},children:oe.map(S=>O("option",{value:S,children:S},S))}),O("button",{type:"button",disabled:H<=1,onClick:()=>T(S=>Math.max(1,S-1)),"aria-label":y.previous,title:y.previous,style:Zn(H<=1),children:O(mc,{size:20})}),O("button",{type:"button",disabled:H>=Oe,onClick:()=>T(S=>Math.min(Oe,S+1)),"aria-label":y.next,title:y.next,style:Zn(H>=Oe),children:O(bc,{size:20})})]})]})]})}import{useState as gt,useMemo as Tt,useCallback as Le,useEffect as En}from"react";function tr(e){return e===!1?Number.MAX_SAFE_INTEGER:e===!0||e===void 0?10:e.pageSize??10}function nr(e){return String(e??"").normalize("NFC").toLowerCase().trim()}function or(e){return e==null||typeof e=="string"&&e.trim()===""}function rr(e){if(typeof e=="number")return Number.isFinite(e)?e:null;let t=String(e??"").trim();if(t==="")return null;let n=Number(t);return Number.isFinite(n)?n:null}function ir(e){let t=e instanceof Date?e.getTime():new Date(String(e)).getTime();return Number.isFinite(t)?t:null}function yc(e,t,n,o){if(n==="number"||typeof e=="number"&&typeof t=="number"){let r=rr(e),a=rr(t);if(r!==null&&a!==null)return r-a}if(n==="date"||e instanceof Date&&t instanceof Date){let r=ir(e),a=ir(t);if(r!==null&&a!==null)return r-a}return typeof e=="boolean"&&typeof t=="boolean"?e===t?0:e?1:-1:String(e).localeCompare(String(t),o,{sensitivity:"base",numeric:!0})}function xc(e){let{data:t,columns:n,pagination:o=!0,mobileBreakpoint:r=768,locale:a,initialFilters:i=[]}=e,[s,l]=gt(null),[c,u]=gt(""),[b,p]=gt(i),[g,f]=gt(1),[h,d]=gt(tr(o)),[x,k]=gt(!1),m=tr(o);En(()=>{d(m),f(1)},[m]),En(()=>{if(typeof window>"u")return;let T=()=>{k(window.innerWidth<=r)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[r]);let v=Tt(()=>tt(n.map(T=>({key:String(T.key),label:T.label,type:T.type}))),[n]),w=Le(T=>{l(P=>!P||P.key!==T?{key:T,direction:"asc"}:P.direction==="asc"?{key:T,direction:"desc"}:null),f(1)},[]),A=Le(T=>{l(T&&T.direction?T:null),f(1)},[]),C=Le(()=>{l(null),f(1)},[]),G=Le(T=>{u(T),f(1)},[]),D=Le(T=>{p(T),f(1)},[]),M=Le(T=>{p(P=>[...P.filter(J=>J.key!==T.key),T]),f(1)},[]),E=Le(T=>{p(P=>P.filter(J=>J.key!==T)),f(1)},[]),I=Le(()=>{p([]),f(1)},[]),y=Le(T=>{d(Math.max(1,Math.floor(T)||1)),f(1)},[]),q=Tt(()=>{let T=nr(c);return T?t.filter(P=>n.some(J=>{let W=P[J.key];return W==null?!1:nr(W).includes(T)})):t},[t,c,n]),B=Tt(()=>Ue(q,v,b),[q,v,b]),j=Tt(()=>{if(!s||!s.direction)return B;let T=n.find(J=>String(J.key)===s.key),P=s.direction==="desc"?-1:1;return[...B].sort((J,W)=>{let se=J[s.key],fe=W[s.key],ve=or(se),De=or(fe);return ve&&De?0:ve?1:De?-1:P*yc(se,fe,T?.type,a)})},[B,s,n,a]),oe=Math.max(1,Math.ceil(j.length/h)),de=Tt(()=>{if(o===!1)return j;let T=(g-1)*h;return j.slice(T,T+h)},[j,g,h,o]);En(()=>{g>oe&&f(oe)},[g,oe]);let z=Le(T=>f(Math.min(Math.max(1,Math.floor(T)||1),oe)),[oe]),H=Le(()=>{l(null),u(""),p([]),f(1)},[]);return{displayedData:de,rows:j,totalCount:t.length,filteredCount:j.length,sort:s,toggleSort:w,setSort:A,clearSort:C,searchQuery:c,setSearchQuery:G,filters:b,setFilters:D,setFilter:M,removeFilter:E,clearFilters:I,page:g,pageSize:h,totalPages:oe,setPage:z,setPageSize:y,isMobile:x,reset:H}}var Jt={"html-lang":{title:"Page language is set",wcag:"3.1.1",severity:"serious",why:"Screen readers pick their voice and pronunciation from the page language. Without it, Telugu or Hindi text may be read with English rules."},"page-title":{title:"Page has a title",wcag:"2.4.2",severity:"serious",why:"The title is the first thing announced and the name shown on browser tabs and bookmarks."},"image-alt":{title:"Images have alternative text",wcag:"1.1.1",severity:"critical",why:'People who cannot see the image get no information from it unless alt text describes it (or alt="" marks it as decorative).'},"heading-order":{title:"Headings follow a logical order",wcag:"1.3.1",severity:"moderate",why:"Many screen-reader users jump between headings. Skipped levels make the page outline confusing."},"single-h1":{title:"Page has one main heading",wcag:"best practice",severity:"minor",why:"A single h1 tells everyone what the page is about."},"landmark-main":{title:"Main content landmark exists",wcag:"1.3.1 / 2.4.1",severity:"moderate",why:"A <main> region lets keyboard and screen-reader users skip straight past menus to the content."},"form-label":{title:"Form fields have labels",wcag:"1.3.1 / 4.1.2",severity:"critical",why:'Without a label, a screen reader just says "edit text" and the user has to guess what to type.'},"button-name":{title:"Buttons have names",wcag:"4.1.2",severity:"critical",why:'An icon-only button with no name is announced as just "button", so its purpose is unknown.'},"link-name":{title:"Links have names",wcag:"2.4.4",severity:"serious",why:"Links are often read out of context in a list. An empty link gives no clue where it goes."},"color-contrast":{title:"Text has enough contrast",wcag:"1.4.3",severity:"serious",why:"Low-contrast text is hard to read for older users, people with low vision, and anyone outdoors on a phone."},"positive-tabindex":{title:"No positive tabindex",wcag:"2.4.3",severity:"moderate",why:"tabindex greater than 0 forces a custom keyboard order that usually doesn't match the visual order."},"keyboard-access":{title:"Clickable things work with a keyboard",wcag:"2.1.1",severity:"critical",why:"A div or span with a click handler can't be reached or activated with Tab and Enter, locking out keyboard users."},"duplicate-id":{title:"IDs are unique",wcag:"best practice",severity:"minor",why:"Labels and ARIA references point at ids. Duplicates make them point at the wrong element."},"form-error":{title:"Errors are linked to their fields",wcag:"3.3.1",severity:"serious",why:"When a field is marked invalid, the error message must be connected to it so it's announced together with the field."},"target-size":{title:"Touch targets are large enough",wcag:"2.5.8",severity:"moderate",why:"Small targets are hard to tap for people with tremors, seniors and everyone on mobile."}},wc={critical:10,serious:5,moderate:2,minor:1};function Ye(e={}){let t=Ae(e.root),n=new Set(e.skip??[]),o=[],r={},a=t?Je(t)?t:t.ownerDocument:null,i=(s,l,c,u,b=!1)=>{if(n.has(s))return;let p=Jt[s],g=r[s]=(r[s]??0)+1;o.push({id:`${s}-${g}`,rule:s,severity:p.severity,wcag:p.wcag,message:c,why:p.why,fix:u,selector:l?Ne(l):"document",snippet:l?pe(l.outerHTML,120):"",autoFixable:b,element:l??void 0})};if(t&&a){a.documentElement.getAttribute("lang")||i("html-lang",a.documentElement,"The <html> element has no lang attribute.",'Add lang to <html>, e.g. <html lang="te"> or "en".',!0),a.title.trim()||i("page-title",null,"The page has no <title>.","Add a short, descriptive <title> that names this page.");for(let d of _(t,"img"))if(!(d.getAttribute("role")==="presentation"||d.getAttribute("role")==="none")&&!d.hasAttribute("alt")&&!d.getAttribute("aria-label")&&!d.getAttribute("aria-labelledby")){let x=d.getAttribute("title");i("image-alt",d,`Image has no alt text${d.getAttribute("src")?` (${pe(d.getAttribute("src")??"",40)})`:""}.`,x?`Use the title as alt: alt="${pe(x,40)}".`:'Describe the image in alt, or use alt="" if it is purely decorative.',!!x)}let s=_(t,"h1,h2,h3,h4,h5,h6"),l=0;for(let d of s){let x=Number(d.tagName[1]);l>0&&x>l+1&&i("heading-order",d,`Heading jumps from h${l} to h${x}: "${pe(d.textContent??"",40)}".`,`Change it to h${l+1}, or add the missing level above it.`),l=x}let c=s.filter(d=>d.tagName==="H1");c.length===0?i("single-h1",null,"The page has no h1.","Add one h1 that names the page."):c.length>1&&i("single-h1",c[1],`The page has ${c.length} h1 headings.`,"Keep one h1; turn the others into h2."),t.querySelectorAll("main,[role='main']").length===0&&i("landmark-main",null,"No <main> landmark found.","Wrap the primary content in <main>.");let u=_(t,"input,select,textarea").filter(d=>{let x=(d.getAttribute("type")??"text").toLowerCase();return!["hidden","submit","button","reset","image"].includes(x)});for(let d of u){if(!Ie(d)){let x=d.getAttribute("placeholder")||d.getAttribute("name");i("form-label",d,`Form field has no label${x?` (placeholder/name: "${pe(x,30)}")`:""}.`,x?`Add a visible <label>. Quick fix: aria-label="${pe(x,30)}".`:"Add a visible <label for=\u2026> describing what to enter.",!!x)}d.getAttribute("aria-invalid")==="true"&&(d.getAttribute("aria-describedby")||d.getAttribute("aria-errormessage")||i("form-error",d,"Field is marked invalid but no error message is linked to it.","Put the error text in an element with an id and point aria-describedby at it."))}for(let d of _(t,"button,[role='button'],input[type='submit'],input[type='button']"))if(!Ie(d)){let x=d.getAttribute("title");i("button-name",d,"Button has no accessible name.",x?`Use the title as the name: aria-label="${x}".`:"Add visible text or an aria-label that says what the button does.",!!x)}for(let d of _(t,"a[href]"))if(!Ie(d)){let x=d.getAttribute("title");i("link-name",d,`Link has no text (${pe(d.getAttribute("href")??"",40)}).`,x?`Use the title as the name: aria-label="${x}".`:"Add link text that says where it goes.",!!x)}for(let d of _(t,"[tabindex]"))Number(d.getAttribute("tabindex"))>0&&i("positive-tabindex",d,`tabindex="${d.getAttribute("tabindex")}" overrides the natural tab order.`,'Use tabindex="0" and fix the order in the HTML instead.',!0);let b="a[href],button,input,select,textarea,summary";for(let d of _(t,"[onclick],[role='button'],[role='link']"))d.matches(b)||d.hasAttribute("tabindex")||i("keyboard-access",d,`<${d.tagName.toLowerCase()}> is clickable but can't be reached with the keyboard.`,'Use a real <button>, or add tabindex="0", a role and Enter/Space key handling.',!0);let p=new Map;for(let d of Array.from(t.querySelectorAll("[id]")))d.closest("[data-yuktai-panel]")||p.set(d.id,(p.get(d.id)??0)+1);for(let[d,x]of p)x>1&&i("duplicate-id",t.querySelector(`[id="${d.replace(/"/g,'\\"')}"]`),`id="${d}" is used ${x} times.`,"Give each element a unique id.");let g=e.maxContrastChecks??600,f=0;for(let d of _(t,"body *")){if(f>=g)break;if(!ht(d)||["SCRIPT","STYLE","NOSCRIPT","OPTION"].includes(d.tagName))continue;f++;let x=ln(window.getComputedStyle(d).color),k=to(d);if(!x||!k)continue;let m=cn(x,k),v=no(d)?3:4.5;m<v&&i("color-contrast",d,`Contrast ${m}:1 is below ${v}:1 for "${pe(d.textContent??"",30)}".`,`Darken the text or lighten the background until the ratio is at least ${v}:1.`)}let h=e.minTargetSize??24;for(let d of _(t,Ft)){let x=d.getBoundingClientRect();x.width===0&&x.height===0||d.tagName==="A"&&d.closest("p,li,td")||(x.width<h||x.height<h)&&i("target-size",d,`Target is ${Math.round(x.width)}\xD7${Math.round(x.height)}px (minimum ${h}\xD7${h}).`,`Increase padding so it's at least ${h}\xD7${h}px (44\xD744 is better for seniors).`)}}return kc(o,a,n)}function kc(e,t,n){let o=Object.keys(Jt).filter(l=>!n.has(l)).map(l=>{let c=e.filter(u=>u.rule===l).length;return{rule:l,title:Jt[l].title,passed:c===0,issueCount:c}}),r=0;for(let l of o){let c=wc[Jt[l.rule].severity];r+=Math.min(25,l.issueCount*c)}let a=Math.max(0,100-r),i=o.filter(l=>!l.passed),s=e.filter(l=>l.severity==="critical").length;return{url:t?.location?.href??"",title:t?.title??"",generatedAt:new Date().toISOString(),score:a,passed:s===0&&a>=80,checks:o,issues:e,summary:e.length===0?`All ${o.length} checks passed.`:`${o.length-i.length} of ${o.length} checks passed. ${e.length} issue(s) found, ${s} critical. Score ${a}/100.`}}function ar(e){let t=["# Accessibility QA report","",`- Page: ${e.title||"(untitled)"} ${e.url}`,`- Generated: ${e.generatedAt}`,`- Score: **${e.score}/100** \u2014 ${e.passed?"PASS":"FAIL"}`,"",e.summary,"","## Checks","","| Check | Result | Issues |","|---|---|---|",...e.checks.map(n=>`| ${n.title} | ${n.passed?"\u2705 Pass":"\u274C Fail"} | ${n.issueCount} |`)];if(e.issues.length){t.push("","## Issues","");for(let n of e.issues)t.push(`### ${n.id} \xB7 ${n.severity} \xB7 WCAG ${n.wcag}`,"",`- **Problem:** ${n.message}`,`- **Why it matters:** ${n.why}`,`- **Fix:** ${n.fix}`,`- **Where:** \`${n.selector}\``,"")}return t.join(`
396
+ `)}function sr(e){return JSON.stringify({...e,issues:e.issues.map(({element:t,...n})=>n)},null,2)}function lr(e={}){let t=null,n=null,o=null,r=!1,a=[],i=()=>({report:t,watching:n!==null,appliedFixes:a.length}),s=()=>e.onUpdate?.(i()),l=p=>t?.issues.find(g=>g.id===p),c=(p,g,f)=>{a.push({element:p,attribute:g,previous:p.getAttribute(g)}),p.setAttribute(g,f)};function u(p){let g=p.element,f=(h,d)=>({issueId:p.id,applied:h,message:d});if(!p.autoFixable||!g)return f(!1,"This needs a human decision \u2014 see the suggested fix.");switch(p.rule){case"html-lang":{let h=e.defaultLang||(We()?navigator.language:"")||"en";return c(g,"lang",h),f(!0,`Set lang="${h}" on <html>.`)}case"image-alt":{let h=g.getAttribute("title");if(!h)break;return c(g,"alt",h),f(!0,`Used the image title as alt text: "${h}".`)}case"form-label":{let h=g.getAttribute("placeholder")||g.getAttribute("name");if(!h)break;let d=h.replace(/[_-]+/g," ").trim();return c(g,"aria-label",d),f(!0,`Added aria-label="${d}". A visible <label> is still better.`)}case"button-name":case"link-name":{let h=g.getAttribute("title");if(!h)break;return c(g,"aria-label",h),f(!0,`Added aria-label="${h}".`)}case"positive-tabindex":return c(g,"tabindex","0"),f(!0,"Changed tabindex to 0 so the natural order applies.");case"keyboard-access":{c(g,"tabindex","0"),g.getAttribute("role")||c(g,"role","button");let h=d=>{let x=d.key;(x==="Enter"||x===" ")&&(d.preventDefault(),g.click())};return g.addEventListener("keydown",h),a.push({element:g,attribute:"",previous:null,listener:h}),f(!0,"Made it focusable and added Enter/Space support.")}default:break}return f(!1,"No safe automatic fix for this one \u2014 see the suggested fix.")}function b(){if(t=Ye(e),e.autoApply){r=!0;let p=t.issues.filter(g=>g.autoFixable).map(u);r=!1,p.some(g=>g.applied)&&(t=Ye(e))}return s(),t}return{start(){if(!We()||n)return;let p=Ae(e.root),g=Je(p)?p.body:p;g&&(n=new MutationObserver(f=>{r||!f.some(d=>!d.target.closest?.("[data-yuktai-panel]"))||(o&&clearTimeout(o),o=setTimeout(b,e.debounceMs??600))}),n.observe(g,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["alt","aria-label","aria-invalid","tabindex","lang","title"]}),b())},stop(){n?.disconnect(),n=null,o&&clearTimeout(o),o=null,s()},scan:b,explain(p){let g=l(p);return g?[`${g.message}`,`Why it matters: ${g.why}`,`How to fix: ${g.fix}`,`Standard: WCAG ${g.wcag} (${g.severity}).`,g.autoFixable?"I can apply a safe fix for this in the browser.":"This one needs a change in your code."].join(`
397
+ `):`No issue "${p}" in the current report. Run a scan first.`},applyFix(p){let g=l(p);if(!g)return{issueId:p,applied:!1,message:"Issue not found. Run a scan first."};r=!0;let f=u(g);return r=!1,f.applied&&b(),f},applyAllFixes(){t||b(),r=!0;let p=(t?.issues??[]).filter(g=>g.autoFixable).map(u);return r=!1,b(),p},undoAll(){let p=a.length;for(r=!0;a.length;){let g=a.pop();g.listener?g.element.removeEventListener("keydown",g.listener):g.previous===null?g.element.removeAttribute(g.attribute):g.element.setAttribute(g.attribute,g.previous)}return r=!1,b(),p},getState:i}}var vc=/^(field|input|value|text|enter|details?|info|data|\*|:)$/i,Sc=/^(go|ok|submit|send|click here|>|→|next)$/i,Tc=[[/e-?mail/i,"email","email"],[/phone|mobile|tel/i,"tel","tel"],[/^(full)?name$|full.?name/i,"name"],[/first.?name|given/i,"given-name"],[/last.?name|surname|family/i,"family-name"],[/address|street/i,"street-address"],[/zip|postal|pin.?code|pincode/i,"postal-code"],[/city|town/i,"address-level2"],[/country/i,"country-name"],[/password/i,"current-password","password"],[/dob|birth/i,"bday"]];function Ac(e){let t=e.getAttribute("id");return t&&e.ownerDocument.querySelector(`label[for="${t.replace(/"/g,'\\"')}"]`)?!0:!!e.closest("label")}function Cc(e){return _(e,"input,select,textarea").filter(t=>!["hidden","submit","button","reset","image"].includes((t.getAttribute("type")??"text").toLowerCase())).map(t=>({label:Ie(t),type:t.tagName==="INPUT"?(t.getAttribute("type")??"text").toLowerCase():t.tagName.toLowerCase(),name:t.getAttribute("name")??t.getAttribute("id")??"",required:t.hasAttribute("required")||t.getAttribute("aria-required")==="true",hasVisibleLabel:Ac(t),selector:Ne(t),element:t}))}function Rc(e,t={}){let n=t.seniorFriendly!==!1,o=t.maxFieldsPerStep??8,r=Cc(e),a=[],i=(p,g,f,h)=>a.push({level:p,message:g,suggestion:f,field:h?.label||h?.name,selector:h?.selector});for(let p of r){let g=p.element,f=p.label||p.name||p.type,h=g.getAttribute("placeholder");!p.label&&h?i("problem",`"${h}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts and aren't read by every screen reader. Add a visible label above the field.",p):p.label?!p.hasVisibleLabel&&h&&!g.getAttribute("aria-label")?i("problem",`"${f}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts. Add a visible label above the field.",p):vc.test(p.label)&&i("improvement",`The label "${p.label}" is unclear.`,'Say exactly what is needed, e.g. "Mobile number (10 digits)".',p):i("problem",`A ${p.type} field${p.name?` ("${p.name}")`:""} has no label.`,"Add a visible <label> that says exactly what to enter.",p),p.required&&p.label&&!/\*|required|mandatory|తప్పనిసరి|आवश्यक/i.test(p.label)&&i("improvement",`"${f}" is required but the label doesn't say so.`,'Add "(required)" to the label so everyone knows before submitting.',p);let d=`${p.name} ${p.label}`;for(let[x,k,m]of Tc)if(x.test(d)){g.getAttribute("autocomplete")||i("improvement",`"${f}" has no autocomplete hint.`,`Add autocomplete="${k}" so browsers can fill it in (WCAG 1.3.5).`,p),m&&p.type==="text"&&i("improvement",`"${f}" uses type="text".`,`Use type="${m}" for the right mobile keyboard and validation.`,p);break}if(g.getAttribute("aria-invalid")==="true"&&!g.getAttribute("aria-describedby")&&!g.getAttribute("aria-errormessage")&&i("problem",`"${f}" shows an error that isn't connected to the field.`,"Link the error text with aria-describedby and explain how to fix it.",p),n){let x=parseFloat(window.getComputedStyle(g).fontSize)||16;x<16&&i("improvement",`"${f}" text is ${x}px.`,"Use at least 16px in inputs; it is easier to read and stops mobile browsers from zooming.",p)}}r.length>o&&i("improvement",`This form has ${r.length} fields on one screen.`,`Split it into steps of about ${o} fields with a progress indicator.`);let s=_(e,"button,input[type='submit'],input[type='button']");if(s.length===0)i("problem","No submit button found.",'Add a clear <button type="submit"> so the form can be completed with the keyboard.');else if(n){let p=qe(Ie(s[s.length-1]));Sc.test(p)&&i("improvement",`The button says "${p}".`,'Name the result, e.g. "Send message" or "Book appointment".')}!_(e,"[role='alert'],[aria-live]",{includeHidden:!0}).length&&r.some(p=>p.required)&&i("improvement","No live region for error messages.",'Add an element with role="alert" so errors are announced when the form is submitted.');let l=a.filter(p=>p.level==="problem").length,c=a.length-l,u=Math.max(0,100-l*15-c*4),b=e.getAttribute("aria-label")||qe(e.querySelector("legend,h1,h2,h3")?.textContent)||e.getAttribute("name")||e.getAttribute("id")||"Form";return{name:pe(b,50),selector:Ne(e),fields:r,findings:a,score:u,summary:a.length===0?`"${pe(b,40)}" looks clear: ${r.length} labelled field(s), nothing to fix.`:`"${pe(b,40)}" has ${r.length} field(s): ${l} problem(s) and ${c} suggestion(s). Score ${u}/100.`}}function Zt(e={}){let t=Ae(e.root);return t?_(t,"form,[role='form']").map(n=>Rc(n,e)):[]}function Ic(e){let t=Ae(e),n={title:"",description:"",language:"",headings:[],landmarks:{},counts:{links:0,buttons:0,images:0,forms:0,tables:0,fields:0},unlabeledFields:[],imagesWithoutAlt:[],purpose:""};if(!t)return n;let o=Je(t)?t:t.ownerDocument,r=_(t,"h1,h2,h3,h4,h5,h6").map(u=>({level:Number(u.tagName[1]),text:pe(u.textContent??"",80)})),a={};for(let[u,b]of Object.entries({header:"header,[role='banner']",navigation:"nav,[role='navigation']",main:"main,[role='main']",search:"search,[role='search']",footer:"footer,[role='contentinfo']"}))a[u]=_(t,b).length;let i=_(t,"input,select,textarea").filter(u=>!["hidden","submit","button","reset","image"].includes((u.getAttribute("type")??"text").toLowerCase())),s=i.filter(u=>!Ie(u)).map(u=>({type:u.tagName==="INPUT"?u.getAttribute("type")??"text":u.tagName.toLowerCase(),hint:u.getAttribute("placeholder")||u.getAttribute("name")||"",selector:Ne(u)})),l=_(t,"img:not([alt])").map(u=>({src:u.getAttribute("src")??"",selector:Ne(u)})),c={title:o.title,description:qe(o.querySelector('meta[name="description"]')?.getAttribute("content")),language:o.documentElement.getAttribute("lang")??"",headings:r,landmarks:a,counts:{links:_(t,"a[href]").length,buttons:_(t,"button,[role='button'],input[type='submit']").length,images:_(t,"img").length,forms:_(t,"form,[role='form']").length,tables:_(t,"table,[role='grid'],[role='table']").length,fields:i.length},unlabeledFields:s,imagesWithoutAlt:l,purpose:""};return c.purpose=$c(c,i),c}function $c(e,t){let n=e.headings.find(i=>i.level===1)?.text||e.title||"This page",o=t.map(i=>`${i.getAttribute("type")} ${i.getAttribute("name")} ${Ie(i)}`).join(" ").toLowerCase(),r=[];/password/.test(o)?r.push("sign in or create an account"):(/search|query|వెతుకు/.test(o)||e.landmarks.search)&&r.push("search"),/message|comment|feedback|contact|enquiry/.test(o)&&r.push("send a message"),/card|payment|upi|amount/.test(o)&&r.push("make a payment"),e.counts.tables&&r.push(`browse ${e.counts.tables} table(s) of data`),!r.length&&e.counts.forms&&r.push(`fill in ${e.counts.forms} form(s)`),r.length||r.push("read content");let a=e.headings.filter(i=>i.level===2).slice(0,5).map(i=>i.text);return[`"${n}" lets you ${r.join(", ")}.`,e.description?`It describes itself as: ${pe(e.description,140)}`:"",a.length?`Main sections: ${a.join(" \xB7 ")}.`:""].filter(Boolean).join(" ")}var Ec=[["missing-labels",/label|unlabel|లేబుల్/i],["images",/image|alt text|picture|photo|చిత్ర/i],["structure",/heading|structure|outline|section|landmark|శీర్షిక/i],["forms",/form|field|input|ఫారం/i],["links",/link|లింక్/i],["counts",/how many|count|ఎన్ని/i],["purpose",/what (does|is)|purpose|about|summar|explain|ఏమి|గురించి/i]];function Fc(e){for(let[t,n]of Ec)if(n.test(e))return t;return"unknown"}async function cr(e,t={}){let n=Ic(t.root),o=Fc(e);switch(o){case"missing-labels":return n.unlabeledFields.length?{intent:o,answer:`${n.unlabeledFields.length} of ${n.counts.fields} field(s) have no label: ${n.unlabeledFields.map(r=>`${r.type}${r.hint?` ("${r.hint}")`:""}`).join(", ")}.`,targets:n.unlabeledFields.map(r=>r.selector),suggestions:["Add a visible <label for=\u2026> to each field.","Run the Accessibility Copilot to add aria-labels from placeholders as a quick fix."]}:{intent:o,answer:`All ${n.counts.fields} form field(s) have labels.`,targets:[],suggestions:[]};case"images":return{intent:o,answer:n.imagesWithoutAlt.length?`${n.imagesWithoutAlt.length} of ${n.counts.images} image(s) have no alt text.`:`All ${n.counts.images} image(s) have alt text.`,targets:n.imagesWithoutAlt.map(r=>r.selector),suggestions:n.imagesWithoutAlt.length?['Describe meaningful images in alt; use alt="" for decorative ones.']:[]};case"structure":{let r=n.headings.slice(0,15).map(i=>`${" ".repeat(i.level-1)}h${i.level} ${i.text}`).join(`
398
+ `),a=Object.entries(n.landmarks).filter(([,i])=>i===0).map(([i])=>i);return{intent:o,answer:`${n.headings.length} heading(s).
399
+ ${r}${a.length?`
400
+ Missing landmarks: ${a.join(", ")}.`:""}`,targets:[],suggestions:a.includes("main")?["Wrap the primary content in <main>."]:[]}}case"forms":{let r=Zt({root:t.root});return{intent:o,answer:r.length?r.map(a=>a.summary).join(`
401
+ `):"There are no forms on this page.",targets:r.flatMap(a=>a.findings.map(i=>i.selector).filter(i=>!!i)),suggestions:r.flatMap(a=>a.findings.slice(0,3).map(i=>i.suggestion))}}case"links":case"counts":{let r=n.counts;return{intent:o,answer:`${r.links} links, ${r.buttons} buttons, ${r.fields} form fields in ${r.forms} form(s), ${r.images} images, ${r.tables} tables.`,targets:[],suggestions:[]}}case"purpose":case"unknown":{let r=n.purpose;if(t.summarize)try{let i=Ae(t.root),s=qe((i&&Je(i)?i.body:i)?.textContent).slice(0,4e3);r=await t.summarize(s)||r}catch{}let a=[];return n.unlabeledFields.length&&a.push(`${n.unlabeledFields.length} form field(s) need labels.`),n.imagesWithoutAlt.length&&a.push(`${n.imagesWithoutAlt.length} image(s) need alt text.`),{intent:o,answer:r,targets:[],suggestions:a}}}}var ze=e=>String(e??"").normalize("NFC").toLowerCase().replace(/\s+/g," ").trim(),Gc=new Set("show me find list get give which who what all the a an rows row records record entries with where that are is have has having and or of for in on to please display only those whose any".split(" "));function Fn(e){let t=ze(e).replace(/(₹|rs\.?|inr|\$|usd|€|£)/g," ").match(/(-?\d[\d,]*(?:\.\d+)?|-?\.\d+)\s*(k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion)?(?![\p{L}])/u);if(!t)return null;let n=Number(t[1].replace(/,/g,""));if(!Number.isFinite(n))return null;let o=t[2]??"",r=/^k|thousand/.test(o)?1e3:/^la/.test(o)?1e5:/^(crore|cr)/.test(o)?1e7:/^(m|mn|million)$/.test(o)?1e6:/^(bn|billion)$/.test(o)?1e9:1;return n*r}function pr(e){let t=new Set([ze(e.label),ze(e.key),ze(e.key.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2"))]);for(let n of Array.from(t))n.endsWith("s")?t.add(n.slice(0,-1)):t.add(`${n}s`);return Array.from(t).filter(n=>n.length>1)}function Pe(e,t,n){let o=` ${ze(e)} `,r;for(let a of t)if(!(n&&(a.type??"text")!==n))for(let i of pr(a)){let s=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${s}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(o)&&(!r||i.length>r.length)&&(r={column:a,length:i.length})}return r?.column}var Lc=/amount|balance|total|price|salary|value|due|revenue|cost|fee|sales|outstanding|paid/i;function Gn(e){let t=e.filter(n=>n.type==="number");return t.find(n=>Lc.test(`${n.key} ${n.label}`))??t[0]}var Xt=/(>=|=>|>|\bover\b|\babove\b|\bmore than\b|\bgreater than\b|\bexceeds?\b|\bexceeding\b|\bhigher than\b|\bat least\b|\bminimum\b|\bmin\b|కంటే ఎక్కువ)/,Ln=/(<=|=<|<|\bunder\b|\bbelow\b|\bless than\b|\blower than\b|\bat most\b|\bmaximum\b|\bmax\b|\bup to\b|కంటే తక్కువ)/,ur=/\b(after|since|from)\b/,Pc=/\b(before|until|till)\b/,Mc="(?:\\s*(?:k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion))?",Pn=`(?:\u20B9|rs\\.?\\s*|\\$)?\\s*-?\\d[\\d,]*(?:\\.\\d+)?${Mc}`;function ft(e,t,n={}){let o={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""},r=ze(e).replace(/[?!]+/g," ").replace(/\.(?!\d)/g," ").trim(),a=[],i=r.match(/\b(top|first|bottom|last|lowest|highest)\s+(\d+)\b/);i&&(o.limit=Number(i[2]),r=r.replace(i[0],` ${i[1]} `));let s=r.match(/\b(?:sort(?:ed)?|order(?:ed)?)\s+by\s+([\p{L}\p{M}\p{N} _]+?)(?:\s+(asc|ascending|desc|descending))?(?=$|,|\band\b|\bthen\b)/u),l=r.match(/\b(top|highest|largest|biggest|most|bottom|lowest|smallest|least)\b(?:\s+\d+)?\s+(?:by\s+)?([\p{L}\p{M}\p{N} _]+)/u);if(s){let f=Pe(s[1],t);f&&(o.sort={key:f.key,direction:/^desc/.test(s[2]??"")?"desc":"asc"},r=r.replace(s[0]," "))}else if(l){let f=Pe(l[2],t,"number")??Pe(l[2],t)??Gn(t);if(f){let h=/top|highest|largest|biggest|most/.test(l[1]);o.sort={key:f.key,direction:h?"desc":"asc"},r=r.replace(new RegExp(`\\b${l[1]}\\b`)," "),!i&&/top|bottom/.test(l[1])&&(o.limit=10)}}let c=new RegExp(`\\bbetween\\s+(${Pn}|\\d{4}-\\d{2}-\\d{2})\\s+(?:and|to|-)\\s+(${Pn}|\\d{4}-\\d{2}-\\d{2})`,"u"),u;for(;u=r.match(c);){let f=r.slice(Math.max(0,(u.index??0)-40),u.index??0),h=/\d{4}-\d{2}-\d{2}/.test(u[1]),d=h?Pe(f,t,"date")??t.find(m=>m.type==="date"):Pe(f,t,"number")??Gn(t),x=h?u[1]:Fn(u[1]),k=h?u[2]:Fn(u[2]);d&&x!==null&&k!==null&&(o.filters.push({key:d.key,operator:"between",value:[x,k]}),a.push(`${d.label} between ${u[1]} and ${u[2]}`)),r=r.replace(u[0]," ")}let b=r.split(/\s*(?:(?<!\d),|,(?!\d)|;|\band\b|(?<!(?:starts?|starting|ends?|ending|begins?|beginning)\s)\bwith\b|\bwhere\b|\bwho\b|\bthat\b|&|మరియు)\s*/u).map(f=>f.trim()).filter(Boolean),p=t.filter(f=>(f.type??"text")==="text"),g=new Map;for(let f of p){let h=new Set;for(let d of(n.data??[]).slice(0,5e3)){let x=ze(d[f.key]);if(x&&x.length<=40&&h.add(x),h.size>300)break}h.size&&h.size<=300&&g.set(f.key,h)}for(let f of b){let h=o.filters.length,d=Pe(f,t),x=f.match(new RegExp(Pn,"u")),k=f.match(/\d{4}-\d{2}-\d{2}/);if(k&&(ur.test(f)||Pc.test(f)||Xt.test(f)||Ln.test(f))){let m=(d?.type==="date"?d:void 0)??t.find(v=>v.type==="date");if(m){let v=ur.test(f)||Xt.test(f);o.filters.push({key:m.key,operator:v?"greaterThan":"lessThan",value:k[0]}),a.push(`${m.label} ${v?"after":"before"} ${k[0]}`)}}else if(x&&(Xt.test(f)||Ln.test(f)||d?.type==="number"&&/\b(is|equals?)\b|=/.test(f))){let m=d?.type==="number"?d:void 0;m||(m=Gn(t),m&&o.notes.push(`Assumed "${f}" refers to ${m.label}.`));let v=Fn(x[0]);if(m&&v!==null){let w=/at least|minimum|\bmin\b|>=|=>|at most|maximum|\bmax\b|up to|<=|=</.test(f);Xt.test(f)?(o.filters.push({key:m.key,operator:"greaterThan",value:w?v-1e-9:v}),a.push(`${m.label} ${w?"\u2265":">"} ${v.toLocaleString("en-IN")}`)):Ln.test(f)?(o.filters.push({key:m.key,operator:"lessThan",value:w?v+1e-9:v}),a.push(`${m.label} ${w?"\u2264":"<"} ${v.toLocaleString("en-IN")}`)):(o.filters.push({key:m.key,operator:"equals",value:v}),a.push(`${m.label} = ${v.toLocaleString("en-IN")}`))}}else{let m=f.match(/\b(?:starts?|starting|begins?|beginning)\s+with\s+(.+)$/),v=f.match(/\b(?:ends?|ending)\s+with\s+(.+)$/),w=f.match(/\b(?:contains?|containing|including|includes?|mentions?)\s+(.+)$/),A=f.match(/\b(?:is|equals?|=|:)\s+(.+)$/),C=m??v??w??A;if(C){let G=d??p[0],D=C[1].replace(/^["'“‘]|["'”’]$/g,"").trim();if(G&&D){let M=m?"startsWith":v?"endsWith":w?"contains":"equals";o.filters.push({key:G.key,operator:M,value:D}),a.push(`${G.label} ${M==="equals"?"is":M==="contains"?"contains":M==="startsWith"?"starts with":"ends with"} "${D}"`),d||o.notes.push(`Assumed "${f}" refers to ${G.label}.`)}}}if(o.filters.length===h)for(let[m,v]of g){let w="";for(let A of v){if(A.length<2||A.length<=w.length)continue;let C=A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${C}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(f)&&(w=A)}if(w){let A=t.find(C=>C.key===m);o.filters.push({key:m,operator:"equals",value:w}),a.push(`${A.label} is "${w}"`)}}if(o.filters.length===h){let m=f.split(/\s+/).filter(w=>!Gc.has(w)&&!/^(top|first|bottom|last|lowest|highest|by|desc|asc|sort(ed)?)$/.test(w)),v=m.length>0&&m.every(w=>t.some(A=>pr(A).includes(w)));if(m.length&&!v&&!(d&&m.length===1)){let w=m.join(" ");/^(customers?|users?|people|items?|entries|poems?|orders?|products?|employees?|students?|members?)$/.test(w)||(o.search.push(w),a.push(`any column contains "${w}"`))}}}if(o.sort){let f=t.find(h=>h.key===o.sort.key)?.label??o.sort.key;a.push(`sorted by ${f} ${o.sort.direction==="desc"?"high \u2192 low":"low \u2192 high"}`)}return o.limit&&a.push(`first ${o.limit}`),o.explanation=a.length?`Showing rows where ${a.join(", ")}.`:"No conditions understood \u2014 showing all rows.",o}function Nc(e,t,n){return n==="number"?(Number(e)||0)-(Number(t)||0):n==="date"?(new Date(String(e)).getTime()||0)-(new Date(String(t)).getTime()||0):String(e??"").localeCompare(String(t??""),void 0,{numeric:!0})}function Ke(e,t,n){let o=Ue(e,t,n.filters);for(let r of n.search)o=o.filter(a=>t.some(i=>ze(a[i.key]).includes(r)));if(n.sort){let r=t.find(i=>i.key===n.sort.key),a=n.sort.direction==="desc"?-1:1;o=[...o].sort((i,s)=>a*Nc(i[n.sort.key],s[n.sort.key],r?.type))}return n.limit&&(o=o.slice(0,n.limit)),o}function zc(e,t,n={}){let o=ft(e,t.columns,{data:t.data}),r=Ke(t.data,t.columns,o),a=r.map(s=>me(s,t.rowKey)).filter(Boolean);n.apply!==!1&&(o.filters.length&&t.onFiltersChange?.(o.filters),o.sort&&t.onSortChange?.(o.sort),a.length&&t.onHighlightRows?.(a));let i=r.length?`${r.length} row(s) found. ${o.explanation}${o.notes.length?` (${o.notes.join(" ")})`:""}`:`No rows match. ${o.explanation}`;return{rows:r,ids:a,parsed:o,message:i}}function dr(e,t){let n=(e.length-1)*t,o=Math.floor(n),r=n-o;return e[o+1]!==void 0?e[o]+r*(e[o+1]-e[o]):e[o]}function Mn(e,t,n={}){let o=n.factor??1.5,r=[],a=t.filter(c=>c.type==="number"&&(!n.columns||n.columns.includes(c.key))),i=c=>c.toLocaleString("en-IN",{maximumFractionDigits:2});for(let c of a){let u=e.map(x=>Number(x[c.key])).filter(x=>Number.isFinite(x));if(u.length<5)continue;let b=[...u].sort((x,k)=>x-k),p=dr(b,.25),g=dr(b,.75),f=g-p;if(f===0)continue;let h=p-o*f,d=g+o*f;for(let x of e){let k=Number(x[c.key]);!Number.isFinite(k)||k>=h&&k<=d||r.push({rowId:me(x,n.rowKey),column:c.key,label:c.label,value:k,kind:k>d?"high":"low",reason:`${c.label} ${i(k)} is far ${k>d?"above":"below"} the typical range (${i(p)}\u2013${i(g)}).`})}}let s=n.rowKey??"id",l=new Map;for(let c of e){let u=JSON.stringify(t.filter(g=>g.key!==s).map(g=>ze(c[g.key]))),b=me(c,n.rowKey),p=l.get(u);p!==void 0?r.push({rowId:b,column:s,label:"Row",value:b,kind:"duplicate",reason:`Row ${b} has the same values as row ${p}.`}):l.set(u,b)}return r}function Nn(e,t){if(!e.length)return"No rows to summarise.";let n=[`${e.length} row(s).`],o=r=>r.toLocaleString("en-IN",{maximumFractionDigits:2});for(let r of t){let a=e.map(i=>i[r.key]);if(r.type==="number"){let i=a.map(Number).filter(Number.isFinite);if(!i.length)continue;let s=i.reduce((l,c)=>l+c,0);n.push(`${r.label}: total ${o(s)}, average ${o(s/i.length)}, range ${o(Math.min(...i))}\u2013${o(Math.max(...i))}.`)}else if(r.type==="date"){let i=a.map(l=>new Date(String(l)).getTime()).filter(Number.isFinite);if(!i.length)continue;let s=l=>new Date(l).toISOString().slice(0,10);n.push(`${r.label}: from ${s(Math.min(...i))} to ${s(Math.max(...i))}.`)}else{let i=new Map;for(let l of a){let c=String(l??"").trim();c&&i.set(c,(i.get(c)??0)+1)}if(i.size===0||i.size>Math.max(8,e.length/3))continue;let s=Array.from(i.entries()).sort((l,c)=>c[1]-l[1]).slice(0,4);n.push(`${r.label}: ${s.map(([l,c])=>`${l} (${c})`).join(", ")}.`)}}return n.join(`
402
+ `)}function gr(e,t){let n=ze(e);if(/unusual|anomal|outlier|odd|strange|suspicious|duplicate|అసాధారణ/.test(n)){let r=Mn(t.data,t.columns,{rowKey:t.rowKey}),a=Array.from(new Set(r.map(s=>s.rowId)));a.length&&t.onHighlightRows?.(a);let i=new Set(a);return{kind:"anomalies",message:r.length?`${a.length} unusual row(s):
403
+ ${r.slice(0,10).map(s=>`\u2022 ${s.reason}`).join(`
404
+ `)}`:"Nothing unusual found.",ids:a,rows:t.data.filter(s=>i.has(me(s,t.rowKey))),anomalies:r}}if(/summar|overview|describe|సారాంశం/.test(n)){let r=Ue(t.data,t.columns,t.filters??[]);return{kind:"summary",message:Nn(r,t.columns),ids:[],rows:r}}let o=zc(e,t);return{kind:"query",message:o.message,ids:o.ids,rows:o.rows}}var Dc=/\b(off|disable|stop|remove|no more|turn off|switch off|deactivate)\b|ఆఫ్|ఆపు|తీసివేయి|बंद/i,Oc=[{pattern:/high contrast|contrast|హై కాంట్రాస్ట్|కాంట్రాస్ట్/i,key:"highContrast",name:"High contrast"},{pattern:/dark mode|dark theme|night mode|డార్క్ మోడ్|చీకటి/i,key:"darkMode",name:"Dark mode"},{pattern:/reduce motion|less motion|stop animation|animations?|కదలికలు/i,key:"reduceMotion",name:"Reduced motion"},{pattern:/large targets?|bigger buttons?|big buttons?|larger buttons?|పెద్ద బటన్/i,key:"largeTargets",name:"Large targets"},{pattern:/dyslexia|readable font|easy font/i,key:"dyslexiaFont",name:"Dyslexia-friendly font"},{pattern:/speak on focus|read aloud|read out|screen reader|speech|చదివి వినిపించు/i,key:"speechEnabled",name:"Speak on focus"},{pattern:/skip links?/i,key:"showSkipLinks",name:"Skip links"}],Wc=[[/deuteranop|green.?blind/i,"deuteranopia"],[/protanop|red.?blind/i,"protanopia"],[/tritanop|blue.?blind/i,"tritanopia"],[/grey ?scale|gray ?scale|achromat|black and white/i,"achromatopsia"]],fr=.1,Bc=.8,Hc=1.3;function qc(e,t={}){let n=e.trim().toLowerCase();if(!n)return null;if(/\b(next|down)\s+(row|line|record|item)\b|తర్వాతి (వరుస|అంశం)/.test(n))return{type:"grid",action:"next-row",say:"Next row."};if(/\b(previous|prev|back|up)\s+(row|line|record|item)\b|ముందరి (వరుస|అంశం)|వెనుక (వరుస|అంశం)/.test(n))return{type:"grid",action:"previous-row",say:"Previous row."};if(/\bfirst\s+(row|record|item)\b|మొదటి (వరుస|అంశం)/.test(n))return{type:"grid",action:"first-row",say:"First row."};if(/\blast\s+(row|record|item)\b|చివరి (వరుస|అంశం)/.test(n))return{type:"grid",action:"last-row",say:"Last row."};if(/\b(open|expand|read)\s+(this\s+)?(row|record|item)\b|ఈ (వరుస|అంశం) తెరువు/.test(n))return{type:"grid",action:"open-row",say:"Opening row."};if(/\b(reset|default|restore)\b.*\b(settings?|accessibility|everything|all)\b|^reset$|రీసెట్/.test(n))return{type:"reset",say:"Accessibility settings reset."};let o=t.fontSizeMultiplier??1,r=i=>Math.round(Math.min(Hc,Math.max(Bc,i))*100)/100;if(/\b(bigger|larger|increase|zoom in)\b.*\b(text|font|letters?)\b|\b(text|font)\b.*\b(bigger|larger|up)\b|పెద్ద అక్షరాలు|అక్షరాలు పెద్ద/.test(n)){let i=r(o+fr);return{type:"setting",patch:{fontSizeMultiplier:i},say:`Text size ${Math.round(i*100)}%.`}}if(/\b(smaller|decrease|reduce|zoom out)\b.*\b(text|font|letters?)\b|\b(text|font)\b.*\b(smaller|down)\b|చిన్న అక్షరాలు|అక్షరాలు చిన్న/.test(n)){let i=r(o-fr);return{type:"setting",patch:{fontSizeMultiplier:i},say:`Text size ${Math.round(i*100)}%.`}}if(/\b(normal|default|reset)\b.*\b(text|font)\s*(size)?\b/.test(n))return{type:"setting",patch:{fontSizeMultiplier:1},say:"Text size 100%."};let a=Dc.test(n);for(let[i,s]of Wc)if(i.test(n))return a?{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."}:{type:"setting",patch:{colorBlindMode:s},say:`${s} filter on.`};if(/colou?r.?blind/.test(n)&&a)return{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."};for(let i of Oc){if(!i.pattern.test(n))continue;let s=/\btoggle\b/.test(n)?!t[i.key]:!a;return i.key==="reduceMotion"&&!/reduce motion|less motion|కదలికలు తగ్గించు/.test(n)&&/animations?/.test(n)&&(s=a||/\bno\b/.test(n)),{type:"setting",patch:{[i.key]:s},say:`${i.name} ${s?"on":"off"}.`}}return null}var mr={highContrast:!1,darkMode:!1,reduceMotion:!1,largeTargets:!1,dyslexiaFont:!1,speechEnabled:!1,colorBlindMode:"none",fontSizeMultiplier:1};function _c(e,t={}){if(!We())return null;let n=t.root??document,o=t.rowSelector??"[data-yuktai-row-id], [role='row']",r=Array.from(n.querySelectorAll(o)).filter(c=>!c.querySelector("th,[role='columnheader']"));if(!r.length)return null;let a=document.activeElement?.closest(o),i=a?r.indexOf(a):-1;if(e==="open-row"){let c=i>=0?r[i]:r[0];return c.click(),c}let s=e==="first-row"?0:e==="last-row"?r.length-1:e==="next-row"?Math.min(r.length-1,i+1):Math.max(0,i-1),l=r[s];return l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1"),l.focus(),l.scrollIntoView?.({block:"nearest"}),l}function br(e={}){let t={enabled:!0,...mr,...e.initial},n=null,o=!1,r=async c=>e.apply?e.apply(c):ke.execute(c),a=c=>{if(e.speak===!1||!We()||!("speechSynthesis"in window))return;let u=new SpeechSynthesisUtterance(c);u.lang=e.lang??"en-IN",window.speechSynthesis.cancel(),window.speechSynthesis.speak(u)};async function i(c){let u=qc(c,t);if(e.onTranscript?.(c,u),!u)return null;if(u.type==="grid"){let b=_c(u.action,{root:e.gridRoot});return a(b?u.say:"No table rows found."),u}return t=u.type==="reset"?{...t,...mr}:{...t,...u.patch},await r(t),a(u.say),u}function s(){if(!We()||o)return o;let c=window,u=c.SpeechRecognition??c.webkitSpeechRecognition;return u?(n=new u,n.lang=e.lang??"en-IN",n.continuous=!0,n.interimResults=!1,n.onresult=b=>{let p=b.results,g=p[p.length-1];g?.[0]?.transcript&&i(g[0].transcript)},n.onend=()=>{o&&n?.start()},n.onerror=b=>{(b.error==="not-allowed"||b.error==="service-not-allowed")&&(o=!1)},o=!0,n.start(),!0):!1}function l(){o=!1,n?.stop(),n=null}return{start:s,stop:l,handle:i,isListening:()=>o,getConfig:()=>({...t})}}var Uc=new Set("a an the is are was were be to of and or in on at for with what which who whom how why when where does do did this that these those it its from by as about any all please tell me show give".split(" "));function en(e){return(e.normalize("NFC").toLowerCase().match(/[\p{L}\p{M}\p{N}]+/gu)??[]).filter(t=>t.length>1&&!Uc.has(t))}function jc(e,t=600){let n=Ae(e);if(!n)return[];let o=[],r="",a="",i=()=>{a.trim()&&o.push({id:`page-${o.length+1}`,source:"page",text:a.trim(),ref:r||void 0}),a=""};for(let s of _(n,"h1,h2,h3,h4,p,li,td,th,dt,dd,blockquote,figcaption,label,summary")){if(s.querySelector("p,li,h1,h2,h3,h4"))continue;let l=qe(s.textContent);if(l){if(/^H[1-4]$/.test(s.tagName)){i(),r=l,a=`${l}. `;continue}a.length+l.length>t&&i(),a+=`${l} `}}return i(),o}function Vc(e,t,n="id"){return e.map((o,r)=>{let a=o,i=String(a[n]??r+1);return{id:`grid-${i}`,source:"grid",ref:i,text:t.map(s=>`${s.label}: ${String(a[s.key]??"")}`).join(". ")}})}function hr(e={}){let t=[],n=[],o=new Map,r=0;function a(){t=[...e.includePage===!1?[]:jc(e.root),...e.rows&&e.columns?Vc(e.rows,e.columns,e.rowKey):[],...(e.documents??[]).map(l=>({id:l.id,source:"custom",text:l.text}))],n=t.map(l=>en(l.text)),o=new Map;for(let l of n)for(let c of new Set(l))o.set(c,(o.get(c)??0)+1);r=n.reduce((l,c)=>l+c.length,0)/Math.max(1,n.length)}a();function i(l,c=5){let u=en(l);if(!u.length)return[];let b=n.length;return n.map((g,f)=>{let h=0;for(let d of u){let x=0;for(let m of g)(m===d||d.length>=4&&m.startsWith(d)||m.length>=4&&d.startsWith(m))&&x++;if(!x)continue;let k=Math.log(1+(b-(o.get(d)??1)+.5)/((o.get(d)??1)+.5));h+=k*(x*2.2/(x+1.2*(.25+.75*(g.length/(r||1)))))}return{...t[f],score:h}}).filter(g=>g.score>0).sort((g,f)=>f.score-g.score).slice(0,c)}async function s(l,c={}){let u=i(l,c.k??4);if(!u.length)return{answer:"I couldn't find anything about that on this page or in the data.",hits:u,generated:!1};if(c.generate)try{let f=u.map((d,x)=>`[${x+1}] ${d.text}`).join(`
405
405
  `),h=await c.generate(l,f);if(h?.trim())return{answer:h.trim(),hits:u,generated:!0}}catch{}let b=new Set(en(l)),p=u.flatMap(f=>f.text.split(/(?<=[.!?।])\s+|\.\s+(?=\p{Lu})/u).map(h=>({s:h.trim(),h:f}))).map(({s:f,h})=>({s:f,h,overlap:en(f).filter(d=>b.has(d)).length})).filter(f=>f.s&&f.overlap>0).sort((f,h)=>h.overlap-f.overlap).slice(0,3);return{answer:p.length?p.map(f=>f.h.source==="grid"?`Row ${f.h.ref}: ${f.s}`:f.s).join(`
406
- `):u[0].text.slice(0,300),hits:u,generated:!1}}return{search:i,ask:a,rebuild:s,update(l){Object.assign(e,l),s()},size:()=>t.length}}var wr="highlight|mark|flag|sort|order|rank|arrange|summari[sz]e|summary|recap|count|how many|open|select|pick|show|filter|find|list|clear|reset|remove|detect|spot|tell";function zn(e){return e.replace(/[?!]/g," ").split(/\s*(?:;|\.(?!\d)\s*|,?\s*\band then\b|,?\s*\bthen\b|,?\s*\bafter that\b|,?\s*\bfinally\b|,?\s*\bnext\b|ఆ తర్వాత)\s*/i).flatMap(o=>o.split(new RegExp(`\\s*(?:,|\\band\\b)\\s+(?=(?:${wr})\\b)`,"i"))).map(o=>o.trim()).filter(o=>o.length>1).map(o=>({action:gl(o),text:o}))}function gl(e){let t=e.toLowerCase();return/^(clear|reset|remove)\b/.test(t)?"clear":/unusual|anomal|outlier|suspicious|odd ones|duplicate/.test(t)?"anomalies":/summari[sz]e|summary|what changed|recap|overview/.test(t)?"summarize":/^(highlight|mark|flag)\b/.test(t)?"highlight":/^(sort|order|rank|arrange)\b/.test(t)?"sort":/^(count|how many)\b/.test(t)?"count":/^(open|go to)\b/.test(t)&&!/filtered|results?/.test(t)?"open":/^(select|pick)\b/.test(t)?"select":"filter"}function fl(e){return e.replace(new RegExp(`^\\s*(?:${wr}|open|go to)\\b`,"i")," ").replace(/\b(the|filtered|results?|rows?|records?|entries|items?|ones|them|those|only|me|all)\b/gi," ").replace(/\s+/g," ").trim()}function yr(e,t){let n=t.find(s=>s.key===e.key)?.label??e.key,o=Array.isArray(e.value)?`${e.value[0]}\u2013${e.value[1]}`:typeof e.value=="number"?e.value.toLocaleString("en-IN",{maximumFractionDigits:2}):`"${e.value}"`,r={contains:"contains",equals:"is",startsWith:"starts with",endsWith:"ends with",greaterThan:">",lessThan:"<",between:"between"}[e.operator];return`${n} ${r} ${o}`}async function kr(e,t,n={}){let o=zn(e),{columns:r,data:s}=t,i=[...t.filters??[]],a=[],l=null,c=[],u=()=>Ke(s,r,{filters:i,search:a,sort:l,limit:null,notes:[],explanation:""}),b={rows:u().length,filters:[...i]},p=[],g=()=>({...t,filters:i});for(let h=0;h<o.length;h++){let d=o[h],x=fl(d.text),k;try{switch(d.action){case"clear":{i=[],a=[],l=null,c=[],t.onFiltersChange?.([]),t.onSortChange?.(null),t.onHighlightRows?.([]),k={...d,success:!0,message:`Cleared filters, sorting and highlights. ${s.length} row(s) shown.`};break}case"filter":{let m=ft(x,r,{data:s});if(!m.filters.length&&!m.search.length&&!m.sort){k={...d,success:!0,message:`Showing ${u().length} row(s) with the current filters.`};break}for(let A of m.filters)i=[...i.filter(C=>C.key!==A.key),A];a=[...a,...m.search],m.sort&&(l=m.sort,t.onSortChange?.(l)),t.onFiltersChange?.(i);let v=u(),w=v.map(A=>me(A,t.rowKey)).filter(Boolean);m.search.length&&w.length&&(c=w,t.onHighlightRows?.(w)),k={...d,success:!0,message:`${v.length} row(s) now shown. ${m.explanation}`,ids:w};break}case"highlight":{let m=u(),v=ft(x,r,{data:m}),A=(v.filters.length||v.search.length?Ke(m,r,{...v,sort:null,limit:v.limit}):m).map(F=>me(F,t.rowKey)).filter(Boolean);if(!A.length){k={...d,success:!1,message:`Nothing to highlight for "${x||"all rows"}".`};break}let C=kt(g(),A);C.success&&(c=C.data??A),k={...d,success:C.success,message:C.success?`Highlighted ${c.length} row(s)${x?` matching "${x}"`:""}.`:C.message,ids:c};break}case"sort":{let v=ft(d.text,r,{data:s}).sort;if(!v){let A=Pe(x,r);A&&(v={key:A.key,direction:/desc|high|large|big|most|newest|latest|z.?to.?a/i.test(d.text)?"desc":"asc"})}if(!v){k={...d,success:!1,message:`Which column should I sort by? Columns: ${r.map(A=>A.label).join(", ")}.`};break}l=v,t.onSortChange?.(l);let w=r.find(A=>A.key===l.key)?.label??l.key;k={...d,success:!0,message:`Sorted by ${w} (${l.direction==="desc"?"high \u2192 low":"low \u2192 high"}).`};break}case"count":{k={...d,success:!0,message:`${u().length} row(s) shown${c.length?`, ${c.length} highlighted`:""}.`};break}case"anomalies":{let m=u(),v=Mn(m,r,{rowKey:t.rowKey}),w=Array.from(new Set(v.map(A=>A.rowId)));if(w.length){let A=kt(g(),w);A.success&&(c=A.data??w)}k={...d,success:!0,message:v.length?`${w.length} unusual row(s): ${v.slice(0,5).map(A=>A.reason).join(" ")}`:"Nothing unusual in the shown rows.",ids:w};break}case"open":case"select":{let m=u(),w=m.find(F=>x&&me(F,t.rowKey).toLowerCase()===x.toLowerCase())??Ke(m,r,ft(x,r,{data:m}))[0]??(x?void 0:m[0]);if(!w){k={...d,success:!1,message:`No row matches "${x}".`};break}let A=me(w,t.rowKey),C=d.action==="open"?Ut(g(),A):jt(g(),A);k={...d,success:C.success,message:C.message,ids:[A]};break}case"summarize":{let m=u();k={...d,success:!0,message:`${xr(b,m.length,i,l,c,r)}
407
- ${Nn(m,r)}`};break}}}catch(m){k={...d,success:!1,message:`This step failed: ${m instanceof Error?m.message:String(m)}`}}p.push(k),n.onStep?.(k,h,o.length)}let f=u().length;return{steps:p,before:b,after:{rows:f,filters:i,sort:l,highlighted:c},summary:xr(b,f,i,l,c,r)}}function xr(e,t,n,o,r,s){let i=[`Rows: ${e.rows} \u2192 ${t}.`],a=n.filter(c=>!e.filters.some(u=>JSON.stringify(u)===JSON.stringify(c))),l=e.filters.filter(c=>!n.some(u=>JSON.stringify(c)===JSON.stringify(u)));return a.length&&i.push(`Filters added: ${a.map(c=>yr(c,s)).join("; ")}.`),l.length&&i.push(`Filters removed: ${l.map(c=>yr(c,s)).join("; ")}.`),o&&i.push(`Sorted by ${s.find(c=>c.key===o.key)?.label??o.key} ${o.direction==="desc"?"high \u2192 low":"low \u2192 high"}.`),r.length&&i.push(`${r.length} row(s) highlighted.`),i.join(" ")}var tn=e=>{let t=typeof e=="number"?e:Number(String(e??"").replace(/[,₹$%\s]/g,""));return Number.isFinite(t)?t:null},vr=e=>{let t=e instanceof Date?e.getTime():new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null};function At(e,t){if(t==="count")return e.length;if(!e.length)return 0;switch(t){case"sum":return e.reduce((n,o)=>n+o,0);case"avg":return e.reduce((n,o)=>n+o,0)/e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function ml(e,t,n,o="sum"){let r=new Map;for(let s of e){let i=String(s[t]??"\u2014").trim()||"\u2014",a=r.get(i)??[];if(n===null||o==="count")a.push(1);else{let l=tn(s[n]);l!==null&&a.push(l)}r.set(i,a)}return Array.from(r.entries()).map(([s,i])=>({group:s,value:At(i,o),count:i.length})).sort((s,i)=>i.value-s.value)}function Sr(e,t,n=1){let o=new Date(e);return o.setHours(0,0,0,0),t==="week"&&o.setDate(o.getDate()-(o.getDay()-n+7)%7),t==="month"&&o.setDate(1),t==="quarter"&&o.setMonth(Math.floor(o.getMonth()/3)*3,1),t==="year"&&o.setMonth(0,1),o}function On(e,t,n){let o=new Date(e);return t==="day"&&o.setDate(o.getDate()+n),t==="week"&&o.setDate(o.getDate()+7*n),t==="month"&&o.setMonth(o.getMonth()+n),t==="quarter"&&o.setMonth(o.getMonth()+3*n),t==="year"&&o.setFullYear(o.getFullYear()+n),o}function bl(e,t){let n=t.referenceDate?new Date(t.referenceDate):new Date,o=Sr(n,t.period,t.weekStartsOn),r=t.toDate===!1?On(o,t.period,1):new Date(Math.max(n.getTime()+1,o.getTime()+1)),s=On(o,t.period,-1),i=t.toDate===!1?o:new Date(s.getTime()+(r.getTime()-o.getTime())),a=t.agg??"sum",l=new Map,c=new Map;for(let p of e){let g=vr(p[t.dateKey]);if(g===null)continue;let f=g>=o.getTime()&&g<r.getTime()?l:g>=s.getTime()&&g<i.getTime()?c:null;if(!f)continue;let h=t.groupKey?String(p[t.groupKey]??"\u2014"):"All",d=a==="count"?1:tn(p[t.metricKey]);d!==null&&f.set(h,[...f.get(h)??[],d])}let u=new Set([...l.keys(),...c.keys()]),b=Array.from(u).map(p=>{let g=At(l.get(p)??[],a),f=At(c.get(p)??[],a);return{group:p,current:g,previous:f,change:g-f,changePct:f===0?null:(g-f)/Math.abs(f)*100}});return{period:t.period,current:{from:o,to:r},previous:{from:s,to:i},rows:b}}function hl(e,t,n,o,r="sum"){let s=new Map;for(let i of e){let a=vr(i[t]),l=r==="count"?1:tn(i[n]);if(a===null||l===null)continue;let c=Sr(new Date(a),o).getTime();s.set(c,[...s.get(c)??[],l])}return Array.from(s.entries()).sort((i,a)=>i[0]-a[0]).map(([i,a])=>({start:new Date(i),value:At(a,r)}))}var yl=/rate|conversion|ratio|percent|%|score|rating|margin|ctr|avg|average/i;function xl(e){let t=e.match(/\b(today|yesterday|this|last|previous|past)\s*(day|week|month|quarter|year)?\b/);return t?t[1]==="today"?{period:"day",shift:0}:t[1]==="yesterday"?{period:"day",shift:-1}:t[2]?{period:t[2],shift:t[1]==="this"?0:-1}:null:null}var xe=e=>e.toLocaleString("en-IN",{maximumFractionDigits:2}),Dn=e=>e===null?"new":`${e>0?"+":""}${e.toFixed(1)}%`;function Tr(e,t,n,o={}){let r=e.toLowerCase(),s=n.filter(m=>m.type==="number"),i=Pe(r,n,"number")??s.find(m=>/amount|revenue|sales|total|value/i.test(`${m.key} ${m.label}`))??s[0],a=n.find(m=>m.type==="date")??n.find(m=>/date|time|day|created|month/i.test(`${m.key} ${m.label}`)),l=r.match(/\b(?:which|by|per|each|across|every|top|for each)\s+([\p{L}\p{M}\p{N} _]+)/u)?.[1]??"",c=Pe(l,n,"text"),u=/how many|number of|count/.test(r),b=u?"count":/average|avg|mean/.test(r)?"avg":/\btotal\b|\bsum\b/.test(r)?"sum":i&&yl.test(`${i.key} ${i.label}`)?"avg":"sum",p=/drop|decline|decrease|fell|fall|down|worst|lost|shrink|reduc/.test(r),g=/increase|growth|grew|rise|rose|up\b|best|improv|gain/.test(r),f=/lowest|least|smallest|bottom|worst|minimum/.test(r),h=xl(r);if(!i&&!u)return{kind:"unknown",answer:"I couldn't find a numeric column to analyse.",table:[]};let d=u?"rows":i.label;if(h&&a&&(g||p||/change|compare|vs|versus/.test(r))){let m=o.referenceDate?new Date(o.referenceDate):new Date,v=h.shift?On(m,h.period,h.shift):m,A=[...bl(t,{dateKey:a.key,metricKey:i?.key??a.key,groupKey:c?.key,agg:b,period:h.period,referenceDate:v,toDate:h.shift===0}).rows].sort((q,B)=>p?q.change-B.change:B.change-q.change),C=A.map(q=>({[c?.label??"Group"]:q.group,Current:xe(q.current),Previous:xe(q.previous),Change:xe(q.change),"Change %":Dn(q.changePct)}));if(!A.length)return{kind:"period-change",answer:`No ${d} data in this ${h.period} or the one before.`,table:C};let F=A[0],D=`${h.shift?"last":"this"} ${h.period} vs the ${h.period} before`,M=F.change===0?"did not change":F.change<0?`dropped ${xe(Math.abs(F.change))}`:`rose ${xe(F.change)}`,E=`${d} ${M} (${xe(F.previous)} \u2192 ${xe(F.current)}, ${Dn(F.changePct)}) \u2014 ${D}.`,I=p&&F.change>=0||g&&F.change<=0;return{kind:"period-change",answer:c?I?`No ${c.label.toLowerCase()} ${p?"dropped":"grew"}. Closest is ${F.group}: ${E}`:`${F.group}: ${E}`:E,table:C}}if(/trend|over time|month by month|week by week/.test(r)&&a&&i){let m=/week/.test(r)?"week":/day|daily/.test(r)?"day":/year/.test(r)?"year":"month",v=hl(t,a.key,i.key,m,b),w=v.map(D=>({Period:D.start.toISOString().slice(0,10),[i.label]:xe(D.value)}));if(v.length<2)return{kind:"trend",answer:`Not enough ${m}s of data for a trend.`,table:w};let A=v[0].value,C=v[v.length-1].value,F=v.reduce((D,M)=>M.value>D.value?M:D);return{kind:"trend",answer:`${i.label} went from ${xe(A)} to ${xe(C)} over ${v.length} ${m}s (${Dn(A?(C-A)/Math.abs(A)*100:null)}). Peak: ${xe(F.value)} in the ${m} of ${F.start.toISOString().slice(0,10)}.`,table:w}}if(c){let m=ml(t,c.key,i?.key??null,b),v=f?[...m].reverse():m,w=v.map(C=>({[c.label]:C.group,[`${b} of ${d}`]:xe(C.value),Rows:C.count}));if(!v.length)return{kind:"group",answer:"No data.",table:w};let A=v[0];return{kind:"group",answer:`${A.group} has the ${f?"lowest":"highest"} ${b==="sum"?"total":b==="avg"?"average":b} ${d}: ${xe(A.value)} (across ${v.length} ${c.label.toLowerCase()} groups).`,table:w}}let x=u?t.map(()=>1):t.map(m=>tn(m[i.key])).filter(m=>m!==null),k=At(x,b);return{kind:"total",answer:`${b==="avg"?"Average":b==="count"?"Count of":b==="sum"?"Total":b} ${d}: ${xe(k)} across ${t.length} row(s).`,table:[{Metric:d,Aggregation:b,Value:xe(k)}]}}var Ar={high:12,medium:6,low:2};function Cr(e={}){let t=Ae(e.root),n=[],o=(a,l,c,u,b)=>n.push({category:a,severity:l,message:c,suggestion:u,selector:b?Ne(b):void 0});if(t&&We()){let a=e.minFontSize??14,l=e.maxLineLength??90,c=E=>window.getComputedStyle(E),u=_(t,"h1");u.length===0&&o("hierarchy","medium","There is no h1, so the page has no clear main title.","Add one prominent h1 near the top."),u.length>1&&o("hierarchy","low",`${u.length} h1 headings compete for attention.`,"Keep one h1 and demote the rest.",u[1]);let b=E=>{let I=_(t,E)[0];return I&&parseFloat(c(I).fontSize)||0},[p,g,f]=[b("h1"),b("h2"),b("h3")];p&&g&&g>=p&&o("hierarchy","medium",`h2 (${g}px) is as large as or larger than h1 (${p}px).`,"Make each heading level visibly smaller than the one above it."),g&&f&&f>g&&o("hierarchy","low",`h3 (${f}px) is larger than h2 (${g}px).`,"Keep heading sizes in descending order.");let h=Ye({root:e.root,skip:["color-contrast","target-size","duplicate-id","page-title","html-lang","form-error","positive-tabindex"]});for(let E of h.issues.filter(I=>I.rule==="heading-order").slice(0,3))o("hierarchy","low",E.message,E.fix,E.element);let d=0,x;for(let E of _(t,"p,li,td,span,a,label,small,div").slice(0,1500)){if(!ht(E))continue;(parseFloat(c(E).fontSize)||16)<a&&(d++,x??=E)}d&&o("readability",d>10?"high":"medium",`${d} text element(s) are smaller than ${a}px, e.g. "${pe(x?.textContent??"",30)}".`,`Use at least ${a}px for body text (16px for senior-friendly pages).`,x);for(let E of _(t,"p").slice(0,200)){let I=c(E),y=parseFloat(I.fontSize)||16,q=E.getBoundingClientRect().width,B=q/(y*.5);if(q>0&&B>l&&(E.textContent??"").length>l){o("readability","low",`A paragraph is about ${Math.round(B)} characters wide.`,`Limit text width to ~${l} characters (e.g. max-width: 70ch).`,E);break}let U=parseFloat(I.lineHeight);if(Number.isFinite(U)&&U/y<1.3){o("readability","low",`Line height is ${(U/y).toFixed(2)}\xD7 the font size.`,"Use line-height of at least 1.5 for body text (WCAG 1.4.12).",E);break}}let k=Ye({root:e.root,skip:["html-lang","page-title","image-alt","heading-order","single-h1","landmark-main","form-label","button-name","link-name","positive-tabindex","keyboard-access","duplicate-id","form-error","target-size"]});k.issues.length&&o("readability",k.issues.length>5?"high":"medium",`${k.issues.length} text element(s) have weak contrast. ${k.issues[0].message}`,"Raise contrast to at least 4.5:1 for body text.",k.issues[0].element);let m=wl();m.length&&o("interaction","high",`Focus outlines are removed by CSS (${m.slice(0,2).join(", ")}) with no replacement.`,"Never remove outlines without a visible :focus-visible style (WCAG 2.4.7).");let v=_(t,Gt).filter(E=>{let I=E.getBoundingClientRect();return I.width>0&&I.height>0&&(I.width<24||I.height<24)&&!(E.tagName==="A"&&E.closest("p,li"))});v.length&&o("interaction",v.length>5?"high":"medium",`${v.length} control(s) are smaller than 24\xD724px.`,"Give controls at least 24\xD724px, ideally 44\xD744px for touch and seniors.",v[0]);let w=window.innerHeight||800,A=_(t,oo).filter(E=>{let I=E.getBoundingClientRect();return I.height>0&&I.top<w});A.length>40&&o("clutter","medium",`${A.length} interactive elements in the first screen.`,"Group secondary actions into menus and keep the first screen focused on one task.");let C=_(t,"button,a[href],[role='button']").filter(E=>{let I=E.getBoundingClientRect();if(I.height===0||I.top>w)return!1;let y=c(E).backgroundColor;return!!y&&!/rgba\(0, 0, 0, 0\)|transparent/.test(y)&&!/rgb\(255, 255, 255\)/.test(y)});C.length>4&&o("clutter","medium",`${C.length} filled buttons compete in the first screen.`,"Keep one primary action per view; make the rest secondary (outline or text).",C[0]);let F=new Set,D=new Set;for(let E of _(t,"body *").slice(0,2e3)){if(!ht(E))continue;let I=c(E);F.add(I.fontFamily.split(",")[0].replace(/["']/g,"").trim().toLowerCase()),D.add(Math.round(parseFloat(I.fontSize)||0))}F.size>4&&o("consistency","low",`${F.size} different font families are used.`,"Stick to 1\u20132 font families (e.g. one Telugu + one Latin)."),D.size>10&&o("consistency","low",`${D.size} different font sizes are used.`,"Use a small type scale (5\u20137 sizes) for a calmer page.");let M=_(t,"img:not([width]):not([height])").filter(E=>!c(E).aspectRatio||c(E).aspectRatio==="auto");M.length>3&&o("consistency","low",`${M.length} images have no width/height, so the layout jumps while loading.`,"Set width and height (or aspect-ratio) on images.",M[0])}let r=["hierarchy","readability","interaction","clutter","consistency"].reduce((a,l)=>{let c=n.filter(u=>u.category===l);return a[l]={score:Math.max(0,100-c.reduce((u,b)=>u+Ar[b.severity]*2,0)),findings:c.length},a},{}),s=Math.max(0,100-n.reduce((a,l)=>a+Ar[l.severity],0)),i=Object.entries(r).sort((a,l)=>a[1].score-l[1].score)[0];return{score:s,categories:r,findings:n,summary:n.length?`Design score ${s}/100 with ${n.length} finding(s). Weakest area: ${i[0]}.`:"No design issues found by the automatic review."}}function wl(){let e=[],t=!1,n=o=>{for(let r of Array.from(o)){let s=r.cssRules;s&&n(s);let i=r;if(!i.selectorText||!/:focus/.test(i.selectorText))continue;let a=`${i.style.outline} ${i.style.outlineStyle} ${i.style.outlineWidth}`,l=/\bnone\b|\b0(px)?\b/.test(a),c=!!(i.style.boxShadow&&i.style.boxShadow!=="none")||!!i.style.borderColor||!!i.style.backgroundColor||!!i.style.textDecoration;/:focus-visible/.test(i.selectorText)&&(!l||c)&&(t=!0),l&&!c&&e.push(i.selectorText)}};for(let o of Array.from(document.styleSheets))try{n(o.cssRules)}catch{}return t?[]:e}import{useCallback as Wn,useEffect as $r,useMemo as Bn,useRef as Hn,useState as se}from"react";import{Fragment as Ir,jsx as G,jsxs as te}from"react/jsx-runtime";var kl=/\b(trend|over time|this (week|month|quarter|year)|last (week|month|quarter|year)|compare|versus|vs)\b|\b(by|per|each|which)\b.*\b(total|average|avg|sum|drop|increase|growth|highest|lowest|most|least)\b|\b(total|average|avg|sum)\b.*\b(by|per|each)\b/i;function Yu(e){let{data:t,rowKey:n="id"}=e,o=Bn(()=>tt(e.columns),[e.columns]),[r,s]=se([]),[i,a]=se(null),[l,c]=se([]),[u,b]=se(""),[p,g]=se(null),[f,h]=se([]),[d,x]=se([]),[k,m]=se(!1),v=Hn(r);v.current=r;let w=Wn(()=>({data:t,columns:o,rowKey:n,filters:v.current,onFiltersChange:D=>{v.current=D,s(D)},onSortChange:a,onHighlightRows:c,onOpenRow:e.onOpenRow,onSelectRow:D=>c([D])}),[t,o,n,e.onOpenRow]),A=Wn(async D=>{let M=D.trim();if(M){m(!0),x([]),h([]);try{if(zn(M).length>1){let E=[],I=await kr(M,w(),{onStep:y=>x((E.push(y),[...E]))});g("tasks"),b(I.summary)}else if(kl.test(M)){let E=Ke(t,o,{filters:v.current,search:[],sort:null,limit:null,notes:[],explanation:""}),I=Tr(M,E,o,{referenceDate:e.referenceDate});g("insight"),b(I.answer),h(I.table)}else{let E=gr(M,w());g(E.kind),b(E.message)}}finally{m(!1)}}},[w,t,o,e.referenceDate]),C=Wn(()=>{v.current=[],s([]),a(null),c([]),b(""),g(null),h([]),x([])},[]),F=Bn(()=>Ke(t,o,{filters:r,search:[],sort:i,limit:null,notes:[],explanation:""}),[t,o,r,i]);return{gridData:F,highlightIds:l,filters:r,sort:i,ask:A,reset:C,answer:u,kind:p,table:f,steps:d,busy:k,visibleIds:F.map(D=>me(D,n))}}var Er={border:"1px solid color-mix(in srgb, CanvasText 20%, transparent)",borderRadius:12,padding:16,background:"Canvas",color:"CanvasText",font:"inherit"},ue={minHeight:44,padding:"8px 14px",borderRadius:8,border:"1px solid color-mix(in srgb, CanvasText 35%, transparent)",background:"ButtonFace",color:"ButtonText",font:"inherit",cursor:"pointer"},qn={...ue,flex:1,minWidth:0,background:"Field",color:"FieldText",cursor:"text"},on={opacity:.75,fontSize:"0.9em"};function _n({rows:e}){if(!e.length)return null;let t=Object.keys(e[0]);return G("div",{style:{overflowX:"auto",marginTop:12},children:te("table",{style:{borderCollapse:"collapse",width:"100%"},children:[G("thead",{children:G("tr",{children:t.map(n=>G("th",{scope:"col",style:{textAlign:"left",padding:"6px 8px",borderBottom:"1px solid currentColor"},children:n},n))})}),G("tbody",{children:e.slice(0,50).map((n,o)=>G("tr",{children:t.map(r=>G("td",{style:{padding:"6px 8px",borderBottom:"1px solid color-mix(in srgb, CanvasText 12%, transparent)"},children:n[r]},r))},o))})]})})}function Rr(e,t,n){let o=URL.createObjectURL(new Blob([t],{type:n})),r=document.createElement("a");r.href=o,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Ku({grid:e,placeholder:t="Ask about this data, e.g. \u201Coverdue and over \u20B910,000\u201D",examples:n=[],style:o}){let[r,s]=se(""),i=a=>{a.preventDefault(),e.ask(r)};return te("section",{"data-yuktai-panel":"","aria-label":"Data assistant",style:{...Er,...o},children:[te("form",{onSubmit:i,style:{display:"flex",gap:8,flexWrap:"wrap"},children:[G("label",{htmlFor:"yuktai-grid-ask",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Question about the data"}),G("input",{id:"yuktai-grid-ask",value:r,onChange:a=>s(a.target.value),placeholder:t,style:qn}),G("button",{type:"submit",style:ue,disabled:e.busy,children:e.busy?"Working\u2026":"Ask"}),G("button",{type:"button",style:ue,onClick:()=>{s(""),e.reset()},children:"Reset"})]}),n.length>0&&G("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:8},children:n.map(a=>G("button",{type:"button",style:{...ue,minHeight:36,fontSize:"0.85em"},onClick:()=>{s(a),e.ask(a)},children:a},a))}),G("div",{"aria-live":"polite",style:{marginTop:12,whiteSpace:"pre-line"},children:e.answer}),e.steps.length>0&&G("ol",{style:{marginTop:8,paddingLeft:20},children:e.steps.map((a,l)=>te("li",{style:{marginBottom:4},children:[G("span",{"aria-hidden":"true",children:a.success?"\u2705 ":"\u26A0\uFE0F "}),G("strong",{children:a.text})," \u2014 ",G("span",{style:{whiteSpace:"pre-line"},children:a.message})]},l))}),G(_n,{rows:e.table})]})}var nn=[["copilot","Copilot"],["qa","QA report"],["forms","Forms"],["design","Design"],["ask","Ask page"],["voice","Voice"]];function Qu({defaultTab:e="copilot",voiceLang:t="en-IN",generate:n,style:o}){let[r,s]=se(e),i=Hn([]),a=(l,c)=>{let u=l.key==="ArrowRight"?1:l.key==="ArrowLeft"?-1:0;if(!u)return;l.preventDefault();let b=(c+u+nn.length)%nn.length;s(nn[b][0]),i.current[b]?.focus()};return te("section",{"data-yuktai-panel":"","aria-label":"yuktai agentic tools",style:{...Er,...o},children:[G("div",{role:"tablist","aria-label":"Tools",style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:12},children:nn.map(([l,c],u)=>G("button",{ref:b=>{i.current[u]=b},role:"tab",id:`yuktai-tab-${l}`,"aria-selected":r===l,"aria-controls":`yuktai-tabpanel-${l}`,tabIndex:r===l?0:-1,onClick:()=>s(l),onKeyDown:b=>a(b,u),style:{...ue,fontWeight:r===l?700:400,outlineOffset:2,borderWidth:r===l?2:1},children:c},l))}),te("div",{role:"tabpanel",id:`yuktai-tabpanel-${r}`,"aria-labelledby":`yuktai-tab-${r}`,children:[r==="copilot"&&G(vl,{}),r==="qa"&&G(Sl,{}),r==="forms"&&G(Tl,{}),r==="design"&&G(Al,{}),r==="ask"&&G(Cl,{generate:n}),r==="voice"&&G(Rl,{lang:t})]})]})}function vl(){let e=Hn(null),[t,n]=se(null),[o,r]=se(null),[s,i]=se("");$r(()=>(e.current=lr({onUpdate:n}),e.current.scan(),()=>e.current?.stop()),[]);let a=e.current,l=t?.report?.issues??[];return te("div",{children:[te("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[G("button",{type:"button",style:ue,onClick:()=>t?.watching?a?.stop():a?.start(),children:t?.watching?"Stop watching":"Watch page live"}),G("button",{type:"button",style:ue,onClick:()=>a?.scan(),children:"Scan now"}),G("button",{type:"button",style:ue,onClick:()=>i(`${a?.applyAllFixes().filter(c=>c.applied).length??0} fix(es) applied.`),children:"Apply safe fixes"}),G("button",{type:"button",style:ue,onClick:()=>i(`${a?.undoAll()??0} change(s) undone.`),children:"Undo all"})]}),te("p",{"aria-live":"polite",style:{marginTop:12},children:[t?.report?.summary," ",s]}),G("ul",{style:{listStyle:"none",padding:0,margin:0},children:l.slice(0,40).map(c=>te("li",{style:{borderTop:"1px solid color-mix(in srgb, CanvasText 12%, transparent)",padding:"8px 0"},children:[te("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[G("span",{style:{...on,minWidth:70},children:c.severity}),G("span",{style:{flex:1},children:c.message}),G("button",{type:"button",style:ue,"aria-expanded":o===c.id,onClick:()=>r(o===c.id?null:c.id),children:"Why?"}),c.autoFixable&&G("button",{type:"button",style:ue,onClick:()=>i(a?.applyFix(c.id).message??""),children:"Fix"})]}),o===c.id&&G("p",{style:{whiteSpace:"pre-line",margin:"8px 0 0"},children:a?.explain(c.id)})]},c.id))})]})}function Sl(){let[e,t]=se(null);return te("div",{children:[te("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[G("button",{type:"button",style:ue,onClick:()=>t(Ye()),children:"Run QA check"}),e&&te(Ir,{children:[G("button",{type:"button",style:ue,onClick:()=>Rr("accessibility-report.md",sr(e),"text/markdown"),children:"Download .md"}),G("button",{type:"button",style:ue,onClick:()=>Rr("accessibility-report.json",ar(e),"application/json"),children:"Download .json"})]})]}),e&&te(Ir,{children:[te("p",{"aria-live":"polite",style:{marginTop:12},children:[G("strong",{children:e.passed?"PASS":"FAIL"})," \u2014 ",e.summary]}),G(_n,{rows:e.checks.map(n=>({Check:n.title,Result:n.passed?"\u2705 Pass":"\u274C Fail",Issues:n.issueCount}))})]})]})}function Tl(){let[e,t]=se(null);return te("div",{children:[G("button",{type:"button",style:ue,onClick:()=>t(Zt()),children:"Review forms"}),te("div",{"aria-live":"polite",children:[e&&e.length===0&&G("p",{children:"No forms on this page."}),e?.map(n=>te("div",{style:{marginTop:12},children:[G("p",{children:G("strong",{children:n.summary})}),G("ul",{children:n.findings.map((o,r)=>te("li",{children:[o.level==="problem"?"Problem: ":"Suggestion: ",o.message," ",G("span",{style:on,children:o.suggestion})]},r))})]},n.selector))]})]})}function Al(){let[e,t]=se(null);return te("div",{children:[G("button",{type:"button",style:ue,onClick:()=>t(Cr()),children:"Review design"}),e&&te("div",{"aria-live":"polite",children:[G("p",{style:{marginTop:12},children:G("strong",{children:e.summary})}),G(_n,{rows:Object.entries(e.categories).map(([n,o])=>({Area:n,Score:o.score,Findings:o.findings}))}),G("ul",{children:e.findings.map((n,o)=>te("li",{children:["[",n.severity,"] ",n.message," ",G("span",{style:on,children:n.suggestion})]},o))})]})]})}function Cl({generate:e}){let[t,n]=se(""),[o,r]=se(""),[s,i]=se([]);return te("div",{children:[te("form",{onSubmit:async l=>{if(l.preventDefault(),!t.trim())return;let c=await cr(t);if(c.intent!=="unknown"&&c.intent!=="purpose"){r(c.answer),i(c.suggestions);return}let u=await hr().ask(t,{generate:e});r(c.intent==="purpose"&&!u.hits.length?c.answer:u.hits.length?u.answer:c.answer),i(c.suggestions)},style:{display:"flex",gap:8,flexWrap:"wrap"},children:[G("label",{htmlFor:"yuktai-page-ask",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Question about this page"}),G("input",{id:"yuktai-page-ask",value:t,onChange:l=>n(l.target.value),placeholder:"What does this page do? Which fields are missing labels?",style:qn}),G("button",{type:"submit",style:ue,children:"Ask"})]}),G("p",{"aria-live":"polite",style:{whiteSpace:"pre-line",marginTop:12},children:o}),s.length>0&&G("ul",{children:s.map((l,c)=>G("li",{children:l},c))})]})}function Rl({lang:e}){let t=Bn(()=>br({lang:e,onTranscript:(l,c)=>s(`\u201C${l}\u201D \u2192 ${c?c.say:"not a command"}`)}),[e]),[n,o]=se(!1),[r,s]=se(""),[i,a]=se("");return $r(()=>()=>t.stop(),[t]),te("div",{children:[G("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:G("button",{type:"button",style:ue,"aria-pressed":n,onClick:()=>{n?(t.stop(),o(!1)):o(t.start())},children:n?"Stop listening":"Start voice commands"})}),te("form",{onSubmit:l=>{l.preventDefault(),t.handle(i),a("")},style:{display:"flex",gap:8,marginTop:8,flexWrap:"wrap"},children:[G("label",{htmlFor:"yuktai-voice-typed",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Type a command"}),G("input",{id:"yuktai-voice-typed",value:i,onChange:l=>a(l.target.value),placeholder:"Or type: turn on high contrast",style:qn}),G("button",{type:"submit",style:ue,children:"Run"})]}),G("p",{"aria-live":"polite",style:{marginTop:12},children:r}),G("p",{style:on,children:"Try: \u201Cturn on high contrast\u201D, \u201Cbigger text\u201D, \u201Cdark mode off\u201D, \u201Cnext row\u201D, \u201C\u0C2A\u0C46\u0C26\u0C4D\u0C26 \u0C05\u0C15\u0C4D\u0C37\u0C30\u0C3E\u0C32\u0C41\u201D, \u201Creset settings\u201D."})]})}function Il(){if(typeof globalThis>"u")return new Xe;if(!globalThis.__yuktai_runtime__){let e=new Xe;e.register(ke.name,ke),e.register(Bt.name,Bt),e.register(Ht.name,Ht),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var Gr=typeof window<"u"?Il():new Xe,yd={wcagPlugin:ke,list(){return Gr.getPlugins()},use(e){return Gr.use(e)},fix(e){return ke.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return ke.scan()}};export{Jt as AUDIT_RULES,Jr as AccessibilityIcon,Ku as AgenticGridBar,Qu as AgenticPanel,vi as AlertIcon,Ki as ArrowLeftIcon,Qi as ArrowRightIcon,Yi as ArrowUpIcon,Li as BookIcon,ls as BulbIcon,Pi as CalendarIcon,pi as CardsIcon,gi as ChatIcon,Yr as CheckIcon,Ur as ChevronLeftIcon,Vr as ChevronRightIcon,ui as ChevronsIcon,Mi as ClockIcon,Kr as CloseIcon,Zr as ContrastIcon,hi as CopyIcon,mr as DEFAULT_A11Y_SETTINGS,bi as DownloadIcon,Vi as ExternalIcon,Ai as EyeIcon,al as FONT_MAX,sl as FONT_MIN,fr as FONT_STEP,Ui as FileIcon,yi as FilterIcon,xi as FirstIcon,Ti as FormIcon,_i as GiftIcon,Di as GlobeIcon,di as GridIcon,Ji as HeadphonesIcon,rs as HelpIcon,Gi as HomeIcon,Dr as ICON_MIN_CONTRAST,zr as ICON_NAMES,Nr as ICON_PATHS,Hr as IconBase,ji as ImageIcon,Si as InfoIcon,os as InstallIcon,Oi as LampIcon,wi as LastIcon,Ci as LayoutIcon,es as MapIcon,ss as MeditateIcon,Fi as MenuIcon,fi as MicIcon,ai as MinusIcon,Xr as MoonIcon,ei as MotionIcon,Zi as MusicIcon,ri as PaletteIcon,Bi as PauseIcon,ts as PenIcon,Ni as PersonIcon,Xi as PinIcon,Wi as PlayIcon,Ei as PlugIcon,si as PlusIcon,ti as ReadingIcon,li as ResetIcon,Xe as Runtime,qr as SearchIcon,Hi as SendIcon,qi as ShareIcon,ii as SkipIcon,jr as SortDownIcon,ci as SortIcon,_r as SortUpIcon,ki as SparkIcon,oi as SpeakerIcon,mi as StopIcon,cs as SunIcon,ni as TargetIcon,is as TempleIcon,$i as ToolsIcon,as as TrophyIcon,Ii as UndoIcon,zi as UsersIcon,ns as WalletIcon,Ri as WandIcon,yd as YuktAI,Sn as YuktAIWrapper,Na as YuktaiGrid,An as YuktaiGridAI,Aa as YuktaiGridAgent,Kt as YuktaiGridWebMCP,Qr as YuktaiIcon,Ie as accessibleName,On as addPeriods,At as aggregate,Bt as aiPlugin,Va as analyzePage,gr as answerGridQuestion,je as applyGridFilters,cr as askAboutPage,Tr as askInsight,ar as auditToJSON,sr as auditToMarkdown,Yo as clearFilters,Qo as clearSort,bl as comparePeriods,cn as contrastRatio,_o as countGrid,lr as createA11yCopilot,hr as createContextIndex,vt as createGridTools,br as createVoiceA11yController,Sn as default,Mn as detectAnomalies,Qa as detectPageIntent,Ke as executeGridQuery,Vo as filterGrid,Pe as findMentionedColumn,jo as getColumns,Uo as getRow,me as getRowId,pl as gridPassages,ml as groupBy,kt as highlightRows,Or as iconContrast,Br as iconSvg,cl as moveGridRowFocus,Ut as openRow,dl as pagePassages,Gn as parseAmount,ln as parseColor,Xo as parseGridIntent,ft as parseGridQuery,ll as parseVoiceA11yCommand,Wr as pickGlyphColor,zn as planTasks,ja as readFormFields,Mr as relativeLuminance,Cr as reviewDesign,Ua as reviewForm,Zt as reviewForms,nl as runGridQuery,Ye as runQaAudit,kr as runTasks,qo as searchGrid,jt as selectRow,Ko as sortGrid,Sr as startOfPeriod,Nn as summarizeRows,tt as toGridToolColumns,en as tokenize,hl as trend,Yu as useAgenticGrid,Da as useGrid,Yt as useYuktaiGridAgent,Ht as voicePlugin,ke as wcag,ke as wcagPlugin};
406
+ `):u[0].text.slice(0,300),hits:u,generated:!1}}return{search:i,ask:s,rebuild:a,update(l){Object.assign(e,l),a()},size:()=>t.length}}var wr="highlight|mark|flag|sort|order|rank|arrange|summari[sz]e|summary|recap|count|how many|open|select|pick|show|filter|find|list|clear|reset|remove|detect|spot|tell";function zn(e){return e.replace(/[?!]/g," ").split(/\s*(?:;|\.(?!\d)\s*|,?\s*\band then\b|,?\s*\bthen\b|,?\s*\bafter that\b|,?\s*\bfinally\b|,?\s*\bnext\b|ఆ తర్వాత)\s*/i).flatMap(o=>o.split(new RegExp(`\\s*(?:,|\\band\\b)\\s+(?=(?:${wr})\\b)`,"i"))).map(o=>o.trim()).filter(o=>o.length>1).map(o=>({action:Yc(o),text:o}))}function Yc(e){let t=e.toLowerCase();return/^(clear|reset|remove)\b/.test(t)?"clear":/unusual|anomal|outlier|suspicious|odd ones|duplicate/.test(t)?"anomalies":/summari[sz]e|summary|what changed|recap|overview/.test(t)?"summarize":/^(highlight|mark|flag)\b/.test(t)?"highlight":/^(sort|order|rank|arrange)\b/.test(t)?"sort":/^(count|how many)\b/.test(t)?"count":/^(open|go to)\b/.test(t)&&!/filtered|results?/.test(t)?"open":/^(select|pick)\b/.test(t)?"select":"filter"}function Kc(e){return e.replace(new RegExp(`^\\s*(?:${wr}|open|go to)\\b`,"i")," ").replace(/\b(the|filtered|results?|rows?|records?|entries|items?|ones|them|those|only|me|all)\b/gi," ").replace(/\s+/g," ").trim()}function yr(e,t){let n=t.find(a=>a.key===e.key)?.label??e.key,o=Array.isArray(e.value)?`${e.value[0]}\u2013${e.value[1]}`:typeof e.value=="number"?e.value.toLocaleString("en-IN",{maximumFractionDigits:2}):`"${e.value}"`,r={contains:"contains",equals:"is",startsWith:"starts with",endsWith:"ends with",greaterThan:">",lessThan:"<",between:"between"}[e.operator];return`${n} ${r} ${o}`}async function kr(e,t,n={}){let o=zn(e),{columns:r,data:a}=t,i=[...t.filters??[]],s=[],l=null,c=[],u=()=>Ke(a,r,{filters:i,search:s,sort:l,limit:null,notes:[],explanation:""}),b={rows:u().length,filters:[...i]},p=[],g=()=>({...t,filters:i});for(let h=0;h<o.length;h++){let d=o[h],x=Kc(d.text),k;try{switch(d.action){case"clear":{i=[],s=[],l=null,c=[],t.onFiltersChange?.([]),t.onSortChange?.(null),t.onHighlightRows?.([]),k={...d,success:!0,message:`Cleared filters, sorting and highlights. ${a.length} row(s) shown.`};break}case"filter":{let m=ft(x,r,{data:a});if(!m.filters.length&&!m.search.length&&!m.sort){k={...d,success:!0,message:`Showing ${u().length} row(s) with the current filters.`};break}for(let A of m.filters)i=[...i.filter(C=>C.key!==A.key),A];s=[...s,...m.search],m.sort&&(l=m.sort,t.onSortChange?.(l)),t.onFiltersChange?.(i);let v=u(),w=v.map(A=>me(A,t.rowKey)).filter(Boolean);m.search.length&&w.length&&(c=w,t.onHighlightRows?.(w)),k={...d,success:!0,message:`${v.length} row(s) now shown. ${m.explanation}`,ids:w};break}case"highlight":{let m=u(),v=ft(x,r,{data:m}),A=(v.filters.length||v.search.length?Ke(m,r,{...v,sort:null,limit:v.limit}):m).map(G=>me(G,t.rowKey)).filter(Boolean);if(!A.length){k={...d,success:!1,message:`Nothing to highlight for "${x||"all rows"}".`};break}let C=kt(g(),A);C.success&&(c=C.data??A),k={...d,success:C.success,message:C.success?`Highlighted ${c.length} row(s)${x?` matching "${x}"`:""}.`:C.message,ids:c};break}case"sort":{let v=ft(d.text,r,{data:a}).sort;if(!v){let A=Pe(x,r);A&&(v={key:A.key,direction:/desc|high|large|big|most|newest|latest|z.?to.?a/i.test(d.text)?"desc":"asc"})}if(!v){k={...d,success:!1,message:`Which column should I sort by? Columns: ${r.map(A=>A.label).join(", ")}.`};break}l=v,t.onSortChange?.(l);let w=r.find(A=>A.key===l.key)?.label??l.key;k={...d,success:!0,message:`Sorted by ${w} (${l.direction==="desc"?"high \u2192 low":"low \u2192 high"}).`};break}case"count":{k={...d,success:!0,message:`${u().length} row(s) shown${c.length?`, ${c.length} highlighted`:""}.`};break}case"anomalies":{let m=u(),v=Mn(m,r,{rowKey:t.rowKey}),w=Array.from(new Set(v.map(A=>A.rowId)));if(w.length){let A=kt(g(),w);A.success&&(c=A.data??w)}k={...d,success:!0,message:v.length?`${w.length} unusual row(s): ${v.slice(0,5).map(A=>A.reason).join(" ")}`:"Nothing unusual in the shown rows.",ids:w};break}case"open":case"select":{let m=u(),w=m.find(G=>x&&me(G,t.rowKey).toLowerCase()===x.toLowerCase())??Ke(m,r,ft(x,r,{data:m}))[0]??(x?void 0:m[0]);if(!w){k={...d,success:!1,message:`No row matches "${x}".`};break}let A=me(w,t.rowKey),C=d.action==="open"?jt(g(),A):Ut(g(),A);k={...d,success:C.success,message:C.message,ids:[A]};break}case"summarize":{let m=u();k={...d,success:!0,message:`${xr(b,m.length,i,l,c,r)}
407
+ ${Nn(m,r)}`};break}}}catch(m){k={...d,success:!1,message:`This step failed: ${m instanceof Error?m.message:String(m)}`}}p.push(k),n.onStep?.(k,h,o.length)}let f=u().length;return{steps:p,before:b,after:{rows:f,filters:i,sort:l,highlighted:c},summary:xr(b,f,i,l,c,r)}}function xr(e,t,n,o,r,a){let i=[`Rows: ${e.rows} \u2192 ${t}.`],s=n.filter(c=>!e.filters.some(u=>JSON.stringify(u)===JSON.stringify(c))),l=e.filters.filter(c=>!n.some(u=>JSON.stringify(c)===JSON.stringify(u)));return s.length&&i.push(`Filters added: ${s.map(c=>yr(c,a)).join("; ")}.`),l.length&&i.push(`Filters removed: ${l.map(c=>yr(c,a)).join("; ")}.`),o&&i.push(`Sorted by ${a.find(c=>c.key===o.key)?.label??o.key} ${o.direction==="desc"?"high \u2192 low":"low \u2192 high"}.`),r.length&&i.push(`${r.length} row(s) highlighted.`),i.join(" ")}var tn=e=>{let t=typeof e=="number"?e:Number(String(e??"").replace(/[,₹$%\s]/g,""));return Number.isFinite(t)?t:null},vr=e=>{let t=e instanceof Date?e.getTime():new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null};function At(e,t){if(t==="count")return e.length;if(!e.length)return 0;switch(t){case"sum":return e.reduce((n,o)=>n+o,0);case"avg":return e.reduce((n,o)=>n+o,0)/e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function Qc(e,t,n,o="sum"){let r=new Map;for(let a of e){let i=String(a[t]??"\u2014").trim()||"\u2014",s=r.get(i)??[];if(n===null||o==="count")s.push(1);else{let l=tn(a[n]);l!==null&&s.push(l)}r.set(i,s)}return Array.from(r.entries()).map(([a,i])=>({group:a,value:At(i,o),count:i.length})).sort((a,i)=>i.value-a.value)}function Sr(e,t,n=1){let o=new Date(e);return o.setHours(0,0,0,0),t==="week"&&o.setDate(o.getDate()-(o.getDay()-n+7)%7),t==="month"&&o.setDate(1),t==="quarter"&&o.setMonth(Math.floor(o.getMonth()/3)*3,1),t==="year"&&o.setMonth(0,1),o}function On(e,t,n){let o=new Date(e);return t==="day"&&o.setDate(o.getDate()+n),t==="week"&&o.setDate(o.getDate()+7*n),t==="month"&&o.setMonth(o.getMonth()+n),t==="quarter"&&o.setMonth(o.getMonth()+3*n),t==="year"&&o.setFullYear(o.getFullYear()+n),o}function Jc(e,t){let n=t.referenceDate?new Date(t.referenceDate):new Date,o=Sr(n,t.period,t.weekStartsOn),r=t.toDate===!1?On(o,t.period,1):new Date(Math.max(n.getTime()+1,o.getTime()+1)),a=On(o,t.period,-1),i=t.toDate===!1?o:new Date(a.getTime()+(r.getTime()-o.getTime())),s=t.agg??"sum",l=new Map,c=new Map;for(let p of e){let g=vr(p[t.dateKey]);if(g===null)continue;let f=g>=o.getTime()&&g<r.getTime()?l:g>=a.getTime()&&g<i.getTime()?c:null;if(!f)continue;let h=t.groupKey?String(p[t.groupKey]??"\u2014"):"All",d=s==="count"?1:tn(p[t.metricKey]);d!==null&&f.set(h,[...f.get(h)??[],d])}let u=new Set([...l.keys(),...c.keys()]),b=Array.from(u).map(p=>{let g=At(l.get(p)??[],s),f=At(c.get(p)??[],s);return{group:p,current:g,previous:f,change:g-f,changePct:f===0?null:(g-f)/Math.abs(f)*100}});return{period:t.period,current:{from:o,to:r},previous:{from:a,to:i},rows:b}}function Zc(e,t,n,o,r="sum"){let a=new Map;for(let i of e){let s=vr(i[t]),l=r==="count"?1:tn(i[n]);if(s===null||l===null)continue;let c=Sr(new Date(s),o).getTime();a.set(c,[...a.get(c)??[],l])}return Array.from(a.entries()).sort((i,s)=>i[0]-s[0]).map(([i,s])=>({start:new Date(i),value:At(s,r)}))}var Xc=/rate|conversion|ratio|percent|%|score|rating|margin|ctr|avg|average/i;function eu(e){let t=e.match(/\b(today|yesterday|this|last|previous|past)\s*(day|week|month|quarter|year)?\b/);return t?t[1]==="today"?{period:"day",shift:0}:t[1]==="yesterday"?{period:"day",shift:-1}:t[2]?{period:t[2],shift:t[1]==="this"?0:-1}:null:null}var xe=e=>e.toLocaleString("en-IN",{maximumFractionDigits:2}),Dn=e=>e===null?"new":`${e>0?"+":""}${e.toFixed(1)}%`;function Tr(e,t,n,o={}){let r=e.toLowerCase(),a=n.filter(m=>m.type==="number"),i=Pe(r,n,"number")??a.find(m=>/amount|revenue|sales|total|value/i.test(`${m.key} ${m.label}`))??a[0],s=n.find(m=>m.type==="date")??n.find(m=>/date|time|day|created|month/i.test(`${m.key} ${m.label}`)),l=r.match(/\b(?:which|by|per|each|across|every|top|for each)\s+([\p{L}\p{M}\p{N} _]+)/u)?.[1]??"",c=Pe(l,n,"text"),u=/how many|number of|count/.test(r),b=u?"count":/average|avg|mean/.test(r)?"avg":/\btotal\b|\bsum\b/.test(r)?"sum":i&&Xc.test(`${i.key} ${i.label}`)?"avg":"sum",p=/drop|decline|decrease|fell|fall|down|worst|lost|shrink|reduc/.test(r),g=/increase|growth|grew|rise|rose|up\b|best|improv|gain/.test(r),f=/lowest|least|smallest|bottom|worst|minimum/.test(r),h=eu(r);if(!i&&!u)return{kind:"unknown",answer:"I couldn't find a numeric column to analyse.",table:[]};let d=u?"rows":i.label;if(h&&s&&(g||p||/change|compare|vs|versus/.test(r))){let m=o.referenceDate?new Date(o.referenceDate):new Date,v=h.shift?On(m,h.period,h.shift):m,A=[...Jc(t,{dateKey:s.key,metricKey:i?.key??s.key,groupKey:c?.key,agg:b,period:h.period,referenceDate:v,toDate:h.shift===0}).rows].sort((q,B)=>p?q.change-B.change:B.change-q.change),C=A.map(q=>({[c?.label??"Group"]:q.group,Current:xe(q.current),Previous:xe(q.previous),Change:xe(q.change),"Change %":Dn(q.changePct)}));if(!A.length)return{kind:"period-change",answer:`No ${d} data in this ${h.period} or the one before.`,table:C};let G=A[0],D=`${h.shift?"last":"this"} ${h.period} vs the ${h.period} before`,M=G.change===0?"did not change":G.change<0?`dropped ${xe(Math.abs(G.change))}`:`rose ${xe(G.change)}`,E=`${d} ${M} (${xe(G.previous)} \u2192 ${xe(G.current)}, ${Dn(G.changePct)}) \u2014 ${D}.`,I=p&&G.change>=0||g&&G.change<=0;return{kind:"period-change",answer:c?I?`No ${c.label.toLowerCase()} ${p?"dropped":"grew"}. Closest is ${G.group}: ${E}`:`${G.group}: ${E}`:E,table:C}}if(/trend|over time|month by month|week by week/.test(r)&&s&&i){let m=/week/.test(r)?"week":/day|daily/.test(r)?"day":/year/.test(r)?"year":"month",v=Zc(t,s.key,i.key,m,b),w=v.map(D=>({Period:D.start.toISOString().slice(0,10),[i.label]:xe(D.value)}));if(v.length<2)return{kind:"trend",answer:`Not enough ${m}s of data for a trend.`,table:w};let A=v[0].value,C=v[v.length-1].value,G=v.reduce((D,M)=>M.value>D.value?M:D);return{kind:"trend",answer:`${i.label} went from ${xe(A)} to ${xe(C)} over ${v.length} ${m}s (${Dn(A?(C-A)/Math.abs(A)*100:null)}). Peak: ${xe(G.value)} in the ${m} of ${G.start.toISOString().slice(0,10)}.`,table:w}}if(c){let m=Qc(t,c.key,i?.key??null,b),v=f?[...m].reverse():m,w=v.map(C=>({[c.label]:C.group,[`${b} of ${d}`]:xe(C.value),Rows:C.count}));if(!v.length)return{kind:"group",answer:"No data.",table:w};let A=v[0];return{kind:"group",answer:`${A.group} has the ${f?"lowest":"highest"} ${b==="sum"?"total":b==="avg"?"average":b} ${d}: ${xe(A.value)} (across ${v.length} ${c.label.toLowerCase()} groups).`,table:w}}let x=u?t.map(()=>1):t.map(m=>tn(m[i.key])).filter(m=>m!==null),k=At(x,b);return{kind:"total",answer:`${b==="avg"?"Average":b==="count"?"Count of":b==="sum"?"Total":b} ${d}: ${xe(k)} across ${t.length} row(s).`,table:[{Metric:d,Aggregation:b,Value:xe(k)}]}}var Ar={high:12,medium:6,low:2};function Cr(e={}){let t=Ae(e.root),n=[],o=(s,l,c,u,b)=>n.push({category:s,severity:l,message:c,suggestion:u,selector:b?Ne(b):void 0});if(t&&We()){let s=e.minFontSize??14,l=e.maxLineLength??90,c=E=>window.getComputedStyle(E),u=_(t,"h1");u.length===0&&o("hierarchy","medium","There is no h1, so the page has no clear main title.","Add one prominent h1 near the top."),u.length>1&&o("hierarchy","low",`${u.length} h1 headings compete for attention.`,"Keep one h1 and demote the rest.",u[1]);let b=E=>{let I=_(t,E)[0];return I&&parseFloat(c(I).fontSize)||0},[p,g,f]=[b("h1"),b("h2"),b("h3")];p&&g&&g>=p&&o("hierarchy","medium",`h2 (${g}px) is as large as or larger than h1 (${p}px).`,"Make each heading level visibly smaller than the one above it."),g&&f&&f>g&&o("hierarchy","low",`h3 (${f}px) is larger than h2 (${g}px).`,"Keep heading sizes in descending order.");let h=Ye({root:e.root,skip:["color-contrast","target-size","duplicate-id","page-title","html-lang","form-error","positive-tabindex"]});for(let E of h.issues.filter(I=>I.rule==="heading-order").slice(0,3))o("hierarchy","low",E.message,E.fix,E.element);let d=0,x;for(let E of _(t,"p,li,td,span,a,label,small,div").slice(0,1500)){if(!ht(E))continue;(parseFloat(c(E).fontSize)||16)<s&&(d++,x??=E)}d&&o("readability",d>10?"high":"medium",`${d} text element(s) are smaller than ${s}px, e.g. "${pe(x?.textContent??"",30)}".`,`Use at least ${s}px for body text (16px for senior-friendly pages).`,x);for(let E of _(t,"p").slice(0,200)){let I=c(E),y=parseFloat(I.fontSize)||16,q=E.getBoundingClientRect().width,B=q/(y*.5);if(q>0&&B>l&&(E.textContent??"").length>l){o("readability","low",`A paragraph is about ${Math.round(B)} characters wide.`,`Limit text width to ~${l} characters (e.g. max-width: 70ch).`,E);break}let j=parseFloat(I.lineHeight);if(Number.isFinite(j)&&j/y<1.3){o("readability","low",`Line height is ${(j/y).toFixed(2)}\xD7 the font size.`,"Use line-height of at least 1.5 for body text (WCAG 1.4.12).",E);break}}let k=Ye({root:e.root,skip:["html-lang","page-title","image-alt","heading-order","single-h1","landmark-main","form-label","button-name","link-name","positive-tabindex","keyboard-access","duplicate-id","form-error","target-size"]});k.issues.length&&o("readability",k.issues.length>5?"high":"medium",`${k.issues.length} text element(s) have weak contrast. ${k.issues[0].message}`,"Raise contrast to at least 4.5:1 for body text.",k.issues[0].element);let m=tu();m.length&&o("interaction","high",`Focus outlines are removed by CSS (${m.slice(0,2).join(", ")}) with no replacement.`,"Never remove outlines without a visible :focus-visible style (WCAG 2.4.7).");let v=_(t,Ft).filter(E=>{let I=E.getBoundingClientRect();return I.width>0&&I.height>0&&(I.width<24||I.height<24)&&!(E.tagName==="A"&&E.closest("p,li"))});v.length&&o("interaction",v.length>5?"high":"medium",`${v.length} control(s) are smaller than 24\xD724px.`,"Give controls at least 24\xD724px, ideally 44\xD744px for touch and seniors.",v[0]);let w=window.innerHeight||800,A=_(t,oo).filter(E=>{let I=E.getBoundingClientRect();return I.height>0&&I.top<w});A.length>40&&o("clutter","medium",`${A.length} interactive elements in the first screen.`,"Group secondary actions into menus and keep the first screen focused on one task.");let C=_(t,"button,a[href],[role='button']").filter(E=>{let I=E.getBoundingClientRect();if(I.height===0||I.top>w)return!1;let y=c(E).backgroundColor;return!!y&&!/rgba\(0, 0, 0, 0\)|transparent/.test(y)&&!/rgb\(255, 255, 255\)/.test(y)});C.length>4&&o("clutter","medium",`${C.length} filled buttons compete in the first screen.`,"Keep one primary action per view; make the rest secondary (outline or text).",C[0]);let G=new Set,D=new Set;for(let E of _(t,"body *").slice(0,2e3)){if(!ht(E))continue;let I=c(E);G.add(I.fontFamily.split(",")[0].replace(/["']/g,"").trim().toLowerCase()),D.add(Math.round(parseFloat(I.fontSize)||0))}G.size>4&&o("consistency","low",`${G.size} different font families are used.`,"Stick to 1\u20132 font families (e.g. one Telugu + one Latin)."),D.size>10&&o("consistency","low",`${D.size} different font sizes are used.`,"Use a small type scale (5\u20137 sizes) for a calmer page.");let M=_(t,"img:not([width]):not([height])").filter(E=>!c(E).aspectRatio||c(E).aspectRatio==="auto");M.length>3&&o("consistency","low",`${M.length} images have no width/height, so the layout jumps while loading.`,"Set width and height (or aspect-ratio) on images.",M[0])}let r=["hierarchy","readability","interaction","clutter","consistency"].reduce((s,l)=>{let c=n.filter(u=>u.category===l);return s[l]={score:Math.max(0,100-c.reduce((u,b)=>u+Ar[b.severity]*2,0)),findings:c.length},s},{}),a=Math.max(0,100-n.reduce((s,l)=>s+Ar[l.severity],0)),i=Object.entries(r).sort((s,l)=>s[1].score-l[1].score)[0];return{score:a,categories:r,findings:n,summary:n.length?`Design score ${a}/100 with ${n.length} finding(s). Weakest area: ${i[0]}.`:"No design issues found by the automatic review."}}function tu(){let e=[],t=!1,n=o=>{for(let r of Array.from(o)){let a=r.cssRules;a&&n(a);let i=r;if(!i.selectorText||!/:focus/.test(i.selectorText))continue;let s=`${i.style.outline} ${i.style.outlineStyle} ${i.style.outlineWidth}`,l=/\bnone\b|\b0(px)?\b/.test(s),c=!!(i.style.boxShadow&&i.style.boxShadow!=="none")||!!i.style.borderColor||!!i.style.backgroundColor||!!i.style.textDecoration;/:focus-visible/.test(i.selectorText)&&(!l||c)&&(t=!0),l&&!c&&e.push(i.selectorText)}};for(let o of Array.from(document.styleSheets))try{n(o.cssRules)}catch{}return t?[]:e}import{useCallback as Wn,useEffect as $r,useMemo as Bn,useRef as Hn,useState as ae}from"react";import{Fragment as Ir,jsx as F,jsxs as te}from"react/jsx-runtime";var nu=/\b(trend|over time|this (week|month|quarter|year)|last (week|month|quarter|year)|compare|versus|vs)\b|\b(by|per|each|which)\b.*\b(total|average|avg|sum|drop|increase|growth|highest|lowest|most|least)\b|\b(total|average|avg|sum)\b.*\b(by|per|each)\b/i;function $p(e){let{data:t,rowKey:n="id"}=e,o=Bn(()=>tt(e.columns),[e.columns]),[r,a]=ae([]),[i,s]=ae(null),[l,c]=ae([]),[u,b]=ae(""),[p,g]=ae(null),[f,h]=ae([]),[d,x]=ae([]),[k,m]=ae(!1),v=Hn(r);v.current=r;let w=Wn(()=>({data:t,columns:o,rowKey:n,filters:v.current,onFiltersChange:D=>{v.current=D,a(D)},onSortChange:s,onHighlightRows:c,onOpenRow:e.onOpenRow,onSelectRow:D=>c([D])}),[t,o,n,e.onOpenRow]),A=Wn(async D=>{let M=D.trim();if(M){m(!0),x([]),h([]);try{if(zn(M).length>1){let E=[],I=await kr(M,w(),{onStep:y=>x((E.push(y),[...E]))});g("tasks"),b(I.summary)}else if(nu.test(M)){let E=Ke(t,o,{filters:v.current,search:[],sort:null,limit:null,notes:[],explanation:""}),I=Tr(M,E,o,{referenceDate:e.referenceDate});g("insight"),b(I.answer),h(I.table)}else{let E=gr(M,w());g(E.kind),b(E.message)}}finally{m(!1)}}},[w,t,o,e.referenceDate]),C=Wn(()=>{v.current=[],a([]),s(null),c([]),b(""),g(null),h([]),x([])},[]),G=Bn(()=>Ke(t,o,{filters:r,search:[],sort:i,limit:null,notes:[],explanation:""}),[t,o,r,i]);return{gridData:G,highlightIds:l,filters:r,sort:i,ask:A,reset:C,answer:u,kind:p,table:f,steps:d,busy:k,visibleIds:G.map(D=>me(D,n))}}var Er={border:"1px solid color-mix(in srgb, CanvasText 20%, transparent)",borderRadius:12,padding:16,background:"Canvas",color:"CanvasText",font:"inherit"},ue={minHeight:44,padding:"8px 14px",borderRadius:8,border:"1px solid color-mix(in srgb, CanvasText 35%, transparent)",background:"ButtonFace",color:"ButtonText",font:"inherit",cursor:"pointer"},qn={...ue,flex:1,minWidth:0,background:"Field",color:"FieldText",cursor:"text"},on={opacity:.75,fontSize:"0.9em"};function _n({rows:e}){if(!e.length)return null;let t=Object.keys(e[0]);return F("div",{style:{overflowX:"auto",marginTop:12},children:te("table",{style:{borderCollapse:"collapse",width:"100%"},children:[F("thead",{children:F("tr",{children:t.map(n=>F("th",{scope:"col",style:{textAlign:"left",padding:"6px 8px",borderBottom:"1px solid currentColor"},children:n},n))})}),F("tbody",{children:e.slice(0,50).map((n,o)=>F("tr",{children:t.map(r=>F("td",{style:{padding:"6px 8px",borderBottom:"1px solid color-mix(in srgb, CanvasText 12%, transparent)"},children:n[r]},r))},o))})]})})}function Rr(e,t,n){let o=URL.createObjectURL(new Blob([t],{type:n})),r=document.createElement("a");r.href=o,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Ep({grid:e,placeholder:t="Ask about this data, e.g. \u201Coverdue and over \u20B910,000\u201D",examples:n=[],style:o}){let[r,a]=ae(""),i=s=>{s.preventDefault(),e.ask(r)};return te("section",{"data-yuktai-panel":"","aria-label":"Data assistant",style:{...Er,...o},children:[te("form",{onSubmit:i,style:{display:"flex",gap:8,flexWrap:"wrap"},children:[F("label",{htmlFor:"yuktai-grid-ask",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Question about the data"}),F("input",{id:"yuktai-grid-ask",value:r,onChange:s=>a(s.target.value),placeholder:t,style:qn}),F("button",{type:"submit",style:ue,disabled:e.busy,children:e.busy?"Working\u2026":"Ask"}),F("button",{type:"button",style:ue,onClick:()=>{a(""),e.reset()},children:"Reset"})]}),n.length>0&&F("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:8},children:n.map(s=>F("button",{type:"button",style:{...ue,minHeight:36,fontSize:"0.85em"},onClick:()=>{a(s),e.ask(s)},children:s},s))}),F("div",{"aria-live":"polite",style:{marginTop:12,whiteSpace:"pre-line"},children:e.answer}),e.steps.length>0&&F("ol",{style:{marginTop:8,paddingLeft:20},children:e.steps.map((s,l)=>te("li",{style:{marginBottom:4},children:[F("span",{"aria-hidden":"true",children:s.success?"\u2705 ":"\u26A0\uFE0F "}),F("strong",{children:s.text})," \u2014 ",F("span",{style:{whiteSpace:"pre-line"},children:s.message})]},l))}),F(_n,{rows:e.table})]})}var nn=[["copilot","Copilot"],["qa","QA report"],["forms","Forms"],["design","Design"],["ask","Ask page"],["voice","Voice"]];function Fp({defaultTab:e="copilot",voiceLang:t="en-IN",generate:n,style:o}){let[r,a]=ae(e),i=Hn([]),s=(l,c)=>{let u=l.key==="ArrowRight"?1:l.key==="ArrowLeft"?-1:0;if(!u)return;l.preventDefault();let b=(c+u+nn.length)%nn.length;a(nn[b][0]),i.current[b]?.focus()};return te("section",{"data-yuktai-panel":"","aria-label":"yuktai agentic tools",style:{...Er,...o},children:[F("div",{role:"tablist","aria-label":"Tools",style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:12},children:nn.map(([l,c],u)=>F("button",{ref:b=>{i.current[u]=b},role:"tab",id:`yuktai-tab-${l}`,"aria-selected":r===l,"aria-controls":`yuktai-tabpanel-${l}`,tabIndex:r===l?0:-1,onClick:()=>a(l),onKeyDown:b=>s(b,u),style:{...ue,fontWeight:r===l?700:400,outlineOffset:2,borderWidth:r===l?2:1},children:c},l))}),te("div",{role:"tabpanel",id:`yuktai-tabpanel-${r}`,"aria-labelledby":`yuktai-tab-${r}`,children:[r==="copilot"&&F(ou,{}),r==="qa"&&F(ru,{}),r==="forms"&&F(iu,{}),r==="design"&&F(au,{}),r==="ask"&&F(su,{generate:n}),r==="voice"&&F(lu,{lang:t})]})]})}function ou(){let e=Hn(null),[t,n]=ae(null),[o,r]=ae(null),[a,i]=ae("");$r(()=>(e.current=lr({onUpdate:n}),e.current.scan(),()=>e.current?.stop()),[]);let s=e.current,l=t?.report?.issues??[];return te("div",{children:[te("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[F("button",{type:"button",style:ue,onClick:()=>t?.watching?s?.stop():s?.start(),children:t?.watching?"Stop watching":"Watch page live"}),F("button",{type:"button",style:ue,onClick:()=>s?.scan(),children:"Scan now"}),F("button",{type:"button",style:ue,onClick:()=>i(`${s?.applyAllFixes().filter(c=>c.applied).length??0} fix(es) applied.`),children:"Apply safe fixes"}),F("button",{type:"button",style:ue,onClick:()=>i(`${s?.undoAll()??0} change(s) undone.`),children:"Undo all"})]}),te("p",{"aria-live":"polite",style:{marginTop:12},children:[t?.report?.summary," ",a]}),F("ul",{style:{listStyle:"none",padding:0,margin:0},children:l.slice(0,40).map(c=>te("li",{style:{borderTop:"1px solid color-mix(in srgb, CanvasText 12%, transparent)",padding:"8px 0"},children:[te("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[F("span",{style:{...on,minWidth:70},children:c.severity}),F("span",{style:{flex:1},children:c.message}),F("button",{type:"button",style:ue,"aria-expanded":o===c.id,onClick:()=>r(o===c.id?null:c.id),children:"Why?"}),c.autoFixable&&F("button",{type:"button",style:ue,onClick:()=>i(s?.applyFix(c.id).message??""),children:"Fix"})]}),o===c.id&&F("p",{style:{whiteSpace:"pre-line",margin:"8px 0 0"},children:s?.explain(c.id)})]},c.id))})]})}function ru(){let[e,t]=ae(null);return te("div",{children:[te("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[F("button",{type:"button",style:ue,onClick:()=>t(Ye()),children:"Run QA check"}),e&&te(Ir,{children:[F("button",{type:"button",style:ue,onClick:()=>Rr("accessibility-report.md",ar(e),"text/markdown"),children:"Download .md"}),F("button",{type:"button",style:ue,onClick:()=>Rr("accessibility-report.json",sr(e),"application/json"),children:"Download .json"})]})]}),e&&te(Ir,{children:[te("p",{"aria-live":"polite",style:{marginTop:12},children:[F("strong",{children:e.passed?"PASS":"FAIL"})," \u2014 ",e.summary]}),F(_n,{rows:e.checks.map(n=>({Check:n.title,Result:n.passed?"\u2705 Pass":"\u274C Fail",Issues:n.issueCount}))})]})]})}function iu(){let[e,t]=ae(null);return te("div",{children:[F("button",{type:"button",style:ue,onClick:()=>t(Zt()),children:"Review forms"}),te("div",{"aria-live":"polite",children:[e&&e.length===0&&F("p",{children:"No forms on this page."}),e?.map(n=>te("div",{style:{marginTop:12},children:[F("p",{children:F("strong",{children:n.summary})}),F("ul",{children:n.findings.map((o,r)=>te("li",{children:[o.level==="problem"?"Problem: ":"Suggestion: ",o.message," ",F("span",{style:on,children:o.suggestion})]},r))})]},n.selector))]})]})}function au(){let[e,t]=ae(null);return te("div",{children:[F("button",{type:"button",style:ue,onClick:()=>t(Cr()),children:"Review design"}),e&&te("div",{"aria-live":"polite",children:[F("p",{style:{marginTop:12},children:F("strong",{children:e.summary})}),F(_n,{rows:Object.entries(e.categories).map(([n,o])=>({Area:n,Score:o.score,Findings:o.findings}))}),F("ul",{children:e.findings.map((n,o)=>te("li",{children:["[",n.severity,"] ",n.message," ",F("span",{style:on,children:n.suggestion})]},o))})]})]})}function su({generate:e}){let[t,n]=ae(""),[o,r]=ae(""),[a,i]=ae([]);return te("div",{children:[te("form",{onSubmit:async l=>{if(l.preventDefault(),!t.trim())return;let c=await cr(t);if(c.intent!=="unknown"&&c.intent!=="purpose"){r(c.answer),i(c.suggestions);return}let u=await hr().ask(t,{generate:e});r(c.intent==="purpose"&&!u.hits.length?c.answer:u.hits.length?u.answer:c.answer),i(c.suggestions)},style:{display:"flex",gap:8,flexWrap:"wrap"},children:[F("label",{htmlFor:"yuktai-page-ask",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Question about this page"}),F("input",{id:"yuktai-page-ask",value:t,onChange:l=>n(l.target.value),placeholder:"What does this page do? Which fields are missing labels?",style:qn}),F("button",{type:"submit",style:ue,children:"Ask"})]}),F("p",{"aria-live":"polite",style:{whiteSpace:"pre-line",marginTop:12},children:o}),a.length>0&&F("ul",{children:a.map((l,c)=>F("li",{children:l},c))})]})}function lu({lang:e}){let t=Bn(()=>br({lang:e,onTranscript:(l,c)=>a(`\u201C${l}\u201D \u2192 ${c?c.say:"not a command"}`)}),[e]),[n,o]=ae(!1),[r,a]=ae(""),[i,s]=ae("");return $r(()=>()=>t.stop(),[t]),te("div",{children:[F("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:F("button",{type:"button",style:ue,"aria-pressed":n,onClick:()=>{n?(t.stop(),o(!1)):o(t.start())},children:n?"Stop listening":"Start voice commands"})}),te("form",{onSubmit:l=>{l.preventDefault(),t.handle(i),s("")},style:{display:"flex",gap:8,marginTop:8,flexWrap:"wrap"},children:[F("label",{htmlFor:"yuktai-voice-typed",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Type a command"}),F("input",{id:"yuktai-voice-typed",value:i,onChange:l=>s(l.target.value),placeholder:"Or type: turn on high contrast",style:qn}),F("button",{type:"submit",style:ue,children:"Run"})]}),F("p",{"aria-live":"polite",style:{marginTop:12},children:r}),F("p",{style:on,children:"Try: \u201Cturn on high contrast\u201D, \u201Cbigger text\u201D, \u201Cdark mode off\u201D, \u201Cnext row\u201D, \u201C\u0C2A\u0C46\u0C26\u0C4D\u0C26 \u0C05\u0C15\u0C4D\u0C37\u0C30\u0C3E\u0C32\u0C41\u201D, \u201Creset settings\u201D."})]})}function cu(){if(typeof globalThis>"u")return new Xe;if(!globalThis.__yuktai_runtime__){let e=new Xe;e.register(ke.name,ke),e.register(Bt.name,Bt),e.register(Ht.name,Ht),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var Fr=typeof window<"u"?cu():new Xe,Xp={wcagPlugin:ke,list(){return Fr.getPlugins()},use(e){return Fr.use(e)},fix(e){return ke.applyFixes({enabled:!0,autoFix:!0,...e})},scan(){return ke.scan()}};export{Jt as AUDIT_RULES,Ia as AbcIcon,Jr as AccessibilityIcon,Fs as AdminIcon,Ep as AgenticGridBar,Fp as AgenticPanel,vi as AlertIcon,ka as AlignCenterIcon,Sa as AlignJustifyIcon,wa as AlignLeftIcon,va as AlignRightIcon,Ka as ApiIcon,ss as ArchitectureIcon,gs as ArrowDownIcon,Ki as ArrowLeftIcon,Qi as ArrowRightIcon,Yi as ArrowUpIcon,Es as BarChartIcon,ha as BoldIcon,Li as BookIcon,rs as BookmarkIcon,ls as BrainIcon,Gs as BugReportIcon,la as BulbIcon,$s as CakeIcon,Pi as CalendarIcon,pi as CardsIcon,gi as ChatIcon,Yr as CheckIcon,jr as ChevronLeftIcon,Vr as ChevronRightIcon,ui as ChevronsIcon,ys as CleaningIcon,Mi as ClockIcon,Kr as CloseIcon,Xa as CloudIcon,ma as CodeIcon,Ja as ComputerIcon,Zr as ContrastIcon,hi as CopyIcon,mr as DEFAULT_A11Y_SETTINGS,hs as DashboardIcon,Qa as DataObjectIcon,ua as DeleteIcon,bs as DocumentScannerIcon,bi as DownloadIcon,xs as DragHandleIcon,Ss as ExploreIcon,Vi as ExternalIcon,Ai as EyeIcon,os as EyeOffIcon,Hc as FONT_MAX,Bc as FONT_MIN,fr as FONT_STEP,fs as FactCheckIcon,ji as FileIcon,yi as FilterIcon,xi as FirstIcon,Ca as FontIcon,Ti as FormIcon,Oa as FullscreenExitIcon,Da as FullscreenIcon,as as GavelIcon,_i as GiftIcon,Di as GlobeIcon,di as GridIcon,Ji as HeadphonesIcon,ga as HeartFilledIcon,pa as HeartIcon,ra as HelpIcon,Fi as HomeIcon,fa as HubIcon,Dr as ICON_MIN_CONTRAST,zr as ICON_NAMES,Nr as ICON_PATHS,Hr as IconBase,Ui as ImageIcon,ms as ImageSearchIcon,Si as InfoIcon,vs as InsightsIcon,oa as InstallIcon,Ps as IntegrationIcon,ya as ItalicIcon,Ba as JoinIcon,Pa as KeyIcon,Cs as KeyboardIcon,As as LabelIcon,Oi as LampIcon,wi as LastIcon,Ci as LayoutIcon,Ea as LinkIcon,Hs as LoaderIcon,Ga as LockIcon,Ds as LoginIcon,Os as LogoutIcon,ea as MapIcon,aa as MeditateIcon,Gi as MenuIcon,Wa as MergeIcon,fi as MicIcon,si as MinusIcon,Xr as MoonIcon,ei as MotionIcon,ja as MovieIcon,Zi as MusicIcon,_a as MusicOffIcon,Ua as MusicVideoIcon,Ms as NamaskarIcon,$a as PageBreakIcon,ri as PaletteIcon,Bi as PauseIcon,ta as PenIcon,Ni as PersonIcon,Za as PhoneIcon,Xi as PinIcon,Wi as PlayIcon,Ei as PlugIcon,ai as PlusIcon,Ta as QuoteIcon,ds as RadioCheckedIcon,us as RadioIcon,ti as ReadingIcon,Ma as RedoIcon,Bs as RepeatIcon,li as ResetIcon,da as RobotIcon,Xe as Runtime,Ts as SaveIcon,is as SchoolIcon,qr as SearchIcon,ns as SearchOffIcon,Hi as SendIcon,Ls as SentimentSadIcon,qi as ShareIcon,_s as ShieldCheckIcon,za as ShuffleIcon,ii as SkipIcon,Va as SlideshowIcon,Ur as SortDownIcon,ci as SortIcon,_r as SortUpIcon,ki as SparkIcon,oi as SpeakerIcon,Ws as SpeedIcon,Ra as SpellcheckIcon,qs as StarIcon,mi as StopIcon,Ya as StorageIcon,Fa as StyleIcon,ca as SunIcon,Ns as SunriseIcon,zs as SunsetIcon,Na as SwapIcon,ni as TargetIcon,ia as TempleIcon,ba as TextIcon,Aa as TitleIcon,$i as ToolsIcon,Ha as TouchIcon,Is as TrendingDownIcon,Rs as TrendingUpIcon,sa as TrophyIcon,xa as UnderlineIcon,Ii as UndoIcon,La as UnlockIcon,ps as UploadIcon,zi as UsersIcon,qa as VolumeOffIcon,cs as VolunteerIcon,na as WalletIcon,Ri as WandIcon,es as WifiIcon,ts as WifiOffIcon,Xp as YuktAI,Sn as YuktAIWrapper,hc as YuktaiGrid,An as YuktaiGridAI,ac as YuktaiGridAgent,Kt as YuktaiGridWebMCP,Qr as YuktaiIcon,ws as ZoomInIcon,ks as ZoomOutIcon,Ie as accessibleName,On as addPeriods,At as aggregate,Bt as aiPlugin,Ic as analyzePage,gr as answerGridQuestion,Ue as applyGridFilters,cr as askAboutPage,Tr as askInsight,sr as auditToJSON,ar as auditToMarkdown,Yo as clearFilters,Qo as clearSort,Jc as comparePeriods,cn as contrastRatio,_o as countGrid,lr as createA11yCopilot,hr as createContextIndex,vt as createGridTools,br as createVoiceA11yController,Sn as default,Mn as detectAnomalies,Fc as detectPageIntent,Ke as executeGridQuery,Vo as filterGrid,Pe as findMentionedColumn,Uo as getColumns,jo as getRow,me as getRowId,Vc as gridPassages,Qc as groupBy,kt as highlightRows,Or as iconContrast,Br as iconSvg,_c as moveGridRowFocus,jt as openRow,jc as pagePassages,Fn as parseAmount,ln as parseColor,Xo as parseGridIntent,ft as parseGridQuery,qc as parseVoiceA11yCommand,Wr as pickGlyphColor,zn as planTasks,Cc as readFormFields,Mr as relativeLuminance,Cr as reviewDesign,Rc as reviewForm,Zt as reviewForms,zc as runGridQuery,Ye as runQaAudit,kr as runTasks,qo as searchGrid,Ut as selectRow,Ko as sortGrid,Sr as startOfPeriod,Nn as summarizeRows,tt as toGridToolColumns,en as tokenize,Zc as trend,$p as useAgenticGrid,xc as useGrid,Yt as useYuktaiGridAgent,Ht as voicePlugin,ke as wcag,ke as wcagPlugin};