@yuktishaalaa/yuktai 5.3.0 → 5.3.2
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/README.md +926 -810
- package/dist/chunk-LV252EOY.mjs +1 -0
- package/dist/icons.d.mts +300 -0
- package/dist/icons.d.ts +300 -0
- package/dist/icons.js +1 -0
- package/dist/icons.mjs +1 -0
- package/dist/index.d.mts +3 -34
- package/dist/index.d.ts +3 -34
- package/dist/index.js +69 -69
- package/dist/index.mjs +23 -23
- package/dist/renderer.global.js +8 -8
- package/package.json +120 -105
- package/vanilla/README.md +162 -162
- package/vanilla/index.js +139 -49
- package/vanilla/index.min.js +34 -33
package/vanilla/index.min.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/*! yuktai vanilla 5.
|
|
1
|
+
/*! yuktai vanilla 5.3.0 — accessible data grid, page agents and WCAG tools for plain HTML.
|
|
2
2
|
* No framework, no API keys, runs in the browser. ISC © Sandeep Miriyala, Yuktishaalaa AI Lab.
|
|
3
3
|
* Built from github.com/sandeepmiriyala03/yuktai (vanilla/src + src/agentic, src/grid, src/core). */
|
|
4
|
-
"use strict";(()=>{var Eo=Object.defineProperty;var Lo=(e,t)=>{for(var n in t)Eo(e,n,{get:t[n],enumerable:!0})};var Jn={};Lo(Jn,{AUDIT_RULES:()=>Xe,DEFAULT_A11Y_SETTINGS:()=>rt,FONT_MAX:()=>Kn,FONT_MIN:()=>Un,FONT_STEP:()=>Qt,accessibleName:()=>he,aggregate:()=>qe,analyzePage:()=>Nn,answerGridQuestion:()=>Lt,applyGridFilters:()=>Re,askAboutPage:()=>zt,askInsight:()=>It,auditToJSON:()=>Dt,auditToMarkdown:()=>bt,clearFilters:()=>yn,clearSort:()=>wn,comparePeriods:()=>Rn,contrastRatio:()=>Pt,countGrid:()=>mn,createA11yCopilot:()=>Ot,createContextIndex:()=>qt,createGridTools:()=>Je,createVoiceA11yController:()=>Yt,detectAnomalies:()=>Oe,detectPageIntent:()=>Fn,executeGridQuery:()=>Ee,filterGrid:()=>bn,findMentionedColumn:()=>ge,getColumns:()=>fn,getRow:()=>hn,getRowId:()=>ee,gridPassages:()=>Gn,groupBy:()=>$n,highlightRows:()=>Ye,moveGridRowFocus:()=>Yn,openRow:()=>pt,pagePassages:()=>Pn,parseAmount:()=>gt,parseColor:()=>ft,parseGridQuery:()=>Ie,parseVoiceA11yCommand:()=>Qn,planTasks:()=>mt,readFormFields:()=>Mn,relativeLuminance:()=>Ft,reviewDesign:()=>Bt,reviewForm:()=>In,reviewForms:()=>Ze,runGridQuery:()=>Tn,runQaAudit:()=>be,runTasks:()=>Nt,searchGrid:()=>gn,selectRow:()=>dt,sortGrid:()=>vn,summarizeRows:()=>ze,toGridToolColumns:()=>Me,tokenize:()=>et,trend:()=>En,wcagPlugin:()=>He});var Mo={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 fe(e){return Mo[e.locale??"en"]}function xe(e,t){return{success:!0,message:e,data:t}}function Q(e,t){return{success:!1,message:t,error:{code:e}}}var br=["contains","equals","startsWith","endsWith","greaterThan","lessThan","between"];function ee(e,t="id"){let n=e==null?void 0:e[t];return n==null?"":String(n)}function De(e){return String(e??"").normalize("NFC").toLowerCase().trim()}function yr(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 vr(e){if(e instanceof Date)return e.getTime();let t=new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null}function wr(e){return(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>String(n).trim()).filter(Boolean)}function pn(e,t){let n=De(t);return e.columns.find(r=>De(r.key)===n||De(r.label)===n)}function Rt(e,t){return e.data.find(n=>ee(n,e.rowKey)===t)}function Io(e,t){return e[t]}function No(e,t,n){let r=Io(e,n.key),a=n.type??"text";if(a==="number"||a==="date"){let l=a==="number"?yr:vr,s=l(r);if(s===null)return!1;if(t.operator==="between"){let[p,f]=t.value,b=l(p),d=l(f);return b!==null&&d!==null&&s>=Math.min(b,d)&&s<=Math.max(b,d)}let u=l(t.value);if(u===null)return!1;switch(t.operator){case"equals":return s===u;case"greaterThan":return s>u;case"lessThan":return s<u;default:break}}let i=De(r),o=De(t.value);switch(t.operator){case"equals":return i===o;case"startsWith":return i.startsWith(o);case"endsWith":return i.endsWith(o);case"contains":return i.includes(o);default:return!1}}function Fo(e,t){let n=t.type??"text",r=n==="date"?vr:yr;return e.operator==="between"?n==="text"||!Array.isArray(e.value)||e.value.length!==2?!1:r(e.value[0])!==null&&r(e.value[1])!==null:e.operator==="greaterThan"||e.operator==="lessThan"?n!=="text"&&r(e.value)!==null:!Array.isArray(e.value)&&String(e.value).trim()!==""}function Re(e,t,n){return n.length?xr({data:e,columns:t},n):e}function Me(e){return e.map(t=>({key:String(t.key),label:t.label,type:t.type==="number"?"number":t.type==="date"?"date":"text"}))}function xr(e,t){return e.data.filter(n=>t.every(r=>{let a=pn(e,r.key);return a?No(n,r,a):!0}))}function gn(e,t){var o;let n=fe(e),r=De(t);if(!r)return Q("INVALID_INPUT",n.emptyQuery);let a=e.data.filter(l=>e.columns.some(s=>De(l[s.key]).includes(r))),i=a.map(l=>ee(l,e.rowKey)).filter(Boolean);return(o=e.onHighlightRows)==null||o.call(e,i),xe(n.found(a.length),a)}function mn(e){return xe(fe(e).count(e.data.length),e.data.length)}function fn(e){return xe(fe(e).columns,e.columns)}function hn(e,t){let n=fe(e),r=String(t??"").trim();if(!r)return Q("INVALID_INPUT",n.noIds);let a=Rt(e,r);return a?xe(n.rowFound,a):Q("NOT_FOUND",n.notFound(r))}function Ye(e,t){let n=fe(e),r=wr(t);if(r.length===0)return Q("INVALID_INPUT",n.noIds);if(!e.onHighlightRows)return Q("NOT_SUPPORTED",n.notSupported("highlight"));let a=r.filter(i=>Rt(e,i)!==void 0);return a.length===0?Q("NOT_FOUND",n.noneFound):(e.onHighlightRows(a),xe(n.highlighted(a.length),a))}function dt(e,t){let n=fe(e),r=String(t??"").trim();return r?e.onSelectRow?Rt(e,r)?(e.onSelectRow(r),xe(n.selected(r),r)):Q("NOT_FOUND",n.notFound(r)):Q("NOT_SUPPORTED",n.notSupported("select")):Q("INVALID_INPUT",n.noIds)}function pt(e,t){let n=fe(e),r=String(t??"").trim();return r?e.onOpenRow?Rt(e,r)?(e.onOpenRow(r),xe(n.opened(r),r)):Q("NOT_FOUND",n.notFound(r)):Q("NOT_SUPPORTED",n.notSupported("open")):Q("INVALID_INPUT",n.noIds)}function bn(e,t){let n=fe(e),r=pn(e,(t==null?void 0:t.key)??"");if(!r)return Q("INVALID_INPUT",n.unknownColumn(String((t==null?void 0:t.key)??"")));if(!br.includes(t.operator))return Q("INVALID_INPUT",n.badOperator(String(t.operator)));let a={...t,key:r.key};if(!Fo(a,r))return Q("INVALID_INPUT",n.badValue);if(!e.onFiltersChange)return Q("NOT_SUPPORTED",n.notSupported("filter"));let i=[...(e.filters??[]).filter(l=>l.key!==r.key),a],o=xr(e,i).length;return e.onFiltersChange(i),xe(n.filtered(o),{filters:i,count:o})}function yn(e){let t=fe(e);return e.onFiltersChange?(e.onFiltersChange([]),xe(t.filtersCleared,[])):Q("NOT_SUPPORTED",t.notSupported("clear filters"))}function vn(e,t,n="asc"){let r=fe(e),a=pn(e,t);if(!a)return Q("INVALID_INPUT",r.unknownColumn(String(t)));if(n!=="asc"&&n!=="desc")return Q("INVALID_INPUT",r.badValue);if(!e.onSortChange)return Q("NOT_SUPPORTED",r.notSupported("sort"));let i={key:a.key,direction:n};return e.onSortChange(i),xe(r.sorted(a.label,n),i)}function wn(e){let t=fe(e);return e.onSortChange?(e.onSortChange(null),xe(t.sortCleared,null)):Q("NOT_SUPPORTED",t.notSupported("clear sort"))}var Po={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."},hr={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 Go(e,t){try{return t()}catch{return Q("INTERNAL",fe(e).internal)}}function Je(e,t={}){let n=t.name??"yuktai_grid",r=hr[e.locale??"en"],a=s=>{var u;return((u=t.descriptions)==null?void 0:u[s])??Po[s]},i={id:{type:"string",description:"Row ID"}},o=e.columns.map(s=>s.key);return[{id:"search",available:!0,schema:{type:"object",properties:{query:{type:"string"}},required:["query"]},run:s=>gn(e,String(s.query??""))},{id:"count",available:!0,schema:{type:"object",properties:{}},run:()=>mn(e)},{id:"columns",available:!0,schema:{type:"object",properties:{}},run:()=>fn(e)},{id:"get_row",available:!0,schema:{type:"object",properties:i,required:["id"]},run:s=>hn(e,String(s.id??""))},{id:"highlight",available:!!e.onHighlightRows,schema:{type:"object",properties:{ids:{type:"array",items:{type:"string"},description:"Row IDs"}},required:["ids"]},run:s=>Ye(e,wr(s.ids))},{id:"select",available:!!e.onSelectRow,schema:{type:"object",properties:i,required:["id"]},run:s=>dt(e,String(s.id??""))},{id:"open",available:!!e.onOpenRow,schema:{type:"object",properties:i,required:["id"]},run:s=>pt(e,String(s.id??""))},{id:"filter",available:!!e.onFiltersChange,schema:{type:"object",properties:{key:{type:"string",enum:o},operator:{type:"string",enum:br},value:{description:"Text or number; for 'between' an array of two numbers or dates"}},required:["key","operator","value"]},run:s=>bn(e,{key:String(s.key??""),operator:String(s.operator??""),value:s.value})},{id:"clear_filters",available:!!e.onFiltersChange,schema:{type:"object",properties:{}},run:()=>yn(e)},{id:"sort",available:!!e.onSortChange,schema:{type:"object",properties:{key:{type:"string",enum:o},direction:{type:"string",enum:["asc","desc"]}},required:["key"]},run:s=>vn(e,String(s.key??""),s.direction==="desc"?"desc":"asc")},{id:"clear_sort",available:!!e.onSortChange,schema:{type:"object",properties:{}},run:()=>wn(e)}].filter(s=>s.available).map(s=>({name:`${n}_${s.id}`,title:hr.en[s.id],description:a(s.id),label:r[s.id],inputSchema:s.schema,execute:u=>Go(e,()=>s.run(u??{}))}))}var Se=e=>String(e??"").normalize("NFC").toLowerCase().replace(/\s+/g," ").trim(),Do=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 gt(e){let t=Se(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 r=t[2]??"",a=/^k|thousand/.test(r)?1e3:/^la/.test(r)?1e5:/^(crore|cr)/.test(r)?1e7:/^(m|mn|million)$/.test(r)?1e6:/^(bn|billion)$/.test(r)?1e9:1;return n*a}function Tr(e){let t=new Set([Se(e.label),Se(e.key),Se(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 ge(e,t,n){let r=` ${Se(e)} `,a;for(let i of t)if(!(n&&(i.type??"text")!==n))for(let o of Tr(i)){let l=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${l}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(r)&&(!a||o.length>a.length)&&(a={column:i,length:o.length})}return a==null?void 0:a.column}var Oo=/amount|balance|total|price|salary|value|due|revenue|cost|fee|sales|outstanding|paid/i;function xn(e){let t=e.filter(n=>n.type==="number");return t.find(n=>Oo.test(`${n.key} ${n.label}`))??t[0]}var Et=/(>=|=>|>|\bover\b|\babove\b|\bmore than\b|\bgreater than\b|\bexceeds?\b|\bexceeding\b|\bhigher than\b|\bat least\b|\bminimum\b|\bmin\b|కంటే ఎక్కువ)/,kn=/(<=|=<|<|\bunder\b|\bbelow\b|\bless than\b|\blower than\b|\bat most\b|\bmaximum\b|\bmax\b|\bup to\b|కంటే తక్కువ)/,kr=/\b(after|since|from)\b/,zo=/\b(before|until|till)\b/,qo="(?:\\s*(?:k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion))?",An=`(?:\u20B9|rs\\.?\\s*|\\$)?\\s*-?\\d[\\d,]*(?:\\.\\d+)?${qo}`;function Ie(e,t,n={}){var S;let r={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""},a=Se(e).replace(/[?!]+/g," ").replace(/\.(?!\d)/g," ").trim(),i=[],o=a.match(/\b(top|first|bottom|last|lowest|highest)\s+(\d+)\b/);o&&(r.limit=Number(o[2]),a=a.replace(o[0],` ${o[1]} `));let l=a.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),s=a.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(l){let y=ge(l[1],t);y&&(r.sort={key:y.key,direction:/^desc/.test(l[2]??"")?"desc":"asc"},a=a.replace(l[0]," "))}else if(s){let y=ge(s[2],t,"number")??ge(s[2],t)??xn(t);if(y){let m=/top|highest|largest|biggest|most/.test(s[1]);r.sort={key:y.key,direction:m?"desc":"asc"},a=a.replace(new RegExp(`\\b${s[1]}\\b`)," "),!o&&/top|bottom/.test(s[1])&&(r.limit=10)}}let u=new RegExp(`\\bbetween\\s+(${An}|\\d{4}-\\d{2}-\\d{2})\\s+(?:and|to|-)\\s+(${An}|\\d{4}-\\d{2}-\\d{2})`,"u"),p;for(;p=a.match(u);){let y=a.slice(Math.max(0,(p.index??0)-40),p.index??0),m=/\d{4}-\d{2}-\d{2}/.test(p[1]),C=m?ge(y,t,"date")??t.find(h=>h.type==="date"):ge(y,t,"number")??xn(t),E=m?p[1]:gt(p[1]),k=m?p[2]:gt(p[2]);C&&E!==null&&k!==null&&(r.filters.push({key:C.key,operator:"between",value:[E,k]}),i.push(`${C.label} between ${p[1]} and ${p[2]}`)),a=a.replace(p[0]," ")}let f=a.split(new RegExp("\\s*(?:(?<!\\d),|,(?!\\d)|;|\\band\\b|(?<!(?:starts?|starting|ends?|ending|begins?|beginning)\\s)\\bwith\\b|\\bwhere\\b|\\bwho\\b|\\bthat\\b|&|\u0C2E\u0C30\u0C3F\u0C2F\u0C41)\\s*","u")).map(y=>y.trim()).filter(Boolean),b=t.filter(y=>(y.type??"text")==="text"),d=new Map;for(let y of b){let m=new Set;for(let C of(n.data??[]).slice(0,5e3)){let E=Se(C[y.key]);if(E&&E.length<=40&&m.add(E),m.size>300)break}m.size&&m.size<=300&&d.set(y.key,m)}for(let y of f){let m=r.filters.length,C=ge(y,t),E=y.match(new RegExp(An,"u")),k=y.match(/\d{4}-\d{2}-\d{2}/);if(k&&(kr.test(y)||zo.test(y)||Et.test(y)||kn.test(y))){let h=((C==null?void 0:C.type)==="date"?C:void 0)??t.find(w=>w.type==="date");if(h){let w=kr.test(y)||Et.test(y);r.filters.push({key:h.key,operator:w?"greaterThan":"lessThan",value:k[0]}),i.push(`${h.label} ${w?"after":"before"} ${k[0]}`)}}else if(E&&(Et.test(y)||kn.test(y)||(C==null?void 0:C.type)==="number"&&/\b(is|equals?)\b|=/.test(y))){let h=(C==null?void 0:C.type)==="number"?C:void 0;h||(h=xn(t),h&&r.notes.push(`Assumed "${y}" refers to ${h.label}.`));let w=gt(E[0]);if(h&&w!==null){let v=/at least|minimum|\bmin\b|>=|=>|at most|maximum|\bmax\b|up to|<=|=</.test(y);Et.test(y)?(r.filters.push({key:h.key,operator:"greaterThan",value:v?w-1e-9:w}),i.push(`${h.label} ${v?"\u2265":">"} ${w.toLocaleString("en-IN")}`)):kn.test(y)?(r.filters.push({key:h.key,operator:"lessThan",value:v?w+1e-9:w}),i.push(`${h.label} ${v?"\u2264":"<"} ${w.toLocaleString("en-IN")}`)):(r.filters.push({key:h.key,operator:"equals",value:w}),i.push(`${h.label} = ${w.toLocaleString("en-IN")}`))}}else{let h=y.match(/\b(?:starts?|starting|begins?|beginning)\s+with\s+(.+)$/),w=y.match(/\b(?:ends?|ending)\s+with\s+(.+)$/),v=y.match(/\b(?:contains?|containing|including|includes?|mentions?)\s+(.+)$/),L=y.match(/\b(?:is|equals?|=|:)\s+(.+)$/),x=h??w??v??L;if(x){let $=C??b[0],I=x[1].replace(/^["'“‘]|["'”’]$/g,"").trim();if($&&I){let T=h?"startsWith":w?"endsWith":v?"contains":"equals";r.filters.push({key:$.key,operator:T,value:I}),i.push(`${$.label} ${T==="equals"?"is":T==="contains"?"contains":T==="startsWith"?"starts with":"ends with"} "${I}"`),C||r.notes.push(`Assumed "${y}" refers to ${$.label}.`)}}}if(r.filters.length===m)for(let[h,w]of d){let v="";for(let L of w){if(L.length<2||L.length<=v.length)continue;let x=L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${x}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(y)&&(v=L)}if(v){let L=t.find(x=>x.key===h);r.filters.push({key:h,operator:"equals",value:v}),i.push(`${L.label} is "${v}"`)}}if(r.filters.length===m){let h=y.split(/\s+/).filter(v=>!Do.has(v)&&!/^(top|first|bottom|last|lowest|highest|by|desc|asc|sort(ed)?)$/.test(v)),w=h.length>0&&h.every(v=>t.some(L=>Tr(L).includes(v)));if(h.length&&!w&&!(C&&h.length===1)){let v=h.join(" ");/^(customers?|users?|people|items?|entries|poems?|orders?|products?|employees?|students?|members?)$/.test(v)||(r.search.push(v),i.push(`any column contains "${v}"`))}}}if(r.sort){let y=((S=t.find(m=>m.key===r.sort.key))==null?void 0:S.label)??r.sort.key;i.push(`sorted by ${y} ${r.sort.direction==="desc"?"high \u2192 low":"low \u2192 high"}`)}return r.limit&&i.push(`first ${r.limit}`),r.explanation=i.length?`Showing rows where ${i.join(", ")}.`:"No conditions understood \u2014 showing all rows.",r}function Bo(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 Ee(e,t,n){let r=Re(e,t,n.filters);for(let a of n.search)r=r.filter(i=>t.some(o=>Se(i[o.key]).includes(a)));if(n.sort){let a=t.find(o=>o.key===n.sort.key),i=n.sort.direction==="desc"?-1:1;r=[...r].sort((o,l)=>i*Bo(o[n.sort.key],l[n.sort.key],a==null?void 0:a.type))}return n.limit&&(r=r.slice(0,n.limit)),r}function Tn(e,t,n={}){var l,s,u;let r=Ie(e,t.columns,{data:t.data}),a=Ee(t.data,t.columns,r),i=a.map(p=>ee(p,t.rowKey)).filter(Boolean);n.apply!==!1&&(r.filters.length&&((l=t.onFiltersChange)==null||l.call(t,r.filters)),r.sort&&((s=t.onSortChange)==null||s.call(t,r.sort)),i.length&&((u=t.onHighlightRows)==null||u.call(t,i)));let o=a.length?`${a.length} row(s) found. ${r.explanation}${r.notes.length?` (${r.notes.join(" ")})`:""}`:`No rows match. ${r.explanation}`;return{rows:a,ids:i,parsed:r,message:o}}function Ar(e,t){let n=(e.length-1)*t,r=Math.floor(n),a=n-r;return e[r+1]!==void 0?e[r]+a*(e[r+1]-e[r]):e[r]}function Oe(e,t,n={}){let r=n.factor??1.5,a=[],i=t.filter(u=>u.type==="number"&&(!n.columns||n.columns.includes(u.key))),o=u=>u.toLocaleString("en-IN",{maximumFractionDigits:2});for(let u of i){let p=e.map(C=>Number(C[u.key])).filter(C=>Number.isFinite(C));if(p.length<5)continue;let f=[...p].sort((C,E)=>C-E),b=Ar(f,.25),d=Ar(f,.75),S=d-b;if(S===0)continue;let y=b-r*S,m=d+r*S;for(let C of e){let E=Number(C[u.key]);!Number.isFinite(E)||E>=y&&E<=m||a.push({rowId:ee(C,n.rowKey),column:u.key,label:u.label,value:E,kind:E>m?"high":"low",reason:`${u.label} ${o(E)} is far ${E>m?"above":"below"} the typical range (${o(b)}\u2013${o(d)}).`})}}let l=n.rowKey??"id",s=new Map;for(let u of e){let p=JSON.stringify(t.filter(d=>d.key!==l).map(d=>Se(u[d.key]))),f=ee(u,n.rowKey),b=s.get(p);b!==void 0?a.push({rowId:f,column:l,label:"Row",value:f,kind:"duplicate",reason:`Row ${f} has the same values as row ${b}.`}):s.set(p,f)}return a}function ze(e,t){if(!e.length)return"No rows to summarise.";let n=[`${e.length} row(s).`],r=a=>a.toLocaleString("en-IN",{maximumFractionDigits:2});for(let a of t){let i=e.map(o=>o[a.key]);if(a.type==="number"){let o=i.map(Number).filter(Number.isFinite);if(!o.length)continue;let l=o.reduce((s,u)=>s+u,0);n.push(`${a.label}: total ${r(l)}, average ${r(l/o.length)}, range ${r(Math.min(...o))}\u2013${r(Math.max(...o))}.`)}else if(a.type==="date"){let o=i.map(s=>new Date(String(s)).getTime()).filter(Number.isFinite);if(!o.length)continue;let l=s=>new Date(s).toISOString().slice(0,10);n.push(`${a.label}: from ${l(Math.min(...o))} to ${l(Math.max(...o))}.`)}else{let o=new Map;for(let s of i){let u=String(s??"").trim();u&&o.set(u,(o.get(u)??0)+1)}if(o.size===0||o.size>Math.max(8,e.length/3))continue;let l=Array.from(o.entries()).sort((s,u)=>u[1]-s[1]).slice(0,4);n.push(`${a.label}: ${l.map(([s,u])=>`${s} (${u})`).join(", ")}.`)}}return n.join(`
|
|
5
|
-
`)}function
|
|
4
|
+
"use strict";(()=>{var Go=Object.defineProperty;var Oo=(e,t)=>{for(var n in t)Go(e,n,{get:t[n],enumerable:!0})};var er={};Oo(er,{AUDIT_RULES:()=>tt,DEFAULT_A11Y_SETTINGS:()=>at,FONT_MAX:()=>Jn,FONT_MIN:()=>Yn,FONT_STEP:()=>Jt,accessibleName:()=>he,aggregate:()=>He,analyzePage:()=>Gn,answerGridQuestion:()=>Nt,applyGridFilters:()=>Re,askAboutPage:()=>Ht,askInsight:()=>Pt,auditToJSON:()=>zt,auditToMarkdown:()=>wt,clearFilters:()=>xn,clearSort:()=>An,comparePeriods:()=>Ln,contrastRatio:()=>et,countGrid:()=>bn,createA11yCopilot:()=>qt,createContextIndex:()=>Bt,createGridTools:()=>Ze,createVoiceA11yController:()=>Xt,detectAnomalies:()=>ze,detectPageIntent:()=>On,executeGridQuery:()=>Me,filterGrid:()=>wn,findMentionedColumn:()=>ge,getColumns:()=>yn,getRow:()=>vn,getRowId:()=>ee,gridPassages:()=>zn,groupBy:()=>En,highlightRows:()=>Xe,moveGridRowFocus:()=>Zn,openRow:()=>ht,pagePassages:()=>Dn,parseAmount:()=>bt,parseColor:()=>Ne,parseGridQuery:()=>Ie,parseVoiceA11yCommand:()=>Xn,planTasks:()=>yt,readFormFields:()=>Fn,relativeLuminance:()=>Ot,reviewDesign:()=>_t,reviewForm:()=>Pn,reviewForms:()=>nt,runGridQuery:()=>$n,runQaAudit:()=>be,runTasks:()=>Gt,searchGrid:()=>hn,selectRow:()=>ft,sortGrid:()=>kn,summarizeRows:()=>qe,toGridToolColumns:()=>Le,tokenize:()=>rt,trend:()=>In,wcagPlugin:()=>_e});var Do={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 fe(e){return Do[e.locale??"en"]}function xe(e,t){return{success:!0,message:e,data:t}}function Q(e,t){return{success:!1,message:t,error:{code:e}}}var xr=["contains","equals","startsWith","endsWith","greaterThan","lessThan","between"];function ee(e,t="id"){let n=e==null?void 0:e[t];return n==null?"":String(n)}function De(e){return String(e??"").normalize("NFC").toLowerCase().trim()}function kr(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 Ar(e){if(e instanceof Date)return e.getTime();let t=new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null}function Tr(e){return(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>String(n).trim()).filter(Boolean)}function fn(e,t){let n=De(t);return e.columns.find(r=>De(r.key)===n||De(r.label)===n)}function Lt(e,t){return e.data.find(n=>ee(n,e.rowKey)===t)}function zo(e,t){return e[t]}function qo(e,t,n){let r=zo(e,n.key),a=n.type??"text";if(a==="number"||a==="date"){let l=a==="number"?kr:Ar,s=l(r);if(s===null)return!1;if(t.operator==="between"){let[p,f]=t.value,b=l(p),d=l(f);return b!==null&&d!==null&&s>=Math.min(b,d)&&s<=Math.max(b,d)}let u=l(t.value);if(u===null)return!1;switch(t.operator){case"equals":return s===u;case"greaterThan":return s>u;case"lessThan":return s<u;default:break}}let i=De(r),o=De(t.value);switch(t.operator){case"equals":return i===o;case"startsWith":return i.startsWith(o);case"endsWith":return i.endsWith(o);case"contains":return i.includes(o);default:return!1}}function Ho(e,t){let n=t.type??"text",r=n==="date"?Ar:kr;return e.operator==="between"?n==="text"||!Array.isArray(e.value)||e.value.length!==2?!1:r(e.value[0])!==null&&r(e.value[1])!==null:e.operator==="greaterThan"||e.operator==="lessThan"?n!=="text"&&r(e.value)!==null:!Array.isArray(e.value)&&String(e.value).trim()!==""}function Re(e,t,n){return n.length?Sr({data:e,columns:t},n):e}function Le(e){return e.map(t=>({key:String(t.key),label:t.label,type:t.type==="number"?"number":t.type==="date"?"date":"text"}))}function Sr(e,t){return e.data.filter(n=>t.every(r=>{let a=fn(e,r.key);return a?qo(n,r,a):!0}))}function hn(e,t){var o;let n=fe(e),r=De(t);if(!r)return Q("INVALID_INPUT",n.emptyQuery);let a=e.data.filter(l=>e.columns.some(s=>De(l[s.key]).includes(r))),i=a.map(l=>ee(l,e.rowKey)).filter(Boolean);return(o=e.onHighlightRows)==null||o.call(e,i),xe(n.found(a.length),a)}function bn(e){return xe(fe(e).count(e.data.length),e.data.length)}function yn(e){return xe(fe(e).columns,e.columns)}function vn(e,t){let n=fe(e),r=String(t??"").trim();if(!r)return Q("INVALID_INPUT",n.noIds);let a=Lt(e,r);return a?xe(n.rowFound,a):Q("NOT_FOUND",n.notFound(r))}function Xe(e,t){let n=fe(e),r=Tr(t);if(r.length===0)return Q("INVALID_INPUT",n.noIds);if(!e.onHighlightRows)return Q("NOT_SUPPORTED",n.notSupported("highlight"));let a=r.filter(i=>Lt(e,i)!==void 0);return a.length===0?Q("NOT_FOUND",n.noneFound):(e.onHighlightRows(a),xe(n.highlighted(a.length),a))}function ft(e,t){let n=fe(e),r=String(t??"").trim();return r?e.onSelectRow?Lt(e,r)?(e.onSelectRow(r),xe(n.selected(r),r)):Q("NOT_FOUND",n.notFound(r)):Q("NOT_SUPPORTED",n.notSupported("select")):Q("INVALID_INPUT",n.noIds)}function ht(e,t){let n=fe(e),r=String(t??"").trim();return r?e.onOpenRow?Lt(e,r)?(e.onOpenRow(r),xe(n.opened(r),r)):Q("NOT_FOUND",n.notFound(r)):Q("NOT_SUPPORTED",n.notSupported("open")):Q("INVALID_INPUT",n.noIds)}function wn(e,t){let n=fe(e),r=fn(e,(t==null?void 0:t.key)??"");if(!r)return Q("INVALID_INPUT",n.unknownColumn(String((t==null?void 0:t.key)??"")));if(!xr.includes(t.operator))return Q("INVALID_INPUT",n.badOperator(String(t.operator)));let a={...t,key:r.key};if(!Ho(a,r))return Q("INVALID_INPUT",n.badValue);if(!e.onFiltersChange)return Q("NOT_SUPPORTED",n.notSupported("filter"));let i=[...(e.filters??[]).filter(l=>l.key!==r.key),a],o=Sr(e,i).length;return e.onFiltersChange(i),xe(n.filtered(o),{filters:i,count:o})}function xn(e){let t=fe(e);return e.onFiltersChange?(e.onFiltersChange([]),xe(t.filtersCleared,[])):Q("NOT_SUPPORTED",t.notSupported("clear filters"))}function kn(e,t,n="asc"){let r=fe(e),a=fn(e,t);if(!a)return Q("INVALID_INPUT",r.unknownColumn(String(t)));if(n!=="asc"&&n!=="desc")return Q("INVALID_INPUT",r.badValue);if(!e.onSortChange)return Q("NOT_SUPPORTED",r.notSupported("sort"));let i={key:a.key,direction:n};return e.onSortChange(i),xe(r.sorted(a.label,n),i)}function An(e){let t=fe(e);return e.onSortChange?(e.onSortChange(null),xe(t.sortCleared,null)):Q("NOT_SUPPORTED",t.notSupported("clear sort"))}var Bo={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."},wr={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 _o(e,t){try{return t()}catch{return Q("INTERNAL",fe(e).internal)}}function Ze(e,t={}){let n=t.name??"yuktai_grid",r=wr[e.locale??"en"],a=s=>{var u;return((u=t.descriptions)==null?void 0:u[s])??Bo[s]},i={id:{type:"string",description:"Row ID"}},o=e.columns.map(s=>s.key);return[{id:"search",available:!0,schema:{type:"object",properties:{query:{type:"string"}},required:["query"]},run:s=>hn(e,String(s.query??""))},{id:"count",available:!0,schema:{type:"object",properties:{}},run:()=>bn(e)},{id:"columns",available:!0,schema:{type:"object",properties:{}},run:()=>yn(e)},{id:"get_row",available:!0,schema:{type:"object",properties:i,required:["id"]},run:s=>vn(e,String(s.id??""))},{id:"highlight",available:!!e.onHighlightRows,schema:{type:"object",properties:{ids:{type:"array",items:{type:"string"},description:"Row IDs"}},required:["ids"]},run:s=>Xe(e,Tr(s.ids))},{id:"select",available:!!e.onSelectRow,schema:{type:"object",properties:i,required:["id"]},run:s=>ft(e,String(s.id??""))},{id:"open",available:!!e.onOpenRow,schema:{type:"object",properties:i,required:["id"]},run:s=>ht(e,String(s.id??""))},{id:"filter",available:!!e.onFiltersChange,schema:{type:"object",properties:{key:{type:"string",enum:o},operator:{type:"string",enum:xr},value:{description:"Text or number; for 'between' an array of two numbers or dates"}},required:["key","operator","value"]},run:s=>wn(e,{key:String(s.key??""),operator:String(s.operator??""),value:s.value})},{id:"clear_filters",available:!!e.onFiltersChange,schema:{type:"object",properties:{}},run:()=>xn(e)},{id:"sort",available:!!e.onSortChange,schema:{type:"object",properties:{key:{type:"string",enum:o},direction:{type:"string",enum:["asc","desc"]}},required:["key"]},run:s=>kn(e,String(s.key??""),s.direction==="desc"?"desc":"asc")},{id:"clear_sort",available:!!e.onSortChange,schema:{type:"object",properties:{}},run:()=>An(e)}].filter(s=>s.available).map(s=>({name:`${n}_${s.id}`,title:wr.en[s.id],description:a(s.id),label:r[s.id],inputSchema:s.schema,execute:u=>_o(e,()=>s.run(u??{}))}))}var Se=e=>String(e??"").normalize("NFC").toLowerCase().replace(/\s+/g," ").trim(),Vo=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 bt(e){let t=Se(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 r=t[2]??"",a=/^k|thousand/.test(r)?1e3:/^la/.test(r)?1e5:/^(crore|cr)/.test(r)?1e7:/^(m|mn|million)$/.test(r)?1e6:/^(bn|billion)$/.test(r)?1e9:1;return n*a}function Rr(e){let t=new Set([Se(e.label),Se(e.key),Se(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 ge(e,t,n){let r=` ${Se(e)} `,a;for(let i of t)if(!(n&&(i.type??"text")!==n))for(let o of Rr(i)){let l=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${l}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(r)&&(!a||o.length>a.length)&&(a={column:i,length:o.length})}return a==null?void 0:a.column}var Wo=/amount|balance|total|price|salary|value|due|revenue|cost|fee|sales|outstanding|paid/i;function Tn(e){let t=e.filter(n=>n.type==="number");return t.find(n=>Wo.test(`${n.key} ${n.label}`))??t[0]}var It=/(>=|=>|>|\bover\b|\babove\b|\bmore than\b|\bgreater than\b|\bexceeds?\b|\bexceeding\b|\bhigher than\b|\bat least\b|\bminimum\b|\bmin\b|కంటే ఎక్కువ)/,Sn=/(<=|=<|<|\bunder\b|\bbelow\b|\bless than\b|\blower than\b|\bat most\b|\bmaximum\b|\bmax\b|\bup to\b|కంటే తక్కువ)/,Cr=/\b(after|since|from)\b/,jo=/\b(before|until|till)\b/,Uo="(?:\\s*(?:k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion))?",Cn=`(?:\u20B9|rs\\.?\\s*|\\$)?\\s*-?\\d[\\d,]*(?:\\.\\d+)?${Uo}`;function Ie(e,t,n={}){var S;let r={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""},a=Se(e).replace(/[?!]+/g," ").replace(/\.(?!\d)/g," ").trim(),i=[],o=a.match(/\b(top|first|bottom|last|lowest|highest)\s+(\d+)\b/);o&&(r.limit=Number(o[2]),a=a.replace(o[0],` ${o[1]} `));let l=a.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),s=a.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(l){let y=ge(l[1],t);y&&(r.sort={key:y.key,direction:/^desc/.test(l[2]??"")?"desc":"asc"},a=a.replace(l[0]," "))}else if(s){let y=ge(s[2],t,"number")??ge(s[2],t)??Tn(t);if(y){let m=/top|highest|largest|biggest|most/.test(s[1]);r.sort={key:y.key,direction:m?"desc":"asc"},a=a.replace(new RegExp(`\\b${s[1]}\\b`)," "),!o&&/top|bottom/.test(s[1])&&(r.limit=10)}}let u=new RegExp(`\\bbetween\\s+(${Cn}|\\d{4}-\\d{2}-\\d{2})\\s+(?:and|to|-)\\s+(${Cn}|\\d{4}-\\d{2}-\\d{2})`,"u"),p;for(;p=a.match(u);){let y=a.slice(Math.max(0,(p.index??0)-40),p.index??0),m=/\d{4}-\d{2}-\d{2}/.test(p[1]),C=m?ge(y,t,"date")??t.find(h=>h.type==="date"):ge(y,t,"number")??Tn(t),M=m?p[1]:bt(p[1]),k=m?p[2]:bt(p[2]);C&&M!==null&&k!==null&&(r.filters.push({key:C.key,operator:"between",value:[M,k]}),i.push(`${C.label} between ${p[1]} and ${p[2]}`)),a=a.replace(p[0]," ")}let f=a.split(new RegExp("\\s*(?:(?<!\\d),|,(?!\\d)|;|\\band\\b|(?<!(?:starts?|starting|ends?|ending|begins?|beginning)\\s)\\bwith\\b|\\bwhere\\b|\\bwho\\b|\\bthat\\b|&|\u0C2E\u0C30\u0C3F\u0C2F\u0C41)\\s*","u")).map(y=>y.trim()).filter(Boolean),b=t.filter(y=>(y.type??"text")==="text"),d=new Map;for(let y of b){let m=new Set;for(let C of(n.data??[]).slice(0,5e3)){let M=Se(C[y.key]);if(M&&M.length<=40&&m.add(M),m.size>300)break}m.size&&m.size<=300&&d.set(y.key,m)}for(let y of f){let m=r.filters.length,C=ge(y,t),M=y.match(new RegExp(Cn,"u")),k=y.match(/\d{4}-\d{2}-\d{2}/);if(k&&(Cr.test(y)||jo.test(y)||It.test(y)||Sn.test(y))){let h=((C==null?void 0:C.type)==="date"?C:void 0)??t.find(w=>w.type==="date");if(h){let w=Cr.test(y)||It.test(y);r.filters.push({key:h.key,operator:w?"greaterThan":"lessThan",value:k[0]}),i.push(`${h.label} ${w?"after":"before"} ${k[0]}`)}}else if(M&&(It.test(y)||Sn.test(y)||(C==null?void 0:C.type)==="number"&&/\b(is|equals?)\b|=/.test(y))){let h=(C==null?void 0:C.type)==="number"?C:void 0;h||(h=Tn(t),h&&r.notes.push(`Assumed "${y}" refers to ${h.label}.`));let w=bt(M[0]);if(h&&w!==null){let v=/at least|minimum|\bmin\b|>=|=>|at most|maximum|\bmax\b|up to|<=|=</.test(y);It.test(y)?(r.filters.push({key:h.key,operator:"greaterThan",value:v?w-1e-9:w}),i.push(`${h.label} ${v?"\u2265":">"} ${w.toLocaleString("en-IN")}`)):Sn.test(y)?(r.filters.push({key:h.key,operator:"lessThan",value:v?w+1e-9:w}),i.push(`${h.label} ${v?"\u2264":"<"} ${w.toLocaleString("en-IN")}`)):(r.filters.push({key:h.key,operator:"equals",value:w}),i.push(`${h.label} = ${w.toLocaleString("en-IN")}`))}}else{let h=y.match(/\b(?:starts?|starting|begins?|beginning)\s+with\s+(.+)$/),w=y.match(/\b(?:ends?|ending)\s+with\s+(.+)$/),v=y.match(/\b(?:contains?|containing|including|includes?|mentions?)\s+(.+)$/),E=y.match(/\b(?:is|equals?|=|:)\s+(.+)$/),x=h??w??v??E;if(x){let $=C??b[0],I=x[1].replace(/^["'“‘]|["'”’]$/g,"").trim();if($&&I){let T=h?"startsWith":w?"endsWith":v?"contains":"equals";r.filters.push({key:$.key,operator:T,value:I}),i.push(`${$.label} ${T==="equals"?"is":T==="contains"?"contains":T==="startsWith"?"starts with":"ends with"} "${I}"`),C||r.notes.push(`Assumed "${y}" refers to ${$.label}.`)}}}if(r.filters.length===m)for(let[h,w]of d){let v="";for(let E of w){if(E.length<2||E.length<=v.length)continue;let x=E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${x}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(y)&&(v=E)}if(v){let E=t.find(x=>x.key===h);r.filters.push({key:h,operator:"equals",value:v}),i.push(`${E.label} is "${v}"`)}}if(r.filters.length===m){let h=y.split(/\s+/).filter(v=>!Vo.has(v)&&!/^(top|first|bottom|last|lowest|highest|by|desc|asc|sort(ed)?)$/.test(v)),w=h.length>0&&h.every(v=>t.some(E=>Rr(E).includes(v)));if(h.length&&!w&&!(C&&h.length===1)){let v=h.join(" ");/^(customers?|users?|people|items?|entries|poems?|orders?|products?|employees?|students?|members?)$/.test(v)||(r.search.push(v),i.push(`any column contains "${v}"`))}}}if(r.sort){let y=((S=t.find(m=>m.key===r.sort.key))==null?void 0:S.label)??r.sort.key;i.push(`sorted by ${y} ${r.sort.direction==="desc"?"high \u2192 low":"low \u2192 high"}`)}return r.limit&&i.push(`first ${r.limit}`),r.explanation=i.length?`Showing rows where ${i.join(", ")}.`:"No conditions understood \u2014 showing all rows.",r}function Ko(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 Me(e,t,n){let r=Re(e,t,n.filters);for(let a of n.search)r=r.filter(i=>t.some(o=>Se(i[o.key]).includes(a)));if(n.sort){let a=t.find(o=>o.key===n.sort.key),i=n.sort.direction==="desc"?-1:1;r=[...r].sort((o,l)=>i*Ko(o[n.sort.key],l[n.sort.key],a==null?void 0:a.type))}return n.limit&&(r=r.slice(0,n.limit)),r}function $n(e,t,n={}){var l,s,u;let r=Ie(e,t.columns,{data:t.data}),a=Me(t.data,t.columns,r),i=a.map(p=>ee(p,t.rowKey)).filter(Boolean);n.apply!==!1&&(r.filters.length&&((l=t.onFiltersChange)==null||l.call(t,r.filters)),r.sort&&((s=t.onSortChange)==null||s.call(t,r.sort)),i.length&&((u=t.onHighlightRows)==null||u.call(t,i)));let o=a.length?`${a.length} row(s) found. ${r.explanation}${r.notes.length?` (${r.notes.join(" ")})`:""}`:`No rows match. ${r.explanation}`;return{rows:a,ids:i,parsed:r,message:o}}function $r(e,t){let n=(e.length-1)*t,r=Math.floor(n),a=n-r;return e[r+1]!==void 0?e[r]+a*(e[r+1]-e[r]):e[r]}function ze(e,t,n={}){let r=n.factor??1.5,a=[],i=t.filter(u=>u.type==="number"&&(!n.columns||n.columns.includes(u.key))),o=u=>u.toLocaleString("en-IN",{maximumFractionDigits:2});for(let u of i){let p=e.map(C=>Number(C[u.key])).filter(C=>Number.isFinite(C));if(p.length<5)continue;let f=[...p].sort((C,M)=>C-M),b=$r(f,.25),d=$r(f,.75),S=d-b;if(S===0)continue;let y=b-r*S,m=d+r*S;for(let C of e){let M=Number(C[u.key]);!Number.isFinite(M)||M>=y&&M<=m||a.push({rowId:ee(C,n.rowKey),column:u.key,label:u.label,value:M,kind:M>m?"high":"low",reason:`${u.label} ${o(M)} is far ${M>m?"above":"below"} the typical range (${o(b)}\u2013${o(d)}).`})}}let l=n.rowKey??"id",s=new Map;for(let u of e){let p=JSON.stringify(t.filter(d=>d.key!==l).map(d=>Se(u[d.key]))),f=ee(u,n.rowKey),b=s.get(p);b!==void 0?a.push({rowId:f,column:l,label:"Row",value:f,kind:"duplicate",reason:`Row ${f} has the same values as row ${b}.`}):s.set(p,f)}return a}function qe(e,t){if(!e.length)return"No rows to summarise.";let n=[`${e.length} row(s).`],r=a=>a.toLocaleString("en-IN",{maximumFractionDigits:2});for(let a of t){let i=e.map(o=>o[a.key]);if(a.type==="number"){let o=i.map(Number).filter(Number.isFinite);if(!o.length)continue;let l=o.reduce((s,u)=>s+u,0);n.push(`${a.label}: total ${r(l)}, average ${r(l/o.length)}, range ${r(Math.min(...o))}\u2013${r(Math.max(...o))}.`)}else if(a.type==="date"){let o=i.map(s=>new Date(String(s)).getTime()).filter(Number.isFinite);if(!o.length)continue;let l=s=>new Date(s).toISOString().slice(0,10);n.push(`${a.label}: from ${l(Math.min(...o))} to ${l(Math.max(...o))}.`)}else{let o=new Map;for(let s of i){let u=String(s??"").trim();u&&o.set(u,(o.get(u)??0)+1)}if(o.size===0||o.size>Math.max(8,e.length/3))continue;let l=Array.from(o.entries()).sort((s,u)=>u[1]-s[1]).slice(0,4);n.push(`${a.label}: ${l.map(([s,u])=>`${s} (${u})`).join(", ")}.`)}}return n.join(`
|
|
5
|
+
`)}function Nt(e,t){var a;let n=Se(e);if(/unusual|anomal|outlier|odd|strange|suspicious|duplicate|అసాధారణ/.test(n)){let i=ze(t.data,t.columns,{rowKey:t.rowKey}),o=Array.from(new Set(i.map(s=>s.rowId)));o.length&&((a=t.onHighlightRows)==null||a.call(t,o));let l=new Set(o);return{kind:"anomalies",message:i.length?`${o.length} unusual row(s):
|
|
6
6
|
${i.slice(0,10).map(s=>`\u2022 ${s.reason}`).join(`
|
|
7
|
-
`)}`:"Nothing unusual found.",ids:o,rows:t.data.filter(s=>l.has(ee(s,t.rowKey))),anomalies:i}}if(/summar|overview|describe|సారాంశం/.test(n)){let i=Re(t.data,t.columns,t.filters??[]);return{kind:"summary",message:ze(i,t.columns),ids:[],rows:i}}let r=Tn(e,t);return{kind:"query",message:r.message,ids:r.ids,rows:r.rows}}var Mt=e=>{let t=typeof e=="number"?e:Number(String(e??"").replace(/[,₹$%\s]/g,""));return Number.isFinite(t)?t:null},Sr=e=>{let t=e instanceof Date?e.getTime():new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null};function qe(e,t){if(t==="count")return e.length;if(!e.length)return 0;switch(t){case"sum":return e.reduce((n,r)=>n+r,0);case"avg":return e.reduce((n,r)=>n+r,0)/e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function $n(e,t,n,r="sum"){let a=new Map;for(let i of e){let o=String(i[t]??"\u2014").trim()||"\u2014",l=a.get(o)??[];if(n===null||r==="count")l.push(1);else{let s=Mt(i[n]);s!==null&&l.push(s)}a.set(o,l)}return Array.from(a.entries()).map(([i,o])=>({group:i,value:qe(o,r),count:o.length})).sort((i,o)=>o.value-i.value)}function Cr(e,t,n=1){let r=new Date(e);return r.setHours(0,0,0,0),t==="week"&&r.setDate(r.getDate()-(r.getDay()-n+7)%7),t==="month"&&r.setDate(1),t==="quarter"&&r.setMonth(Math.floor(r.getMonth()/3)*3,1),t==="year"&&r.setMonth(0,1),r}function Cn(e,t,n){let r=new Date(e);return t==="day"&&r.setDate(r.getDate()+n),t==="week"&&r.setDate(r.getDate()+7*n),t==="month"&&r.setMonth(r.getMonth()+n),t==="quarter"&&r.setMonth(r.getMonth()+3*n),t==="year"&&r.setFullYear(r.getFullYear()+n),r}function Rn(e,t){let n=t.referenceDate?new Date(t.referenceDate):new Date,r=Cr(n,t.period,t.weekStartsOn),a=t.toDate===!1?Cn(r,t.period,1):new Date(Math.max(n.getTime()+1,r.getTime()+1)),i=Cn(r,t.period,-1),o=t.toDate===!1?r:new Date(i.getTime()+(a.getTime()-r.getTime())),l=t.agg??"sum",s=new Map,u=new Map;for(let b of e){let d=Sr(b[t.dateKey]);if(d===null)continue;let S=d>=r.getTime()&&d<a.getTime()?s:d>=i.getTime()&&d<o.getTime()?u:null;if(!S)continue;let y=t.groupKey?String(b[t.groupKey]??"\u2014"):"All",m=l==="count"?1:Mt(b[t.metricKey]);m!==null&&S.set(y,[...S.get(y)??[],m])}let p=new Set([...s.keys(),...u.keys()]),f=Array.from(p).map(b=>{let d=qe(s.get(b)??[],l),S=qe(u.get(b)??[],l);return{group:b,current:d,previous:S,change:d-S,changePct:S===0?null:(d-S)/Math.abs(S)*100}});return{period:t.period,current:{from:r,to:a},previous:{from:i,to:o},rows:f}}function En(e,t,n,r,a="sum"){let i=new Map;for(let o of e){let l=Sr(o[t]),s=a==="count"?1:Mt(o[n]);if(l===null||s===null)continue;let u=Cr(new Date(l),r).getTime();i.set(u,[...i.get(u)??[],s])}return Array.from(i.entries()).sort((o,l)=>o[0]-l[0]).map(([o,l])=>({start:new Date(o),value:qe(l,a)}))}var Ho=/rate|conversion|ratio|percent|%|score|rating|margin|ctr|avg|average/i;function _o(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 ae=e=>e.toLocaleString("en-IN",{maximumFractionDigits:2}),Sn=e=>e===null?"new":`${e>0?"+":""}${e.toFixed(1)}%`;function It(e,t,n,r={}){var k;let a=e.toLowerCase(),i=n.filter(h=>h.type==="number"),o=ge(a,n,"number")??i.find(h=>/amount|revenue|sales|total|value/i.test(`${h.key} ${h.label}`))??i[0],l=n.find(h=>h.type==="date")??n.find(h=>/date|time|day|created|month/i.test(`${h.key} ${h.label}`)),s=((k=a.match(/\b(?:which|by|per|each|across|every|top|for each)\s+([\p{L}\p{M}\p{N} _]+)/u))==null?void 0:k[1])??"",u=ge(s,n,"text"),p=/how many|number of|count/.test(a),f=p?"count":/average|avg|mean/.test(a)?"avg":/\btotal\b|\bsum\b/.test(a)?"sum":o&&Ho.test(`${o.key} ${o.label}`)?"avg":"sum",b=/drop|decline|decrease|fell|fall|down|worst|lost|shrink|reduc/.test(a),d=/increase|growth|grew|rise|rose|up\b|best|improv|gain/.test(a),S=/lowest|least|smallest|bottom|worst|minimum/.test(a),y=_o(a);if(!o&&!p)return{kind:"unknown",answer:"I couldn't find a numeric column to analyse.",table:[]};let m=p?"rows":o.label;if(y&&l&&(d||b||/change|compare|vs|versus/.test(a))){let h=r.referenceDate?new Date(r.referenceDate):new Date,w=y.shift?Cn(h,y.period,y.shift):h,L=[...Rn(t,{dateKey:l.key,metricKey:(o==null?void 0:o.key)??l.key,groupKey:u==null?void 0:u.key,agg:f,period:y.period,referenceDate:w,toDate:y.shift===0}).rows].sort((F,B)=>b?F.change-B.change:B.change-F.change),x=L.map(F=>({[(u==null?void 0:u.label)??"Group"]:F.group,Current:ae(F.current),Previous:ae(F.previous),Change:ae(F.change),"Change %":Sn(F.changePct)}));if(!L.length)return{kind:"period-change",answer:`No ${m} data in this ${y.period} or the one before.`,table:x};let $=L[0],I=`${y.shift?"last":"this"} ${y.period} vs the ${y.period} before`,T=$.change===0?"did not change":$.change<0?`dropped ${ae(Math.abs($.change))}`:`rose ${ae($.change)}`,R=`${m} ${T} (${ae($.previous)} \u2192 ${ae($.current)}, ${Sn($.changePct)}) \u2014 ${I}.`,G=b&&$.change>=0||d&&$.change<=0;return{kind:"period-change",answer:u?G?`No ${u.label.toLowerCase()} ${b?"dropped":"grew"}. Closest is ${$.group}: ${R}`:`${$.group}: ${R}`:R,table:x}}if(/trend|over time|month by month|week by week/.test(a)&&l&&o){let h=/week/.test(a)?"week":/day|daily/.test(a)?"day":/year/.test(a)?"year":"month",w=En(t,l.key,o.key,h,f),v=w.map(I=>({Period:I.start.toISOString().slice(0,10),[o.label]:ae(I.value)}));if(w.length<2)return{kind:"trend",answer:`Not enough ${h}s of data for a trend.`,table:v};let L=w[0].value,x=w[w.length-1].value,$=w.reduce((I,T)=>T.value>I.value?T:I);return{kind:"trend",answer:`${o.label} went from ${ae(L)} to ${ae(x)} over ${w.length} ${h}s (${Sn(L?(x-L)/Math.abs(L)*100:null)}). Peak: ${ae($.value)} in the ${h} of ${$.start.toISOString().slice(0,10)}.`,table:v}}if(u){let h=$n(t,u.key,(o==null?void 0:o.key)??null,f),w=S?[...h].reverse():h,v=w.map(x=>({[u.label]:x.group,[`${f} of ${m}`]:ae(x.value),Rows:x.count}));if(!w.length)return{kind:"group",answer:"No data.",table:v};let L=w[0];return{kind:"group",answer:`${L.group} has the ${S?"lowest":"highest"} ${f==="sum"?"total":f==="avg"?"average":f} ${m}: ${ae(L.value)} (across ${w.length} ${u.label.toLowerCase()} groups).`,table:v}}let C=p?t.map(()=>1):t.map(h=>Mt(h[o.key])).filter(h=>h!==null),E=qe(C,f);return{kind:"total",answer:`${f==="avg"?"Average":f==="count"?"Count of":f==="sum"?"Total":f} ${m}: ${ae(E)} across ${t.length} row(s).`,table:[{Metric:m,Aggregation:f,Value:ae(E)}]}}var Er="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 mt(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(r=>r.split(new RegExp(`\\s*(?:,|\\band\\b)\\s+(?=(?:${Er})\\b)`,"i"))).map(r=>r.trim()).filter(r=>r.length>1).map(r=>({action:Vo(r),text:r}))}function Vo(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 jo(e){return e.replace(new RegExp(`^\\s*(?:${Er}|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 $r(e,t){var i;let n=((i=t.find(o=>o.key===e.key))==null?void 0:i.label)??e.key,r=Array.isArray(e.value)?`${e.value[0]}\u2013${e.value[1]}`:typeof e.value=="number"?e.value.toLocaleString("en-IN",{maximumFractionDigits:2}):`"${e.value}"`,a={contains:"contains",equals:"is",startsWith:"starts with",endsWith:"ends with",greaterThan:">",lessThan:"<",between:"between"}[e.operator];return`${n} ${a} ${r}`}async function Nt(e,t,n={}){var y,m,C,E,k,h,w,v,L;let r=mt(e),{columns:a,data:i}=t,o=[...t.filters??[]],l=[],s=null,u=[],p=()=>Ee(i,a,{filters:o,search:l,sort:s,limit:null,notes:[],explanation:""}),f={rows:p().length,filters:[...o]},b=[],d=()=>({...t,filters:o});for(let x=0;x<r.length;x++){let $=r[x],I=jo($.text),T;try{switch($.action){case"clear":{o=[],l=[],s=null,u=[],(y=t.onFiltersChange)==null||y.call(t,[]),(m=t.onSortChange)==null||m.call(t,null),(C=t.onHighlightRows)==null||C.call(t,[]),T={...$,success:!0,message:`Cleared filters, sorting and highlights. ${i.length} row(s) shown.`};break}case"filter":{let R=Ie(I,a,{data:i});if(!R.filters.length&&!R.search.length&&!R.sort){T={...$,success:!0,message:`Showing ${p().length} row(s) with the current filters.`};break}for(let F of R.filters)o=[...o.filter(B=>B.key!==F.key),F];l=[...l,...R.search],R.sort&&(s=R.sort,(E=t.onSortChange)==null||E.call(t,s)),(k=t.onFiltersChange)==null||k.call(t,o);let G=p(),N=G.map(F=>ee(F,t.rowKey)).filter(Boolean);R.search.length&&N.length&&(u=N,(h=t.onHighlightRows)==null||h.call(t,N)),T={...$,success:!0,message:`${G.length} row(s) now shown. ${R.explanation}`,ids:N};break}case"highlight":{let R=p(),G=Ie(I,a,{data:R}),F=(G.filters.length||G.search.length?Ee(R,a,{...G,sort:null,limit:G.limit}):R).map(pe=>ee(pe,t.rowKey)).filter(Boolean);if(!F.length){T={...$,success:!1,message:`Nothing to highlight for "${I||"all rows"}".`};break}let B=Ye(d(),F);B.success&&(u=B.data??F),T={...$,success:B.success,message:B.success?`Highlighted ${u.length} row(s)${I?` matching "${I}"`:""}.`:B.message,ids:u};break}case"sort":{let G=Ie($.text,a,{data:i}).sort;if(!G){let F=ge(I,a);F&&(G={key:F.key,direction:/desc|high|large|big|most|newest|latest|z.?to.?a/i.test($.text)?"desc":"asc"})}if(!G){T={...$,success:!1,message:`Which column should I sort by? Columns: ${a.map(F=>F.label).join(", ")}.`};break}s=G,(w=t.onSortChange)==null||w.call(t,s);let N=((v=a.find(F=>F.key===s.key))==null?void 0:v.label)??s.key;T={...$,success:!0,message:`Sorted by ${N} (${s.direction==="desc"?"high \u2192 low":"low \u2192 high"}).`};break}case"count":{T={...$,success:!0,message:`${p().length} row(s) shown${u.length?`, ${u.length} highlighted`:""}.`};break}case"anomalies":{let R=p(),G=Oe(R,a,{rowKey:t.rowKey}),N=Array.from(new Set(G.map(F=>F.rowId)));if(N.length){let F=Ye(d(),N);F.success&&(u=F.data??N)}T={...$,success:!0,message:G.length?`${N.length} unusual row(s): ${G.slice(0,5).map(F=>F.reason).join(" ")}`:"Nothing unusual in the shown rows.",ids:N};break}case"open":case"select":{let R=p(),N=R.find(pe=>I&&ee(pe,t.rowKey).toLowerCase()===I.toLowerCase())??Ee(R,a,Ie(I,a,{data:R}))[0]??(I?void 0:R[0]);if(!N){T={...$,success:!1,message:`No row matches "${I}".`};break}let F=ee(N,t.rowKey),B=$.action==="open"?pt(d(),F):dt(d(),F);T={...$,success:B.success,message:B.message,ids:[F]};break}case"summarize":{let R=p();T={...$,success:!0,message:`${Rr(f,R.length,o,s,u,a)}
|
|
8
|
-
${ze(R,a)}`};break}}}catch(R){T={...$,success:!1,message:`This step failed: ${R instanceof Error?R.message:String(R)}`}}b.push(T),(L=n.onStep)==null||L.call(n,T,x,r.length)}let S=p().length;return{steps:b,before:f,after:{rows:S,filters:o,sort:s,highlighted:u},summary:Rr(f,S,o,s,u,a)}}function Rr(e,t,n,r,a,i){var u;let o=[`Rows: ${e.rows} \u2192 ${t}.`],l=n.filter(p=>!e.filters.some(f=>JSON.stringify(f)===JSON.stringify(p))),s=e.filters.filter(p=>!n.some(f=>JSON.stringify(p)===JSON.stringify(f)));return l.length&&o.push(`Filters added: ${l.map(p=>$r(p,i)).join("; ")}.`),s.length&&o.push(`Filters removed: ${s.map(p=>$r(p,i)).join("; ")}.`),r&&o.push(`Sorted by ${((u=i.find(p=>p.key===r.key))==null?void 0:u.label)??r.key} ${r.direction==="desc"?"high \u2192 low":"low \u2192 high"}.`),a.length&&o.push(`${a.length} row(s) highlighted.`),o.join(" ")}var Wo="[data-yuktai-panel]";function ke(){return typeof window<"u"&&typeof document<"u"}function Be(e){return typeof e=="object"&&e!==null&&e.nodeType===9}function me(e){return e||(ke()?document:null)}function z(e,t,n={}){return Array.from(e.querySelectorAll(t)).filter(r=>!r.closest(Wo)&&(n.includeHidden||Uo(r)))}function Uo(e){if(!ke()||e.closest("[hidden],[aria-hidden='true']"))return!1;let t=e;for(;t;){let n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden")return!1;t=t.parentElement}return!0}function te(e){return(e??"").replace(/\s+/g," ").trim()}function ne(e,t=60){let n=te(e);return n.length>t?`${n.slice(0,t-1)}\u2026`:n}function Ce(e){let t=[],n=e;for(;n&&n.nodeType===1&&t.length<4;){let r=n.tagName.toLowerCase();if(n.id&&/^[A-Za-z][\w-]*$/.test(n.id)){t.unshift(`${r}#${n.id}`);break}let a=n.parentElement;if(!a){t.unshift(r);break}let i=Array.from(a.children).filter(o=>o.tagName===n.tagName);t.unshift(i.length>1?`${r}:nth-of-type(${i.indexOf(n)+1})`:r),n=a}return t.join(" > ")}function Ko(e,t){return e.split(/\s+/).map(n=>{var r;return te((r=t.getElementById(n))==null?void 0:r.textContent)}).filter(Boolean).join(" ")}function he(e){let t=e.ownerDocument,n=e.getAttribute("aria-labelledby");if(n){let i=Ko(n,t);if(i)return i}let r=te(e.getAttribute("aria-label"));if(r)return r;let a=e.tagName.toLowerCase();if(a==="input"||a==="select"||a==="textarea"){let i=e.getAttribute("id");if(i){let s=t.querySelector(`label[for="${Qo(i)}"]`),u=te(s==null?void 0:s.textContent);if(u)return u}let o=e.closest("label");if(o){let s=te(o.textContent);if(s)return s}let l=(e.getAttribute("type")??"").toLowerCase();if(l==="submit"||l==="button"||l==="reset")return te(e.getAttribute("value"))||(l==="submit"?"Submit":"");if(l==="image")return te(e.getAttribute("alt"))}if(a==="img")return te(e.getAttribute("alt"));if(a==="button"||a==="a"||e.getAttribute("role")){let i=te(e.textContent);if(i)return i;let o=Array.from(e.querySelectorAll("img[alt], svg[aria-label]")).map(l=>te(l.getAttribute("alt")??l.getAttribute("aria-label"))).filter(Boolean).join(" ");if(o)return o}return te(e.getAttribute("title"))}function Qo(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function ft(e){if(!e)return null;let t=e.trim().toLowerCase();if(t==="transparent")return{r:0,g:0,b:0,a:0};let n=t.match(/^rgba?\(([^)]+)\)$/);if(n){let a=n[1].split(/[\s,/]+/).filter(Boolean),[i,o,l]=a.slice(0,3).map(Number),s=a[3],u=s===void 0?1:s.endsWith("%")?Number(s.slice(0,-1))/100:Number(s);return[i,o,l,u].some(p=>!Number.isFinite(p))?null:{r:i,g:o,b:l,a:u}}let r=t.match(/^#([0-9a-f]{3,8})$/);if(r){let a=r[1];return(a.length===3||a.length===4)&&(a=a.split("").map(i=>i+i).join("")),a.length!==6&&a.length!==8?null:{r:parseInt(a.slice(0,2),16),g:parseInt(a.slice(2,4),16),b:parseInt(a.slice(4,6),16),a:a.length===8?parseInt(a.slice(6,8),16)/255:1}}return null}function Ln(e,t){let n=e.a+t.a*(1-e.a);if(n===0)return{r:0,g:0,b:0,a:0};let r=(a,i)=>(a*e.a+i*t.a*(1-e.a))/n;return{r:r(e.r,t.r),g:r(e.g,t.g),b:r(e.b,t.b),a:n}}function Ft(e){let t=n=>{let r=n/255;return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function Pt(e,t){let n=t.a<1?Ln(t,{r:255,g:255,b:255,a:1}):t,r=e.a<1?Ln(e,n):e,a=Ft(r),i=Ft(n),[o,l]=a>i?[a,i]:[i,a];return Math.round((o+.05)/(l+.05)*100)/100}function Lr(e){let t=[],n=e;for(;n;){let a=window.getComputedStyle(n);if(a.backgroundImage&&a.backgroundImage!=="none")return null;let i=ft(a.backgroundColor);if(i&&i.a>0&&(t.push(i),i.a>=1))break;n=n.parentElement}let r={r:255,g:255,b:255,a:1};for(let a=t.length-1;a>=0;a--)r=Ln(t[a],r);return r}function Mr(e){let t=window.getComputedStyle(e),n=parseFloat(t.fontSize)||16,r=parseInt(t.fontWeight,10)||400;return n>=24||n>=18.66&&r>=700}function ht(e){return Array.from(e.childNodes).some(t=>t.nodeType===3&&te(t.textContent).length>0)}var Ir="a[href],button,input:not([type='hidden']),select,textarea,summary,[tabindex]:not([tabindex='-1']),[contenteditable='true']",Gt="a[href],button,input:not([type='hidden']),select,textarea,summary,[role='button'],[role='link'],[role='checkbox'],[role='tab'],[role='menuitem']";var Xe={"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."}},Yo={critical:10,serious:5,moderate:2,minor:1};function be(e={}){let t=me(e.root),n=new Set(e.skip??[]),r=[],a={},i=t?Be(t)?t:t.ownerDocument:null,o=(l,s,u,p,f=!1)=>{if(n.has(l))return;let b=Xe[l],d=a[l]=(a[l]??0)+1;r.push({id:`${l}-${d}`,rule:l,severity:b.severity,wcag:b.wcag,message:u,why:b.why,fix:p,selector:s?Ce(s):"document",snippet:s?ne(s.outerHTML,120):"",autoFixable:f,element:s??void 0})};if(t&&i){i.documentElement.getAttribute("lang")||o("html-lang",i.documentElement,"The <html> element has no lang attribute.",'Add lang to <html>, e.g. <html lang="te"> or "en".',!0),i.title.trim()||o("page-title",null,"The page has no <title>.","Add a short, descriptive <title> that names this page.");for(let m of z(t,"img"))if(!(m.getAttribute("role")==="presentation"||m.getAttribute("role")==="none")&&!m.hasAttribute("alt")&&!m.getAttribute("aria-label")&&!m.getAttribute("aria-labelledby")){let C=m.getAttribute("title");o("image-alt",m,`Image has no alt text${m.getAttribute("src")?` (${ne(m.getAttribute("src")??"",40)})`:""}.`,C?`Use the title as alt: alt="${ne(C,40)}".`:'Describe the image in alt, or use alt="" if it is purely decorative.',!!C)}let l=z(t,"h1,h2,h3,h4,h5,h6"),s=0;for(let m of l){let C=Number(m.tagName[1]);s>0&&C>s+1&&o("heading-order",m,`Heading jumps from h${s} to h${C}: "${ne(m.textContent??"",40)}".`,`Change it to h${s+1}, or add the missing level above it.`),s=C}let u=l.filter(m=>m.tagName==="H1");u.length===0?o("single-h1",null,"The page has no h1.","Add one h1 that names the page."):u.length>1&&o("single-h1",u[1],`The page has ${u.length} h1 headings.`,"Keep one h1; turn the others into h2."),t.querySelectorAll("main,[role='main']").length===0&&o("landmark-main",null,"No <main> landmark found.","Wrap the primary content in <main>.");let p=z(t,"input,select,textarea").filter(m=>{let C=(m.getAttribute("type")??"text").toLowerCase();return!["hidden","submit","button","reset","image"].includes(C)});for(let m of p){if(!he(m)){let C=m.getAttribute("placeholder")||m.getAttribute("name");o("form-label",m,`Form field has no label${C?` (placeholder/name: "${ne(C,30)}")`:""}.`,C?`Add a visible <label>. Quick fix: aria-label="${ne(C,30)}".`:"Add a visible <label for=\u2026> describing what to enter.",!!C)}m.getAttribute("aria-invalid")==="true"&&(m.getAttribute("aria-describedby")||m.getAttribute("aria-errormessage")||o("form-error",m,"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 m of z(t,"button,[role='button'],input[type='submit'],input[type='button']"))if(!he(m)){let C=m.getAttribute("title");o("button-name",m,"Button has no accessible name.",C?`Use the title as the name: aria-label="${C}".`:"Add visible text or an aria-label that says what the button does.",!!C)}for(let m of z(t,"a[href]"))if(!he(m)){let C=m.getAttribute("title");o("link-name",m,`Link has no text (${ne(m.getAttribute("href")??"",40)}).`,C?`Use the title as the name: aria-label="${C}".`:"Add link text that says where it goes.",!!C)}for(let m of z(t,"[tabindex]"))Number(m.getAttribute("tabindex"))>0&&o("positive-tabindex",m,`tabindex="${m.getAttribute("tabindex")}" overrides the natural tab order.`,'Use tabindex="0" and fix the order in the HTML instead.',!0);let f="a[href],button,input,select,textarea,summary";for(let m of z(t,"[onclick],[role='button'],[role='link']"))m.matches(f)||m.hasAttribute("tabindex")||o("keyboard-access",m,`<${m.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 b=new Map;for(let m of Array.from(t.querySelectorAll("[id]")))m.closest("[data-yuktai-panel]")||b.set(m.id,(b.get(m.id)??0)+1);for(let[m,C]of b)C>1&&o("duplicate-id",t.querySelector(`[id="${m.replace(/"/g,'\\"')}"]`),`id="${m}" is used ${C} times.`,"Give each element a unique id.");let d=e.maxContrastChecks??600,S=0;for(let m of z(t,"body *")){if(S>=d)break;if(!ht(m)||["SCRIPT","STYLE","NOSCRIPT","OPTION"].includes(m.tagName))continue;S++;let C=ft(window.getComputedStyle(m).color),E=Lr(m);if(!C||!E)continue;let k=Pt(C,E),h=Mr(m)?3:4.5;k<h&&o("color-contrast",m,`Contrast ${k}:1 is below ${h}:1 for "${ne(m.textContent??"",30)}".`,`Darken the text or lighten the background until the ratio is at least ${h}:1.`)}let y=e.minTargetSize??24;for(let m of z(t,Gt)){let C=m.getBoundingClientRect();C.width===0&&C.height===0||m.tagName==="A"&&m.closest("p,li,td")||(C.width<y||C.height<y)&&o("target-size",m,`Target is ${Math.round(C.width)}\xD7${Math.round(C.height)}px (minimum ${y}\xD7${y}).`,`Increase padding so it's at least ${y}\xD7${y}px (44\xD744 is better for seniors).`)}}return Jo(r,i,n)}function Jo(e,t,n){var s;let r=Object.keys(Xe).filter(u=>!n.has(u)).map(u=>{let p=e.filter(f=>f.rule===u).length;return{rule:u,title:Xe[u].title,passed:p===0,issueCount:p}}),a=0;for(let u of r){let p=Yo[Xe[u.rule].severity];a+=Math.min(25,u.issueCount*p)}let i=Math.max(0,100-a),o=r.filter(u=>!u.passed),l=e.filter(u=>u.severity==="critical").length;return{url:((s=t==null?void 0:t.location)==null?void 0:s.href)??"",title:(t==null?void 0:t.title)??"",generatedAt:new Date().toISOString(),score:i,passed:l===0&&i>=80,checks:r,issues:e,summary:e.length===0?`All ${r.length} checks passed.`:`${r.length-o.length} of ${r.length} checks passed. ${e.length} issue(s) found, ${l} critical. Score ${i}/100.`}}function bt(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(`
|
|
9
|
-
`)}function
|
|
10
|
-
`):`No issue "${b}" in the current report. Run a scan first.`},applyFix(b){let d=s(b);if(!d)return{issueId:b,applied:!1,message:"Issue not found. Run a scan first."};a=!0;let S=p(d);return a=!1,S.applied&&f(),S},applyAllFixes(){t||f(),a=!0;let b=((t==null?void 0:t.issues)??[]).filter(d=>d.autoFixable).map(p);return a=!1,f(),b},undoAll(){let b=i.length;for(a=!0;i.length;){let d=i.pop();d.listener?d.element.removeEventListener("keydown",d.listener):d.previous===null?d.element.removeAttribute(d.attribute):d.element.setAttribute(d.attribute,d.previous)}return a=!1,f(),b},getState:o}}var
|
|
7
|
+
`)}`:"Nothing unusual found.",ids:o,rows:t.data.filter(s=>l.has(ee(s,t.rowKey))),anomalies:i}}if(/summar|overview|describe|సారాంశం/.test(n)){let i=Re(t.data,t.columns,t.filters??[]);return{kind:"summary",message:qe(i,t.columns),ids:[],rows:i}}let r=$n(e,t);return{kind:"query",message:r.message,ids:r.ids,rows:r.rows}}var Ft=e=>{let t=typeof e=="number"?e:Number(String(e??"").replace(/[,₹$%\s]/g,""));return Number.isFinite(t)?t:null},Mr=e=>{let t=e instanceof Date?e.getTime():new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null};function He(e,t){if(t==="count")return e.length;if(!e.length)return 0;switch(t){case"sum":return e.reduce((n,r)=>n+r,0);case"avg":return e.reduce((n,r)=>n+r,0)/e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function En(e,t,n,r="sum"){let a=new Map;for(let i of e){let o=String(i[t]??"\u2014").trim()||"\u2014",l=a.get(o)??[];if(n===null||r==="count")l.push(1);else{let s=Ft(i[n]);s!==null&&l.push(s)}a.set(o,l)}return Array.from(a.entries()).map(([i,o])=>({group:i,value:He(o,r),count:o.length})).sort((i,o)=>o.value-i.value)}function Er(e,t,n=1){let r=new Date(e);return r.setHours(0,0,0,0),t==="week"&&r.setDate(r.getDate()-(r.getDay()-n+7)%7),t==="month"&&r.setDate(1),t==="quarter"&&r.setMonth(Math.floor(r.getMonth()/3)*3,1),t==="year"&&r.setMonth(0,1),r}function Mn(e,t,n){let r=new Date(e);return t==="day"&&r.setDate(r.getDate()+n),t==="week"&&r.setDate(r.getDate()+7*n),t==="month"&&r.setMonth(r.getMonth()+n),t==="quarter"&&r.setMonth(r.getMonth()+3*n),t==="year"&&r.setFullYear(r.getFullYear()+n),r}function Ln(e,t){let n=t.referenceDate?new Date(t.referenceDate):new Date,r=Er(n,t.period,t.weekStartsOn),a=t.toDate===!1?Mn(r,t.period,1):new Date(Math.max(n.getTime()+1,r.getTime()+1)),i=Mn(r,t.period,-1),o=t.toDate===!1?r:new Date(i.getTime()+(a.getTime()-r.getTime())),l=t.agg??"sum",s=new Map,u=new Map;for(let b of e){let d=Mr(b[t.dateKey]);if(d===null)continue;let S=d>=r.getTime()&&d<a.getTime()?s:d>=i.getTime()&&d<o.getTime()?u:null;if(!S)continue;let y=t.groupKey?String(b[t.groupKey]??"\u2014"):"All",m=l==="count"?1:Ft(b[t.metricKey]);m!==null&&S.set(y,[...S.get(y)??[],m])}let p=new Set([...s.keys(),...u.keys()]),f=Array.from(p).map(b=>{let d=He(s.get(b)??[],l),S=He(u.get(b)??[],l);return{group:b,current:d,previous:S,change:d-S,changePct:S===0?null:(d-S)/Math.abs(S)*100}});return{period:t.period,current:{from:r,to:a},previous:{from:i,to:o},rows:f}}function In(e,t,n,r,a="sum"){let i=new Map;for(let o of e){let l=Mr(o[t]),s=a==="count"?1:Ft(o[n]);if(l===null||s===null)continue;let u=Er(new Date(l),r).getTime();i.set(u,[...i.get(u)??[],s])}return Array.from(i.entries()).sort((o,l)=>o[0]-l[0]).map(([o,l])=>({start:new Date(o),value:He(l,a)}))}var Qo=/rate|conversion|ratio|percent|%|score|rating|margin|ctr|avg|average/i;function Yo(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 ae=e=>e.toLocaleString("en-IN",{maximumFractionDigits:2}),Rn=e=>e===null?"new":`${e>0?"+":""}${e.toFixed(1)}%`;function Pt(e,t,n,r={}){var k;let a=e.toLowerCase(),i=n.filter(h=>h.type==="number"),o=ge(a,n,"number")??i.find(h=>/amount|revenue|sales|total|value/i.test(`${h.key} ${h.label}`))??i[0],l=n.find(h=>h.type==="date")??n.find(h=>/date|time|day|created|month/i.test(`${h.key} ${h.label}`)),s=((k=a.match(/\b(?:which|by|per|each|across|every|top|for each)\s+([\p{L}\p{M}\p{N} _]+)/u))==null?void 0:k[1])??"",u=ge(s,n,"text"),p=/how many|number of|count/.test(a),f=p?"count":/average|avg|mean/.test(a)?"avg":/\btotal\b|\bsum\b/.test(a)?"sum":o&&Qo.test(`${o.key} ${o.label}`)?"avg":"sum",b=/drop|decline|decrease|fell|fall|down|worst|lost|shrink|reduc/.test(a),d=/increase|growth|grew|rise|rose|up\b|best|improv|gain/.test(a),S=/lowest|least|smallest|bottom|worst|minimum/.test(a),y=Yo(a);if(!o&&!p)return{kind:"unknown",answer:"I couldn't find a numeric column to analyse.",table:[]};let m=p?"rows":o.label;if(y&&l&&(d||b||/change|compare|vs|versus/.test(a))){let h=r.referenceDate?new Date(r.referenceDate):new Date,w=y.shift?Mn(h,y.period,y.shift):h,E=[...Ln(t,{dateKey:l.key,metricKey:(o==null?void 0:o.key)??l.key,groupKey:u==null?void 0:u.key,agg:f,period:y.period,referenceDate:w,toDate:y.shift===0}).rows].sort((F,H)=>b?F.change-H.change:H.change-F.change),x=E.map(F=>({[(u==null?void 0:u.label)??"Group"]:F.group,Current:ae(F.current),Previous:ae(F.previous),Change:ae(F.change),"Change %":Rn(F.changePct)}));if(!E.length)return{kind:"period-change",answer:`No ${m} data in this ${y.period} or the one before.`,table:x};let $=E[0],I=`${y.shift?"last":"this"} ${y.period} vs the ${y.period} before`,T=$.change===0?"did not change":$.change<0?`dropped ${ae(Math.abs($.change))}`:`rose ${ae($.change)}`,R=`${m} ${T} (${ae($.previous)} \u2192 ${ae($.current)}, ${Rn($.changePct)}) \u2014 ${I}.`,G=b&&$.change>=0||d&&$.change<=0;return{kind:"period-change",answer:u?G?`No ${u.label.toLowerCase()} ${b?"dropped":"grew"}. Closest is ${$.group}: ${R}`:`${$.group}: ${R}`:R,table:x}}if(/trend|over time|month by month|week by week/.test(a)&&l&&o){let h=/week/.test(a)?"week":/day|daily/.test(a)?"day":/year/.test(a)?"year":"month",w=In(t,l.key,o.key,h,f),v=w.map(I=>({Period:I.start.toISOString().slice(0,10),[o.label]:ae(I.value)}));if(w.length<2)return{kind:"trend",answer:`Not enough ${h}s of data for a trend.`,table:v};let E=w[0].value,x=w[w.length-1].value,$=w.reduce((I,T)=>T.value>I.value?T:I);return{kind:"trend",answer:`${o.label} went from ${ae(E)} to ${ae(x)} over ${w.length} ${h}s (${Rn(E?(x-E)/Math.abs(E)*100:null)}). Peak: ${ae($.value)} in the ${h} of ${$.start.toISOString().slice(0,10)}.`,table:v}}if(u){let h=En(t,u.key,(o==null?void 0:o.key)??null,f),w=S?[...h].reverse():h,v=w.map(x=>({[u.label]:x.group,[`${f} of ${m}`]:ae(x.value),Rows:x.count}));if(!w.length)return{kind:"group",answer:"No data.",table:v};let E=w[0];return{kind:"group",answer:`${E.group} has the ${S?"lowest":"highest"} ${f==="sum"?"total":f==="avg"?"average":f} ${m}: ${ae(E.value)} (across ${w.length} ${u.label.toLowerCase()} groups).`,table:v}}let C=p?t.map(()=>1):t.map(h=>Ft(h[o.key])).filter(h=>h!==null),M=He(C,f);return{kind:"total",answer:`${f==="avg"?"Average":f==="count"?"Count of":f==="sum"?"Total":f} ${m}: ${ae(M)} across ${t.length} row(s).`,table:[{Metric:m,Aggregation:f,Value:ae(M)}]}}var Nr="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 yt(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(r=>r.split(new RegExp(`\\s*(?:,|\\band\\b)\\s+(?=(?:${Nr})\\b)`,"i"))).map(r=>r.trim()).filter(r=>r.length>1).map(r=>({action:Jo(r),text:r}))}function Jo(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 Xo(e){return e.replace(new RegExp(`^\\s*(?:${Nr}|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 Lr(e,t){var i;let n=((i=t.find(o=>o.key===e.key))==null?void 0:i.label)??e.key,r=Array.isArray(e.value)?`${e.value[0]}\u2013${e.value[1]}`:typeof e.value=="number"?e.value.toLocaleString("en-IN",{maximumFractionDigits:2}):`"${e.value}"`,a={contains:"contains",equals:"is",startsWith:"starts with",endsWith:"ends with",greaterThan:">",lessThan:"<",between:"between"}[e.operator];return`${n} ${a} ${r}`}async function Gt(e,t,n={}){var y,m,C,M,k,h,w,v,E;let r=yt(e),{columns:a,data:i}=t,o=[...t.filters??[]],l=[],s=null,u=[],p=()=>Me(i,a,{filters:o,search:l,sort:s,limit:null,notes:[],explanation:""}),f={rows:p().length,filters:[...o]},b=[],d=()=>({...t,filters:o});for(let x=0;x<r.length;x++){let $=r[x],I=Xo($.text),T;try{switch($.action){case"clear":{o=[],l=[],s=null,u=[],(y=t.onFiltersChange)==null||y.call(t,[]),(m=t.onSortChange)==null||m.call(t,null),(C=t.onHighlightRows)==null||C.call(t,[]),T={...$,success:!0,message:`Cleared filters, sorting and highlights. ${i.length} row(s) shown.`};break}case"filter":{let R=Ie(I,a,{data:i});if(!R.filters.length&&!R.search.length&&!R.sort){T={...$,success:!0,message:`Showing ${p().length} row(s) with the current filters.`};break}for(let F of R.filters)o=[...o.filter(H=>H.key!==F.key),F];l=[...l,...R.search],R.sort&&(s=R.sort,(M=t.onSortChange)==null||M.call(t,s)),(k=t.onFiltersChange)==null||k.call(t,o);let G=p(),N=G.map(F=>ee(F,t.rowKey)).filter(Boolean);R.search.length&&N.length&&(u=N,(h=t.onHighlightRows)==null||h.call(t,N)),T={...$,success:!0,message:`${G.length} row(s) now shown. ${R.explanation}`,ids:N};break}case"highlight":{let R=p(),G=Ie(I,a,{data:R}),F=(G.filters.length||G.search.length?Me(R,a,{...G,sort:null,limit:G.limit}):R).map(pe=>ee(pe,t.rowKey)).filter(Boolean);if(!F.length){T={...$,success:!1,message:`Nothing to highlight for "${I||"all rows"}".`};break}let H=Xe(d(),F);H.success&&(u=H.data??F),T={...$,success:H.success,message:H.success?`Highlighted ${u.length} row(s)${I?` matching "${I}"`:""}.`:H.message,ids:u};break}case"sort":{let G=Ie($.text,a,{data:i}).sort;if(!G){let F=ge(I,a);F&&(G={key:F.key,direction:/desc|high|large|big|most|newest|latest|z.?to.?a/i.test($.text)?"desc":"asc"})}if(!G){T={...$,success:!1,message:`Which column should I sort by? Columns: ${a.map(F=>F.label).join(", ")}.`};break}s=G,(w=t.onSortChange)==null||w.call(t,s);let N=((v=a.find(F=>F.key===s.key))==null?void 0:v.label)??s.key;T={...$,success:!0,message:`Sorted by ${N} (${s.direction==="desc"?"high \u2192 low":"low \u2192 high"}).`};break}case"count":{T={...$,success:!0,message:`${p().length} row(s) shown${u.length?`, ${u.length} highlighted`:""}.`};break}case"anomalies":{let R=p(),G=ze(R,a,{rowKey:t.rowKey}),N=Array.from(new Set(G.map(F=>F.rowId)));if(N.length){let F=Xe(d(),N);F.success&&(u=F.data??N)}T={...$,success:!0,message:G.length?`${N.length} unusual row(s): ${G.slice(0,5).map(F=>F.reason).join(" ")}`:"Nothing unusual in the shown rows.",ids:N};break}case"open":case"select":{let R=p(),N=R.find(pe=>I&&ee(pe,t.rowKey).toLowerCase()===I.toLowerCase())??Me(R,a,Ie(I,a,{data:R}))[0]??(I?void 0:R[0]);if(!N){T={...$,success:!1,message:`No row matches "${I}".`};break}let F=ee(N,t.rowKey),H=$.action==="open"?ht(d(),F):ft(d(),F);T={...$,success:H.success,message:H.message,ids:[F]};break}case"summarize":{let R=p();T={...$,success:!0,message:`${Ir(f,R.length,o,s,u,a)}
|
|
8
|
+
${qe(R,a)}`};break}}}catch(R){T={...$,success:!1,message:`This step failed: ${R instanceof Error?R.message:String(R)}`}}b.push(T),(E=n.onStep)==null||E.call(n,T,x,r.length)}let S=p().length;return{steps:b,before:f,after:{rows:S,filters:o,sort:s,highlighted:u},summary:Ir(f,S,o,s,u,a)}}function Ir(e,t,n,r,a,i){var u;let o=[`Rows: ${e.rows} \u2192 ${t}.`],l=n.filter(p=>!e.filters.some(f=>JSON.stringify(f)===JSON.stringify(p))),s=e.filters.filter(p=>!n.some(f=>JSON.stringify(p)===JSON.stringify(f)));return l.length&&o.push(`Filters added: ${l.map(p=>Lr(p,i)).join("; ")}.`),s.length&&o.push(`Filters removed: ${s.map(p=>Lr(p,i)).join("; ")}.`),r&&o.push(`Sorted by ${((u=i.find(p=>p.key===r.key))==null?void 0:u.label)??r.key} ${r.direction==="desc"?"high \u2192 low":"low \u2192 high"}.`),a.length&&o.push(`${a.length} row(s) highlighted.`),o.join(" ")}var Zo="[data-yuktai-panel]";function ke(){return typeof window<"u"&&typeof document<"u"}function Be(e){return typeof e=="object"&&e!==null&&e.nodeType===9}function me(e){return e||(ke()?document:null)}function z(e,t,n={}){return Array.from(e.querySelectorAll(t)).filter(r=>!r.closest(Zo)&&(n.includeHidden||ei(r)))}function ei(e){if(!ke()||e.closest("[hidden],[aria-hidden='true']"))return!1;let t=e;for(;t;){let n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden")return!1;t=t.parentElement}return!0}function te(e){return(e??"").replace(/\s+/g," ").trim()}function ne(e,t=60){let n=te(e);return n.length>t?`${n.slice(0,t-1)}\u2026`:n}function Ce(e){let t=[],n=e;for(;n&&n.nodeType===1&&t.length<4;){let r=n.tagName.toLowerCase();if(n.id&&/^[A-Za-z][\w-]*$/.test(n.id)){t.unshift(`${r}#${n.id}`);break}let a=n.parentElement;if(!a){t.unshift(r);break}let i=Array.from(a.children).filter(o=>o.tagName===n.tagName);t.unshift(i.length>1?`${r}:nth-of-type(${i.indexOf(n)+1})`:r),n=a}return t.join(" > ")}function ti(e,t){return e.split(/\s+/).map(n=>{var r;return te((r=t.getElementById(n))==null?void 0:r.textContent)}).filter(Boolean).join(" ")}function he(e){let t=e.ownerDocument,n=e.getAttribute("aria-labelledby");if(n){let i=ti(n,t);if(i)return i}let r=te(e.getAttribute("aria-label"));if(r)return r;let a=e.tagName.toLowerCase();if(a==="input"||a==="select"||a==="textarea"){let i=e.getAttribute("id");if(i){let s=t.querySelector(`label[for="${ni(i)}"]`),u=te(s==null?void 0:s.textContent);if(u)return u}let o=e.closest("label");if(o){let s=te(o.textContent);if(s)return s}let l=(e.getAttribute("type")??"").toLowerCase();if(l==="submit"||l==="button"||l==="reset")return te(e.getAttribute("value"))||(l==="submit"?"Submit":"");if(l==="image")return te(e.getAttribute("alt"))}if(a==="img")return te(e.getAttribute("alt"));if(a==="button"||a==="a"||e.getAttribute("role")){let i=te(e.textContent);if(i)return i;let o=Array.from(e.querySelectorAll("img[alt], svg[aria-label]")).map(l=>te(l.getAttribute("alt")??l.getAttribute("aria-label"))).filter(Boolean).join(" ");if(o)return o}return te(e.getAttribute("title"))}function ni(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Ne(e){if(!e)return null;let t=e.trim().toLowerCase();if(t==="transparent")return{r:0,g:0,b:0,a:0};let n=t.match(/^rgba?\(([^)]+)\)$/);if(n){let a=n[1].split(/[\s,/]+/).filter(Boolean),[i,o,l]=a.slice(0,3).map(Number),s=a[3],u=s===void 0?1:s.endsWith("%")?Number(s.slice(0,-1))/100:Number(s);return[i,o,l,u].some(p=>!Number.isFinite(p))?null:{r:i,g:o,b:l,a:u}}let r=t.match(/^#([0-9a-f]{3,8})$/);if(r){let a=r[1];return(a.length===3||a.length===4)&&(a=a.split("").map(i=>i+i).join("")),a.length!==6&&a.length!==8?null:{r:parseInt(a.slice(0,2),16),g:parseInt(a.slice(2,4),16),b:parseInt(a.slice(4,6),16),a:a.length===8?parseInt(a.slice(6,8),16)/255:1}}return null}function Nn(e,t){let n=e.a+t.a*(1-e.a);if(n===0)return{r:0,g:0,b:0,a:0};let r=(a,i)=>(a*e.a+i*t.a*(1-e.a))/n;return{r:r(e.r,t.r),g:r(e.g,t.g),b:r(e.b,t.b),a:n}}function Ot(e){let t=n=>{let r=n/255;return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function et(e,t){let n=t.a<1?Nn(t,{r:255,g:255,b:255,a:1}):t,r=e.a<1?Nn(e,n):e,a=Ot(r),i=Ot(n),[o,l]=a>i?[a,i]:[i,a];return Math.round((o+.05)/(l+.05)*100)/100}function Fr(e){let t=[],n=e;for(;n;){let a=window.getComputedStyle(n);if(a.backgroundImage&&a.backgroundImage!=="none")return null;let i=Ne(a.backgroundColor);if(i&&i.a>0&&(t.push(i),i.a>=1))break;n=n.parentElement}let r={r:255,g:255,b:255,a:1};for(let a=t.length-1;a>=0;a--)r=Nn(t[a],r);return r}function Pr(e){let t=window.getComputedStyle(e),n=parseFloat(t.fontSize)||16,r=parseInt(t.fontWeight,10)||400;return n>=24||n>=18.66&&r>=700}function vt(e){return Array.from(e.childNodes).some(t=>t.nodeType===3&&te(t.textContent).length>0)}var Gr="a[href],button,input:not([type='hidden']),select,textarea,summary,[tabindex]:not([tabindex='-1']),[contenteditable='true']",Dt="a[href],button,input:not([type='hidden']),select,textarea,summary,[role='button'],[role='link'],[role='checkbox'],[role='tab'],[role='menuitem']";var tt={"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."}},ri={critical:10,serious:5,moderate:2,minor:1};function be(e={}){let t=me(e.root),n=new Set(e.skip??[]),r=[],a={},i=t?Be(t)?t:t.ownerDocument:null,o=(l,s,u,p,f=!1)=>{if(n.has(l))return;let b=tt[l],d=a[l]=(a[l]??0)+1;r.push({id:`${l}-${d}`,rule:l,severity:b.severity,wcag:b.wcag,message:u,why:b.why,fix:p,selector:s?Ce(s):"document",snippet:s?ne(s.outerHTML,120):"",autoFixable:f,element:s??void 0})};if(t&&i){i.documentElement.getAttribute("lang")||o("html-lang",i.documentElement,"The <html> element has no lang attribute.",'Add lang to <html>, e.g. <html lang="te"> or "en".',!0),i.title.trim()||o("page-title",null,"The page has no <title>.","Add a short, descriptive <title> that names this page.");for(let m of z(t,"img"))if(!(m.getAttribute("role")==="presentation"||m.getAttribute("role")==="none")&&!m.hasAttribute("alt")&&!m.getAttribute("aria-label")&&!m.getAttribute("aria-labelledby")){let C=m.getAttribute("title");o("image-alt",m,`Image has no alt text${m.getAttribute("src")?` (${ne(m.getAttribute("src")??"",40)})`:""}.`,C?`Use the title as alt: alt="${ne(C,40)}".`:'Describe the image in alt, or use alt="" if it is purely decorative.',!!C)}let l=z(t,"h1,h2,h3,h4,h5,h6"),s=0;for(let m of l){let C=Number(m.tagName[1]);s>0&&C>s+1&&o("heading-order",m,`Heading jumps from h${s} to h${C}: "${ne(m.textContent??"",40)}".`,`Change it to h${s+1}, or add the missing level above it.`),s=C}let u=l.filter(m=>m.tagName==="H1");u.length===0?o("single-h1",null,"The page has no h1.","Add one h1 that names the page."):u.length>1&&o("single-h1",u[1],`The page has ${u.length} h1 headings.`,"Keep one h1; turn the others into h2."),t.querySelectorAll("main,[role='main']").length===0&&o("landmark-main",null,"No <main> landmark found.","Wrap the primary content in <main>.");let p=z(t,"input,select,textarea").filter(m=>{let C=(m.getAttribute("type")??"text").toLowerCase();return!["hidden","submit","button","reset","image"].includes(C)});for(let m of p){if(!he(m)){let C=m.getAttribute("placeholder")||m.getAttribute("name");o("form-label",m,`Form field has no label${C?` (placeholder/name: "${ne(C,30)}")`:""}.`,C?`Add a visible <label>. Quick fix: aria-label="${ne(C,30)}".`:"Add a visible <label for=\u2026> describing what to enter.",!!C)}m.getAttribute("aria-invalid")==="true"&&(m.getAttribute("aria-describedby")||m.getAttribute("aria-errormessage")||o("form-error",m,"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 m of z(t,"button,[role='button'],input[type='submit'],input[type='button']"))if(!he(m)){let C=m.getAttribute("title");o("button-name",m,"Button has no accessible name.",C?`Use the title as the name: aria-label="${C}".`:"Add visible text or an aria-label that says what the button does.",!!C)}for(let m of z(t,"a[href]"))if(!he(m)){let C=m.getAttribute("title");o("link-name",m,`Link has no text (${ne(m.getAttribute("href")??"",40)}).`,C?`Use the title as the name: aria-label="${C}".`:"Add link text that says where it goes.",!!C)}for(let m of z(t,"[tabindex]"))Number(m.getAttribute("tabindex"))>0&&o("positive-tabindex",m,`tabindex="${m.getAttribute("tabindex")}" overrides the natural tab order.`,'Use tabindex="0" and fix the order in the HTML instead.',!0);let f="a[href],button,input,select,textarea,summary";for(let m of z(t,"[onclick],[role='button'],[role='link']"))m.matches(f)||m.hasAttribute("tabindex")||o("keyboard-access",m,`<${m.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 b=new Map;for(let m of Array.from(t.querySelectorAll("[id]")))m.closest("[data-yuktai-panel]")||b.set(m.id,(b.get(m.id)??0)+1);for(let[m,C]of b)C>1&&o("duplicate-id",t.querySelector(`[id="${m.replace(/"/g,'\\"')}"]`),`id="${m}" is used ${C} times.`,"Give each element a unique id.");let d=e.maxContrastChecks??600,S=0;for(let m of z(t,"body *")){if(S>=d)break;if(!vt(m)||["SCRIPT","STYLE","NOSCRIPT","OPTION"].includes(m.tagName))continue;S++;let C=Ne(window.getComputedStyle(m).color),M=Fr(m);if(!C||!M)continue;let k=et(C,M),h=Pr(m)?3:4.5;k<h&&o("color-contrast",m,`Contrast ${k}:1 is below ${h}:1 for "${ne(m.textContent??"",30)}".`,`Darken the text or lighten the background until the ratio is at least ${h}:1.`)}let y=e.minTargetSize??24;for(let m of z(t,Dt)){let C=m.getBoundingClientRect();C.width===0&&C.height===0||m.tagName==="A"&&m.closest("p,li,td")||(C.width<y||C.height<y)&&o("target-size",m,`Target is ${Math.round(C.width)}\xD7${Math.round(C.height)}px (minimum ${y}\xD7${y}).`,`Increase padding so it's at least ${y}\xD7${y}px (44\xD744 is better for seniors).`)}}return oi(r,i,n)}function oi(e,t,n){var s;let r=Object.keys(tt).filter(u=>!n.has(u)).map(u=>{let p=e.filter(f=>f.rule===u).length;return{rule:u,title:tt[u].title,passed:p===0,issueCount:p}}),a=0;for(let u of r){let p=ri[tt[u.rule].severity];a+=Math.min(25,u.issueCount*p)}let i=Math.max(0,100-a),o=r.filter(u=>!u.passed),l=e.filter(u=>u.severity==="critical").length;return{url:((s=t==null?void 0:t.location)==null?void 0:s.href)??"",title:(t==null?void 0:t.title)??"",generatedAt:new Date().toISOString(),score:i,passed:l===0&&i>=80,checks:r,issues:e,summary:e.length===0?`All ${r.length} checks passed.`:`${r.length-o.length} of ${r.length} checks passed. ${e.length} issue(s) found, ${l} critical. Score ${i}/100.`}}function wt(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(`
|
|
9
|
+
`)}function zt(e){return JSON.stringify({...e,issues:e.issues.map(({element:t,...n})=>n)},null,2)}function qt(e={}){let t=null,n=null,r=null,a=!1,i=[],o=()=>({report:t,watching:n!==null,appliedFixes:i.length}),l=()=>{var b;return(b=e.onUpdate)==null?void 0:b.call(e,o())},s=b=>t==null?void 0:t.issues.find(d=>d.id===b),u=(b,d,S)=>{i.push({element:b,attribute:d,previous:b.getAttribute(d)}),b.setAttribute(d,S)};function p(b){let d=b.element,S=(y,m)=>({issueId:b.id,applied:y,message:m});if(!b.autoFixable||!d)return S(!1,"This needs a human decision \u2014 see the suggested fix.");switch(b.rule){case"html-lang":{let y=e.defaultLang||(ke()?navigator.language:"")||"en";return u(d,"lang",y),S(!0,`Set lang="${y}" on <html>.`)}case"image-alt":{let y=d.getAttribute("title");if(!y)break;return u(d,"alt",y),S(!0,`Used the image title as alt text: "${y}".`)}case"form-label":{let y=d.getAttribute("placeholder")||d.getAttribute("name");if(!y)break;let m=y.replace(/[_-]+/g," ").trim();return u(d,"aria-label",m),S(!0,`Added aria-label="${m}". A visible <label> is still better.`)}case"button-name":case"link-name":{let y=d.getAttribute("title");if(!y)break;return u(d,"aria-label",y),S(!0,`Added aria-label="${y}".`)}case"positive-tabindex":return u(d,"tabindex","0"),S(!0,"Changed tabindex to 0 so the natural order applies.");case"keyboard-access":{u(d,"tabindex","0"),d.getAttribute("role")||u(d,"role","button");let y=m=>{let C=m.key;(C==="Enter"||C===" ")&&(m.preventDefault(),d.click())};return d.addEventListener("keydown",y),i.push({element:d,attribute:"",previous:null,listener:y}),S(!0,"Made it focusable and added Enter/Space support.")}default:break}return S(!1,"No safe automatic fix for this one \u2014 see the suggested fix.")}function f(){if(t=be(e),e.autoApply){a=!0;let b=t.issues.filter(d=>d.autoFixable).map(p);a=!1,b.some(d=>d.applied)&&(t=be(e))}return l(),t}return{start(){if(!ke()||n)return;let b=me(e.root),d=Be(b)?b.body:b;d&&(n=new MutationObserver(S=>{a||!S.some(m=>{var C,M;return!((M=(C=m.target).closest)!=null&&M.call(C,"[data-yuktai-panel]"))})||(r&&clearTimeout(r),r=setTimeout(f,e.debounceMs??600))}),n.observe(d,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["alt","aria-label","aria-invalid","tabindex","lang","title"]}),f())},stop(){n==null||n.disconnect(),n=null,r&&clearTimeout(r),r=null,l()},scan:f,explain(b){let d=s(b);return d?[`${d.message}`,`Why it matters: ${d.why}`,`How to fix: ${d.fix}`,`Standard: WCAG ${d.wcag} (${d.severity}).`,d.autoFixable?"I can apply a safe fix for this in the browser.":"This one needs a change in your code."].join(`
|
|
10
|
+
`):`No issue "${b}" in the current report. Run a scan first.`},applyFix(b){let d=s(b);if(!d)return{issueId:b,applied:!1,message:"Issue not found. Run a scan first."};a=!0;let S=p(d);return a=!1,S.applied&&f(),S},applyAllFixes(){t||f(),a=!0;let b=((t==null?void 0:t.issues)??[]).filter(d=>d.autoFixable).map(p);return a=!1,f(),b},undoAll(){let b=i.length;for(a=!0;i.length;){let d=i.pop();d.listener?d.element.removeEventListener("keydown",d.listener):d.previous===null?d.element.removeAttribute(d.attribute):d.element.setAttribute(d.attribute,d.previous)}return a=!1,f(),b},getState:o}}var ii=/^(field|input|value|text|enter|details?|info|data|\*|:)$/i,ai=/^(go|ok|submit|send|click here|>|→|next)$/i,si=[[/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 li(e){let t=e.getAttribute("id");return t&&e.ownerDocument.querySelector(`label[for="${t.replace(/"/g,'\\"')}"]`)?!0:!!e.closest("label")}function Fn(e){return z(e,"input,select,textarea").filter(t=>!["hidden","submit","button","reset","image"].includes((t.getAttribute("type")??"text").toLowerCase())).map(t=>({label:he(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:li(t),selector:Ce(t),element:t}))}function Pn(e,t={}){var b;let n=t.seniorFriendly!==!1,r=t.maxFieldsPerStep??8,a=Fn(e),i=[],o=(d,S,y,m)=>i.push({level:d,message:S,suggestion:y,field:(m==null?void 0:m.label)||(m==null?void 0:m.name),selector:m==null?void 0:m.selector});for(let d of a){let S=d.element,y=d.label||d.name||d.type,m=S.getAttribute("placeholder");!d.label&&m?o("problem",`"${m}" 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.",d):d.label?!d.hasVisibleLabel&&m&&!S.getAttribute("aria-label")?o("problem",`"${y}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts. Add a visible label above the field.",d):ii.test(d.label)&&o("improvement",`The label "${d.label}" is unclear.`,'Say exactly what is needed, e.g. "Mobile number (10 digits)".',d):o("problem",`A ${d.type} field${d.name?` ("${d.name}")`:""} has no label.`,"Add a visible <label> that says exactly what to enter.",d),d.required&&d.label&&!/\*|required|mandatory|తప్పనిసరి|आवश्यक/i.test(d.label)&&o("improvement",`"${y}" is required but the label doesn't say so.`,'Add "(required)" to the label so everyone knows before submitting.',d);let C=`${d.name} ${d.label}`;for(let[M,k,h]of si)if(M.test(C)){S.getAttribute("autocomplete")||o("improvement",`"${y}" has no autocomplete hint.`,`Add autocomplete="${k}" so browsers can fill it in (WCAG 1.3.5).`,d),h&&d.type==="text"&&o("improvement",`"${y}" uses type="text".`,`Use type="${h}" for the right mobile keyboard and validation.`,d);break}if(S.getAttribute("aria-invalid")==="true"&&!S.getAttribute("aria-describedby")&&!S.getAttribute("aria-errormessage")&&o("problem",`"${y}" shows an error that isn't connected to the field.`,"Link the error text with aria-describedby and explain how to fix it.",d),n){let M=parseFloat(window.getComputedStyle(S).fontSize)||16;M<16&&o("improvement",`"${y}" text is ${M}px.`,"Use at least 16px in inputs; it is easier to read and stops mobile browsers from zooming.",d)}}a.length>r&&o("improvement",`This form has ${a.length} fields on one screen.`,`Split it into steps of about ${r} fields with a progress indicator.`);let l=z(e,"button,input[type='submit'],input[type='button']");if(l.length===0)o("problem","No submit button found.",'Add a clear <button type="submit"> so the form can be completed with the keyboard.');else if(n){let d=te(he(l[l.length-1]));ai.test(d)&&o("improvement",`The button says "${d}".`,'Name the result, e.g. "Send message" or "Book appointment".')}!z(e,"[role='alert'],[aria-live]",{includeHidden:!0}).length&&a.some(d=>d.required)&&o("improvement","No live region for error messages.",'Add an element with role="alert" so errors are announced when the form is submitted.');let s=i.filter(d=>d.level==="problem").length,u=i.length-s,p=Math.max(0,100-s*15-u*4),f=e.getAttribute("aria-label")||te((b=e.querySelector("legend,h1,h2,h3"))==null?void 0:b.textContent)||e.getAttribute("name")||e.getAttribute("id")||"Form";return{name:ne(f,50),selector:Ce(e),fields:a,findings:i,score:p,summary:i.length===0?`"${ne(f,40)}" looks clear: ${a.length} labelled field(s), nothing to fix.`:`"${ne(f,40)}" has ${a.length} field(s): ${s} problem(s) and ${u} suggestion(s). Score ${p}/100.`}}function nt(e={}){let t=me(e.root);return t?z(t,"form,[role='form']").map(n=>Pn(n,e)):[]}function Gn(e){var p;let t=me(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 r=Be(t)?t:t.ownerDocument,a=z(t,"h1,h2,h3,h4,h5,h6").map(f=>({level:Number(f.tagName[1]),text:ne(f.textContent??"",80)})),i={};for(let[f,b]of Object.entries({header:"header,[role='banner']",navigation:"nav,[role='navigation']",main:"main,[role='main']",search:"search,[role='search']",footer:"footer,[role='contentinfo']"}))i[f]=z(t,b).length;let o=z(t,"input,select,textarea").filter(f=>!["hidden","submit","button","reset","image"].includes((f.getAttribute("type")??"text").toLowerCase())),l=o.filter(f=>!he(f)).map(f=>({type:f.tagName==="INPUT"?f.getAttribute("type")??"text":f.tagName.toLowerCase(),hint:f.getAttribute("placeholder")||f.getAttribute("name")||"",selector:Ce(f)})),s=z(t,"img:not([alt])").map(f=>({src:f.getAttribute("src")??"",selector:Ce(f)})),u={title:r.title,description:te((p=r.querySelector('meta[name="description"]'))==null?void 0:p.getAttribute("content")),language:r.documentElement.getAttribute("lang")??"",headings:a,landmarks:i,counts:{links:z(t,"a[href]").length,buttons:z(t,"button,[role='button'],input[type='submit']").length,images:z(t,"img").length,forms:z(t,"form,[role='form']").length,tables:z(t,"table,[role='grid'],[role='table']").length,fields:o.length},unlabeledFields:l,imagesWithoutAlt:s,purpose:""};return u.purpose=ci(u,o),u}function ci(e,t){var o;let n=((o=e.headings.find(l=>l.level===1))==null?void 0:o.text)||e.title||"This page",r=t.map(l=>`${l.getAttribute("type")} ${l.getAttribute("name")} ${he(l)}`).join(" ").toLowerCase(),a=[];/password/.test(r)?a.push("sign in or create an account"):(/search|query|వెతుకు/.test(r)||e.landmarks.search)&&a.push("search"),/message|comment|feedback|contact|enquiry/.test(r)&&a.push("send a message"),/card|payment|upi|amount/.test(r)&&a.push("make a payment"),e.counts.tables&&a.push(`browse ${e.counts.tables} table(s) of data`),!a.length&&e.counts.forms&&a.push(`fill in ${e.counts.forms} form(s)`),a.length||a.push("read content");let i=e.headings.filter(l=>l.level===2).slice(0,5).map(l=>l.text);return[`"${n}" lets you ${a.join(", ")}.`,e.description?`It describes itself as: ${ne(e.description,140)}`:"",i.length?`Main sections: ${i.join(" \xB7 ")}.`:""].filter(Boolean).join(" ")}var ui=[["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 On(e){for(let[t,n]of ui)if(n.test(e))return t;return"unknown"}async function Ht(e,t={}){var a;let n=Gn(t.root),r=On(e);switch(r){case"missing-labels":return n.unlabeledFields.length?{intent:r,answer:`${n.unlabeledFields.length} of ${n.counts.fields} field(s) have no label: ${n.unlabeledFields.map(i=>`${i.type}${i.hint?` ("${i.hint}")`:""}`).join(", ")}.`,targets:n.unlabeledFields.map(i=>i.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:r,answer:`All ${n.counts.fields} form field(s) have labels.`,targets:[],suggestions:[]};case"images":return{intent:r,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(i=>i.selector),suggestions:n.imagesWithoutAlt.length?['Describe meaningful images in alt; use alt="" for decorative ones.']:[]};case"structure":{let i=n.headings.slice(0,15).map(l=>`${" ".repeat(l.level-1)}h${l.level} ${l.text}`).join(`
|
|
11
11
|
`),o=Object.entries(n.landmarks).filter(([,l])=>l===0).map(([l])=>l);return{intent:r,answer:`${n.headings.length} heading(s).
|
|
12
12
|
${i}${o.length?`
|
|
13
|
-
Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("main")?["Wrap the primary content in <main>."]:[]}}case"forms":{let i=
|
|
14
|
-
`):"There are no forms on this page.",targets:i.flatMap(o=>o.findings.map(l=>l.selector).filter(l=>!!l)),suggestions:i.flatMap(o=>o.findings.slice(0,3).map(l=>l.suggestion))}}case"links":case"counts":{let i=n.counts;return{intent:r,answer:`${i.links} links, ${i.buttons} buttons, ${i.fields} form fields in ${i.forms} form(s), ${i.images} images, ${i.tables} tables.`,targets:[],suggestions:[]}}case"purpose":case"unknown":{let i=n.purpose;if(t.summarize)try{let l=me(t.root),s=te((a=l&&Be(l)?l.body:l)==null?void 0:a.textContent).slice(0,4e3);i=await t.summarize(s)||i}catch{}let o=[];return n.unlabeledFields.length&&o.push(`${n.unlabeledFields.length} form field(s) need labels.`),n.imagesWithoutAlt.length&&o.push(`${n.imagesWithoutAlt.length} image(s) need alt text.`),{intent:r,answer:i,targets:[],suggestions:o}}}}var
|
|
15
|
-
`),y=await u.generate(s,S);if(y!=null&&y.trim())return{answer:y.trim(),hits:p,generated:!0}}catch{}let f=new Set(
|
|
16
|
-
`):p[0].text.slice(0,300),hits:p,generated:!1}}return{search:o,ask:l,rebuild:i,update(s){Object.assign(e,s),i()},size:()=>t.length}}var
|
|
13
|
+
Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("main")?["Wrap the primary content in <main>."]:[]}}case"forms":{let i=nt({root:t.root});return{intent:r,answer:i.length?i.map(o=>o.summary).join(`
|
|
14
|
+
`):"There are no forms on this page.",targets:i.flatMap(o=>o.findings.map(l=>l.selector).filter(l=>!!l)),suggestions:i.flatMap(o=>o.findings.slice(0,3).map(l=>l.suggestion))}}case"links":case"counts":{let i=n.counts;return{intent:r,answer:`${i.links} links, ${i.buttons} buttons, ${i.fields} form fields in ${i.forms} form(s), ${i.images} images, ${i.tables} tables.`,targets:[],suggestions:[]}}case"purpose":case"unknown":{let i=n.purpose;if(t.summarize)try{let l=me(t.root),s=te((a=l&&Be(l)?l.body:l)==null?void 0:a.textContent).slice(0,4e3);i=await t.summarize(s)||i}catch{}let o=[];return n.unlabeledFields.length&&o.push(`${n.unlabeledFields.length} form field(s) need labels.`),n.imagesWithoutAlt.length&&o.push(`${n.imagesWithoutAlt.length} image(s) need alt text.`),{intent:r,answer:i,targets:[],suggestions:o}}}}var di=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 rt(e){return(e.normalize("NFC").toLowerCase().match(/[\p{L}\p{M}\p{N}]+/gu)??[]).filter(t=>t.length>1&&!di.has(t))}function Dn(e,t=600){let n=me(e);if(!n)return[];let r=[],a="",i="",o=()=>{i.trim()&&r.push({id:`page-${r.length+1}`,source:"page",text:i.trim(),ref:a||void 0}),i=""};for(let l of z(n,"h1,h2,h3,h4,p,li,td,th,dt,dd,blockquote,figcaption,label,summary")){if(l.querySelector("p,li,h1,h2,h3,h4"))continue;let s=te(l.textContent);if(s){if(/^H[1-4]$/.test(l.tagName)){o(),a=s,i=`${s}. `;continue}i.length+s.length>t&&o(),i+=`${s} `}}return o(),r}function zn(e,t,n="id"){return e.map((r,a)=>{let i=r,o=String(i[n]??a+1);return{id:`grid-${o}`,source:"grid",ref:o,text:t.map(l=>`${l.label}: ${String(i[l.key]??"")}`).join(". ")}})}function Bt(e={}){let t=[],n=[],r=new Map,a=0;function i(){t=[...e.includePage===!1?[]:Dn(e.root),...e.rows&&e.columns?zn(e.rows,e.columns,e.rowKey):[],...(e.documents??[]).map(s=>({id:s.id,source:"custom",text:s.text}))],n=t.map(s=>rt(s.text)),r=new Map;for(let s of n)for(let u of new Set(s))r.set(u,(r.get(u)??0)+1);a=n.reduce((s,u)=>s+u.length,0)/Math.max(1,n.length)}i();function o(s,u=5){let p=rt(s);if(!p.length)return[];let f=n.length;return n.map((d,S)=>{let y=0;for(let m of p){let C=0;for(let k of d)(k===m||m.length>=4&&k.startsWith(m)||k.length>=4&&m.startsWith(k))&&C++;if(!C)continue;let M=Math.log(1+(f-(r.get(m)??1)+.5)/((r.get(m)??1)+.5));y+=M*(C*2.2/(C+1.2*(.25+.75*(d.length/(a||1)))))}return{...t[S],score:y}}).filter(d=>d.score>0).sort((d,S)=>S.score-d.score).slice(0,u)}async function l(s,u={}){let p=o(s,u.k??4);if(!p.length)return{answer:"I couldn't find anything about that on this page or in the data.",hits:p,generated:!1};if(u.generate)try{let S=p.map((m,C)=>`[${C+1}] ${m.text}`).join(`
|
|
15
|
+
`),y=await u.generate(s,S);if(y!=null&&y.trim())return{answer:y.trim(),hits:p,generated:!0}}catch{}let f=new Set(rt(s)),b=p.flatMap(S=>S.text.split(new RegExp("(?<=[.!?\u0964])\\s+|\\.\\s+(?=\\p{Lu})","u")).map(y=>({s:y.trim(),h:S}))).map(({s:S,h:y})=>({s:S,h:y,overlap:rt(S).filter(m=>f.has(m)).length})).filter(S=>S.s&&S.overlap>0).sort((S,y)=>y.overlap-S.overlap).slice(0,3);return{answer:b.length?b.map(S=>S.h.source==="grid"?`Row ${S.h.ref}: ${S.s}`:S.s).join(`
|
|
16
|
+
`):p[0].text.slice(0,300),hits:p,generated:!1}}return{search:o,ask:l,rebuild:i,update(s){Object.assign(e,s),i()},size:()=>t.length}}var Or={high:12,medium:6,low:2};function _t(e={}){let t=me(e.root),n=[],r=(l,s,u,p,f)=>n.push({category:l,severity:s,message:u,suggestion:p,selector:f?Ce(f):void 0});if(t&&ke()){let l=e.minFontSize??14,s=e.maxLineLength??90,u=T=>window.getComputedStyle(T),p=z(t,"h1");p.length===0&&r("hierarchy","medium","There is no h1, so the page has no clear main title.","Add one prominent h1 near the top."),p.length>1&&r("hierarchy","low",`${p.length} h1 headings compete for attention.`,"Keep one h1 and demote the rest.",p[1]);let f=T=>{let R=z(t,T)[0];return R&&parseFloat(u(R).fontSize)||0},[b,d,S]=[f("h1"),f("h2"),f("h3")];b&&d&&d>=b&&r("hierarchy","medium",`h2 (${d}px) is as large as or larger than h1 (${b}px).`,"Make each heading level visibly smaller than the one above it."),d&&S&&S>d&&r("hierarchy","low",`h3 (${S}px) is larger than h2 (${d}px).`,"Keep heading sizes in descending order.");let y=be({root:e.root,skip:["color-contrast","target-size","duplicate-id","page-title","html-lang","form-error","positive-tabindex"]});for(let T of y.issues.filter(R=>R.rule==="heading-order").slice(0,3))r("hierarchy","low",T.message,T.fix,T.element);let m=0,C;for(let T of z(t,"p,li,td,span,a,label,small,div").slice(0,1500)){if(!vt(T))continue;(parseFloat(u(T).fontSize)||16)<l&&(m++,C??=T)}m&&r("readability",m>10?"high":"medium",`${m} text element(s) are smaller than ${l}px, e.g. "${ne((C==null?void 0:C.textContent)??"",30)}".`,`Use at least ${l}px for body text (16px for senior-friendly pages).`,C);for(let T of z(t,"p").slice(0,200)){let R=u(T),G=parseFloat(R.fontSize)||16,N=T.getBoundingClientRect().width,F=N/(G*.5);if(N>0&&F>s&&(T.textContent??"").length>s){r("readability","low",`A paragraph is about ${Math.round(F)} characters wide.`,`Limit text width to ~${s} characters (e.g. max-width: 70ch).`,T);break}let H=parseFloat(R.lineHeight);if(Number.isFinite(H)&&H/G<1.3){r("readability","low",`Line height is ${(H/G).toFixed(2)}\xD7 the font size.`,"Use line-height of at least 1.5 for body text (WCAG 1.4.12).",T);break}}let M=be({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"]});M.issues.length&&r("readability",M.issues.length>5?"high":"medium",`${M.issues.length} text element(s) have weak contrast. ${M.issues[0].message}`,"Raise contrast to at least 4.5:1 for body text.",M.issues[0].element);let k=pi();k.length&&r("interaction","high",`Focus outlines are removed by CSS (${k.slice(0,2).join(", ")}) with no replacement.`,"Never remove outlines without a visible :focus-visible style (WCAG 2.4.7).");let h=z(t,Dt).filter(T=>{let R=T.getBoundingClientRect();return R.width>0&&R.height>0&&(R.width<24||R.height<24)&&!(T.tagName==="A"&&T.closest("p,li"))});h.length&&r("interaction",h.length>5?"high":"medium",`${h.length} control(s) are smaller than 24\xD724px.`,"Give controls at least 24\xD724px, ideally 44\xD744px for touch and seniors.",h[0]);let w=window.innerHeight||800,v=z(t,Gr).filter(T=>{let R=T.getBoundingClientRect();return R.height>0&&R.top<w});v.length>40&&r("clutter","medium",`${v.length} interactive elements in the first screen.`,"Group secondary actions into menus and keep the first screen focused on one task.");let E=z(t,"button,a[href],[role='button']").filter(T=>{let R=T.getBoundingClientRect();if(R.height===0||R.top>w)return!1;let G=u(T).backgroundColor;return!!G&&!/rgba\(0, 0, 0, 0\)|transparent/.test(G)&&!/rgb\(255, 255, 255\)/.test(G)});E.length>4&&r("clutter","medium",`${E.length} filled buttons compete in the first screen.`,"Keep one primary action per view; make the rest secondary (outline or text).",E[0]);let x=new Set,$=new Set;for(let T of z(t,"body *").slice(0,2e3)){if(!vt(T))continue;let R=u(T);x.add(R.fontFamily.split(",")[0].replace(/["']/g,"").trim().toLowerCase()),$.add(Math.round(parseFloat(R.fontSize)||0))}x.size>4&&r("consistency","low",`${x.size} different font families are used.`,"Stick to 1\u20132 font families (e.g. one Telugu + one Latin)."),$.size>10&&r("consistency","low",`${$.size} different font sizes are used.`,"Use a small type scale (5\u20137 sizes) for a calmer page.");let I=z(t,"img:not([width]):not([height])").filter(T=>!u(T).aspectRatio||u(T).aspectRatio==="auto");I.length>3&&r("consistency","low",`${I.length} images have no width/height, so the layout jumps while loading.`,"Set width and height (or aspect-ratio) on images.",I[0])}let a=["hierarchy","readability","interaction","clutter","consistency"].reduce((l,s)=>{let u=n.filter(p=>p.category===s);return l[s]={score:Math.max(0,100-u.reduce((p,f)=>p+Or[f.severity]*2,0)),findings:u.length},l},{}),i=Math.max(0,100-n.reduce((l,s)=>l+Or[s.severity],0)),o=Object.entries(a).sort((l,s)=>l[1].score-s[1].score)[0];return{score:i,categories:a,findings:n,summary:n.length?`Design score ${i}/100 with ${n.length} finding(s). Weakest area: ${o[0]}.`:"No design issues found by the automatic review."}}function pi(){let e=[],t=!1,n=r=>{for(let a of Array.from(r)){let i=a.cssRules;i&&n(i);let o=a;if(!o.selectorText||!/:focus/.test(o.selectorText))continue;let l=`${o.style.outline} ${o.style.outlineStyle} ${o.style.outlineWidth}`,s=/\bnone\b|\b0(px)?\b/.test(l),u=!!(o.style.boxShadow&&o.style.boxShadow!=="none")||!!o.style.borderColor||!!o.style.backgroundColor||!!o.style.textDecoration;/:focus-visible/.test(o.selectorText)&&(!s||u)&&(t=!0),s&&!u&&e.push(o.selectorText)}};for(let r of Array.from(document.styleSheets))try{n(r.cssRules)}catch{}return t?[]:e}function Dr(){var t;let e=window;return e.Rewriter||((t=e.ai)==null?void 0:t.rewriter)||null}async function qn(){try{let e=Dr();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}if(typeof e.capabilities=="function"){let t=await e.capabilities();return(t==null?void 0:t.available)!=="no"}return typeof e.create=="function"}catch{return!1}}async function gi(e){if(!e||e.trim().length<20)return{success:!1,original:e,rewritten:e,error:"Text too short"};try{let t=Dr();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"}),r=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:r.trim()}}catch(t){return{success:!1,original:e,rewritten:e,error:t instanceof Error?t.message:"Rewrite failed"}}}async function zr(){var r;if(!await qn())return{fixed:0,error:"Chrome Built-in AI Rewriter not available. Enable via chrome://flags."};let t=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption"),n=0;for(let a of t){let i=(r=a.innerText)==null?void 0:r.trim();if(!i||i.length<20||a.closest("[data-yuktai-panel]"))continue;let o=await gi(i);o.success&&o.rewritten!==i&&(a.dataset.yuktaiOriginal=i,a.innerText=o.rewritten,n++)}return{fixed:n}}function qr(){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 Hr="yuktai-summary-box";function Br(){var t;let e=window;return e.Summarizer||((t=e.ai)==null?void 0:t.summarizer)||null}async function Hn(){try{let e=Br();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}if(typeof e.capabilities=="function"){let t=await e.capabilities();return(t==null?void 0:t.available)!=="no"}return typeof e.create=="function"}catch{return!1}}function mi(){var n;let e=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, article, section"),t=[];for(let r of e){if(r.closest("[data-yuktai-panel]"))continue;let a=window.getComputedStyle(r);if(a.display==="none"||a.visibility==="hidden")continue;let i=(n=r.innerText)==null?void 0:n.trim();i&&i.length>10&&t.push(i)}return t.join(" ").slice(0,5e3)}async function _r(){if(!await Hn())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=mi();if(!t||t.length<100)return{success:!1,summary:"",error:"Not enough text on this page to summarise."};try{let n=Br();if(!n)throw new Error("Summarizer API not available");let r=await n.create({type:"tl;dr",format:"plain-text",length:"short",outputLanguage:"en"}),a=await r.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 r.destroy(),fi(a.trim()),{success:!0,summary:a.trim()}}catch(n){return{success:!1,summary:"",error:n instanceof Error?n.message:"Summary failed"}}}function fi(e){Vt();let t=document.createElement("div");t.id=Hr,t.setAttribute("data-yuktai-panel","true"),t.setAttribute("role","region"),t.setAttribute("aria-label","Page summary by yuktai"),t.style.cssText=`
|
|
17
17
|
position: fixed;
|
|
18
18
|
top: 0;
|
|
19
19
|
left: 0;
|
|
@@ -34,7 +34,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
34
34
|
background: none; border: none; color: #ffffff;
|
|
35
35
|
font-size: 20px; cursor: pointer; padding: 0 4px;
|
|
36
36
|
line-height: 1; flex-shrink: 0;
|
|
37
|
-
`,r.addEventListener("click",
|
|
37
|
+
`,r.addEventListener("click",Vt),t.appendChild(n),t.appendChild(r),document.body.prepend(t)}function Vt(){let e=document.getElementById(Hr);e&&e.remove()}var Vr=[{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"}],Wt="en";function hi(){let e=window;return e.Translator||e.translation||null}async function bi(e){try{let t=window;if(!hi())return!1;if(t.Translator&&typeof t.Translator.availability=="function")try{let r=await t.Translator.availability({sourceLanguage:"en",targetLanguage:e});return r==="readily"||r==="available"||r==="downloadable"||r==="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 yi(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 Wr(e){var n;if(e===Wt)return{success:!0,language:e,fixed:0};if(e==="en")return Bn(),Wt="en",{success:!0,language:"en",fixed:0};if(!await bi(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let r=await yi(e),a=document.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, label, figcaption, span, a"),i=0;for(let o of a){if(o.closest("[data-yuktai-panel]")||o.children.length>0)continue;let l=(n=o.innerText)==null?void 0:n.trim();if(!l||l.length<2)continue;o.dataset.yuktaiTranslationOriginal||(o.dataset.yuktaiTranslationOriginal=l);let s=await r.translate(l);s&&s!==l&&(o.innerText=s,i++)}return typeof r.destroy=="function"&&r.destroy(),Wt=e,{success:!0,language:e,fixed:i}}catch(r){return{success:!1,language:e,fixed:0,error:r instanceof Error?r.message:"Translation failed"}}}function Bn(){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)}Wt="en"}var vi=[{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,jt=!1,ot=null;function _n(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function wi(e){let t=e.toLowerCase().trim();for(let n of vi)for(let r of n.phrases)if(t.includes(r))return{action:n.action,label:n.label};return null}function xi(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=jr(),n=t.indexOf(document.activeElement),r=t[n+1]||t[0];r&&r.focus();break}case"tab-back":{let t=jr(),n=t.indexOf(document.activeElement),r=t[n-1]||t[t.length-1];r&&r.focus();break}case"stop-voice":{Vn();break}}}function jr(){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 Ur(e){if(!_n())return!1;if(jt)return!0;e&&(ot=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 r=n.results[n.results.length-1][0].transcript,a=wi(r);if(a){xi(a.action);let i={success:!0,command:r,action:a.label};if(ot&&ot(i),a.action==="stop-voice")return}},ce.onend=()=>{jt&&(ce==null||ce.start())},ce.onerror=n=>{n.error!=="no-speech"&&ot&&ot({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},ce.start(),jt=!0,ki(),!0}function Vn(){jt=!1,ce&&(ce.stop(),ce=null),ot=null,Qr()}var Kr="yuktai-voice-indicator";function ki(){Qr();let e=document.createElement("div");e.id=Kr,e.setAttribute("data-yuktai-panel","true"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","yuktai voice control is listening"),e.style.cssText=`
|
|
38
38
|
position: fixed;
|
|
39
39
|
bottom: 80px;
|
|
40
40
|
left: 50%;
|
|
@@ -64,7 +64,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
64
64
|
0%, 100% { opacity: 1; transform: scale(1); }
|
|
65
65
|
50% { opacity: 0.4; transform: scale(0.7); }
|
|
66
66
|
}
|
|
67
|
-
`,document.head.appendChild(r)}let n=document.createElement("span");n.textContent="Listening for commands...",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}function
|
|
67
|
+
`,document.head.appendChild(r)}let n=document.createElement("span");n.textContent="Listening for commands...",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}function Qr(){let e=document.getElementById(Kr);e&&e.remove()}var Ai=["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 Yr(){var t;let e=window;return e.Writer||((t=e.ai)==null?void 0:t.writer)||null}async function Wn(){try{let e=Yr();if(!e)return!1;if(typeof e.availability=="function"){let t=await e.availability();return t==="readily"||t==="available"||t==="downloadable"}if(typeof e.capabilities=="function"){let t=await e.capabilities();return(t==null?void 0:t.available)!=="no"}return typeof e.create=="function"}catch{return!1}}function Ti(e){var u,p,f,b,d,S,y;let t=[],n=(u=e.innerText)==null?void 0:u.trim();n&&t.push(`element text: "${n}"`);let r=(p=e.placeholder)==null?void 0:p.trim();r&&t.push(`placeholder: "${r}"`);let a=(f=e.getAttribute("name"))==null?void 0:f.trim();a&&t.push(`name: "${a}"`);let i=(b=e.getAttribute("type"))==null?void 0:b.trim();i&&t.push(`type: "${i}"`);let o=e.id;if(o){let m=document.querySelector(`label[for="${o}"]`);m&&t.push(`label: "${(d=m.innerText)==null?void 0:d.trim()}"`)}let l=(y=(S=e.parentElement)==null?void 0:S.innerText)==null?void 0:y.trim().slice(0,60);l&&t.push(`parent context: "${l}"`),t.push(`tag: ${e.tagName.toLowerCase()}`);let s=e.getAttribute("role");return s&&t.push(`role: ${s}`),t.join(". ")}async function Si(e,t){let n=`
|
|
68
68
|
Generate a short, clear aria-label for an HTML element.
|
|
69
69
|
The label must be 2-6 words maximum.
|
|
70
70
|
The label must describe what the element does or what it is.
|
|
@@ -75,7 +75,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
75
75
|
${t}
|
|
76
76
|
|
|
77
77
|
Output only the label. Nothing else.
|
|
78
|
-
`.trim();return(await e.write(n)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function
|
|
78
|
+
`.trim();return(await e.write(n)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Jr(){if(!await Wn())return{success:!1,fixed:0,elements:[],error:"Chrome Built-in AI Writer not available. Enable via chrome://flags."};let t=document.querySelectorAll(Ai);if(t.length===0)return{success:!0,fixed:0,elements:[]};try{let n=Yr();if(!n)throw new Error("Writer API not available");let r=await n.create({tone:"neutral",format:"plain-text",length:"short",outputLanguage:"en"}),a=0,i=[];for(let o of t){if(o.closest("[data-yuktai-panel]"))continue;let l=window.getComputedStyle(o);if(l.display==="none"||l.visibility==="hidden")continue;let s=Ti(o),u=await Si(r,s);u&&u.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",u),a++,i.push({tag:o.tagName.toLowerCase(),label:u}))}return r.destroy(),{success:!0,fixed:a,elements:i}}catch(n){return{success:!1,fixed:0,elements:[],error:n instanceof Error?n.message:"Label generation failed"}}}function Xr(){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 Qt=null,Zr=null;var eo=null,jn=null,X=null,it=null,Ut=null,Un=null,ue=null,Kt={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"};var to=new Set(["input","select","textarea"]);var Kn={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"};function Qn(e,t="polite"){if(typeof window>"u"||!(ue!=null&&ue.speechEnabled)||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.rate=1,n.pitch=1,n.volume=1;let r=window.speechSynthesis.getVoices();r.length>0&&(n.voice=r[0]),window.speechSynthesis.speak(n)}function co(e,t="info"){if(typeof document>"u")return;let r={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];X||(X=document.createElement("div"),X.setAttribute("role","alert"),X.setAttribute("aria-live","assertive"),X.setAttribute("aria-atomic","true"),X.style.cssText=`
|
|
79
79
|
position: fixed;
|
|
80
80
|
top: 80px;
|
|
81
81
|
right: 16px;
|
|
@@ -101,7 +101,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
101
101
|
onclick="this.parentElement.style.transform='translateX(120%)';this.parentElement.style.opacity='0'"
|
|
102
102
|
style="background:none;border:none;color:#fff;cursor:pointer;font-size:18px;padding:0;line-height:1"
|
|
103
103
|
aria-label="Close notification">\xD7</button>
|
|
104
|
-
`,window.innerWidth<=480&&(X.style.right="8px",X.style.left="8px",X.style.maxWidth="none",X.style.width="auto"),requestAnimationFrame(()=>{X&&(X.style.transform="translateX(0)",X.style.opacity="1")}),setTimeout(()=>{X&&(X.style.transform="translateX(120%)",X.style.opacity="0")},5e3)}function V(e,t="info",n=!0){
|
|
104
|
+
`,window.innerWidth<=480&&(X.style.right="8px",X.style.left="8px",X.style.maxWidth="none",X.style.width="auto"),requestAnimationFrame(()=>{X&&(X.style.transform="translateX(0)",X.style.opacity="1")}),setTimeout(()=>{X&&(X.style.transform="translateX(120%)",X.style.opacity="0")},5e3)}function V(e,t="info",n=!0){Qt&&(Qt.textContent=e),co(e,t),n&&Qn(e,t==="error"?"assertive":"polite")}function Ci(){if(typeof document>"u"||eo)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=`
|
|
105
105
|
position: fixed;
|
|
106
106
|
top: 0;
|
|
107
107
|
left: 0;
|
|
@@ -111,13 +111,13 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
111
111
|
flex-wrap: wrap;
|
|
112
112
|
gap: 4px;
|
|
113
113
|
padding: 4px;
|
|
114
|
-
background: #
|
|
114
|
+
background: #001124;
|
|
115
115
|
transform: translateY(-100%);
|
|
116
116
|
transition: transform 0.2s ease;
|
|
117
117
|
font-family: system-ui, sans-serif;
|
|
118
118
|
`;let n=!1;if(e.forEach(({label:a,selector:i})=>{let o=document.querySelector(i);if(!o)return;n=!0,o.getAttribute("tabindex")||o.setAttribute("tabindex","-1");let l=document.createElement("a");l.href="#",l.textContent=a,l.style.cssText=`
|
|
119
119
|
color: #fff;
|
|
120
|
-
background: #
|
|
120
|
+
background: #005A9C;
|
|
121
121
|
padding: 8px 14px;
|
|
122
122
|
border-radius: 4px;
|
|
123
123
|
font-size: 13px;
|
|
@@ -126,7 +126,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
126
126
|
white-space: nowrap;
|
|
127
127
|
border: 2px solid transparent;
|
|
128
128
|
transition: background 0.15s, border-color 0.15s;
|
|
129
|
-
`,l.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),l.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),l.addEventListener("click",s=>{s.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),V(`Jumped to ${a.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(l)}),!n)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),
|
|
129
|
+
`,l.addEventListener("focus",()=>{t.style.transform="translateY(0)"}),l.addEventListener("blur",()=>{setTimeout(()=>{t.matches(":focus-within")||(t.style.transform="translateY(-100%)")},2e3)}),l.addEventListener("click",s=>{s.preventDefault(),o.focus(),o.scrollIntoView({behavior:"smooth",block:"start"}),V(`Jumped to ${a.replace("Skip to ","")}`,"info"),t.style.transform="translateY(-100%)"}),t.appendChild(l)}),!n)return;window.innerWidth<768&&(t.style.transform="translateY(0)",t.style.position="sticky"),window.addEventListener("resize",()=>{window.innerWidth<768&&(t.style.transform="translateY(0)")}),document.body.insertBefore(t,document.body.firstChild),eo=t}function $i(){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=`
|
|
130
130
|
|
|
131
131
|
/* \u2500\u2500 Focus indicator \u2014 WCAG 2.4.11 minimum 2px solid \u2500\u2500 */
|
|
132
132
|
[data-yuktai-a11y] *:focus-visible {
|
|
@@ -272,7 +272,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
272
272
|
width: auto !important;
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
|
-
`,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function
|
|
275
|
+
`,document.head.appendChild(e),document.documentElement.setAttribute("data-yuktai-a11y","true")}function Ri(){typeof document>"u"||document.querySelector("[data-yuktai-kb-init]")||(document.documentElement.setAttribute("data-yuktai-kb-init","true"),document.addEventListener("keydown",e=>{var r,a,i,o,l,s,u;let t=document.activeElement;if(!t)return;let n=t.getAttribute("role")||"";if(e.key==="Escape"){let p=t.closest("[role='dialog'],[role='alertdialog']");if(p){p.style.display="none",V("Dialog closed","info");return}let f=t.closest("[role='menu'],[role='menubar']");f&&(f.style.display="none",V("Menu closed","info"))}if(n==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let p=t.closest("[role='menu'],[role='menubar']");if(!p)return;let f=Array.from(p.querySelectorAll("[role='menuitem']:not([disabled])")),b=f.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),(r=f[(b+1)%f.length])==null||r.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),(a=f[(b-1+f.length)%f.length])==null||a.focus()):e.key==="Home"?(e.preventDefault(),(i=f[0])==null||i.focus()):e.key==="End"&&(e.preventDefault(),(o=f[f.length-1])==null||o.focus())}if(n==="tab"||t.closest("[role='tablist']")){let p=t.closest("[role='tablist']");if(!p)return;let f=Array.from(p.querySelectorAll("[role='tab']:not([disabled])")),b=f.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let d=f[(b+1)%f.length];d==null||d.focus(),d==null||d.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let d=f[(b-1+f.length)%f.length];d==null||d.focus(),d==null||d.click()}}if(n==="option"||t.closest("[role='listbox']")){let p=t.closest("[role='listbox']");if(!p)return;let f=Array.from(p.querySelectorAll("[role='option']:not([aria-disabled='true'])")),b=f.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),(l=f[(b+1)%f.length])==null||l.focus()):e.key==="ArrowUp"?(e.preventDefault(),(s=f[(b-1+f.length)%f.length])==null||s.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),f.forEach(d=>{d!==t&&d.setAttribute("aria-selected","false")}),V(`Selected: ${(u=t.textContent)==null?void 0:u.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Mi()),e.key==="Tab"&&(ue!=null&&ue.speechEnabled)&&setTimeout(()=>{var d;let p=document.activeElement;if(!p)return;let f=p.getAttribute("aria-label")||p.getAttribute("title")||((d=p.textContent)==null?void 0:d.trim())||p.tagName.toLowerCase(),b=p.getAttribute("role")||p.tagName.toLowerCase();Qn(`${f}, ${b}`)},100)}))}function Yt(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],r=t[t.length-1];n.focus(),e.addEventListener("keydown",a=>{a.key==="Tab"&&(a.shiftKey?document.activeElement===n&&(a.preventDefault(),r.focus()):document.activeElement===r&&(a.preventDefault(),n.focus()))})}function Mi(){if(typeof document>"u")return;if(it){it.remove(),it=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=`
|
|
276
276
|
position: fixed;
|
|
277
277
|
top: 50%;
|
|
278
278
|
left: 50%;
|
|
@@ -302,7 +302,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
302
302
|
<span style="font-size:12px;color:#ccc;text-align:right;flex:1;margin-left:12px">${a}</span>
|
|
303
303
|
</div>
|
|
304
304
|
`).join("")}
|
|
305
|
-
`;let n=e.querySelector("[data-yuktai-close]");n==null||n.addEventListener("click",()=>{e.remove(),
|
|
305
|
+
`;let n=e.querySelector("[data-yuktai-close]");n==null||n.addEventListener("click",()=>{e.remove(),it=null}),e.addEventListener("keydown",r=>{r.key==="Escape"&&(e.remove(),it=null)}),document.body.appendChild(e),it=e,Yt(e),V("Keyboard shortcuts opened. Press Escape to close.","info")}function Ei(e){if(typeof document>"u"||!(ue!=null&&ue.showAuditBadge)||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;jn&&jn.remove();let t=e.score,n=t>=90?"#0f9d58":t>=70?"#f29900":"#d93025",r=t>=90?"\u267F":t>=70?"\u26A0":"\u2715",a=document.createElement("button");a.setAttribute("aria-label",`Accessibility score: ${t} out of 100`),a.setAttribute("data-yuktai-badge","true"),a.style.cssText=`
|
|
306
306
|
position: fixed;
|
|
307
307
|
bottom: 16px;
|
|
308
308
|
left: 16px;
|
|
@@ -321,7 +321,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
321
321
|
align-items: center;
|
|
322
322
|
gap: 6px;
|
|
323
323
|
transition: transform 0.15s;
|
|
324
|
-
`,a.innerHTML=`${r} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,a.addEventListener("click",()=>
|
|
324
|
+
`,a.innerHTML=`${r} ${t}/100 <span style="font-weight:400;opacity:0.85">${e.details.length} issues</span>`,a.addEventListener("click",()=>Li(e)),document.body.appendChild(a),jn=a}function Li(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=`
|
|
325
325
|
position: fixed;
|
|
326
326
|
bottom: 56px;
|
|
327
327
|
left: 16px;
|
|
@@ -353,7 +353,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
353
353
|
</div>
|
|
354
354
|
`).join("")}
|
|
355
355
|
${e.details.length>20?`<div style="color:#888;padding:8px 0;text-align:center">+${e.details.length-20} more issues</div>`:""}
|
|
356
|
-
`,n.addEventListener("keydown",a=>{a.key==="Escape"&&n.remove()}),document.body.appendChild(n),
|
|
356
|
+
`,n.addEventListener("keydown",a=>{a.key==="Escape"&&n.remove()}),document.body.appendChild(n),Yt(n)}function uo(e){typeof document>"u"||(Un&&clearTimeout(Un),Un=setTimeout(()=>{if(Ut)return;let t=document.createElement("div");t.setAttribute("role","alertdialog"),t.setAttribute("aria-label","Session timeout warning"),t.setAttribute("aria-modal","true"),t.setAttribute("data-yuktai-timeout","true"),t.style.cssText=`
|
|
357
357
|
position: fixed;
|
|
358
358
|
top: 50%;
|
|
359
359
|
left: 50%;
|
|
@@ -382,22 +382,22 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
382
382
|
No, sign out
|
|
383
383
|
</button>
|
|
384
384
|
</div>
|
|
385
|
-
`;let n=t.querySelector("[data-yuktai-extend]"),r=t.querySelector("[data-yuktai-dismiss]");n==null||n.addEventListener("click",()=>{t.remove(),
|
|
385
|
+
`;let n=t.querySelector("[data-yuktai-extend]"),r=t.querySelector("[data-yuktai-dismiss]");n==null||n.addEventListener("click",()=>{t.remove(),Ut=null,V("Session extended. You have more time.","success"),ue!=null&&ue.timeoutWarning&&uo(ue.timeoutWarning)}),r==null||r.addEventListener("click",()=>{t.remove(),Ut=null}),document.body.appendChild(t),Ut=t,Yt(t),V("Warning: Your session will expire soon. Do you need more time?","warning")},e*1e3))}function Ii(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(#${Kt[e.colorBlindMode]})`;document.body.style.filter=n}else document.body.style.filter=""}function Ni(e){try{let t=localStorage.getItem("yuktai-a11y-prefs");t&&Object.assign(e,JSON.parse(t))}catch{}}async function no(e){if(e){if(!await qn()){V("Plain English requires Chrome 127+","warning");return}V("Rewriting page in plain English...","info",!1);let n=await zr();V(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else qr(),V("Original text restored","info",!1)}async function ro(e){if(e){if(!await Hn()){V("Page summariser requires Chrome 127+","warning");return}V("Generating page summary...","info",!1);let n=await _r();V(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else Vt(),V("Page summary removed","info",!1)}async function oo(e){if(e==="en"){Bn(),V("Page restored to English","info",!1);return}V(`Translating page to ${e}...`,"info",!1);let t=await Wr(e);V(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function io(e){if(e){if(!_n()){V("Voice control not supported in this browser","warning");return}Ur(t=>{t.success&&V(`Voice: ${t.action}`,"info",!1)}),V("Voice control started. Say a command.","success",!1)}else Vn(),V("Voice control stopped","info",!1)}async function ao(e){if(e){if(!await Wn()){V("Smart labels requires Chrome 127+","warning");return}V("Generating smart labels...","info",!1);let n=await Jr();V(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else Xr(),V("Smart labels removed","info",!1)}function Fi(){if(typeof document>"u"||Qt)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),Qt=e}function Pi(){if(typeof document>"u"||Zr)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=`
|
|
386
386
|
<defs>
|
|
387
|
-
<filter id="${
|
|
387
|
+
<filter id="${Kt.deuteranopia}">
|
|
388
388
|
<feColorMatrix type="matrix"
|
|
389
389
|
values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
|
|
390
390
|
</filter>
|
|
391
|
-
<filter id="${
|
|
391
|
+
<filter id="${Kt.protanopia}">
|
|
392
392
|
<feColorMatrix type="matrix"
|
|
393
393
|
values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
|
|
394
394
|
</filter>
|
|
395
|
-
<filter id="${
|
|
395
|
+
<filter id="${Kt.tritanopia}">
|
|
396
396
|
<feColorMatrix type="matrix"
|
|
397
397
|
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"/>
|
|
398
398
|
</filter>
|
|
399
399
|
</defs>
|
|
400
|
-
`,document.body.appendChild(e),Qr=e}function ro(e){var t,n,r;return(t=e.getAttribute("aria-label"))!=null&&t.trim()||e.getAttribute("aria-labelledby")||(n=e.getAttribute("title"))!=null&&n.trim()||(r=e.textContent)!=null&&r.trim()?!0:!!e.querySelector("img[alt]:not([alt='']), svg[aria-label], svg title, [aria-label]")}function oo(e){let t={critical:20,serious:10,moderate:5,minor:2},n=e.details.reduce((r,a)=>r+(t[a.severity]||0),0);return Math.max(0,Math.min(100,100-n))}var He={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";ue=e,Ci(e),$i(),Ri(),wi(),xi(),e.showSkipLinks!==!1&&vi(),e.showPreferencePanel,Si(e);let t=this.applyFixes(e);t.score=oo(t),e.showAuditBadge&&Ai(t),e.timeoutWarning&&ao(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await Xr(!0),e.summarisePage&&await Zr(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await eo(e.translateLanguage),e.voiceControl&&await to(!0),e.smartLabels&&await no(!0);let n=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return V(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(),r=document.querySelectorAll("*");t.scanned=r.length;let a=(i,o,l,s)=>{t.details.push({tag:i,fix:o,severity:l,element:s.outerHTML.slice(0,100)}),t.fixed++};return r.forEach(i=>{var p,f;let o=i,l=o.tagName.toLowerCase();if(l==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),a(l,'lang="en" added',"critical",o)),l==="meta"){let b=o.getAttribute("name"),d=o.getAttribute("content")||"";b==="viewport"&&d.includes("user-scalable=no")&&(o.setAttribute("content",d.replace("user-scalable=no","user-scalable=yes")),a(l,"user-scalable=yes restored","serious",o)),b==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(d)&&(o.setAttribute("content",d.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(l,"maximum-scale=5 restored","serious",o))}if(l==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),l==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),a(l,'alt="" aria-hidden="true"',"serious",o))),l==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!i.querySelector("title")&&(o.setAttribute("aria-hidden","true"),a(l,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),l==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),a(l,"title + aria-label added","serious",o)),l==="button"){if(!ro(o)){let b=o.getAttribute("title")||"button";o.setAttribute("aria-label",b),a(l,`aria-label="${b}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(l==="a"){let b=o;ro(o)||(o.setAttribute("aria-label",o.getAttribute("title")||"link"),a(l,"aria-label added (empty link)","critical",o)),b.target==="_blank"&&!((p=b.rel)!=null&&p.includes("noopener"))&&(b.rel="noopener noreferrer",t.fixed++)}if(Jr.has(l)){let b=o;if(!(!!(b.labels&&b.labels.length)||!!o.getAttribute("title")||b.type==="hidden"||b.type==="submit"||b.type==="button"||b.type==="reset")&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let S=o.getAttribute("placeholder")||o.getAttribute("name")||l;o.setAttribute("aria-label",S),a(l,`aria-label="${S}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),l==="input"&&!b.autocomplete){let S=b.name||"",y=b.type==="email"||S.includes("email")?"email":b.type==="tel"||S.includes("tel")?"tel":b.type==="password"?"current-password":"";y&&(b.autocomplete=y,t.fixed++)}}l==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),a(l,"scope added to <th>","moderate",o));let s=(l==="header"||l==="footer")&&!!((f=o.parentElement)!=null&&f.closest("article,aside,main,nav,section,[role='dialog'],[role='region']"));jn[l]&&!o.getAttribute("role")&&!s&&(o.setAttribute("role",jn[l]),a(l,`role="${jn[l]}"`,"minor",o));let u=o.getAttribute("role")||"";u==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(u)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",u==="alert"?"assertive":"polite"),a(l,`aria-live added on role=${u}`,"moderate",o)),u==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),a(l,'aria-expanded="false" on combobox',"serious",o)),(u==="checkbox"||u==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),a(l,`aria-checked="false" on role=${u}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-n).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),n=document.querySelectorAll("*");e.scanned=n.length;let r=(a,i,o,l)=>e.details.push({tag:a,fix:i,severity:o,element:l.outerHTML.slice(0,100)});return n.forEach(a=>{var l;let i=a,o=i.tagName.toLowerCase();(o==="a"||o==="button")&&!((l=i.innerText)!=null&&l.trim())&&!i.getAttribute("aria-label")&&r(o,"needs aria-label (empty)","critical",i),o==="img"&&!i.hasAttribute("alt")&&r(o,"needs alt text","serious",i),Jr.has(o)&&!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")&&r(o,"needs aria-label","serious",i),o==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&r(o,"iframe needs title","serious",i)}),e.fixed=e.details.length,e.score=oo(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(){var e;(e=this.observer)==null||e.disconnect(),this.observer=null},announce:V,speak:Wn,showVisualAlert:io,trapFocus:Kt,handlePlainEnglish:Xr,handleSummarisePage:Zr,handleTranslate:eo,handleVoiceControl:to,handleSmartLabels:no,SUPPORTED_LANGUAGES:qr};var Ei=/\b(off|disable|stop|remove|no more|turn off|switch off|deactivate)\b|ఆఫ్|ఆపు|తీసివేయి|बंद/i,Li=[{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"}],Mi=[[/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"]],Qt=.1,Un=.8,Kn=1.3;function Qn(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 r=t.fontSizeMultiplier??1,a=o=>Math.round(Math.min(Kn,Math.max(Un,o))*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 o=a(r+Qt);return{type:"setting",patch:{fontSizeMultiplier:o},say:`Text size ${Math.round(o*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 o=a(r-Qt);return{type:"setting",patch:{fontSizeMultiplier:o},say:`Text size ${Math.round(o*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 i=Ei.test(n);for(let[o,l]of Mi)if(o.test(n))return i?{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."}:{type:"setting",patch:{colorBlindMode:l},say:`${l} filter on.`};if(/colou?r.?blind/.test(n)&&i)return{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."};for(let o of Li){if(!o.pattern.test(n))continue;let l=/\btoggle\b/.test(n)?!t[o.key]:!i;return o.key==="reduceMotion"&&!/reduce motion|less motion|కదలికలు తగ్గించు/.test(n)&&/animations?/.test(n)&&(l=i||/\bno\b/.test(n)),{type:"setting",patch:{[o.key]:l},say:`${o.name} ${l?"on":"off"}.`}}return null}var rt={highContrast:!1,darkMode:!1,reduceMotion:!1,largeTargets:!1,dyslexiaFont:!1,speechEnabled:!1,colorBlindMode:"none",fontSizeMultiplier:1};function Yn(e,t={}){var u,p;if(!ke())return null;let n=t.root??document,r=t.rowSelector??"[data-yuktai-row-id], [role='row']",a=Array.from(n.querySelectorAll(r)).filter(f=>!f.querySelector("th,[role='columnheader']"));if(!a.length)return null;let i=(u=document.activeElement)==null?void 0:u.closest(r),o=i?a.indexOf(i):-1;if(e==="open-row"){let f=o>=0?a[o]:a[0];return f.click(),f}let l=e==="first-row"?0:e==="last-row"?a.length-1:e==="next-row"?Math.min(a.length-1,o+1):Math.max(0,o-1),s=a[l];return s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1"),s.focus(),(p=s.scrollIntoView)==null||p.call(s,{block:"nearest"}),s}function Yt(e={}){let t={enabled:!0,...rt,...e.initial},n=null,r=!1,a=async u=>e.apply?e.apply(u):He.execute(u),i=u=>{if(e.speak===!1||!ke()||!("speechSynthesis"in window))return;let p=new SpeechSynthesisUtterance(u);p.lang=e.lang??"en-IN",window.speechSynthesis.cancel(),window.speechSynthesis.speak(p)};async function o(u){var f;let p=Qn(u,t);if((f=e.onTranscript)==null||f.call(e,u,p),!p)return null;if(p.type==="grid"){let b=Yn(p.action,{root:e.gridRoot});return i(b?p.say:"No table rows found."),p}return t=p.type==="reset"?{...t,...rt}:{...t,...p.patch},await a(t),i(p.say),p}function l(){if(!ke()||r)return r;let u=window,p=u.SpeechRecognition??u.webkitSpeechRecognition;return p?(n=new p,n.lang=e.lang??"en-IN",n.continuous=!0,n.interimResults=!1,n.onresult=f=>{var S;let b=f.results,d=b[b.length-1];(S=d==null?void 0:d[0])!=null&&S.transcript&&o(d[0].transcript)},n.onend=()=>{r&&(n==null||n.start())},n.onerror=f=>{(f.error==="not-allowed"||f.error==="service-not-allowed")&&(r=!1)},r=!0,n.start(),!0):!1}function s(){r=!1,n==null||n.stop(),n=null}return{start:l,stop:s,handle:o,isListening:()=>r,getConfig:()=>({...t})}}function co(){let e=new Set;return{subscribe(t){return e.add(t),()=>e.delete(t)},emit(t){e.forEach(n=>{try{n(t)}catch(r){console.error("[yuktai] listener failed",r)}})}}}var Xn=e=>e instanceof Error?e:new Error(String(e)),Ii={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."}},so=e=>String(e??"").normalize("NFC").toLowerCase().trim(),Ne={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 Ni(e,t){let n=so(e),r=null;for(let a of t)for(let i of[a.label,a.key]){let o=so(i);o&&n.includes(o)&&(!r||o.length>r.len)&&(r={key:a.key,len:o.length})}return r?r.key:null}function Zn(e,t){let n=String(e??"").trim();if(!n)return null;let r=t&&t.columns||[];if(Ne.clearFilters.test(n))return{kind:"tool",tool:"clear_filters",input:{}};if(Ne.clearSort.test(n))return{kind:"tool",tool:"clear_sort",input:{}};if(Ne.count.test(n))return{kind:"tool",tool:"count",input:{}};if(Ne.sort.test(n)){let o=Ni(n,r);return o?{kind:"tool",tool:"sort",input:{key:o,direction:Ne.desc.test(n)?"desc":"asc"}}:null}let a=n.match(Ne.openEn)||n.match(Ne.openTe);if(a&&a[1])return{kind:"open",text:a[1].trim()};let i=n.replace(Ne.searchFiller,"").trim();return i?{kind:"tool",tool:"search",input:{query:i}}:null}function Fi(e){return!!e&&typeof e=="object"&&typeof e.success=="boolean"&&typeof e.message=="string"}function Pi(e,t){let n=e.inputSchema&&e.inputSchema.required;return Array.isArray(n)?n.map(String).filter(r=>t[r]===void 0||t[r]===null||String(t[r]).trim()===""):[]}function Gi(e,t){let n=e.find(a=>a.name===t);if(n)return n;let r=e.filter(a=>a.name.endsWith(`_${t}`)).sort((a,i)=>a.name.length-i.name.length);if(r.length&&!(r.length>1&&r[0].name.length===r[1].name.length))return r[0]}var lo=e=>String(e??"").normalize("NFC").trim().toLocaleLowerCase();function Di(e,t){let n=lo(e);return(t||[]).find(r=>(r.phrases||[]).some(a=>{let i=lo(a);return i.length>0&&n.includes(i)}))}function Jt(e={}){let t=E=>typeof E=="function"?E():E,n={locale:"en",rowKey:"id",historyLimit:20,customRules:[],...e},r=co(),a=0,i=null,o=null,l=[],s=0,u=()=>Ii[n.locale==="te"?"te":"en"],p=()=>t(n.tools)||[],f=()=>({loading:a>0,lastResult:i,lastError:o,history:l.slice()}),b=()=>r.emit(f());function d(E,k,h,w,v){v===s&&(i=h),l=[...l,{id:v,tool:E,input:k,result:h,source:w,at:Date.now()}].slice(-n.historyLimit),b()}async function S(E,k,h){let w=++s,v=Gi(p(),E);if(!v){let x={success:!1,message:u().toolMissing(E),error:{code:"NOT_SUPPORTED"}};return o=new Error(x.message),n.onError&&n.onError(o),d(E,k,x,h,w),x}let L=Pi(v,k);if(L.length){let x={success:!1,message:u().missingInput(L.join(", ")),error:{code:"INVALID_INPUT"},tool:v.name};return d(v.name,k,x,h,w),n.onResult&&n.onResult(x),x}a++,b();try{let x=await v.execute(k),$=Fi(x)?{...x,tool:v.name}:{success:!0,message:u().done,data:x,tool:v.name};return $.success&&(o=null),d(v.name,k,$,h,w),n.onResult&&n.onResult($),$}catch(x){o=Xn(x);let $={success:!1,message:u().failed,error:{code:"INTERNAL"},tool:v.name};return n.onError&&n.onError(o),d(v.name,k,$,h,w),$}finally{a=Math.max(0,a-1),b()}}let y=(E,k={})=>S(E,k||{},"tool");async function m(E){let k=t(n.columns)||[],h=Di(E,n.customRules);if(h){let x=++s;try{let $=await h.execute({input:E,data:t(n.data)||[],columns:k,executeTool:y}),I={success:!0,message:String($??u().done),tool:`rule:${h.name}`};return d(`rule:${h.name}`,{text:E},I,"ask",x),n.onResult&&n.onResult(I),I}catch($){o=Xn($),n.onError&&n.onError(o);let I={success:!1,message:u().failed,error:{code:"INTERNAL"},tool:`rule:${h.name}`};return d(`rule:${h.name}`,{text:E},I,"ask",x),I}}let w=(n.parseIntent||Zn)(E,{columns:k,locale:n.locale});if(!w){let x={success:!1,message:u().notUnderstood,error:{code:"NOT_UNDERSTOOD"}};return d("ask",{text:E},x,"ask",++s),x}if(w.kind==="tool")return S(w.tool,w.input,"ask");let v=await S("search",{query:w.text},"ask");if(!v.success)return v;let L=Array.isArray(v.data)?v.data:[];if(!L.length){let x={success:!1,message:u().noMatch(w.text),error:{code:"NOT_FOUND"},tool:v.tool};return d("open",{text:w.text},x,"ask",++s),x}return S("open",{id:ee(L[0],n.rowKey)},"ask")}function C(){l=[],i=null,o=null,b()}return{ask:m,executeTool:y,clearHistory:C,subscribe:r.subscribe,getState:f,get tools(){return p()},get loading(){return a>0},get lastResult(){return i},get lastError(){return o},get history(){return l.slice()}}}function Xt(e,t={}){let n=()=>(typeof e=="function"?e():e)||[],r=l=>{a.status=l,t.onStatusChange&&t.onStatusChange(l)},a={status:{state:"unsupported",registered:[],errors:[]},done:Promise.resolve(),unregister(){o.abort()}},i=typeof document<"u"?document.modelContext:void 0,o=new AbortController;return!i||typeof i.registerTool!="function"?(r({state:"unsupported",registered:[],errors:[]}),a):(a.done=(async()=>{r({state:"registering",registered:[],errors:[]});let l=[],s=[];for(let u of n()){if(o.signal.aborted)return;try{await i.registerTool({name:u.name,title:u.title,description:u.description,inputSchema:u.inputSchema,execute:p=>{let f=n().find(b=>b.name===u.name);return f?f.execute(p||{}):{success:!1,message:`Tool "${u.name}" is no longer available.`,error:{code:"NOT_SUPPORTED"}}}},{signal:o.signal}),l.push(u.name)}catch(p){s.push({tool:u.name,message:Xn(p).message})}}o.signal.aborted||r({state:s.length===0?"ready":l.length?"partial":"error",registered:l,errors:s})})(),a)}var Oi=/\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,zi={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""};function Zt(e={}){let t=co(),n=e.rowKey||"id",r=e.bind||null,a=Array.isArray(e.data)?e.data:[],i=Me(e.columns||[]),o={filters:[],sort:null,highlightIds:[]},l="",s=null,u=[],p=[],f=!1,b=()=>r?r.getFilters():o.filters,d=()=>r?r.getSort():o.sort,S=()=>r?r.getHighlightIds():o.highlightIds,y=()=>r?r.getData():a,m=I=>r?r.setFilters(I):o={...o,filters:I},C=I=>r?r.setSort(I):o={...o,sort:I},E=I=>r?r.setHighlightIds(I):o={...o,highlightIds:I};function k(){return Ee(y(),i,{...zi,filters:b(),sort:d()})}let h=()=>{let I=k();return{gridData:I,highlightIds:S().slice(),filters:b().slice(),sort:d(),answer:l,kind:s,table:u.slice(),steps:p.slice(),busy:f,visibleIds:I.map(T=>ee(T,n))}},w=()=>t.emit(h()),v=()=>({get data(){return y()},columns:i,rowKey:n,get filters(){return b()},onFiltersChange:I=>{m(I),w()},onSortChange:I=>{C(I),w()},onHighlightRows:I=>{E(I),w()},onOpenRow:e.onOpenRow,onSelectRow:I=>{r&&r.selectRow?r.selectRow(I):E([I]),w()}});async function L(I){let T=String(I??"").trim();if(!T)return h();f=!0,p=[],u=[],w();try{if(mt(T).length>1){let R=[],G=await Nt(T,v(),{onStep:N=>{R.push(N),p=R.slice(),w()}});s="tasks",l=G.summary}else if(Oi.test(T)){let R=Re(y(),i,b()),G=It(T,R,i,{referenceDate:e.referenceDate});s="insight",l=G.answer,u=G.table||[]}else{let R=Lt(T,v());s=R.kind,l=R.message}}catch(R){console.error("[yuktai] ask failed",R),s=null,l="Something went wrong while answering. Please rephrase the question."}finally{f=!1,w()}return h()}function x(){m([]),C(null),E([]),l="",s=null,u=[],p=[],w()}function $(I={}){Array.isArray(I.data)&&(a=I.data),Array.isArray(I.columns)&&(i=Me(I.columns)),w()}return{ask:L,reset:x,update:$,subscribe:t.subscribe,getState:h,get gridData(){return k()},get highlightIds(){return S().slice()},get filters(){return b().slice()},get sort(){return d()},get answer(){return l},get kind(){return s},get table(){return u.slice()},get steps(){return p.slice()},get busy(){return f},get visibleIds(){return k().map(I=>ee(I,n))}}}var Fe=()=>typeof window<"u"&&typeof document<"u";function yt(e){return String(e??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function c(e,t,...n){let r=document.createElement(e);if(t)for(let[a,i]of Object.entries(t))i==null||i===!1||(a.startsWith("on")&&typeof i=="function"?r.addEventListener(a.slice(2),i):a==="html"?r.innerHTML=i:a==="text"?r.textContent=i:i===!0?r.setAttribute(a,""):r.setAttribute(a,String(i)));for(let a of n.flat())a==null||a===!1||r.append(a instanceof Node?a:document.createTextNode(String(a)));return r}var qi=0,W=(e="yv")=>`${e}-${++qi}`;function en(e,t){if(typeof e!="string"||!Fe())return t;let n=document.createElement("span");return n.style.color=e,n.style.color?e:t}var tr=()=>Fe()&&(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.hasAttribute("data-yuktai-reduce-motion")),er={accessibility:'<circle cx="12" cy="4" r="2"/><path d="M4 8l8-1 8 1M12 7v5m-5 9 5-8 5 8M7 12l-2 5m12-5 2 5"/>',contrast:'<circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 0 0 18z"/>',moon:'<path d="M20 14.5A8.5 8.5 0 0 1 9.5 4 8.5 8.5 0 1 0 20 14.5z"/>',motion:'<path d="M4 12h12m-5-5 5 5-5 5M20 5v14"/>',reading:'<path d="M4 5h16M4 10h12M4 15h16M4 20h10"/>',target:'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="4"/>',speaker:'<path d="M4 9v6h4l5 4V5L8 9H4z"/><path d="M16 9a4 4 0 0 1 0 6M18.5 6.5a8 8 0 0 1 0 11"/>',palette:'<circle cx="12" cy="12" r="9"/><circle cx="8" cy="10" r="1.3"/><circle cx="12" cy="7.5" r="1.3"/><circle cx="16" cy="10" r="1.3"/><path d="M12 21a3 3 0 0 1 0-6h2"/>',skip:'<path d="M5 5l7 7-7 7M13 5l7 7-7 7"/>',close:'<path d="m18 6-12 12M6 6l12 12"/>',plus:'<path d="M12 5v14M5 12h14"/>',minus:'<path d="M5 12h14"/>',reset:'<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>',search:'<circle cx="11" cy="11" r="6.5"/><path d="m16 16 5 5"/>',sort:'<path d="m8 9 4-4 4 4m-8 6 4 4 4-4"/>',sortUp:'<path d="m6 15 6-6 6 6"/>',sortDown:'<path d="m6 9 6 6 6-6"/>',chevrons:'<path d="m8 9 4-4 4 4m-8 6 4 4 4-4"/>',grid:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/>',cards:'<rect x="3" y="4" width="18" height="7" rx="1.5"/><rect x="3" y="13" width="18" height="7" rx="1.5"/>',chat:'<path d="M21 11.5a8.5 8.5 0 0 1-8.5 8.5 9 9 0 0 1-4-.9L3 21l1.9-5.5a9 9 0 0 1-.9-4A8.5 8.5 0 0 1 12.5 3H13a8.5 8.5 0 0 1 8 8z"/>',mic:'<rect x="9" y="2" width="6" height="12" rx="3"/><path d="M5 10a7 7 0 0 0 14 0M12 17v5m-4 0h8"/>',stop:'<rect x="6" y="6" width="12" height="12" rx="2"/>',download:'<path d="M12 3v12m-5-5 5 5 5-5M4 21h16"/>',copy:'<rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/>',filter:'<path d="M4 5h16l-6 7v6l-4 2v-8z"/>',check:'<path d="m5 12 4 4L19 6"/>',left:'<path d="m15 18-6-6 6-6"/>',right:'<path d="m9 18 6-6-6-6"/>',first:'<path d="m11 18-6-6 6-6M19 18l-6-6 6-6"/>',last:'<path d="m13 18 6-6-6-6M5 18l6-6-6-6"/>',spark:'<path d="m12 3 1.9 5.8L20 11l-6.1 2.2L12 19l-1.9-5.8L4 11l6.1-2.2zM19 14l1.2 2.8L23 18l-2.8 1.2L19 22l-1.2-2.8L15 18l2.8-1.2z"/>',alert:'<path d="m12 3 10 18H2L12 3z"/><path d="M12 9v5m0 3h.01"/>',info:'<circle cx="12" cy="12" r="9"/><path d="M12 11v6m0-9h.01"/>',form:'<rect x="5" y="3" width="14" height="18" rx="2"/><path d="M9 8h6M9 12h6M9 16h3"/>',eye:'<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>',layout:'<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/>',wand:'<path d="m15 4 5 5L9 20H4v-5z"/><path d="m13 6 5 5"/>',undo:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 0 12h-3"/>',tools:'<path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.5 2.5-2.4-.6-.6-2.4z"/>',plug:'<path d="M9 2v6M15 2v6M6 8h12v4a6 6 0 0 1-12 0zM12 18v4"/>'},uo=Object.keys(er);function de(e,t=20,n){return`<svg ${n?`role="img" aria-label="${yt(n)}"`:'aria-hidden="true" focusable="false"'} width="${Number(t)||20}" height="${Number(t)||20}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round">${er[e]||er.spark}</svg>`}function q(e,t,n){let r=document.createElement("span");return r.className="yv-ic",r.innerHTML=de(e,t,n),r}var _e=null;function re(e){!Fe()||!e||((!_e||!document.contains(_e))&&(_e=c("div",{id:"yuktai-vanilla-live",class:"yv-sr",role:"status","aria-live":"polite","aria-atomic":"true"}),document.body.appendChild(_e)),_e.textContent="",setTimeout(()=>{_e&&(_e.textContent=String(e).slice(0,300))},30))}function vt(e,t,n="text/plain;charset=utf-8"){let r=URL.createObjectURL(new Blob([t],{type:n})),a=c("a",{href:r,download:e,hidden:!0});document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(r),1500)}async function po(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=c("textarea",{"aria-hidden":"true",style:"position:fixed;opacity:0;left:-9999px"});t.value=e,document.body.appendChild(t),t.select();let n=!1;try{n=document.execCommand("copy")}catch{n=!1}return t.remove(),n}}function nr(e){let t=String(e??"");return/^[=+\-@\t\r]/.test(t)&&(t="'"+t),'"'+t.replace(/"/g,'""')+'"'}function go(e){let t=(e||[]).map(n=>{try{return document.querySelector(n)}catch{return null}}).filter(Boolean);return t.forEach(n=>{n.setAttribute("data-yv-flash",""),setTimeout(()=>n.removeAttribute("data-yv-flash"),4e3)}),t[0]&&t[0].scrollIntoView({block:"center",behavior:tr()?"auto":"smooth"}),t.length}function tn(e,t){if(!Fe()||document.getElementById("yuktai-vanilla-css"))return;let n=document.createElement("style");n.id="yuktai-vanilla-css",n.textContent=`
|
|
400
|
+
`,document.body.appendChild(e),Zr=e}function so(e){var t,n,r;return(t=e.getAttribute("aria-label"))!=null&&t.trim()||e.getAttribute("aria-labelledby")||(n=e.getAttribute("title"))!=null&&n.trim()||(r=e.textContent)!=null&&r.trim()?!0:!!e.querySelector("img[alt]:not([alt='']), svg[aria-label], svg title, [aria-label]")}function lo(e){let t={critical:20,serious:10,moderate:5,minor:2},n=e.details.reduce((r,a)=>r+(t[a.severity]||0),0);return Math.max(0,Math.min(100,100-n))}var _e={name:"yuktai-a11y",version:"4.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai: disabled.";ue=e,Ni(e),Fi(),Pi(),$i(),Ri(),e.showSkipLinks!==!1&&Ci(),e.showPreferencePanel,Ii(e);let t=this.applyFixes(e);t.score=lo(t),e.showAuditBadge&&Ei(t),e.timeoutWarning&&uo(e.timeoutWarning),e.autoFix&&this.startObserver(e),e.plainEnglish&&await no(!0),e.summarisePage&&await ro(!0),e.translateLanguage&&e.translateLanguage!=="en"&&await oo(e.translateLanguage),e.voiceControl&&await io(!0),e.smartLabels&&await ao(!0);let n=`${t.fixed} fixes applied. Score: ${t.score}/100.`;return V(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(),r=document.querySelectorAll("*");t.scanned=r.length;let a=(i,o,l,s)=>{t.details.push({tag:i,fix:o,severity:l,element:s.outerHTML.slice(0,100)}),t.fixed++};return r.forEach(i=>{var p,f;let o=i,l=o.tagName.toLowerCase();if(l==="html"&&!o.getAttribute("lang")&&(o.setAttribute("lang","en"),a(l,'lang="en" added',"critical",o)),l==="meta"){let b=o.getAttribute("name"),d=o.getAttribute("content")||"";b==="viewport"&&d.includes("user-scalable=no")&&(o.setAttribute("content",d.replace("user-scalable=no","user-scalable=yes")),a(l,"user-scalable=yes restored","serious",o)),b==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(d)&&(o.setAttribute("content",d.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(l,"maximum-scale=5 restored","serious",o))}if(l==="main"&&!o.getAttribute("tabindex")&&(o.setAttribute("tabindex","-1"),o.getAttribute("id")||o.setAttribute("id","main-content")),l==="img"&&(o.hasAttribute("alt")||(o.setAttribute("alt",""),o.setAttribute("aria-hidden","true"),a(l,'alt="" aria-hidden="true"',"serious",o))),l==="svg"&&(!o.getAttribute("aria-hidden")&&!o.getAttribute("aria-label")&&!i.querySelector("title")&&(o.setAttribute("aria-hidden","true"),a(l,'aria-hidden="true" (decorative svg)',"minor",o)),o.getAttribute("focusable")||o.setAttribute("focusable","false")),l==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&(o.setAttribute("title","embedded content"),o.setAttribute("aria-label","embedded content"),a(l,"title + aria-label added","serious",o)),l==="button"){if(!so(o)){let b=o.getAttribute("title")||"button";o.setAttribute("aria-label",b),a(l,`aria-label="${b}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(l==="a"){let b=o;so(o)||(o.setAttribute("aria-label",o.getAttribute("title")||"link"),a(l,"aria-label added (empty link)","critical",o)),b.target==="_blank"&&!((p=b.rel)!=null&&p.includes("noopener"))&&(b.rel="noopener noreferrer",t.fixed++)}if(to.has(l)){let b=o;if(!(!!(b.labels&&b.labels.length)||!!o.getAttribute("title")||b.type==="hidden"||b.type==="submit"||b.type==="button"||b.type==="reset")&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let S=o.getAttribute("placeholder")||o.getAttribute("name")||l;o.setAttribute("aria-label",S),a(l,`aria-label="${S}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),l==="input"&&!b.autocomplete){let S=b.name||"",y=b.type==="email"||S.includes("email")?"email":b.type==="tel"||S.includes("tel")?"tel":b.type==="password"?"current-password":"";y&&(b.autocomplete=y,t.fixed++)}}l==="th"&&!o.getAttribute("scope")&&(o.setAttribute("scope",o.closest("thead")?"col":"row"),a(l,"scope added to <th>","moderate",o));let s=(l==="header"||l==="footer")&&!!((f=o.parentElement)!=null&&f.closest("article,aside,main,nav,section,[role='dialog'],[role='region']"));Kn[l]&&!o.getAttribute("role")&&!s&&(o.setAttribute("role",Kn[l]),a(l,`role="${Kn[l]}"`,"minor",o));let u=o.getAttribute("role")||"";u==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(u)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",u==="alert"?"assertive":"polite"),a(l,`aria-live added on role=${u}`,"moderate",o)),u==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),a(l,'aria-expanded="false" on combobox',"serious",o)),(u==="checkbox"||u==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),a(l,`aria-checked="false" on role=${u}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-n).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),n=document.querySelectorAll("*");e.scanned=n.length;let r=(a,i,o,l)=>e.details.push({tag:a,fix:i,severity:o,element:l.outerHTML.slice(0,100)});return n.forEach(a=>{var l;let i=a,o=i.tagName.toLowerCase();(o==="a"||o==="button")&&!((l=i.innerText)!=null&&l.trim())&&!i.getAttribute("aria-label")&&r(o,"needs aria-label (empty)","critical",i),o==="img"&&!i.hasAttribute("alt")&&r(o,"needs alt text","serious",i),to.has(o)&&!i.getAttribute("aria-label")&&!i.getAttribute("aria-labelledby")&&r(o,"needs aria-label","serious",i),o==="iframe"&&!i.getAttribute("title")&&!i.getAttribute("aria-label")&&r(o,"iframe needs title","serious",i)}),e.fixed=e.details.length,e.score=lo(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(){var e;(e=this.observer)==null||e.disconnect(),this.observer=null},announce:V,speak:Qn,showVisualAlert:co,trapFocus:Yt,handlePlainEnglish:no,handleSummarisePage:ro,handleTranslate:oo,handleVoiceControl:io,handleSmartLabels:ao,SUPPORTED_LANGUAGES:Vr};var Gi=/\b(off|disable|stop|remove|no more|turn off|switch off|deactivate)\b|ఆఫ్|ఆపు|తీసివేయి|बंद/i,Oi=[{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"}],Di=[[/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"]],Jt=.1,Yn=.8,Jn=1.3;function Xn(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 r=t.fontSizeMultiplier??1,a=o=>Math.round(Math.min(Jn,Math.max(Yn,o))*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 o=a(r+Jt);return{type:"setting",patch:{fontSizeMultiplier:o},say:`Text size ${Math.round(o*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 o=a(r-Jt);return{type:"setting",patch:{fontSizeMultiplier:o},say:`Text size ${Math.round(o*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 i=Gi.test(n);for(let[o,l]of Di)if(o.test(n))return i?{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."}:{type:"setting",patch:{colorBlindMode:l},say:`${l} filter on.`};if(/colou?r.?blind/.test(n)&&i)return{type:"setting",patch:{colorBlindMode:"none"},say:"Colour filter off."};for(let o of Oi){if(!o.pattern.test(n))continue;let l=/\btoggle\b/.test(n)?!t[o.key]:!i;return o.key==="reduceMotion"&&!/reduce motion|less motion|కదలికలు తగ్గించు/.test(n)&&/animations?/.test(n)&&(l=i||/\bno\b/.test(n)),{type:"setting",patch:{[o.key]:l},say:`${o.name} ${l?"on":"off"}.`}}return null}var at={highContrast:!1,darkMode:!1,reduceMotion:!1,largeTargets:!1,dyslexiaFont:!1,speechEnabled:!1,colorBlindMode:"none",fontSizeMultiplier:1};function Zn(e,t={}){var u,p;if(!ke())return null;let n=t.root??document,r=t.rowSelector??"[data-yuktai-row-id], [role='row']",a=Array.from(n.querySelectorAll(r)).filter(f=>!f.querySelector("th,[role='columnheader']"));if(!a.length)return null;let i=(u=document.activeElement)==null?void 0:u.closest(r),o=i?a.indexOf(i):-1;if(e==="open-row"){let f=o>=0?a[o]:a[0];return f.click(),f}let l=e==="first-row"?0:e==="last-row"?a.length-1:e==="next-row"?Math.min(a.length-1,o+1):Math.max(0,o-1),s=a[l];return s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1"),s.focus(),(p=s.scrollIntoView)==null||p.call(s,{block:"nearest"}),s}function Xt(e={}){let t={enabled:!0,...at,...e.initial},n=null,r=!1,a=async u=>e.apply?e.apply(u):_e.execute(u),i=u=>{if(e.speak===!1||!ke()||!("speechSynthesis"in window))return;let p=new SpeechSynthesisUtterance(u);p.lang=e.lang??"en-IN",window.speechSynthesis.cancel(),window.speechSynthesis.speak(p)};async function o(u){var f;let p=Xn(u,t);if((f=e.onTranscript)==null||f.call(e,u,p),!p)return null;if(p.type==="grid"){let b=Zn(p.action,{root:e.gridRoot});return i(b?p.say:"No table rows found."),p}return t=p.type==="reset"?{...t,...at}:{...t,...p.patch},await a(t),i(p.say),p}function l(){if(!ke()||r)return r;let u=window,p=u.SpeechRecognition??u.webkitSpeechRecognition;return p?(n=new p,n.lang=e.lang??"en-IN",n.continuous=!0,n.interimResults=!1,n.onresult=f=>{var S;let b=f.results,d=b[b.length-1];(S=d==null?void 0:d[0])!=null&&S.transcript&&o(d[0].transcript)},n.onend=()=>{r&&(n==null||n.start())},n.onerror=f=>{(f.error==="not-allowed"||f.error==="service-not-allowed")&&(r=!1)},r=!0,n.start(),!0):!1}function s(){r=!1,n==null||n.stop(),n=null}return{start:l,stop:s,handle:o,isListening:()=>r,getConfig:()=>({...t})}}function mo(){let e=new Set;return{subscribe(t){return e.add(t),()=>e.delete(t)},emit(t){e.forEach(n=>{try{n(t)}catch(r){console.error("[yuktai] listener failed",r)}})}}}var tr=e=>e instanceof Error?e:new Error(String(e)),zi={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."}},po=e=>String(e??"").normalize("NFC").toLowerCase().trim(),Fe={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 qi(e,t){let n=po(e),r=null;for(let a of t)for(let i of[a.label,a.key]){let o=po(i);o&&n.includes(o)&&(!r||o.length>r.len)&&(r={key:a.key,len:o.length})}return r?r.key:null}function nr(e,t){let n=String(e??"").trim();if(!n)return null;let r=t&&t.columns||[];if(Fe.clearFilters.test(n))return{kind:"tool",tool:"clear_filters",input:{}};if(Fe.clearSort.test(n))return{kind:"tool",tool:"clear_sort",input:{}};if(Fe.count.test(n))return{kind:"tool",tool:"count",input:{}};if(Fe.sort.test(n)){let o=qi(n,r);return o?{kind:"tool",tool:"sort",input:{key:o,direction:Fe.desc.test(n)?"desc":"asc"}}:null}let a=n.match(Fe.openEn)||n.match(Fe.openTe);if(a&&a[1])return{kind:"open",text:a[1].trim()};let i=n.replace(Fe.searchFiller,"").trim();return i?{kind:"tool",tool:"search",input:{query:i}}:null}function Hi(e){return!!e&&typeof e=="object"&&typeof e.success=="boolean"&&typeof e.message=="string"}function Bi(e,t){let n=e.inputSchema&&e.inputSchema.required;return Array.isArray(n)?n.map(String).filter(r=>t[r]===void 0||t[r]===null||String(t[r]).trim()===""):[]}function _i(e,t){let n=e.find(a=>a.name===t);if(n)return n;let r=e.filter(a=>a.name.endsWith(`_${t}`)).sort((a,i)=>a.name.length-i.name.length);if(r.length&&!(r.length>1&&r[0].name.length===r[1].name.length))return r[0]}var go=e=>String(e??"").normalize("NFC").trim().toLocaleLowerCase();function Vi(e,t){let n=go(e);return(t||[]).find(r=>(r.phrases||[]).some(a=>{let i=go(a);return i.length>0&&n.includes(i)}))}function Zt(e={}){let t=M=>typeof M=="function"?M():M,n={locale:"en",rowKey:"id",historyLimit:20,customRules:[],...e},r=mo(),a=0,i=null,o=null,l=[],s=0,u=()=>zi[n.locale==="te"?"te":"en"],p=()=>t(n.tools)||[],f=()=>({loading:a>0,lastResult:i,lastError:o,history:l.slice()}),b=()=>r.emit(f());function d(M,k,h,w,v){v===s&&(i=h),l=[...l,{id:v,tool:M,input:k,result:h,source:w,at:Date.now()}].slice(-n.historyLimit),b()}async function S(M,k,h){let w=++s,v=_i(p(),M);if(!v){let x={success:!1,message:u().toolMissing(M),error:{code:"NOT_SUPPORTED"}};return o=new Error(x.message),n.onError&&n.onError(o),d(M,k,x,h,w),x}let E=Bi(v,k);if(E.length){let x={success:!1,message:u().missingInput(E.join(", ")),error:{code:"INVALID_INPUT"},tool:v.name};return d(v.name,k,x,h,w),n.onResult&&n.onResult(x),x}a++,b();try{let x=await v.execute(k),$=Hi(x)?{...x,tool:v.name}:{success:!0,message:u().done,data:x,tool:v.name};return $.success&&(o=null),d(v.name,k,$,h,w),n.onResult&&n.onResult($),$}catch(x){o=tr(x);let $={success:!1,message:u().failed,error:{code:"INTERNAL"},tool:v.name};return n.onError&&n.onError(o),d(v.name,k,$,h,w),$}finally{a=Math.max(0,a-1),b()}}let y=(M,k={})=>S(M,k||{},"tool");async function m(M){let k=t(n.columns)||[],h=Vi(M,n.customRules);if(h){let x=++s;try{let $=await h.execute({input:M,data:t(n.data)||[],columns:k,executeTool:y}),I={success:!0,message:String($??u().done),tool:`rule:${h.name}`};return d(`rule:${h.name}`,{text:M},I,"ask",x),n.onResult&&n.onResult(I),I}catch($){o=tr($),n.onError&&n.onError(o);let I={success:!1,message:u().failed,error:{code:"INTERNAL"},tool:`rule:${h.name}`};return d(`rule:${h.name}`,{text:M},I,"ask",x),I}}let w=(n.parseIntent||nr)(M,{columns:k,locale:n.locale});if(!w){let x={success:!1,message:u().notUnderstood,error:{code:"NOT_UNDERSTOOD"}};return d("ask",{text:M},x,"ask",++s),x}if(w.kind==="tool")return S(w.tool,w.input,"ask");let v=await S("search",{query:w.text},"ask");if(!v.success)return v;let E=Array.isArray(v.data)?v.data:[];if(!E.length){let x={success:!1,message:u().noMatch(w.text),error:{code:"NOT_FOUND"},tool:v.tool};return d("open",{text:w.text},x,"ask",++s),x}return S("open",{id:ee(E[0],n.rowKey)},"ask")}function C(){l=[],i=null,o=null,b()}return{ask:m,executeTool:y,clearHistory:C,subscribe:r.subscribe,getState:f,get tools(){return p()},get loading(){return a>0},get lastResult(){return i},get lastError(){return o},get history(){return l.slice()}}}function en(e,t={}){let n=()=>(typeof e=="function"?e():e)||[],r=l=>{a.status=l,t.onStatusChange&&t.onStatusChange(l)},a={status:{state:"unsupported",registered:[],errors:[]},done:Promise.resolve(),unregister(){o.abort()}},i=typeof document<"u"?document.modelContext:void 0,o=new AbortController;return!i||typeof i.registerTool!="function"?(r({state:"unsupported",registered:[],errors:[]}),a):(a.done=(async()=>{r({state:"registering",registered:[],errors:[]});let l=[],s=[];for(let u of n()){if(o.signal.aborted)return;try{await i.registerTool({name:u.name,title:u.title,description:u.description,inputSchema:u.inputSchema,execute:p=>{let f=n().find(b=>b.name===u.name);return f?f.execute(p||{}):{success:!1,message:`Tool "${u.name}" is no longer available.`,error:{code:"NOT_SUPPORTED"}}}},{signal:o.signal}),l.push(u.name)}catch(p){s.push({tool:u.name,message:tr(p).message})}}o.signal.aborted||r({state:s.length===0?"ready":l.length?"partial":"error",registered:l,errors:s})})(),a)}var Wi=/\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,ji={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""};function tn(e={}){let t=mo(),n=e.rowKey||"id",r=e.bind||null,a=Array.isArray(e.data)?e.data:[],i=Le(e.columns||[]),o={filters:[],sort:null,highlightIds:[]},l="",s=null,u=[],p=[],f=!1,b=()=>r?r.getFilters():o.filters,d=()=>r?r.getSort():o.sort,S=()=>r?r.getHighlightIds():o.highlightIds,y=()=>r?r.getData():a,m=I=>r?r.setFilters(I):o={...o,filters:I},C=I=>r?r.setSort(I):o={...o,sort:I},M=I=>r?r.setHighlightIds(I):o={...o,highlightIds:I};function k(){return Me(y(),i,{...ji,filters:b(),sort:d()})}let h=()=>{let I=k();return{gridData:I,highlightIds:S().slice(),filters:b().slice(),sort:d(),answer:l,kind:s,table:u.slice(),steps:p.slice(),busy:f,visibleIds:I.map(T=>ee(T,n))}},w=()=>t.emit(h()),v=()=>({get data(){return y()},columns:i,rowKey:n,get filters(){return b()},onFiltersChange:I=>{m(I),w()},onSortChange:I=>{C(I),w()},onHighlightRows:I=>{M(I),w()},onOpenRow:e.onOpenRow,onSelectRow:I=>{r&&r.selectRow?r.selectRow(I):M([I]),w()}});async function E(I){let T=String(I??"").trim();if(!T)return h();f=!0,p=[],u=[],w();try{if(yt(T).length>1){let R=[],G=await Gt(T,v(),{onStep:N=>{R.push(N),p=R.slice(),w()}});s="tasks",l=G.summary}else if(Wi.test(T)){let R=Re(y(),i,b()),G=Pt(T,R,i,{referenceDate:e.referenceDate});s="insight",l=G.answer,u=G.table||[]}else{let R=Nt(T,v());s=R.kind,l=R.message}}catch(R){console.error("[yuktai] ask failed",R),s=null,l="Something went wrong while answering. Please rephrase the question."}finally{f=!1,w()}return h()}function x(){m([]),C(null),M([]),l="",s=null,u=[],p=[],w()}function $(I={}){Array.isArray(I.data)&&(a=I.data),Array.isArray(I.columns)&&(i=Le(I.columns)),w()}return{ask:E,reset:x,update:$,subscribe:t.subscribe,getState:h,get gridData(){return k()},get highlightIds(){return S().slice()},get filters(){return b().slice()},get sort(){return d()},get answer(){return l},get kind(){return s},get table(){return u.slice()},get steps(){return p.slice()},get busy(){return f},get visibleIds(){return k().map(I=>ee(I,n))}}}var st={accessibility:'<circle cx="12" cy="4" r="2"/><path d="M4 8l8-1 8 1M12 7v5m-5 9 5-8 5 8M7 12l-2 5m12-5 2 5"/>',contrast:'<circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 0 0 18z"/>',moon:'<path d="M20 14.5A8.5 8.5 0 0 1 9.5 4 8.5 8.5 0 1 0 20 14.5z"/>',motion:'<path d="M4 12h12m-5-5 5 5-5 5M20 5v14"/>',reading:'<path d="M4 5h16M4 10h12M4 15h16M4 20h10"/>',target:'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="4"/>',speaker:'<path d="M4 9v6h4l5 4V5L8 9H4z"/><path d="M16 9a4 4 0 0 1 0 6M18.5 6.5a8 8 0 0 1 0 11"/>',palette:'<circle cx="12" cy="12" r="9"/><circle cx="8" cy="10" r="1.3"/><circle cx="12" cy="7.5" r="1.3"/><circle cx="16" cy="10" r="1.3"/><path d="M12 21a3 3 0 0 1 0-6h2"/>',skip:'<path d="M5 5l7 7-7 7M13 5l7 7-7 7"/>',close:'<path d="m18 6-12 12M6 6l12 12"/>',plus:'<path d="M12 5v14M5 12h14"/>',minus:'<path d="M5 12h14"/>',reset:'<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/>',search:'<circle cx="11" cy="11" r="6.5"/><path d="m16 16 5 5"/>',sort:'<path d="m8 9 4-4 4 4m-8 6 4 4 4-4"/>',sortUp:'<path d="m6 15 6-6 6 6"/>',sortDown:'<path d="m6 9 6 6 6-6"/>',chevrons:'<path d="m8 9 4-4 4 4m-8 6 4 4 4-4"/>',grid:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/>',cards:'<rect x="3" y="4" width="18" height="7" rx="1.5"/><rect x="3" y="13" width="18" height="7" rx="1.5"/>',chat:'<path d="M21 11.5a8.5 8.5 0 0 1-8.5 8.5 9 9 0 0 1-4-.9L3 21l1.9-5.5a9 9 0 0 1-.9-4A8.5 8.5 0 0 1 12.5 3H13a8.5 8.5 0 0 1 8 8z"/>',mic:'<rect x="9" y="2" width="6" height="12" rx="3"/><path d="M5 10a7 7 0 0 0 14 0M12 17v5m-4 0h8"/>',stop:'<rect x="6" y="6" width="12" height="12" rx="2"/>',download:'<path d="M12 3v12m-5-5 5 5 5-5M4 21h16"/>',copy:'<rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/>',filter:'<path d="M4 5h16l-6 7v6l-4 2v-8z"/>',check:'<path d="m5 12 4 4L19 6"/>',left:'<path d="m15 18-6-6 6-6"/>',right:'<path d="m9 18 6-6-6-6"/>',first:'<path d="m11 18-6-6 6-6M19 18l-6-6 6-6"/>',last:'<path d="m13 18 6-6-6-6M5 18l6-6-6-6"/>',spark:'<path d="m12 3 1.9 5.8L20 11l-6.1 2.2L12 19l-1.9-5.8L4 11l6.1-2.2zM19 14l1.2 2.8L23 18l-2.8 1.2L19 22l-1.2-2.8L15 18l2.8-1.2z"/>',alert:'<path d="m12 3 10 18H2L12 3z"/><path d="M12 9v5m0 3h.01"/>',info:'<circle cx="12" cy="12" r="9"/><path d="M12 11v6m0-9h.01"/>',form:'<rect x="5" y="3" width="14" height="18" rx="2"/><path d="M9 8h6M9 12h6M9 16h3"/>',eye:'<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>',layout:'<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/>',wand:'<path d="m15 4 5 5L9 20H4v-5z"/><path d="m13 6 5 5"/>',undo:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 0 12h-3"/>',tools:'<path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.5 2.5-2.4-.6-.6-2.4z"/>',plug:'<path d="M9 2v6M15 2v6M6 8h12v4a6 6 0 0 1-12 0zM12 18v4"/>',home:'<path d="M3 11 12 4l9 7"/><path d="M5 10v10h5v-6h4v6h5V10"/>',menu:'<path d="M4 6h16M4 12h16M4 18h16"/>',book:'<path d="M12 6c-2-1.5-5-2-8-2v14c3 0 6 .5 8 2 2-1.5 5-2 8-2V4c-3 0-6 .5-8 2zM12 6v14"/>',calendar:'<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18M8 3v4M16 3v4M7.5 14h2M14.5 14h2M7.5 17.5h2"/>',clock:'<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',person:'<circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/>',users:'<circle cx="9" cy="8" r="3.5"/><path d="M2 20a7 7 0 0 1 14 0"/><path d="M16 4.5a3.5 3.5 0 0 1 0 7M18 13.5a7 7 0 0 1 4 6.5"/>',globe:'<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/>',lamp:'<path d="M12 3c2 2.6 3 4.3 3 6a3 3 0 0 1-6 0c0-1.7 1-3.4 3-6z"/><path d="M3 14h18c0 3.5-4 6-9 6s-9-2.5-9-6z"/><path d="M12 12v2"/>',play:'<circle cx="12" cy="12" r="9"/><path d="M10 8.5v7l6-3.5z"/>',pause:'<circle cx="12" cy="12" r="9"/><path d="M10 9v6M14 9v6"/>',send:'<path d="M21 3 3 10.5l7 3 3 7.5z"/><path d="m10 13.5 4.5-4.5"/>',share:'<circle cx="18" cy="5" r="2.5"/><circle cx="6" cy="12" r="2.5"/><circle cx="18" cy="19" r="2.5"/><path d="m8.2 10.8 7.6-4.6M8.2 13.2l7.6 4.6"/>',gift:'<rect x="3" y="8" width="18" height="4" rx="1"/><path d="M5 12v9h14v-9M12 8v13M12 8C10.5 5 7 4 7 6.5S10 8 12 8zm0 0c1.5-3 5-4 5-1.5S14 8 12 8z"/>',image:'<rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="8.5" cy="9.5" r="1.5"/><path d="m21 15-5-5-10 10"/>',file:'<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5M9 13h6M9 17h6"/>',external:'<path d="M14 4h6v6M20 4l-9 9"/><path d="M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/>',arrowUp:'<path d="M12 19V5m-6 6 6-6 6 6"/>',arrowLeft:'<path d="M19 12H5m6-6-6 6 6 6"/>',arrowRight:'<path d="M5 12h14m-6-6 6 6-6 6"/>',headphones:'<path d="M4 15v-3a8 8 0 0 1 16 0v3"/><rect x="3" y="14" width="4" height="7" rx="1.5"/><rect x="17" y="14" width="4" height="7" rx="1.5"/>',music:'<path d="M9 18V5l11-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="17" cy="16" r="3"/>',pin:'<path d="M12 21s7-6.2 7-11.5a7 7 0 0 0-14 0C5 14.8 12 21 12 21z"/><circle cx="12" cy="9.5" r="2.5"/>',map:'<path d="M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3z"/><path d="M9 3v15M15 6v15"/>',pen:'<path d="M12 3 6 9l1.5 8h9L18 9z"/><path d="M12 3v7.5"/><circle cx="12" cy="12" r="1.5"/><path d="M8 21h8"/>',wallet:'<rect x="3" y="7" width="18" height="13" rx="2"/><path d="M16 13.5h2M6 7l9-4 2 4"/>',install:'<rect x="6" y="2" width="12" height="20" rx="2"/><path d="M12 6v8m-3-3 3 3 3-3M10 18h4"/>',help:'<circle cx="12" cy="12" r="9"/><path d="M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .9-1 1.6v.6M12 17h.01"/>',temple:'<path d="M12 2v2M10 4h4l1 3H9zM8 7h8l1.5 4h-11zM6.5 11h11L19 15H5zM4 15h16v6H4z"/><path d="M10 21v-3a2 2 0 0 1 4 0v3"/>',meditate:'<circle cx="12" cy="4.5" r="2.2"/><path d="M12 8c-2.2 0-3.3 1.3-3.7 3.2L7.5 16M12 8c2.2 0 3.3 1.3 3.7 3.2l.8 4.8"/><path d="M4 18c3 2 5.5 2.4 8 1.2 2.5 1.2 5 .8 8-1.2"/><path d="M7.5 16c1.4 1.4 3 2 4.5 2s3.1-.6 4.5-2"/>',trophy:'<path d="M8 4h8v5a4 4 0 0 1-8 0z"/><path d="M8 6H5a3 3 0 0 0 3 4M16 6h3a3 3 0 0 1-3 4M12 13v4M8 21h8M9 17h6"/>',bulb:'<path d="M9 18h6M10 21h4"/><path d="M12 3a6 6 0 0 0-4 10.5c.7.7 1 1.5 1 2.5h6c0-1 .3-1.8 1-2.5A6 6 0 0 0 12 3z"/>',sun:'<circle cx="12" cy="12" r="4"/><path d="M12 2v2.5M12 19.5V22M4.9 4.9l1.8 1.8M17.3 17.3l1.8 1.8M2 12h2.5M19.5 12H22M4.9 19.1l1.8-1.8M17.3 6.7l1.8-1.8"/>'},ss=Object.keys(st);var Ui=3,rr="#ffffff",fo="#111827";function xt(e,t){let n=Ne(e),r=Ne(t);return n&&r?et(n,r):null}function or(e){let t=xt(rr,e),n=xt(fo,e);return t===null||n===null||t>=n?rr:fo}var ho=new Set;function Ki(e,t){ho.has(e)||(ho.add(e),typeof console<"u"&&console.warn(`[yuktai icons] ${t}`))}function Qi(e={}){let t=e.variant==="filled"?"filled":"outline",n=e.color||"currentColor";if(t==="outline")return{variant:t,color:n,glyph:n,contrast:null};let r=e.glyphColor||or(n),a=xt(r,n);return a!==null&&a<Ui&&Ki(`${r}|${n}`,`glyph ${r} on ${n} is ${a}:1. WCAG 1.4.11 needs at least 3:1 for icons.`),{variant:t,color:n,glyph:r,contrast:a}}var Yi="translate(3.6 3.6) scale(0.7)",Ji="@media (forced-colors: active){.yi-bg{fill:CanvasText}.yi-glyph{stroke:Canvas}}",Ve=e=>String(e).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function bo(e,t={}){let n=st[e]??st.spark,r=t.size??20,{variant:a,color:i,glyph:o}=Qi(t),l=t.strokeWidth??(a==="filled"?2.4:1.9),u=`<svg xmlns="http://www.w3.org/2000/svg" ${t.label?`role="img" aria-label="${Ve(t.label)}"`:'aria-hidden="true"'} focusable="false" width="${Ve(r)}" height="${Ve(r)}" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round" data-variant="${a}">`;if(a==="outline")return`${u}<g stroke="${Ve(i)}" stroke-width="${l}">${n}</g></svg>`;let p=t.shape==="circle"?`<circle class="yi-bg" cx="12" cy="12" r="12" fill="${Ve(i)}"/>`:`<rect class="yi-bg" width="24" height="24" rx="6" fill="${Ve(i)}"/>`;return`${u}<style>${Ji}</style>${p}<g class="yi-glyph" stroke="${Ve(o)}" stroke-width="${l}" transform="${Yi}">${n}</g></svg>`}var Pe=()=>typeof window<"u"&&typeof document<"u";function nn(e){return String(e??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function c(e,t,...n){let r=document.createElement(e);if(t)for(let[a,i]of Object.entries(t))i==null||i===!1||(a.startsWith("on")&&typeof i=="function"?r.addEventListener(a.slice(2),i):a==="html"?r.innerHTML=i:a==="text"?r.textContent=i:i===!0?r.setAttribute(a,""):r.setAttribute(a,String(i)));for(let a of n.flat())a==null||a===!1||r.append(a instanceof Node?a:document.createTextNode(String(a)));return r}var Xi=0,j=(e="yv")=>`${e}-${++Xi}`;function rn(e,t){if(typeof e!="string"||!Pe())return t;let n=document.createElement("span");return n.style.color=e,n.style.color?e:t}var ir=()=>Pe()&&(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.hasAttribute("data-yuktai-reduce-motion")),yo=Object.keys(st);function de(e,t=20,n,r){let a=typeof t=="object"&&t!==null?{...t}:{...r||{},size:t,label:n};return bo(e,a)}function q(e,t,n){let r=document.createElement("span");return r.className="yv-ic",r.innerHTML=de(e,t,n),r}var We=null;function re(e){!Pe()||!e||((!We||!document.contains(We))&&(We=c("div",{id:"yuktai-vanilla-live",class:"yv-sr",role:"status","aria-live":"polite","aria-atomic":"true"}),document.body.appendChild(We)),We.textContent="",setTimeout(()=>{We&&(We.textContent=String(e).slice(0,300))},30))}function kt(e,t,n="text/plain;charset=utf-8"){let r=URL.createObjectURL(new Blob([t],{type:n})),a=c("a",{href:r,download:e,hidden:!0});document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(r),1500)}async function vo(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=c("textarea",{"aria-hidden":"true",style:"position:fixed;opacity:0;left:-9999px"});t.value=e,document.body.appendChild(t),t.select();let n=!1;try{n=document.execCommand("copy")}catch{n=!1}return t.remove(),n}}function ar(e){let t=String(e??"");return/^[=+\-@\t\r]/.test(t)&&(t="'"+t),'"'+t.replace(/"/g,'""')+'"'}function wo(e){let t=(e||[]).map(n=>{try{return document.querySelector(n)}catch{return null}}).filter(Boolean);return t.forEach(n=>{n.setAttribute("data-yv-flash",""),setTimeout(()=>n.removeAttribute("data-yv-flash"),4e3)}),t[0]&&t[0].scrollIntoView({block:"center",behavior:ir()?"auto":"smooth"}),t.length}function on(e,t){if(!Pe()||document.getElementById("yuktai-vanilla-css"))return;let n=document.createElement("style");n.id="yuktai-vanilla-css",n.textContent=`
|
|
401
401
|
:root{--yv-primary:${e}}
|
|
402
402
|
.yv-sr{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
|
|
403
403
|
.yv-ic{display:inline-flex;line-height:0}
|
|
@@ -423,8 +423,8 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
423
423
|
.yv-sev-high{color:#b91c1c}.yv-sev-medium{color:#a16207}.yv-sev-low{color:#475569}
|
|
424
424
|
|
|
425
425
|
/* themes (shared by grid, boxes and dialogs) */
|
|
426
|
-
.yv-grid,.yv-box,.yv-dialog{--yv-bg:#fff;--yv-surface:#fff;--yv-soft:#f8fafc;--yv-head:#f8fafc;--yv-hover:#f1f5f9;--yv-text:#0f172a;--yv-muted:#475569;--yv-border:#e2e8f0;--yv-border-strong:#94a3b8;--yv-accent-bg:#
|
|
427
|
-
.yv-theme-dark{--yv-bg:#0f172a;--yv-surface:#111c33;--yv-soft:#16233f;--yv-head:#16233f;--yv-hover:#1e2d4d;--yv-text:#f1f5f9;--yv-muted:#cbd5e1;--yv-border:#334155;--yv-border-strong:#64748b;--yv-accent-bg:#
|
|
426
|
+
.yv-grid,.yv-box,.yv-dialog{--yv-bg:#fff;--yv-surface:#fff;--yv-soft:#f8fafc;--yv-head:#f8fafc;--yv-hover:#f1f5f9;--yv-text:#0f172a;--yv-muted:#475569;--yv-border:#e2e8f0;--yv-border-strong:#94a3b8;--yv-accent-bg:#E8F1F8;--yv-accent-text:#003F6E;--yv-hl-bg:#fef3c7;--yv-hl-edge:#b45309;--yv-sel-bg:#EEF5FB}
|
|
427
|
+
.yv-theme-dark{--yv-bg:#0f172a;--yv-surface:#111c33;--yv-soft:#16233f;--yv-head:#16233f;--yv-hover:#1e2d4d;--yv-text:#f1f5f9;--yv-muted:#cbd5e1;--yv-border:#334155;--yv-border-strong:#64748b;--yv-accent-bg:#0B2A4A;--yv-accent-text:#DCEBFA;--yv-hl-bg:#4a3a0c;--yv-hl-edge:#fbbf24;--yv-sel-bg:#12304f}
|
|
428
428
|
.yv-theme-high-contrast{--yv-bg:#fff;--yv-surface:#fff;--yv-soft:#fff;--yv-head:#fff;--yv-hover:#e5e5e5;--yv-text:#000;--yv-muted:#000;--yv-border:#000;--yv-border-strong:#000;--yv-accent-bg:#000;--yv-accent-text:#fff;--yv-hl-bg:#ffff00;--yv-hl-edge:#000;--yv-sel-bg:#e5e5e5}
|
|
429
429
|
.yv-theme-high-contrast.yv-grid,.yv-theme-high-contrast .yv-btn,.yv-theme-high-contrast .yv-input{border-width:2px}
|
|
430
430
|
.yv-theme-high-contrast .yv-btn.yv-primary{background:#000;border-color:#000}
|
|
@@ -510,7 +510,8 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
510
510
|
/* floating buttons and dialogs */
|
|
511
511
|
.yv-fabs{position:fixed;bottom:max(16px,env(safe-area-inset-bottom));${t}:16px;display:flex;flex-direction:column;gap:10px;z-index:2147483000}
|
|
512
512
|
.yv-fab{width:56px;height:56px;display:grid;place-items:center;border:2px solid #fff;border-radius:50%;background:var(--yv-primary);color:#fff;box-shadow:0 4px 16px rgba(0,0,0,.25);cursor:pointer}
|
|
513
|
-
.yv-fab.yv-fab-alt{background:#
|
|
513
|
+
.yv-fab.yv-fab-alt{background:#fff;color:var(--yv-primary);border-color:var(--yv-primary)}
|
|
514
|
+
.yv-fab:hover{filter:brightness(1.08)}
|
|
514
515
|
.yv-dialog{position:fixed;bottom:max(90px,calc(env(safe-area-inset-bottom) + 84px));${t}:12px;width:min(440px,calc(100vw - 24px));max-height:calc(100dvh - 110px);overflow:auto;background:var(--yv-bg);color:var(--yv-text);border:1px solid var(--yv-border);border-radius:16px;box-shadow:0 12px 40px rgba(15,23,42,.25);z-index:2147483001;font:15px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif}
|
|
515
516
|
.yv-dialog.yv-wide{width:min(620px,calc(100vw - 24px))}
|
|
516
517
|
.yv-dialog-head{position:sticky;top:0;z-index:1;display:flex;justify-content:space-between;align-items:flex-start;gap:10px;padding:14px 16px;border-bottom:1px solid var(--yv-border);background:var(--yv-bg)}
|
|
@@ -537,6 +538,6 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
537
538
|
.yv-status:empty{display:none}
|
|
538
539
|
@media (max-width:560px){.yv-dialog{${t}:8px;width:calc(100vw - 16px)}.yv-toolbar{align-items:stretch}.yv-search{flex-basis:100%}}
|
|
539
540
|
@media (prefers-reduced-motion:reduce){.yv-switch span,.yv-switch span::after{transition:none}}
|
|
540
|
-
`,document.head.appendChild(n)}var Bi={query:"Grid query",anomalies:"Anomalies",summary:"Summary",insight:"BI insight",tasks:"Task steps"};function nn(e,t,n={}){let r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new Error("mountAgenticGridBar: container not found");if(!t||typeof t.ask!="function")throw new Error("mountAgenticGridBar: pass the object from createAgenticGrid() or grid.agentic");let a=n.title||"Ask about this data",i=W("yv-q"),o=W("yv-qh"),l=c("input",{id:i,class:"yv-input",type:"text",autocomplete:"off",placeholder:n.placeholder||"Ask the grid\u2026 e.g. salary over 1 lakh in Hyderabad","aria-describedby":o}),s=c("button",{type:"submit",class:"yv-btn yv-primary"},q("spark",16),"Ask"),u=c("button",{type:"button",class:"yv-btn"},q("reset",16),"Show all rows"),p=c("p",{class:"yv-muted",style:"margin:10px 0 0",hidden:!0}),f=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),b=c("div"),d=n.examples||["salary over 1 lakh","anything unusual?","average salary by department","show salary over 80k, then sort by salary, then summarize"],S=c("div",{class:"yv-chips","aria-label":"Example questions"},...d.map(k=>c("button",{type:"button",class:"yv-chip","data-example":k},k))),y=c("form",{class:"yv-row",role:"search","aria-label":a},c("label",{for:i,class:"yv-sr"},a),l,s,u),m=c("section",{class:`yv-box yv-agentic-bar${n.theme?" yv-theme-"+n.theme:""}`,"aria-label":a},c("h3",null,q("spark",16)," ",a),c("p",{id:o,class:"yv-muted",style:"margin:0 0 8px"},n.hint||"Plain-English questions. Understands 10k, 1.5 lakh, 2cr. Every answer says which filters it used."),y,S,p,f,b);r.appendChild(m);function C(k){if(s.disabled=!!k.busy,m.setAttribute("aria-busy",String(!!k.busy)),!k.busy){if(f.textContent=k.answer||"",p.hidden=!k.kind,p.textContent=k.kind?`${Bi[k.kind]||k.kind} \xB7 ${k.visibleIds.length} row(s) shown`:"",b.replaceChildren(),k.table&&k.table.length){let h=Object.keys(k.table[0]),w=c("table",{class:"yv-mini"});w.innerHTML=`<caption class="yv-sr">Answer table</caption><thead><tr>${h.map(v=>`<th scope="col">${yt(v)}</th>`).join("")}</tr></thead><tbody>${k.table.map(v=>`<tr>${h.map(L=>`<td>${yt(v[L])}</td>`).join("")}</tr>`).join("")}</tbody>`,b.append(c("div",{style:"overflow-x:auto"},w))}k.steps&&k.steps.length&&b.append(c("ol",{class:"yv-steps","aria-label":"Steps"},...k.steps.map(h=>c("li",null,c("span",{class:h.success===!1?"yv-fail":"yv-ok"},h.success===!1?"\u2717 ":"\u2713 "),c("b",null,h.action),": ",h.message||h.text))))}}let E=t.subscribe(C);return y.addEventListener("submit",k=>{k.preventDefault(),t.ask(l.value)}),u.addEventListener("click",()=>{l.value="",t.reset()}),S.addEventListener("click",k=>{let h=k.target.closest("[data-example]");h&&(l.value=h.getAttribute("data-example"),t.ask(l.value))}),{element:m,ask:k=>(l.value=k,t.ask(k)),destroy(){E(),m.remove()}}}var Hi={en:{search:"Search\u2026",searchAria:"Search grid",rows:"rows",selected:"selected",loading:"Loading\u2026",noData:"No data found.",selectRow:e=>`Select row ${e}`,selectPage:"Select all rows on this page",pageSize:"Rows per page",page:(e,t)=>`Page ${e} of ${t}`,showing:(e,t,n)=>n?`Showing ${e}\u2013${t} of ${n}`:"No rows",first:"First page",previous:"Previous page",next:"Next page",last:"Last page",yes:"Yes",no:"No",sortedAsc:e=>`Sorted by ${e}, ascending`,sortedDesc:e=>`Sorted by ${e}, descending`,sortCleared:"Sorting cleared",filters:e=>`${e} filter(s) applied`,clearFilters:"Clear filters",removeFilter:e=>`Remove filter: ${e}`,export:"Export CSV",tableView:"Table view",cardView:"Card view",highlighted:"highlighted",results:e=>`${e} result(s)`,ops:{contains:"contains",equals:"is",startsWith:"starts with",endsWith:"ends with",greaterThan:">",lessThan:"<",between:"between"}},te:{search:"\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F\u2026",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",selected:"\u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C41\u0C28\u0C4D\u0C28\u0C35\u0C3F",loading:"\u0C32\u0C4B\u0C21\u0C4D \u0C05\u0C35\u0C41\u0C24\u0C4B\u0C02\u0C26\u0C3F\u2026",noData:"\u0C21\u0C47\u0C1F\u0C3E \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.",selectRow:e=>`\u0C35\u0C30\u0C41\u0C38 ${e} \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B\u0C02\u0C21\u0C3F`,selectPage:"\u0C08 \u0C2A\u0C47\u0C1C\u0C40\u0C32\u0C4B\u0C28\u0C3F \u0C05\u0C28\u0C4D\u0C28\u0C3F \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B\u0C02\u0C21\u0C3F",pageSize:"\u0C2A\u0C47\u0C1C\u0C40 \u0C2A\u0C30\u0C3F\u0C2E\u0C3E\u0C23\u0C02",page:(e,t)=>`\u0C2A\u0C47\u0C1C\u0C40 ${e} / ${t}`,showing:(e,t,n)=>n?`${n} \u0C32\u0C4B ${e}\u2013${t}`:"\u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C32\u0C47\u0C35\u0C41",first:"\u0C2E\u0C4A\u0C26\u0C1F\u0C3F \u0C2A\u0C47\u0C1C\u0C40",previous:"\u0C35\u0C46\u0C28\u0C41\u0C15\u0C15\u0C41",next:"\u0C2E\u0C41\u0C02\u0C26\u0C41\u0C15\u0C41",last:"\u0C1A\u0C3F\u0C35\u0C30\u0C3F \u0C2A\u0C47\u0C1C\u0C40",yes:"\u0C05\u0C35\u0C41\u0C28\u0C41",no:"\u0C15\u0C3E\u0C26\u0C41",sortedAsc:e=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C06\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02`,sortedDesc:e=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02`,sortCleared:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C30\u0C41",filters: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",removeFilter:e=>`\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C02\u0C21\u0C3F: ${e}`,export:"CSV \u0C21\u0C4C\u0C28\u0C4D\u200C\u0C32\u0C4B\u0C21\u0C4D",tableView:"\u0C2A\u0C1F\u0C4D\u0C1F\u0C3F\u0C15",cardView:"\u0C15\u0C3E\u0C30\u0C4D\u0C21\u0C41\u0C32\u0C41",highlighted:"\u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D",results:e=>`${e} \u0C2B\u0C32\u0C3F\u0C24\u0C3E\u0C32\u0C41`,ops:{contains:"\u0C32\u0C4B \u0C09\u0C02\u0C26\u0C3F",equals:"=",startsWith:"\u0C24\u0C4B \u0C2E\u0C4A\u0C26\u0C32\u0C41",endsWith:"\u0C24\u0C4B \u0C2E\u0C41\u0C17\u0C3F\u0C02\u0C2A\u0C41",greaterThan:">",lessThan:"<",between:"\u0C2E\u0C27\u0C4D\u0C2F"}}},mo=["default","high-contrast","dark","color-blind","dyslexia"],rr=e=>String(e??"").normalize("NFC").toLowerCase();function fo(e,t){return(Array.isArray(e)&&e.length?e:t[0]?Object.keys(t[0]).map(r=>({key:r,label:r})):[]).map(r=>({key:String(r.key),label:r.label==null?String(r.key):String(r.label),sortable:r.sortable!==!1,type:r.type||"text",align:r.align||(r.type==="number"?"right":"left"),render:typeof r.render=="function"?r.render:null,hiddenOnMobile:!!r.hiddenOnMobile,width:r.width}))}function ho(e,t,n,r){let a=typeof e=="string"?document.querySelector(e):e;if(!a||typeof a.appendChild!="function")throw new Error("renderGrid: container not found. Pass an element or a CSS selector.");let i=Array.isArray(t)?{...r||{},data:t,columns:n}:{...t||{}},o=i.locale||"en-IN",l=String(o).split("-")[0],s=Hi[l==="te"?"te":"en"],u=l==="te"?"te":"en",p=l==="en"||l==="te"?"en-IN":o,f=i.rowKey||"id",b=i.label||i.ariaLabel||"Data grid",d=i.pagination===!1?!1:typeof i.pagination=="object"?i.pagination:{},S=d&&d.sizeOptions||[10,20,50,100],y=i.selectable!==!1,m=i.autoScrollToHighlight!==!1,C=Number(i.mobileBreakpoint)||640,E=Array.isArray(i.data)?i.data.slice():[],k=fo(i.columns,E),h=Me(k),w=[],v=null,L="",x=1,$=Number(d&&d.pageSize||i.pageSize)||10,I=mo.includes(i.theme)?i.theme:"default",T=["table","card","auto"].includes(i.view)?i.view:"auto",R=!!i.loading,G=!1,N={r:1,c:0},F=new Set((i.selectedKeys||[]).map(String)),B=new Set((i.highlightIds||[]).map(String)),pe={grid:W("yv-grid"),title:W("yv-title"),status:W("yv-status")};S.includes($)||S.push($),S.sort((g,A)=>g-A);let j=g=>ee(g,f)||String(E.indexOf(g)),Y=g=>{let A=k.find(M=>M.type==="text")||k[0];return A?String(g[A.key]??j(g)):j(g)},Z=c("section",{class:`yv-grid yv-theme-${I}${i.wrap?" yv-wrap":""}${i.className?" "+i.className:""}`,role:"region","aria-labelledby":pe.title,lang:i.lang||(l!=="en"?o:null)});i.maxHeight&&Z.style.setProperty("--yv-max-height",typeof i.maxHeight=="number"?`${i.maxHeight}px`:i.maxHeight);let kt=c("h3",{id:pe.title,class:i.showTitle?"yv-grid-title":"yv-sr"},b);i.showTitle&&(kt.style.cssText="margin:0;padding:12px 12px 0;font-size:1.05em");let Ae=c("input",{type:"search",placeholder:s.search,"aria-label":s.searchAria,"aria-controls":pe.grid,autocomplete:"off",spellcheck:"false"}),on=i.search===!1?null:c("label",{class:"yv-search"},q("search",18),Ae),lr=c("span",{class:"yv-info","aria-hidden":"true"}),ot=c("button",{type:"button",class:"yv-btn yv-icon","data-view-toggle":""}),cr=i.exportable===!1?null:c("button",{type:"button",class:"yv-btn"},q("download",16),s.export),wo=c("div",{class:"yv-tools"},T==="auto"||i.viewToggle?ot:null,cr),xo=c("div",{class:"yv-toolbar"},on,lr,wo),Le=c("div",{class:"yv-filterbar",hidden:!0,"aria-label":s.filters(0)}),an=c("div",{class:"yv-slot"}),oe=c("div",{class:"yv-body",id:pe.grid}),At=c("div",{class:"yv-pager"}),sn=c("p",{class:"yv-sr",id:pe.status,role:"status","aria-live":"polite","aria-atomic":"true"});Z.append(kt,xo,Le,an,oe,At,sn),a.appendChild(Z);let ln=null,Tt=g=>{clearTimeout(ln),sn.textContent="",ln=setTimeout(()=>sn.textContent=g,40)};function ko(g,A,M,P){let D=g[M.key],O=A[M.key];if(D==null||D==="")return O==null||O===""?0:1;if(O==null||O==="")return-1;let _;return M.type==="number"?_=Number(D)-Number(O):M.type==="date"?_=new Date(D).getTime()-new Date(O).getTime():_=String(D).localeCompare(String(O),o,{numeric:!0,sensitivity:"base"}),Number.isFinite(_)||(_=String(D).localeCompare(String(O))),P==="desc"?-_:_}function Pe(){let g=Re(E,h,w);if(L){let A=rr(L);g=g.filter(M=>k.some(P=>rr(M[P.key]).includes(A)||rr(it(P,M[P.key])).includes(A)))}if(v&&v.key){let A=k.find(M=>M.key===v.key);A&&(g=g.slice().sort((M,P)=>ko(M,P,A,v.direction)))}return g}function it(g,A){if(A==null||A==="")return"";if(g.type==="number"&&Number.isFinite(Number(A)))return Number(A).toLocaleString(p);if(g.type==="date"){let M=new Date(A);return Number.isNaN(M.getTime())?String(A):M.toLocaleDateString(p,{year:"numeric",month:"short",day:"numeric"})}return g.type==="boolean"?A===!0||A==="true"?s.yes:s.no:String(A)}function ur(g,A,M){let P=A[g.key];if(g.render)try{let D=g.render(P,A,M);return D instanceof Node?D:document.createTextNode(D==null?"":String(D))}catch(D){return console.error("[yuktai] column render failed",g.key,D),document.createTextNode(it(g,P))}return g.type==="badge"&&P!=null&&P!==""?c("span",{class:"yv-cellbadge"},String(P)):document.createTextNode(it(g,P))}let at=()=>T==="card"||T==="auto"&&G;function Ve(g){if(d===!1)return{pages:1,start:0,end:g};let A=Math.max(1,Math.ceil(g/$));return x=Math.min(Math.max(1,x),A),{pages:A,start:(x-1)*$,end:Math.min(g,x*$)}}let ye=[];function U(){let g=Pe();ye=g;let{pages:A,start:M,end:P}=Ve(g.length),D=g.slice(M,P);Z.className=`yv-grid yv-theme-${I}${i.wrap?" yv-wrap":""}${i.className?" "+i.className:""}`,Z.setAttribute("aria-busy",String(R)),lr.textContent=`${g.length.toLocaleString(p)} ${s.rows}${y?` \xB7 ${F.size.toLocaleString(p)} ${s.selected}`:""}`,ot.innerHTML=de(at()?"grid":"cards",18),ot.setAttribute("aria-label",at()?s.tableView:s.cardView),ot.title=at()?s.tableView:s.cardView,So();let O=oe.contains(document.activeElement);oe.replaceChildren(R?c("div",{class:"yv-loading",role:"status"},s.loading):at()?To(D,M):Ao(D,M,g.length)),O&&!R&&pr(),Co(g.length,A,M,P)}function Ao(g,A,M){let P=k,D=P.length+(y?1:0),O=c("table",{class:"yv-table",role:"grid","aria-labelledby":pe.title,"aria-rowcount":M+1,"aria-colcount":D,"aria-multiselectable":y?"true":null}),_=c("tr",{role:"row","aria-rowindex":1});if(y){let H=g.length>0&&g.every(we=>F.has(j(we))),ve=g.some(we=>F.has(j(we))),J=c("input",{type:"checkbox","data-select-page":"","aria-label":s.selectPage,tabindex:-1});J.checked=H,J.indeterminate=!H&&ve,_.append(c("th",{role:"columnheader",scope:"col","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},J)))}P.forEach((H,ve)=>{let J=ve+(y?1:0),we=v&&v.key===H.key?v.direction:null,Ge=c("th",{role:"columnheader",scope:"col","aria-colindex":J+1,"aria-sort":H.sortable?we==="asc"?"ascending":we==="desc"?"descending":"none":null,class:H.align!=="left"?`yv-align-${H.align}`:null,tabindex:-1,"data-col":J});if(H.width&&(Ge.style.width=typeof H.width=="number"?`${H.width}px`:H.width),H.sortable){let Ke=c("button",{type:"button",class:"yv-sortbtn","data-sort":H.key,tabindex:-1},H.label);Ke.insertAdjacentHTML("beforeend",de(we==="asc"?"sortUp":we==="desc"?"sortDown":"sort",14)),Ge.append(Ke)}else Ge.append(H.label);_.append(Ge)});let ie=c("tbody");if(!g.length){let H=i.empty instanceof Node?i.empty.cloneNode(!0):document.createTextNode(i.empty?String(i.empty):s.noData);ie.append(c("tr",{role:"row","aria-rowindex":2},c("td",{role:"gridcell",class:"yv-empty",colspan:D,tabindex:-1,"data-col":0},H)))}g.forEach((H,ve)=>{let J=j(H),we=F.has(J),Ge=B.has(J),Ke=c("tr",{role:"row","aria-rowindex":A+ve+2,"aria-selected":y?String(we):null,"data-yuktai-row-id":J,class:Ge?"yv-hl":null});if(y){let Qe=c("input",{type:"checkbox","data-select":J,"aria-label":s.selectRow(Y(H)),tabindex:-1});Qe.checked=we,Ke.append(c("td",{role:"gridcell","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},Qe)))}P.forEach((Qe,mr)=>{let fr=mr+(y?1:0),dn=c("td",{role:"gridcell","aria-colindex":fr+1,tabindex:-1,"data-col":fr,class:Qe.align!=="left"?`yv-align-${Qe.align}`:null});dn.append(ur(Qe,H,A+ve)),mr===0&&Ge&&dn.append(c("span",{class:"yv-sr"},` (${s.highlighted})`)),Ke.append(dn)}),ie.append(Ke)}),O.append(c("thead",null,_),ie);let se=O.querySelectorAll("tr");N.r=Math.min(N.r,se.length-1);let le=dr(O,N.r,N.c)||dr(O,0,0);return le&&le.setAttribute("tabindex","0"),c("div",{class:"yv-tablewrap"},O)}function To(g,A){if(!g.length){let P=i.empty instanceof Node?i.empty.cloneNode(!0):document.createTextNode(i.empty?String(i.empty):s.noData);return c("div",{class:"yv-empty",role:"status"},P)}let M=c("ul",{class:"yv-cards","aria-labelledby":pe.title});return g.forEach((P,D)=>{let O=j(P),_=F.has(O),ie=B.has(O),se=W("yv-card"),le=c("li",{class:`yv-card${ie?" yv-hl":""}`,"data-yuktai-row-id":O,"aria-labelledby":se,"aria-selected":y?String(_):null,tabindex:-1}),H=c("div",{class:"yv-card-head"},c("p",{class:"yv-card-title",id:se},Y(P),ie?c("span",{class:"yv-sr"},` (${s.highlighted})`):null));if(y){let J=c("input",{type:"checkbox","data-select":O,"aria-label":s.selectRow(Y(P))});J.checked=_,H.append(c("label",{class:"yv-check"},J))}let ve=c("dl");k.forEach(J=>{J.hiddenOnMobile||ve.append(c("dt",null,J.label),c("dd",null,ur(J,P,A+D)))}),le.append(H,ve),typeof i.onRowClick=="function"&&le.append(c("button",{type:"button",class:"yv-btn yv-small","data-open":O,style:"margin-top:8px"},i.openLabel||(l==="te"?"\u0C24\u0C46\u0C30\u0C41\u0C35\u0C41":"Open"))),M.append(le)}),M}function So(){if(Le.replaceChildren(),!w.length){Le.hidden=!0;return}Le.hidden=!1,Le.setAttribute("aria-label",s.filters(w.length)),Le.append(c("span",{class:"yv-muted"},q("filter",15)," ",s.filters(w.length))),w.forEach((g,A)=>{let M=k.find(_=>_.key===g.key),P=Array.isArray(g.value)?g.value.map(_=>it(M||{},_)).join(" \u2013 "):M?it(M,g.value):String(g.value),D=`${M?M.label:g.key} ${s.ops[g.operator]||g.operator} ${P}`,O=c("button",{type:"button",class:"yv-chip","data-remove-filter":A,"aria-label":s.removeFilter(D)},D,q("close",14));Le.append(O)}),Le.append(c("button",{type:"button",class:"yv-btn yv-small","data-clear-filters":""},s.clearFilters))}function Co(g,A,M,P){if(At.replaceChildren(),d===!1){At.append(c("span",{class:"yv-muted"},s.results(g.toLocaleString(p))));return}let D=se=>se.toLocaleString(p),O=c("span",{class:"yv-muted"},g?s.showing(D(M+1),D(P),D(g)):s.showing(0,0,0)),_=c("div",{class:"yv-pages"});if(d.showSizeChanger!==!1){let se=W("yv-size"),le=c("select",{id:se,"data-page-size":""},...S.map(H=>c("option",{value:H,selected:H===$},String(H))));_.append(c("label",{for:se,class:"yv-muted"},s.pageSize),le)}let ie=(se,le,H,ve)=>{let J=c("button",{type:"button",class:"yv-btn yv-icon","aria-label":le,title:le,disabled:H,"data-page":ve});return J.innerHTML=de(se,18),J};_.append(ie("first",s.first,x<=1,"first"),ie("left",s.previous,x<=1,"prev"),c("span",{class:"yv-muted","aria-current":"page"},s.page(D(x),D(A))),ie("right",s.next,x>=A,"next"),ie("last",s.last,x>=A,"last")),At.append(O,_)}function dr(g,A,M){let P=g.querySelectorAll("tr")[A];if(!P)return null;let D=P.querySelectorAll("th,td");return D[Math.min(M,D.length-1)]||null}function $e(g,A){let M=oe.querySelector("table");if(!M)return;let P=M.querySelectorAll("tr");g=Math.max(0,Math.min(g,P.length-1));let D=P[g].querySelectorAll("th,td");A=Math.max(0,Math.min(A,D.length-1)),M.querySelectorAll('[tabindex="0"]').forEach(_=>_.setAttribute("tabindex","-1"));let O=D[A];O.setAttribute("tabindex","0"),N={r:g,c:A},O.focus()}function pr(){if(oe.querySelector("table"))$e(N.r,N.c);else{let A=oe.querySelector(".yv-card");A&&A.focus()}}function $o(g){let A=oe.querySelector("table"),M=g.target.closest&&g.target.closest("th,td");if(!A||!M||!A.contains(M))return;let P=M.parentElement,D=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),O=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),M),_=A.querySelectorAll("tr").length-1,ie=!0;switch(g.key){case"ArrowRight":$e(D,O+1);break;case"ArrowLeft":$e(D,O-1);break;case"ArrowDown":$e(D+1,O);break;case"ArrowUp":$e(D-1,O);break;case"Home":g.ctrlKey?$e(0,0):$e(D,0);break;case"End":g.ctrlKey?$e(_,999):$e(D,999);break;case"PageDown":d!==!1&&(N={r:Math.max(1,D),c:O},We(x+1,!0));break;case"PageUp":d!==!1&&(N={r:Math.max(1,D),c:O},We(x-1,!0));break;case"Enter":case" ":{let se=M.querySelector("[data-sort]"),le=M.querySelector("input[type=checkbox]");se?gr(se.getAttribute("data-sort")):le?le.click():g.key==="Enter"&&P.hasAttribute("data-yuktai-row-id")&&typeof i.onRowClick=="function"?st(P.getAttribute("data-yuktai-row-id")):g.key===" "&&y&&P.hasAttribute("data-yuktai-row-id")?Ro(P.getAttribute("data-yuktai-row-id")):ie=!1;break}default:ie=!1}ie&&(g.preventDefault(),g.stopPropagation())}function gr(g){let A=k.find(P=>P.key===g);if(!A||!A.sortable)return;!v||v.key!==g?v={key:g,direction:"asc"}:v.direction==="asc"?v={key:g,direction:"desc"}:v=null,x=1,oe.querySelector("table")&&oe.contains(document.activeElement)&&(N={r:0,c:N.c}),U(),Tt(v?v.direction==="asc"?s.sortedAsc(A.label):s.sortedDesc(A.label):s.sortCleared),i.onSortChange&&i.onSortChange(v?{key:v.key,direction:v.direction}:null)}function je(){i.onSelectionChange&&i.onSelectionChange(Array.from(F)),Z.dispatchEvent(new CustomEvent("yuktai:selection",{detail:{keys:Array.from(F)},bubbles:!0}))}function Ro(g,A){(A===void 0?!F.has(g):A)?F.add(g):F.delete(g),U(),je()}function We(g,A){let{pages:M}=Ve(ye.length),P=Math.min(Math.max(1,g),M);P===x&&!A||(x=P,U(),Tt(s.page(x,M)),A&&oe.querySelector("table")&&pr())}function st(g){let A=E.find(M=>j(M)===String(g));return A?(typeof i.onRowClick=="function"&&i.onRowClick(A,E.indexOf(A)),typeof i.onOpenRow=="function"&&i.onOpenRow(String(g)),!0):!1}function lt(g,A=m){if(B.clear(),(g||[]).forEach(M=>B.add(typeof M=="object"&&M!==null?j(M):String(M))),A&&B.size){let M=ye.length?ye.findIndex(P=>B.has(j(P))):Pe().findIndex(P=>B.has(j(P)));M>=0&&d!==!1&&(x=Math.floor(M/$)+1)}if(U(),A&&B.size){let M=oe.querySelector(".yv-hl");M&&M.scrollIntoView&&M.scrollIntoView({block:"nearest",behavior:tr()?"auto":"smooth"})}}let cn=null;Ae.addEventListener("input",()=>{clearTimeout(cn),cn=setTimeout(()=>{L=Ae.value.trim(),x=1,U(),Tt(s.results(ye.length.toLocaleString(p)))},160)}),Z.addEventListener("click",g=>{let A=g.target.closest("button, input, tr[data-yuktai-row-id]");if(!(!A||!Z.contains(A))){if(A.matches("[data-sort]"))return gr(A.getAttribute("data-sort"));if(A.matches("[data-page]")){let M=A.getAttribute("data-page"),{pages:P}=Ve(ye.length);return We(M==="first"?1:M==="prev"?x-1:M==="next"?x+1:P)}if(A.matches("[data-remove-filter]")){w=w.filter((M,P)=>P!==Number(A.getAttribute("data-remove-filter"))),x=1,U(),i.onFiltersChange&&i.onFiltersChange(w.slice());return}if(A.matches("[data-clear-filters]"))return K.clearFilters();if(A.matches("[data-open]"))return st(A.getAttribute("data-open"));if(A===ot){T=at()?"table":"card",U();return}if(A===cr)return K.exportCSV();A.matches("tr[data-yuktai-row-id]")&&typeof i.onRowClick=="function"&&!g.target.closest("label,input,button,a")&&st(A.getAttribute("data-yuktai-row-id"))}}),Z.addEventListener("change",g=>{let A=g.target;if(A.matches("[data-select]"))A.checked?F.add(A.getAttribute("data-select")):F.delete(A.getAttribute("data-select")),U(),je();else if(A.matches("[data-select-page]")){let{start:M,end:P}=Ve(ye.length);ye.slice(M,P).forEach(D=>A.checked?F.add(j(D)):F.delete(j(D))),U(),je()}else A.matches("[data-page-size]")&&($=Number(A.value)||$,x=1,U(),oe.closest(".yv-grid").querySelector("[data-page-size]").focus())}),oe.addEventListener("keydown",$o),oe.addEventListener("focusin",g=>{let A=oe.querySelector("table"),M=g.target.closest&&g.target.closest("th,td");if(!A||!M)return;let P=M.parentElement,D=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),O=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),M);D<0||O<0||(A.querySelectorAll('[tabindex="0"]').forEach(_=>_!==M&&_.setAttribute("tabindex","-1")),M.setAttribute("tabindex","0"),N={r:D,c:O})});let St=null;typeof ResizeObserver=="function"&&(St=new ResizeObserver(g=>{let A=g[0]&&g[0].contentRect.width,M=A>0&&A<C;M!==G&&(G=M,T==="auto"&&U())}),St.observe(Z));let Te={get data(){return E},get columns(){return h},rowKey:f,locale:u,get filters(){return w},onHighlightRows:g=>lt(g),onSelectRow:g=>{F.add(String(g)),lt([String(g)]),je()},onOpenRow:typeof i.onRowClick=="function"||typeof i.onOpenRow=="function"?g=>st(g):void 0,onFiltersChange:g=>{w=g.slice(),x=1,U(),i.onFiltersChange&&i.onFiltersChange(w.slice())},onSortChange:g=>{v=g?{key:g.key,direction:g.direction==="desc"?"desc":"asc"}:null,x=1,U(),i.onSortChange&&i.onSortChange(v)}},Ct=Je(Te,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions}),ct=Jt({tools:()=>Ct,data:()=>E,columns:()=>h.map(g=>({key:g.key,label:g.label})),rowKey:f,locale:u,customRules:i.customRules||[],parseIntent:i.parseIntent,historyLimit:i.historyLimit||20,onResult:g=>{i.onAgentResult&&i.onAgentResult({success:g.success,message:g.message,tool:g.tool})},onError:i.onAgentError}),$t={status:{state:"unsupported",registered:[],errors:[]},unregister(){}};i.webmcp&&($t=Xt(()=>Ct,{onStatusChange:g=>{i.onWebMCPStatusChange&&i.onWebMCPStatusChange(g),Z.dispatchEvent(new CustomEvent("yuktai:webmcp",{detail:g,bubbles:!0}))}}));let Ue=Zt({data:E,columns:h,rowKey:f,referenceDate:i.referenceDate,onOpenRow:Te.onOpenRow,bind:{getData:()=>E,getFilters:()=>w,getSort:()=>v,getHighlightIds:()=>Array.from(B),setFilters:g=>Te.onFiltersChange(g),setSort:g=>Te.onSortChange(g),setHighlightIds:g=>lt(g),selectRow:g=>Te.onSelectRow(g)}}),ut=null;i.ai&&(ut=or(an,ct,{locale:u,inputLanguage:i.inputLanguage||(u==="te"?"te-IN":"en-IN"),examples:i.assistantExamples,webmcp:()=>$t.status,showWebMCP:!!i.webmcp}),i.webmcp&&Z.addEventListener("yuktai:webmcp",()=>ut&&ut.refreshStatus()));let un=null;if(i.agentic){let g=typeof i.agentic=="object"?i.agentic:{};un=nn(an,Ue,g)}let K={element:Z,host:Z,get tools(){return Ct},agent:ct,agentic:Ue,get webmcpStatus(){return $t.status},refresh(g){return Array.isArray(g)&&(E=g.slice(),F.clear(),B.clear(),x=1),U(),K},setData(g,A){return Array.isArray(A)&&(k=fo(A,g||E),h=Me(k),Ct=Je(Te,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions})),K.refresh(g)},getData:()=>E.slice(),getRows:()=>Pe(),getPageRows(){let g=Pe(),{start:A,end:M}=Ve(g.length);return g.slice(A,M)},getSelectedRows:()=>E.filter(g=>F.has(j(g))),getSelectedKeys:()=>Array.from(F),select(g,A=!0){return[].concat(g).forEach(M=>A?F.add(String(M)):F.delete(String(M))),U(),je(),K},clearSelection(){return F.clear(),U(),je(),K},search(g){return L=String(g||"").trim(),Ae.value=L,x=1,U(),ye.length},setFilters(g){return Te.onFiltersChange(Array.isArray(g)?g:[]),K},addFilter(g){return ct.executeTool("filter",g)},getFilters:()=>w.slice(),clearFilters(){return Te.onFiltersChange([]),Tt(l==="te"?"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C30\u0C41":"Filters cleared"),K},sortBy(g,A="asc"){return Te.onSortChange(g?{key:g,direction:A}:null),K},clearSort(){return Te.onSortChange(null),K},getSort:()=>v?{...v}:null,highlight(g,A){return lt(g,A===void 0?m:A),K},clearHighlight(){return lt([],!1),K},getHighlightIds:()=>Array.from(B),goToPage(g){return We(Number(g)||1),K},nextPage(){return We(x+1),K},prevPage(){return We(x-1),K},getPage:()=>({page:x,pageSize:$,pages:Ve(ye.length).pages,total:ye.length}),setPageSize(g){return $=Number(g)||$,S.includes($)||(S.push($),S.sort((A,M)=>A-M)),x=1,U(),K},setTheme(g){return I=mo.includes(g)?g:"default",U(),K},getTheme:()=>I,setView(g){return T=["table","card","auto"].includes(g)?g:"auto",U(),K},setLoading(g){return R=!!g,U(),K},openRow:g=>st(g),async ask(g){return(await Ue.ask(g)).answer},askDetailed:g=>Ue.ask(g),assistantAsk:g=>ct.ask(g),executeTool:(g,A)=>ct.executeTool(g,A),biSummary:()=>ze(Pe(),h),anomalies:()=>Oe(Pe(),h,{rowKey:f}),async runTasks(g){return(await Ue.ask(g)).answer},reset(){return Ue.reset(),L="",Ae.value="",U(),K},exportCSV(g=i.exportFileName||"yuktai-grid-export.csv"){let A=F.size?E.filter(P=>F.has(j(P))):Pe(),M="\uFEFF"+[k.map(P=>nr(P.label)).join(","),...A.map(P=>k.map(D=>nr(P[D.key])).join(","))].join(`\r
|
|
541
|
-
`);return vt(g,M,"text/csv;charset=utf-8"),re(`${A.length} row(s) exported`),A.length},destroy(){clearTimeout(cn),clearTimeout(ln),St&&St.disconnect(),$t.unregister(),ut&&ut.destroy(),un&&un.destroy(),Z.remove()}};return typeof i.onReady=="function"&&i.onReady(K),U(),K}var _i={en:{title:"Ask the grid",hint:"Type or speak: a word to search, \u201Csort by <column>\u201D, \u201Chow many\u201D, \u201Cclear filters\u201D, \u201Copen <name>\u201D.",placeholder:"Ask the grid\u2026",ask:"Ask",listen:"Speak",stop:"Stop",listening:"Listening\u2026",noVoice:"Voice input is not available in this browser. Type your question instead.",history:"History",clear:"Clear history",webmcp:{unsupported:"WebMCP: not available in this browser (no document.modelContext).",registering:"WebMCP: registering tools\u2026",ready:"WebMCP: tools ready",partial:"WebMCP: some tools failed",error:"WebMCP: registration failed"}},te:{title:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C28\u0C41 \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F",hint:"\u0C1F\u0C48\u0C2A\u0C4D \u0C1A\u0C47\u0C2F\u0C02\u0C21\u0C3F \u0C32\u0C47\u0C26\u0C3E \u0C2E\u0C3E\u0C1F\u0C4D\u0C32\u0C3E\u0C21\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, \u201C\u0C0E\u0C28\u0C4D\u0C28\u0C3F\u201D, \u201C\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F\u201D.",placeholder:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C28\u0C41 \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F\u2026",ask:"\u0C05\u0C21\u0C41\u0C17\u0C41",listen:"\u0C2E\u0C3E\u0C1F\u0C4D\u0C32\u0C3E\u0C21\u0C41",stop:"\u0C06\u0C2A\u0C41",listening:"\u0C35\u0C3F\u0C02\u0C1F\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41\u2026",noVoice:"\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 \u0C32\u0C47\u0C26\u0C41. \u0C1F\u0C48\u0C2A\u0C4D \u0C1A\u0C47\u0C2F\u0C02\u0C21\u0C3F.",history:"\u0C1A\u0C30\u0C3F\u0C24\u0C4D\u0C30",clear:"\u0C1A\u0C30\u0C3F\u0C24\u0C4D\u0C30 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F",webmcp:{unsupported:"WebMCP: \u0C08 \u0C2C\u0C4D\u0C30\u0C4C\u0C1C\u0C30\u0C4D\u200C\u0C32\u0C4B \u0C32\u0C47\u0C26\u0C41.",registering:"WebMCP: \u0C28\u0C2E\u0C4B\u0C26\u0C41 \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C4B\u0C02\u0C26\u0C3F\u2026",ready:"WebMCP: \u0C38\u0C3F\u0C26\u0C4D\u0C27\u0C02",partial:"WebMCP: \u0C15\u0C4A\u0C28\u0C4D\u0C28\u0C3F \u0C35\u0C3F\u0C2B\u0C32\u0C02",error:"WebMCP: \u0C35\u0C3F\u0C2B\u0C32\u0C02"}}};function or(e,t,n={}){let r=_i[n.locale==="te"?"te":"en"],a=W("yv-ask"),i=W("yv-hint"),o=c("input",{id:a,class:"yv-input",type:"text",placeholder:r.placeholder,autocomplete:"off","aria-describedby":i}),l=c("button",{type:"submit",class:"yv-btn yv-primary"},q("spark",16),r.ask),s=typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition),u=c("button",{type:"button",class:"yv-btn","aria-pressed":"false"},q("mic",16),r.listen),p=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),f=c("ol"),b=c("details",{class:"yv-history"},c("summary",null,r.history),f,c("button",{type:"button",class:"yv-btn yv-small","data-clear-history":""},r.clear)),d=n.showWebMCP?c("p",{class:"yv-muted",style:"margin:8px 0 0"}):null,S=n.examples||(n.locale==="te"?["\u0C0E\u0C28\u0C4D\u0C28\u0C3F","\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F"]:["how many","clear filters","clear sort"]),y=c("div",{class:"yv-chips"},...S.map(v=>c("button",{type:"button",class:"yv-chip","data-example":v},v))),m=c("form",{class:"yv-row",role:"search","aria-label":r.title},c("label",{for:a,class:"yv-sr"},r.title),o,l,u),C=c("section",{class:"yv-box yv-assistant","aria-label":r.title},c("h3",null,q("chat",16)," ",r.title),c("p",{id:i,class:"yv-muted",style:"margin:0 0 8px"},r.hint),m,y,p,b,d);e.appendChild(C);async function E(v){let L=String(v||"").trim();if(L){l.disabled=!0;try{let x=await t.ask(L);p.textContent=x.message,p.className=`yv-answer ${x.success?"":"yv-fail"}`}finally{l.disabled=!1}}}let k=t.subscribe(v=>{f.replaceChildren(...v.history.slice().reverse().map(L=>c("li",null,c("span",{class:L.result.success?"yv-ok":"yv-fail"},L.result.success?"\u2713 ":"\u2717 "),L.result.message,c("span",{class:"yv-muted"},` (${L.tool})`)))),b.querySelector("summary").textContent=`${r.history} (${v.history.length})`});m.addEventListener("submit",v=>{v.preventDefault(),E(o.value)}),C.addEventListener("click",v=>{let L=v.target.closest("[data-example],[data-clear-history]");L&&(L.hasAttribute("data-example")?(o.value=L.getAttribute("data-example"),E(o.value)):(t.clearHistory(),p.textContent=""))});let h=null;u.addEventListener("click",()=>{if(!s){p.textContent=r.noVoice;return}if(h){h.stop();return}h=new s,h.lang=n.inputLanguage||"en-IN",h.interimResults=!1,h.maxAlternatives=1,u.setAttribute("aria-pressed","true"),u.lastChild.textContent=r.stop,p.textContent=r.listening,h.onresult=v=>{let L=v.results[0][0].transcript;o.value=L,E(L)},h.onerror=v=>{p.textContent=`${r.noVoice} (${v.error})`},h.onend=()=>{h=null,u.setAttribute("aria-pressed","false"),u.lastChild.textContent=r.listen};try{h.start()}catch(v){p.textContent=`${r.noVoice} (${v.message})`,h=null}}),s||(u.title=r.noVoice);function w(){if(!d||!n.webmcp)return;let v=n.webmcp();d.textContent=r.webmcp[v.state]+(v.registered&&v.registered.length?` (${v.registered.length})`:"")}return w(),{element:C,ask:E,refreshStatus:w,destroy(){k(),h&&h.stop(),C.remove()}}}var bo=[{id:"copilot",label:"Copilot",icon:"wand"},{id:"qa",label:"QA report",icon:"check"},{id:"forms",label:"Forms",icon:"form"},{id:"design",label:"Design",icon:"layout"},{id:"ask",label:"Ask page",icon:"chat"},{id:"voice",label:"Voice",icon:"mic"}],Vi=[["en-IN","English (India)"],["en-US","English (US)"],["te-IN","\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41 (Telugu)"],["hi-IN","\u0939\u093F\u0928\u094D\u0926\u0940 (Hindi)"],["ta-IN","\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD (Tamil)"],["kn-IN","\u0C95\u0CA8\u0CCD\u0CA8\u0CA1 (Kannada)"],["ml-IN","\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02 (Malayalam)"],["mr-IN","\u092E\u0930\u093E\u0920\u0940 (Marathi)"],["bn-IN","\u09AC\u09BE\u0982\u09B2\u09BE (Bengali)"],["gu-IN","\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0 (Gujarati)"]],ir=e=>c("span",{class:`yv-badge yv-sev-${e}`},e);function ar(e,t){return c("div",null,c("div",{class:"yv-score"},c("strong",null,String(e)),c("span",{class:"yv-muted"},"/ 100")),c("div",{class:"yv-meter",role:"img","aria-label":`Score ${e} out of 100`},c("span",{style:`width:${Math.max(0,Math.min(100,e))}%`})),c("p",{style:"margin:0 0 6px"},t))}function wt(e){let t=(e||[]).filter(Boolean);return t.length?c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>re(`${go(t)} element(s) outlined on the page`)},q("eye",14),"Show on page"):null}function rn(e,t={}){let n=e==null?null:typeof e=="string"?document.querySelector(e):e;if(e!=null&&!n)throw new Error("mountAgenticPanel: container not found");let r=W("yv-tabs"),a=c("section",{class:`yv-box yv-agentic-panel${t.theme?" yv-theme-"+t.theme:""}`,"data-yuktai-panel":"","aria-label":t.title||"Page tools"}),i=c("div",{class:"yv-tabs",role:"tablist","aria-label":"Page tools",id:r}),o={};bo.forEach(k=>{let h=`${r}-${k.id}`,w=`${h}-panel`;i.append(c("button",{type:"button",class:"yv-tab",role:"tab",id:h,"aria-controls":w,"aria-selected":"false",tabindex:-1,"data-tab":k.id},q(k.icon,15)," ",k.label)),o[k.id]=c("div",{role:"tabpanel",id:w,"aria-labelledby":h,hidden:!0,tabindex:0})}),a.append(i,...Object.values(o)),n&&n.appendChild(a);let l={},s=null;function u(k,h){o[k]||(k="qa"),s=k,i.querySelectorAll("[role=tab]").forEach(w=>{let v=w.getAttribute("data-tab")===k;w.setAttribute("aria-selected",String(v)),w.tabIndex=v?0:-1,v&&h&&w.focus()}),Object.entries(o).forEach(([w,v])=>v.hidden=w!==k),l[k]||(l[k]=!0,E[k](o[k]))}i.addEventListener("click",k=>{let h=k.target.closest("[role=tab]");h&&u(h.getAttribute("data-tab"),!0)}),i.addEventListener("keydown",k=>{let h=bo.map(x=>x.id),w=k.target.closest&&k.target.closest("[role=tab]"),v=h.indexOf(w?w.getAttribute("data-tab"):s),L=null;k.key==="ArrowRight"?L=h[(v+1)%h.length]:k.key==="ArrowLeft"?L=h[(v-1+h.length)%h.length]:k.key==="Home"?L=h[0]:k.key==="End"&&(L=h[h.length-1]),L&&(k.preventDefault(),k.stopPropagation(),u(L,!0))});let p=null;function f(k){let h=c("ul",{class:"yv-list"}),w=c("p",{class:"yv-status",role:"status","aria-live":"polite"}),v=c("div",{class:"yv-answer","aria-live":"polite"}),L=c("button",{type:"button",class:"yv-btn","aria-pressed":"false"},q("eye",16),"Watch page");p=Ot({defaultLang:t.defaultLang,debounceMs:600,onUpdate:$=>x($)});function x($){let I=$.report;L.setAttribute("aria-pressed",String($.watching)),w.textContent=I?`${I.summary} Fixes applied: ${$.appliedFixes}.${$.watching?" Watching for page changes.":""}`:"Scan the page to see issues.",h.replaceChildren(...(I?I.issues.slice(0,40):[]).map(T=>c("li",{class:"yv-item"},c("p",null,ir(T.severity)," ",c("b",null,T.message)),c("p",{class:"yv-muted"},`WCAG ${T.wcag} \xB7 `,c("code",null,T.selector)),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>v.textContent=p.explain(T.id)},q("info",14),"Explain"),T.autoFixable?c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>re(p.applyFix(T.id).message)},q("wand",14),"Fix"):null,wt([T.selector])))))}k.append(c("p",{class:"yv-muted"},"Finds accessibility problems, explains them in plain English, and applies safe fixes you can undo."),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-primary",onclick:()=>p.scan()},q("search",16),"Scan page"),L,c("button",{type:"button",class:"yv-btn",onclick:()=>re(`${p.applyAllFixes().filter($=>$.applied).length} fix(es) applied`)},q("wand",16),"Apply all safe fixes"),c("button",{type:"button",class:"yv-btn",onclick:()=>re(`${p.undoAll()} change(s) undone`)},q("undo",16),"Undo all")),w,v,h),L.addEventListener("click",()=>p.getState().watching?p.stop():p.start()),x(p.getState())}function b(k){let h=c("div",{"aria-live":"polite"}),w=null,v=()=>{w=be(t.auditOptions||{});let L=w.issues;h.replaceChildren(ar(w.score,w.summary),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:async()=>re(await po(bt(w))?"Markdown report copied":"Copy failed")},q("copy",14),"Copy Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>vt("yuktai-qa-report.md",bt(w),"text/markdown;charset=utf-8")},q("download",14),"Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>vt("yuktai-qa-report.json",Dt(w),"application/json")},q("download",14),"JSON")),c("details",{class:"yv-history"},c("summary",null,`Checks (${w.checks.filter(x=>x.passed).length}/${w.checks.length} passed)`),c("ul",{class:"yv-steps"},...w.checks.map(x=>c("li",null,c("span",{class:x.passed?"yv-ok":"yv-fail"},x.passed?"\u2713 ":"\u2717 "),x.title||x.rule,x.issueCount?` \u2014 ${x.issueCount} issue(s)`:"")))),c("ul",{class:"yv-list"},...L.slice(0,60).map(x=>c("li",{class:"yv-item"},c("p",null,ir(x.severity)," ",c("b",null,x.message)),c("p",null,c("b",null,"Fix: "),x.fix),c("p",{class:"yv-muted"},`${x.rule} \xB7 WCAG ${x.wcag} \xB7 `,c("code",null,x.selector)),wt([x.selector])))),L.length>60?c("p",{class:"yv-muted"},`${L.length-60} more issue(s) in the downloaded report.`):null),re(w.summary)};k.append(c("p",{class:"yv-muted"},"15 WCAG checks on this page with a 0\u2013100 score. Heuristic: still test with a keyboard and a screen reader."),c("button",{type:"button",class:"yv-btn yv-primary",onclick:v},q("check",16),"Run QA audit"),h)}function d(k){let h=c("input",{type:"checkbox",id:W("yv-senior"),checked:t.seniorFriendly!==!1}),w=c("div",{"aria-live":"polite"}),v=()=>{let L=Ze({seniorFriendly:h.checked,maxFieldsPerStep:t.maxFieldsPerStep||8});if(!L.length)return w.replaceChildren(c("p",{class:"yv-answer"},"There are no forms on this page.")),re("No forms found");w.replaceChildren(...L.map(x=>c("div",{class:"yv-item",style:"margin-top:10px"},ar(x.score,x.summary),c("ul",{class:"yv-steps"},...x.findings.map($=>c("li",null,c("span",{class:`yv-badge yv-sev-${$.level==="problem"?"serious":"minor"}`},$.level)," ",$.message,c("br"),c("span",{class:"yv-muted"},$.suggestion)))),wt(x.findings.map($=>$.selector))))),re(`${L.length} form(s) reviewed`)};k.append(c("p",{class:"yv-muted"},"Checks labels, autocomplete, error messages and senior-friendly tips."),c("div",{class:"yv-row"},c("label",{class:"yv-check",for:h.id},h),c("label",{for:h.id},"Senior-friendly checks"),c("button",{type:"button",class:"yv-btn yv-primary",onclick:v},q("form",16),"Review forms")),w)}function S(k){let h=W("yv-min"),w=c("input",{id:h,class:"yv-input",type:"number",min:10,max:24,value:t.minFontSize||16,style:"width:90px"}),v=c("div",{"aria-live":"polite"}),L=()=>{let x=Bt({minFontSize:Number(w.value)||16,maxLineLength:t.maxLineLength||90});v.replaceChildren(ar(x.score,x.summary),c("div",{class:"yv-cats"},...Object.entries(x.categories).map(([$,I])=>c("div",{class:"yv-cat"},c("span",{class:"yv-muted"},$),c("strong",null,String(I.score)),c("span",{class:"yv-muted"},`${I.findings} finding(s)`)))),c("ul",{class:"yv-list"},...x.findings.slice(0,40).map($=>c("li",{class:"yv-item"},c("p",null,ir($.severity)," ",c("b",null,$.category),": ",$.message),c("p",{class:"yv-muted"},$.suggestion),wt([$.selector]))))),re(x.summary)};k.append(c("p",{class:"yv-muted"},"Hierarchy, readability, interaction, clutter and consistency. Heuristic, not a visual-design certification."),c("div",{class:"yv-row"},c("label",{for:h},"Minimum text size (px)"),w,c("button",{type:"button",class:"yv-btn yv-primary",onclick:L},q("layout",16),"Review design")),v)}function y(k){let h=W("yv-pq"),w=c("input",{id:h,class:"yv-input",type:"text",placeholder:"What is this page about?",autocomplete:"off"}),v=c("div",{"aria-live":"polite"}),L=null,x=async()=>{let T=w.value.trim()||"What is this page about?",R=await zt(T,{summarize:t.summarize}),G=[c("div",{class:"yv-answer"},R.answer)];R.suggestions.length&&G.push(c("ul",{class:"yv-steps"},...R.suggestions.map(F=>c("li",null,F))));let N=wt(R.targets);if(N&&G.push(N),R.intent==="unknown"){L?L.rebuild():L=qt({includePage:!0,documents:t.documents});let F=await L.ask(T,{generate:t.generate});G.push(c("h4",{style:"margin:12px 0 4px"},F.generated?"Answer (your model)":"From the page text"),c("div",{class:"yv-answer"},F.answer))}v.replaceChildren(...G),re(R.answer)},$=c("form",{class:"yv-row"},c("label",{for:h,class:"yv-sr"},"Ask about this page"),w,c("button",{type:"submit",class:"yv-btn yv-primary"},"Ask"));$.addEventListener("submit",T=>{T.preventDefault(),x()});let I=["What is this page about?","Which fields have no label?","Which images have no alt text?","Show the page structure","How many links are there?","Tell me about the forms"];k.append(c("p",{class:"yv-muted"},"Answers from this page only, offline. Pass generate() to use your own model."),$,c("div",{class:"yv-chips"},...I.map(T=>c("button",{type:"button",class:"yv-chip",onclick:()=>(w.value=T,x())},T))),v)}let m=null;function C(k){let h=W("yv-lang"),w=c("select",{id:h,class:"yv-input",style:"width:auto"},...Vi.map(([N,F])=>c("option",{value:N,selected:N===(t.voiceLang||"en-IN")},F))),v=c("button",{type:"button",class:"yv-btn yv-primary","aria-pressed":"false"},q("mic",16),"Start listening"),L=W("yv-cmd"),x=c("input",{id:L,class:"yv-input",type:"text",placeholder:"Type a command, e.g. make text bigger",autocomplete:"off"}),$=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),I=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition),T=()=>{m&&m.stop(),m=Yt({lang:w.value,speak:t.speak!==!1,initial:t.getSettings?t.getSettings():void 0,apply:t.applySettings,onTranscript:(N,F)=>{$.textContent=`Heard: \u201C${N}\u201D
|
|
542
|
-
${F?F.say:"Not a voice command. Try: make text bigger, high contrast on, dark mode, next row, reset."}`,t.onVoiceCommand&&t.onVoiceCommand(N,F)}})};T(),w.addEventListener("change",()=>{let N=v.getAttribute("aria-pressed")==="true";T(),N&&m.start()}),v.addEventListener("click",()=>{if(v.getAttribute("aria-pressed")==="true"){m.stop(),v.setAttribute("aria-pressed","false"),v.lastChild.textContent="Start listening";return}if(!m.start()){$.textContent="Speech recognition is not available in this browser. Typed commands below still work.";return}v.setAttribute("aria-pressed","true"),v.lastChild.textContent="Stop listening",$.textContent="Listening\u2026 say \u201Cmake text bigger\u201D or \u201Cnext row\u201D."});let R=c("form",{class:"yv-row"},c("label",{for:L,class:"yv-sr"},"Type a voice command"),x,c("button",{type:"submit",class:"yv-btn"},"Run"));R.addEventListener("submit",async N=>{N.preventDefault(),x.value.trim()&&await m.handle(x.value)});let G=["make text bigger","make text smaller","high contrast on","dark mode","reduce motion","dyslexia font","next row","previous row","first row","reset","\u0C2A\u0C46\u0C26\u0C4D\u0C26 \u0C05\u0C15\u0C4D\u0C37\u0C30\u0C3E\u0C32\u0C41","\u0C39\u0C48 \u0C15\u0C3E\u0C02\u0C1F\u0C4D\u0C30\u0C3E\u0C38\u0C4D\u0C1F\u0C4D","\u0C24\u0C30\u0C4D\u0C35\u0C3E\u0C24\u0C3F \u0C35\u0C30\u0C41\u0C38"];k.append(c("p",{class:"yv-muted"},I?"Speak accessibility commands in English or Telugu. Text size moves 80\u2013130% in 10% steps.":"Your browser has no speech recognition. You can still type the same commands."),c("div",{class:"yv-row"},c("label",{for:h},"Language"),w,v),R,c("div",{class:"yv-chips"},...G.map(N=>c("button",{type:"button",class:"yv-chip",onclick:()=>(x.value=N,m.handle(N))},N))),$)}let E={copilot:f,qa:b,forms:d,design:S,ask:y,voice:C};return u(t.defaultTab||"qa",!1),{element:a,select:k=>u(k,!1),get tab(){return s},get copilot(){return p},destroy(){p&&p.stop(),m&&m.stop(),a.remove()}}}var sr="yuktai-a11y-prefs",xt=[.8,.9,1,1.1,1.2,1.3],ji=[["none","None"],["deuteranopia","Deuteranopia (red-green)"],["protanopia","Protanopia (red-green)"],["tritanopia","Tritanopia (blue-yellow)"],["achromatopsia","Achromatopsia (no colour)"]],Wi=[["highContrast","High contrast","Stronger text and borders","contrast"],["darkMode","Dark mode","Light text on a dark page","moon"],["reduceMotion","Reduce motion","Stop animations and transitions","motion"],["largeTargets","Large targets","Buttons and links at least 44\xD744","target"],["dyslexiaFont","Dyslexia-friendly font","Easier letters and wider spacing","reading"],["speechEnabled","Speak on focus","Read out each control you Tab to","speaker"],["autoFix","Auto-fix page","Add missing ARIA, labels and alt text; watch new content","wand"],["showSkipLinks","Skip links","\u201CSkip to main content\u201D on Tab","skip"]];function Ui(){try{let e=localStorage.getItem(sr);return e?JSON.parse(e):{}}catch{return{}}}function Ki(e){try{let t={};["highContrast","darkMode","reduceMotion","largeTargets","speechEnabled","colorBlindMode","dyslexiaFont","fontSizeMultiplier"].forEach(n=>t[n]=e[n]),localStorage.setItem(sr,JSON.stringify(t))}catch{}}function yo(e={}){let t={position:"left",title:"Accessibility",showPageTools:!1,...e},n=t.position==="right"?"right":"left",r=en(t.primaryColor,"#0f766e"),a={enabled:!0,autoFix:!0,showSkipLinks:!0,showPreferencePanel:!1,...rt,...t.config||{}},i={...a,...Ui()},o,l,s,u,p,f,b,d="";async function S(T,R){i={...i,...T,enabled:!0},Ki(i);try{d=await He.execute({...i}),i.autoFix||He.stopObserver()}catch(G){console.error("[yuktai] accessibility engine failed",G),d="Some settings could not be applied. See the browser console."}return C(),R||re("Accessibility settings updated"),d}async function y(){try{localStorage.removeItem(sr)}catch{}return i={...a},await S(i,!0),re("Accessibility settings reset"),i}function m(){let T=W("yv-a11y-title"),R=W("yv-font"),G=W("yv-cb"),N=c("section",{class:"yv-dialog",role:"dialog","aria-modal":"false","aria-labelledby":T,"data-yuktai-panel":""}),F=Wi.map(([j,Y,Z,kt])=>{let Ae=W("yv-opt"),on=c("input",{id:Ae,type:"checkbox",role:"switch","data-setting":j,"aria-describedby":`${Ae}-d`});return c("div",{class:"yv-option"},c("span",{class:"yv-option-icon"},q(kt,18)),c("span",{class:"yv-option-copy"},c("label",{for:Ae},c("b",null,Y)),c("small",{id:`${Ae}-d`},Z)),c("span",{class:"yv-switch"},on,c("span",{"aria-hidden":"true"})))}),B=c("div",{class:"yv-steps-bar",role:"group","aria-labelledby":R},...xt.map(j=>c("button",{type:"button",class:"yv-step","data-font":j,"aria-label":`${Math.round(j*100)} percent`,"aria-pressed":"false"}))),pe=c("select",{id:G,class:"yv-input","data-colorblind":""},...ji.map(([j,Y])=>c("option",{value:j},Y)));return N.append(c("header",{class:"yv-dialog-head"},c("div",null,c("div",{class:"yv-muted",style:"font-weight:800;font-size:.75em;letter-spacing:.05em"},"YUKTAI"),c("h2",{id:T},t.title),c("p",{class:"yv-muted",style:"margin:2px 0 0"},"Saved on this device. Works on every page.")),c("button",{type:"button",class:"yv-btn yv-icon","data-close":"","aria-label":"Close accessibility settings",html:de("close")})),c("div",{class:"yv-dialog-body"},...F,c("div",{style:"padding:12px 0;border-bottom:1px solid var(--yv-border)"},c("div",{style:"display:flex;justify-content:space-between"},c("b",{id:R},"Text size"),c("strong",{"data-font-value":""})),c("div",{class:"yv-row",style:"flex-wrap:nowrap;margin-top:6px"},c("button",{type:"button",class:"yv-btn yv-icon","data-font-step":"-1","aria-label":"Smaller text",html:de("minus",16)}),B,c("button",{type:"button",class:"yv-btn yv-icon","data-font-step":"1","aria-label":"Bigger text",html:de("plus",16)}))),c("div",{style:"padding:12px 0"},c("label",{for:G},c("b",null,"Colour-blind filter")),pe),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn","data-reset":""},q("reset",16),"Reset all"),c("button",{type:"button",class:"yv-btn yv-primary","data-close":""},q("check",16),"Done")),c("p",{class:"yv-status",role:"status","aria-live":"polite","data-status":""}))),N.addEventListener("change",j=>{let Y=j.target;Y.matches("[data-setting]")?S({[Y.getAttribute("data-setting")]:Y.checked}):Y.matches("[data-colorblind]")&&S({colorBlindMode:Y.value})}),N.addEventListener("click",j=>{let Y=j.target.closest("button");if(Y){if(Y.hasAttribute("data-close"))return w();if(Y.hasAttribute("data-reset"))return y();if(Y.hasAttribute("data-font"))return E(Number(Y.getAttribute("data-font")));if(Y.hasAttribute("data-font-step")){let Z=xt.indexOf(Number(i.fontSizeMultiplier||1));return E(xt[Math.min(xt.length-1,Math.max(0,(Z<0?2:Z)+Number(Y.getAttribute("data-font-step"))))])}}}),N.addEventListener("keydown",j=>k(j,N,w)),N}function C(){if(!u)return;u.querySelectorAll("[data-setting]").forEach(N=>N.checked=!!i[N.getAttribute("data-setting")]&&i[N.getAttribute("data-setting")]!==!1);let T=u.querySelector('[data-setting="showSkipLinks"]');T&&(T.checked=i.showSkipLinks!==!1);let R=Number(i.fontSizeMultiplier||1);u.querySelector("[data-font-value]").textContent=`${Math.round(R*100)}%`,u.querySelectorAll("[data-font]").forEach(N=>N.setAttribute("aria-pressed",String(Math.abs(Number(N.getAttribute("data-font"))-R)<.001))),u.querySelector("[data-colorblind]").value=i.colorBlindMode||"none";let G=/(\d+) fixes applied/.exec(d);u.querySelector("[data-status]").textContent=G?`${G[1]} automatic accessibility fix(es) applied on this page.`:d}function E(T){xt.some(R=>Math.abs(R-T)<.001)&&(S({fontSizeMultiplier:T},!0),re(`Text size ${Math.round(T*100)} percent`))}function k(T,R,G){if(T.key==="Escape"){T.preventDefault(),T.stopPropagation(),G();return}if(T.key!=="Tab")return;let N=Array.from(R.querySelectorAll("button,input,select,textarea,[tabindex]:not([tabindex='-1'])")).filter(F=>!F.disabled&&F.offsetParent!==null);N.length&&(T.shiftKey&&document.activeElement===N[0]?(T.preventDefault(),N[N.length-1].focus()):!T.shiftKey&&document.activeElement===N[N.length-1]&&(T.preventDefault(),N[0].focus()))}function h(){l||I(),!u&&(x(),b=document.activeElement,u=m(),$().appendChild(u),l.setAttribute("aria-expanded","true"),C(),u.querySelector("[data-close]").focus(),document.addEventListener("pointerdown",v,!0))}function w(){u&&(u.remove(),u=null,l.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",v,!0),(b&&document.contains(b)?b:l).focus())}function v(T){u&&!u.contains(T.target)&&!o.contains(T.target)&&w(),p&&!p.contains(T.target)&&!o.contains(T.target)&&x()}function L(T){if(l||I(),p){T&&f&&f.select(T);return}w(),b=document.activeElement;let R=W("yv-tools-title");p=c("section",{class:"yv-dialog yv-wide",role:"dialog","aria-modal":"false","aria-labelledby":R,"data-yuktai-panel":""});let G=c("div",{class:"yv-dialog-body"});p.append(c("header",{class:"yv-dialog-head"},c("h2",{id:R},t.toolsTitle||"Page tools"),c("button",{type:"button",class:"yv-btn yv-icon","aria-label":"Close page tools",html:de("close"),onclick:()=>x()})),G),$().appendChild(p),f=rn(G,{defaultTab:T||t.defaultTab||"qa",voiceLang:t.voiceLang,generate:t.generate,summarize:t.summarize,defaultLang:t.defaultLang,getSettings:()=>({...i}),applySettings:N=>S(N,!0)}),s&&s.setAttribute("aria-expanded","true"),p.addEventListener("keydown",N=>k(N,p,x)),p.querySelector("[role=tab][aria-selected=true]").focus(),document.addEventListener("pointerdown",v,!0)}function x(){p&&(f&&f.destroy(),f=null,p.remove(),p=null,s&&s.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",v,!0),(b&&document.contains(b)?b:s||l).focus())}let $=()=>document.documentElement||document.body;function I(){!Fe()||l||!document.body||(tn(r,n),o=c("div",{class:"yv-fabs","data-yuktai-fabs":""}),l=c("button",{type:"button",class:"yv-fab","aria-label":"Accessibility settings",title:"Accessibility settings","aria-haspopup":"dialog","aria-expanded":"false",html:de("accessibility",26)}),l.addEventListener("click",()=>u?w():h()),o.append(l),t.showPageTools&&(s=c("button",{type:"button",class:"yv-fab yv-fab-alt","aria-label":"Page tools: QA, forms, design, ask, voice",title:"Page tools","aria-haspopup":"dialog","aria-expanded":"false",html:de("tools",24)}),s.addEventListener("click",()=>p?x():L()),o.prepend(s)),$().appendChild(o),t.applyOnLoad!==!1&&S({},!0))}return{init:I,open:h,close:w,openTools:L,closeTools:x,apply:T=>S(T||{}),reset:y,getSettings:()=>({...i}),destroy(){w(),x(),o&&o.remove(),l=s=o=null}}}var vo="5.2.0";(function(){if(!Fe()||window.yuktai&&window.yuktai.__vanillaInitialized)return;let t=window.YUKTAI_CONFIG||{},n=en(t.primaryColor,"#0f766e"),r=t.position==="right"?"right":"left",a=yo(t),i=()=>tn(n,r),o=s=>(...u)=>(i(),s(...u)),l={__vanillaInitialized:!0,version:vo,init:()=>a.init(),open:()=>a.open(),close:()=>a.close(),openTools:s=>a.openTools(s),closeTools:()=>a.closeTools(),apply:s=>a.apply(s),reset:()=>a.reset(),getSettings:()=>a.getSettings(),renderGrid:o(ho),mountAgenticGridBar:o(nn),mountAgenticPanel:o(rn),mountGridAssistant:o(or),createAgenticGrid:Zt,createGridAgent:Jt,parseGridIntent:Zn,registerWebMCP:Xt,icon:de,iconNames:uo.slice(),...Jn,runPageQA:()=>be().summary,getCapabilities:()=>({version:vo,inlineSVG:!0,grid:!0,gridAssistant:!0,agenticGrid:!0,ruleBasedBI:!0,taskRunner:!0,anomalyChecks:!0,pageQA:!0,a11yCopilot:!0,formsReview:!0,designReview:!0,pageQandA:!0,localPageSearch:!0,voiceCommands:!0,voice:!!(window.SpeechRecognition||window.webkitSpeechRecognition),speech:"speechSynthesis"in window,webMCP:!!(document.modelContext&&typeof document.modelContext.registerTool=="function"),modelConnected:!1})};window.yuktai=l,t.autoInit!==!1&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>a.init(),{once:!0}):a.init())})();})();
|
|
541
|
+
`,document.head.appendChild(n)}var Zi={query:"Grid query",anomalies:"Anomalies",summary:"Summary",insight:"BI insight",tasks:"Task steps"};function an(e,t,n={}){let r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new Error("mountAgenticGridBar: container not found");if(!t||typeof t.ask!="function")throw new Error("mountAgenticGridBar: pass the object from createAgenticGrid() or grid.agentic");let a=n.title||"Ask about this data",i=j("yv-q"),o=j("yv-qh"),l=c("input",{id:i,class:"yv-input",type:"text",autocomplete:"off",placeholder:n.placeholder||"Ask the grid\u2026 e.g. salary over 1 lakh in Hyderabad","aria-describedby":o}),s=c("button",{type:"submit",class:"yv-btn yv-primary"},q("spark",16),"Ask"),u=c("button",{type:"button",class:"yv-btn"},q("reset",16),"Show all rows"),p=c("p",{class:"yv-muted",style:"margin:10px 0 0",hidden:!0}),f=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),b=c("div"),d=n.examples||["salary over 1 lakh","anything unusual?","average salary by department","show salary over 80k, then sort by salary, then summarize"],S=c("div",{class:"yv-chips","aria-label":"Example questions"},...d.map(k=>c("button",{type:"button",class:"yv-chip","data-example":k},k))),y=c("form",{class:"yv-row",role:"search","aria-label":a},c("label",{for:i,class:"yv-sr"},a),l,s,u),m=c("section",{class:`yv-box yv-agentic-bar${n.theme?" yv-theme-"+n.theme:""}`,"aria-label":a},c("h3",null,q("spark",16)," ",a),c("p",{id:o,class:"yv-muted",style:"margin:0 0 8px"},n.hint||"Plain-English questions. Understands 10k, 1.5 lakh, 2cr. Every answer says which filters it used."),y,S,p,f,b);r.appendChild(m);function C(k){if(s.disabled=!!k.busy,m.setAttribute("aria-busy",String(!!k.busy)),!k.busy){if(f.textContent=k.answer||"",p.hidden=!k.kind,p.textContent=k.kind?`${Zi[k.kind]||k.kind} \xB7 ${k.visibleIds.length} row(s) shown`:"",b.replaceChildren(),k.table&&k.table.length){let h=Object.keys(k.table[0]),w=c("table",{class:"yv-mini"});w.innerHTML=`<caption class="yv-sr">Answer table</caption><thead><tr>${h.map(v=>`<th scope="col">${nn(v)}</th>`).join("")}</tr></thead><tbody>${k.table.map(v=>`<tr>${h.map(E=>`<td>${nn(v[E])}</td>`).join("")}</tr>`).join("")}</tbody>`,b.append(c("div",{style:"overflow-x:auto"},w))}k.steps&&k.steps.length&&b.append(c("ol",{class:"yv-steps","aria-label":"Steps"},...k.steps.map(h=>c("li",null,c("span",{class:h.success===!1?"yv-fail":"yv-ok"},h.success===!1?"\u2717 ":"\u2713 "),c("b",null,h.action),": ",h.message||h.text))))}}let M=t.subscribe(C);return y.addEventListener("submit",k=>{k.preventDefault(),t.ask(l.value)}),u.addEventListener("click",()=>{l.value="",t.reset()}),S.addEventListener("click",k=>{let h=k.target.closest("[data-example]");h&&(l.value=h.getAttribute("data-example"),t.ask(l.value))}),{element:m,ask:k=>(l.value=k,t.ask(k)),destroy(){M(),m.remove()}}}var ea={en:{search:"Search\u2026",searchAria:"Search grid",rows:"rows",selected:"selected",loading:"Loading\u2026",noData:"No data found.",selectRow:e=>`Select row ${e}`,selectPage:"Select all rows on this page",pageSize:"Rows per page",page:(e,t)=>`Page ${e} of ${t}`,showing:(e,t,n)=>n?`Showing ${e}\u2013${t} of ${n}`:"No rows",first:"First page",previous:"Previous page",next:"Next page",last:"Last page",yes:"Yes",no:"No",sortedAsc:e=>`Sorted by ${e}, ascending`,sortedDesc:e=>`Sorted by ${e}, descending`,sortCleared:"Sorting cleared",filters:e=>`${e} filter(s) applied`,clearFilters:"Clear filters",removeFilter:e=>`Remove filter: ${e}`,export:"Export CSV",tableView:"Table view",cardView:"Card view",highlighted:"highlighted",results:e=>`${e} result(s)`,ops:{contains:"contains",equals:"is",startsWith:"starts with",endsWith:"ends with",greaterThan:">",lessThan:"<",between:"between"}},te:{search:"\u0C36\u0C4B\u0C27\u0C3F\u0C02\u0C1A\u0C02\u0C21\u0C3F\u2026",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",selected:"\u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C41\u0C28\u0C4D\u0C28\u0C35\u0C3F",loading:"\u0C32\u0C4B\u0C21\u0C4D \u0C05\u0C35\u0C41\u0C24\u0C4B\u0C02\u0C26\u0C3F\u2026",noData:"\u0C21\u0C47\u0C1F\u0C3E \u0C15\u0C28\u0C2C\u0C21\u0C32\u0C47\u0C26\u0C41.",selectRow:e=>`\u0C35\u0C30\u0C41\u0C38 ${e} \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B\u0C02\u0C21\u0C3F`,selectPage:"\u0C08 \u0C2A\u0C47\u0C1C\u0C40\u0C32\u0C4B\u0C28\u0C3F \u0C05\u0C28\u0C4D\u0C28\u0C3F \u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C0E\u0C02\u0C1A\u0C41\u0C15\u0C4B\u0C02\u0C21\u0C3F",pageSize:"\u0C2A\u0C47\u0C1C\u0C40 \u0C2A\u0C30\u0C3F\u0C2E\u0C3E\u0C23\u0C02",page:(e,t)=>`\u0C2A\u0C47\u0C1C\u0C40 ${e} / ${t}`,showing:(e,t,n)=>n?`${n} \u0C32\u0C4B ${e}\u2013${t}`:"\u0C35\u0C30\u0C41\u0C38\u0C32\u0C41 \u0C32\u0C47\u0C35\u0C41",first:"\u0C2E\u0C4A\u0C26\u0C1F\u0C3F \u0C2A\u0C47\u0C1C\u0C40",previous:"\u0C35\u0C46\u0C28\u0C41\u0C15\u0C15\u0C41",next:"\u0C2E\u0C41\u0C02\u0C26\u0C41\u0C15\u0C41",last:"\u0C1A\u0C3F\u0C35\u0C30\u0C3F \u0C2A\u0C47\u0C1C\u0C40",yes:"\u0C05\u0C35\u0C41\u0C28\u0C41",no:"\u0C15\u0C3E\u0C26\u0C41",sortedAsc:e=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C06\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02`,sortedDesc:e=>`${e} \u0C2A\u0C4D\u0C30\u0C15\u0C3E\u0C30\u0C02 \u0C05\u0C35\u0C30\u0C4B\u0C39\u0C23 \u0C15\u0C4D\u0C30\u0C2E\u0C02`,sortCleared:"\u0C15\u0C4D\u0C30\u0C2E\u0C02 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C30\u0C41",filters: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",removeFilter:e=>`\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C02\u0C21\u0C3F: ${e}`,export:"CSV \u0C21\u0C4C\u0C28\u0C4D\u200C\u0C32\u0C4B\u0C21\u0C4D",tableView:"\u0C2A\u0C1F\u0C4D\u0C1F\u0C3F\u0C15",cardView:"\u0C15\u0C3E\u0C30\u0C4D\u0C21\u0C41\u0C32\u0C41",highlighted:"\u0C39\u0C48\u0C32\u0C48\u0C1F\u0C4D",results:e=>`${e} \u0C2B\u0C32\u0C3F\u0C24\u0C3E\u0C32\u0C41`,ops:{contains:"\u0C32\u0C4B \u0C09\u0C02\u0C26\u0C3F",equals:"=",startsWith:"\u0C24\u0C4B \u0C2E\u0C4A\u0C26\u0C32\u0C41",endsWith:"\u0C24\u0C4B \u0C2E\u0C41\u0C17\u0C3F\u0C02\u0C2A\u0C41",greaterThan:">",lessThan:"<",between:"\u0C2E\u0C27\u0C4D\u0C2F"}}},xo=["default","high-contrast","dark","color-blind","dyslexia"],sr=e=>String(e??"").normalize("NFC").toLowerCase();function ko(e,t){return(Array.isArray(e)&&e.length?e:t[0]?Object.keys(t[0]).map(r=>({key:r,label:r})):[]).map(r=>({key:String(r.key),label:r.label==null?String(r.key):String(r.label),sortable:r.sortable!==!1,type:r.type||"text",align:r.align||(r.type==="number"?"right":"left"),render:typeof r.render=="function"?r.render:null,hiddenOnMobile:!!r.hiddenOnMobile,width:r.width}))}function Ao(e,t,n,r){let a=typeof e=="string"?document.querySelector(e):e;if(!a||typeof a.appendChild!="function")throw new Error("renderGrid: container not found. Pass an element or a CSS selector.");let i=Array.isArray(t)?{...r||{},data:t,columns:n}:{...t||{}},o=i.locale||"en-IN",l=String(o).split("-")[0],s=ea[l==="te"?"te":"en"],u=l==="te"?"te":"en",p=l==="en"||l==="te"?"en-IN":o,f=i.rowKey||"id",b=i.label||i.ariaLabel||"Data grid",d=i.pagination===!1?!1:typeof i.pagination=="object"?i.pagination:{},S=d&&d.sizeOptions||[10,20,50,100],y=i.selectable!==!1,m=i.autoScrollToHighlight!==!1,C=Number(i.mobileBreakpoint)||640,M=Array.isArray(i.data)?i.data.slice():[],k=ko(i.columns,M),h=Le(k),w=[],v=null,E="",x=1,$=Number(d&&d.pageSize||i.pageSize)||10,I=xo.includes(i.theme)?i.theme:"default",T=["table","card","auto"].includes(i.view)?i.view:"auto",R=!!i.loading,G=!1,N={r:1,c:0},F=new Set((i.selectedKeys||[]).map(String)),H=new Set((i.highlightIds||[]).map(String)),pe={grid:j("yv-grid"),title:j("yv-title"),status:j("yv-status")};S.includes($)||S.push($),S.sort((g,A)=>g-A);let W=g=>ee(g,f)||String(M.indexOf(g)),Y=g=>{let A=k.find(L=>L.type==="text")||k[0];return A?String(g[A.key]??W(g)):W(g)},Z=c("section",{class:`yv-grid yv-theme-${I}${i.wrap?" yv-wrap":""}${i.className?" "+i.className:""}`,role:"region","aria-labelledby":pe.title,lang:i.lang||(l!=="en"?o:null)});i.maxHeight&&Z.style.setProperty("--yv-max-height",typeof i.maxHeight=="number"?`${i.maxHeight}px`:i.maxHeight);let St=c("h3",{id:pe.title,class:i.showTitle?"yv-grid-title":"yv-sr"},b);i.showTitle&&(St.style.cssText="margin:0;padding:12px 12px 0;font-size:1.05em");let Ae=c("input",{type:"search",placeholder:s.search,"aria-label":s.searchAria,"aria-controls":pe.grid,autocomplete:"off",spellcheck:"false"}),ln=i.search===!1?null:c("label",{class:"yv-search"},q("search",18),Ae),pr=c("span",{class:"yv-info","aria-hidden":"true"}),lt=c("button",{type:"button",class:"yv-btn yv-icon","data-view-toggle":""}),gr=i.exportable===!1?null:c("button",{type:"button",class:"yv-btn"},q("download",16),s.export),$o=c("div",{class:"yv-tools"},T==="auto"||i.viewToggle?lt:null,gr),Ro=c("div",{class:"yv-toolbar"},ln,pr,$o),Ee=c("div",{class:"yv-filterbar",hidden:!0,"aria-label":s.filters(0)}),cn=c("div",{class:"yv-slot"}),oe=c("div",{class:"yv-body",id:pe.grid}),Ct=c("div",{class:"yv-pager"}),un=c("p",{class:"yv-sr",id:pe.status,role:"status","aria-live":"polite","aria-atomic":"true"});Z.append(St,Ro,Ee,cn,oe,Ct,un),a.appendChild(Z);let dn=null,$t=g=>{clearTimeout(dn),un.textContent="",dn=setTimeout(()=>un.textContent=g,40)};function Mo(g,A,L,P){let O=g[L.key],D=A[L.key];if(O==null||O==="")return D==null||D===""?0:1;if(D==null||D==="")return-1;let _;return L.type==="number"?_=Number(O)-Number(D):L.type==="date"?_=new Date(O).getTime()-new Date(D).getTime():_=String(O).localeCompare(String(D),o,{numeric:!0,sensitivity:"base"}),Number.isFinite(_)||(_=String(O).localeCompare(String(D))),P==="desc"?-_:_}function Ge(){let g=Re(M,h,w);if(E){let A=sr(E);g=g.filter(L=>k.some(P=>sr(L[P.key]).includes(A)||sr(ct(P,L[P.key])).includes(A)))}if(v&&v.key){let A=k.find(L=>L.key===v.key);A&&(g=g.slice().sort((L,P)=>Mo(L,P,A,v.direction)))}return g}function ct(g,A){if(A==null||A==="")return"";if(g.type==="number"&&Number.isFinite(Number(A)))return Number(A).toLocaleString(p);if(g.type==="date"){let L=new Date(A);return Number.isNaN(L.getTime())?String(A):L.toLocaleDateString(p,{year:"numeric",month:"short",day:"numeric"})}return g.type==="boolean"?A===!0||A==="true"?s.yes:s.no:String(A)}function mr(g,A,L){let P=A[g.key];if(g.render)try{let O=g.render(P,A,L);return O instanceof Node?O:document.createTextNode(O==null?"":String(O))}catch(O){return console.error("[yuktai] column render failed",g.key,O),document.createTextNode(ct(g,P))}return g.type==="badge"&&P!=null&&P!==""?c("span",{class:"yv-cellbadge"},String(P)):document.createTextNode(ct(g,P))}let ut=()=>T==="card"||T==="auto"&&G;function je(g){if(d===!1)return{pages:1,start:0,end:g};let A=Math.max(1,Math.ceil(g/$));return x=Math.min(Math.max(1,x),A),{pages:A,start:(x-1)*$,end:Math.min(g,x*$)}}let ye=[];function U(){let g=Ge();ye=g;let{pages:A,start:L,end:P}=je(g.length),O=g.slice(L,P);Z.className=`yv-grid yv-theme-${I}${i.wrap?" yv-wrap":""}${i.className?" "+i.className:""}`,Z.setAttribute("aria-busy",String(R)),pr.textContent=`${g.length.toLocaleString(p)} ${s.rows}${y?` \xB7 ${F.size.toLocaleString(p)} ${s.selected}`:""}`,lt.innerHTML=de(ut()?"grid":"cards",18),lt.setAttribute("aria-label",ut()?s.tableView:s.cardView),lt.title=ut()?s.tableView:s.cardView,Io();let D=oe.contains(document.activeElement);oe.replaceChildren(R?c("div",{class:"yv-loading",role:"status"},s.loading):ut()?Lo(O,L):Eo(O,L,g.length)),D&&!R&&hr(),No(g.length,A,L,P)}function Eo(g,A,L){let P=k,O=P.length+(y?1:0),D=c("table",{class:"yv-table",role:"grid","aria-labelledby":pe.title,"aria-rowcount":L+1,"aria-colcount":O,"aria-multiselectable":y?"true":null}),_=c("tr",{role:"row","aria-rowindex":1});if(y){let B=g.length>0&&g.every(we=>F.has(W(we))),ve=g.some(we=>F.has(W(we))),J=c("input",{type:"checkbox","data-select-page":"","aria-label":s.selectPage,tabindex:-1});J.checked=B,J.indeterminate=!B&&ve,_.append(c("th",{role:"columnheader",scope:"col","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},J)))}P.forEach((B,ve)=>{let J=ve+(y?1:0),we=v&&v.key===B.key?v.direction:null,Oe=c("th",{role:"columnheader",scope:"col","aria-colindex":J+1,"aria-sort":B.sortable?we==="asc"?"ascending":we==="desc"?"descending":"none":null,class:B.align!=="left"?`yv-align-${B.align}`:null,tabindex:-1,"data-col":J});if(B.width&&(Oe.style.width=typeof B.width=="number"?`${B.width}px`:B.width),B.sortable){let Ye=c("button",{type:"button",class:"yv-sortbtn","data-sort":B.key,tabindex:-1},B.label);Ye.insertAdjacentHTML("beforeend",de(we==="asc"?"sortUp":we==="desc"?"sortDown":"sort",14)),Oe.append(Ye)}else Oe.append(B.label);_.append(Oe)});let ie=c("tbody");if(!g.length){let B=i.empty instanceof Node?i.empty.cloneNode(!0):document.createTextNode(i.empty?String(i.empty):s.noData);ie.append(c("tr",{role:"row","aria-rowindex":2},c("td",{role:"gridcell",class:"yv-empty",colspan:O,tabindex:-1,"data-col":0},B)))}g.forEach((B,ve)=>{let J=W(B),we=F.has(J),Oe=H.has(J),Ye=c("tr",{role:"row","aria-rowindex":A+ve+2,"aria-selected":y?String(we):null,"data-yuktai-row-id":J,class:Oe?"yv-hl":null});if(y){let Je=c("input",{type:"checkbox","data-select":J,"aria-label":s.selectRow(Y(B)),tabindex:-1});Je.checked=we,Ye.append(c("td",{role:"gridcell","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},Je)))}P.forEach((Je,yr)=>{let vr=yr+(y?1:0),mn=c("td",{role:"gridcell","aria-colindex":vr+1,tabindex:-1,"data-col":vr,class:Je.align!=="left"?`yv-align-${Je.align}`:null});mn.append(mr(Je,B,A+ve)),yr===0&&Oe&&mn.append(c("span",{class:"yv-sr"},` (${s.highlighted})`)),Ye.append(mn)}),ie.append(Ye)}),D.append(c("thead",null,_),ie);let se=D.querySelectorAll("tr");N.r=Math.min(N.r,se.length-1);let le=fr(D,N.r,N.c)||fr(D,0,0);return le&&le.setAttribute("tabindex","0"),c("div",{class:"yv-tablewrap"},D)}function Lo(g,A){if(!g.length){let P=i.empty instanceof Node?i.empty.cloneNode(!0):document.createTextNode(i.empty?String(i.empty):s.noData);return c("div",{class:"yv-empty",role:"status"},P)}let L=c("ul",{class:"yv-cards","aria-labelledby":pe.title});return g.forEach((P,O)=>{let D=W(P),_=F.has(D),ie=H.has(D),se=j("yv-card"),le=c("li",{class:`yv-card${ie?" yv-hl":""}`,"data-yuktai-row-id":D,"aria-labelledby":se,"aria-selected":y?String(_):null,tabindex:-1}),B=c("div",{class:"yv-card-head"},c("p",{class:"yv-card-title",id:se},Y(P),ie?c("span",{class:"yv-sr"},` (${s.highlighted})`):null));if(y){let J=c("input",{type:"checkbox","data-select":D,"aria-label":s.selectRow(Y(P))});J.checked=_,B.append(c("label",{class:"yv-check"},J))}let ve=c("dl");k.forEach(J=>{J.hiddenOnMobile||ve.append(c("dt",null,J.label),c("dd",null,mr(J,P,A+O)))}),le.append(B,ve),typeof i.onRowClick=="function"&&le.append(c("button",{type:"button",class:"yv-btn yv-small","data-open":D,style:"margin-top:8px"},i.openLabel||(l==="te"?"\u0C24\u0C46\u0C30\u0C41\u0C35\u0C41":"Open"))),L.append(le)}),L}function Io(){if(Ee.replaceChildren(),!w.length){Ee.hidden=!0;return}Ee.hidden=!1,Ee.setAttribute("aria-label",s.filters(w.length)),Ee.append(c("span",{class:"yv-muted"},q("filter",15)," ",s.filters(w.length))),w.forEach((g,A)=>{let L=k.find(_=>_.key===g.key),P=Array.isArray(g.value)?g.value.map(_=>ct(L||{},_)).join(" \u2013 "):L?ct(L,g.value):String(g.value),O=`${L?L.label:g.key} ${s.ops[g.operator]||g.operator} ${P}`,D=c("button",{type:"button",class:"yv-chip","data-remove-filter":A,"aria-label":s.removeFilter(O)},O,q("close",14));Ee.append(D)}),Ee.append(c("button",{type:"button",class:"yv-btn yv-small","data-clear-filters":""},s.clearFilters))}function No(g,A,L,P){if(Ct.replaceChildren(),d===!1){Ct.append(c("span",{class:"yv-muted"},s.results(g.toLocaleString(p))));return}let O=se=>se.toLocaleString(p),D=c("span",{class:"yv-muted"},g?s.showing(O(L+1),O(P),O(g)):s.showing(0,0,0)),_=c("div",{class:"yv-pages"});if(d.showSizeChanger!==!1){let se=j("yv-size"),le=c("select",{id:se,"data-page-size":""},...S.map(B=>c("option",{value:B,selected:B===$},String(B))));_.append(c("label",{for:se,class:"yv-muted"},s.pageSize),le)}let ie=(se,le,B,ve)=>{let J=c("button",{type:"button",class:"yv-btn yv-icon","aria-label":le,title:le,disabled:B,"data-page":ve});return J.innerHTML=de(se,18),J};_.append(ie("first",s.first,x<=1,"first"),ie("left",s.previous,x<=1,"prev"),c("span",{class:"yv-muted","aria-current":"page"},s.page(O(x),O(A))),ie("right",s.next,x>=A,"next"),ie("last",s.last,x>=A,"last")),Ct.append(D,_)}function fr(g,A,L){let P=g.querySelectorAll("tr")[A];if(!P)return null;let O=P.querySelectorAll("th,td");return O[Math.min(L,O.length-1)]||null}function $e(g,A){let L=oe.querySelector("table");if(!L)return;let P=L.querySelectorAll("tr");g=Math.max(0,Math.min(g,P.length-1));let O=P[g].querySelectorAll("th,td");A=Math.max(0,Math.min(A,O.length-1)),L.querySelectorAll('[tabindex="0"]').forEach(_=>_.setAttribute("tabindex","-1"));let D=O[A];D.setAttribute("tabindex","0"),N={r:g,c:A},D.focus()}function hr(){if(oe.querySelector("table"))$e(N.r,N.c);else{let A=oe.querySelector(".yv-card");A&&A.focus()}}function Fo(g){let A=oe.querySelector("table"),L=g.target.closest&&g.target.closest("th,td");if(!A||!L||!A.contains(L))return;let P=L.parentElement,O=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),D=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),L),_=A.querySelectorAll("tr").length-1,ie=!0;switch(g.key){case"ArrowRight":$e(O,D+1);break;case"ArrowLeft":$e(O,D-1);break;case"ArrowDown":$e(O+1,D);break;case"ArrowUp":$e(O-1,D);break;case"Home":g.ctrlKey?$e(0,0):$e(O,0);break;case"End":g.ctrlKey?$e(_,999):$e(O,999);break;case"PageDown":d!==!1&&(N={r:Math.max(1,O),c:D},Ke(x+1,!0));break;case"PageUp":d!==!1&&(N={r:Math.max(1,O),c:D},Ke(x-1,!0));break;case"Enter":case" ":{let se=L.querySelector("[data-sort]"),le=L.querySelector("input[type=checkbox]");se?br(se.getAttribute("data-sort")):le?le.click():g.key==="Enter"&&P.hasAttribute("data-yuktai-row-id")&&typeof i.onRowClick=="function"?dt(P.getAttribute("data-yuktai-row-id")):g.key===" "&&y&&P.hasAttribute("data-yuktai-row-id")?Po(P.getAttribute("data-yuktai-row-id")):ie=!1;break}default:ie=!1}ie&&(g.preventDefault(),g.stopPropagation())}function br(g){let A=k.find(P=>P.key===g);if(!A||!A.sortable)return;!v||v.key!==g?v={key:g,direction:"asc"}:v.direction==="asc"?v={key:g,direction:"desc"}:v=null,x=1,oe.querySelector("table")&&oe.contains(document.activeElement)&&(N={r:0,c:N.c}),U(),$t(v?v.direction==="asc"?s.sortedAsc(A.label):s.sortedDesc(A.label):s.sortCleared),i.onSortChange&&i.onSortChange(v?{key:v.key,direction:v.direction}:null)}function Ue(){i.onSelectionChange&&i.onSelectionChange(Array.from(F)),Z.dispatchEvent(new CustomEvent("yuktai:selection",{detail:{keys:Array.from(F)},bubbles:!0}))}function Po(g,A){(A===void 0?!F.has(g):A)?F.add(g):F.delete(g),U(),Ue()}function Ke(g,A){let{pages:L}=je(ye.length),P=Math.min(Math.max(1,g),L);P===x&&!A||(x=P,U(),$t(s.page(x,L)),A&&oe.querySelector("table")&&hr())}function dt(g){let A=M.find(L=>W(L)===String(g));return A?(typeof i.onRowClick=="function"&&i.onRowClick(A,M.indexOf(A)),typeof i.onOpenRow=="function"&&i.onOpenRow(String(g)),!0):!1}function pt(g,A=m){if(H.clear(),(g||[]).forEach(L=>H.add(typeof L=="object"&&L!==null?W(L):String(L))),A&&H.size){let L=ye.length?ye.findIndex(P=>H.has(W(P))):Ge().findIndex(P=>H.has(W(P)));L>=0&&d!==!1&&(x=Math.floor(L/$)+1)}if(U(),A&&H.size){let L=oe.querySelector(".yv-hl");L&&L.scrollIntoView&&L.scrollIntoView({block:"nearest",behavior:ir()?"auto":"smooth"})}}let pn=null;Ae.addEventListener("input",()=>{clearTimeout(pn),pn=setTimeout(()=>{E=Ae.value.trim(),x=1,U(),$t(s.results(ye.length.toLocaleString(p)))},160)}),Z.addEventListener("click",g=>{let A=g.target.closest("button, input, tr[data-yuktai-row-id]");if(!(!A||!Z.contains(A))){if(A.matches("[data-sort]"))return br(A.getAttribute("data-sort"));if(A.matches("[data-page]")){let L=A.getAttribute("data-page"),{pages:P}=je(ye.length);return Ke(L==="first"?1:L==="prev"?x-1:L==="next"?x+1:P)}if(A.matches("[data-remove-filter]")){w=w.filter((L,P)=>P!==Number(A.getAttribute("data-remove-filter"))),x=1,U(),i.onFiltersChange&&i.onFiltersChange(w.slice());return}if(A.matches("[data-clear-filters]"))return K.clearFilters();if(A.matches("[data-open]"))return dt(A.getAttribute("data-open"));if(A===lt){T=ut()?"table":"card",U();return}if(A===gr)return K.exportCSV();A.matches("tr[data-yuktai-row-id]")&&typeof i.onRowClick=="function"&&!g.target.closest("label,input,button,a")&&dt(A.getAttribute("data-yuktai-row-id"))}}),Z.addEventListener("change",g=>{let A=g.target;if(A.matches("[data-select]"))A.checked?F.add(A.getAttribute("data-select")):F.delete(A.getAttribute("data-select")),U(),Ue();else if(A.matches("[data-select-page]")){let{start:L,end:P}=je(ye.length);ye.slice(L,P).forEach(O=>A.checked?F.add(W(O)):F.delete(W(O))),U(),Ue()}else A.matches("[data-page-size]")&&($=Number(A.value)||$,x=1,U(),oe.closest(".yv-grid").querySelector("[data-page-size]").focus())}),oe.addEventListener("keydown",Fo),oe.addEventListener("focusin",g=>{let A=oe.querySelector("table"),L=g.target.closest&&g.target.closest("th,td");if(!A||!L)return;let P=L.parentElement,O=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),D=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),L);O<0||D<0||(A.querySelectorAll('[tabindex="0"]').forEach(_=>_!==L&&_.setAttribute("tabindex","-1")),L.setAttribute("tabindex","0"),N={r:O,c:D})});let Rt=null;typeof ResizeObserver=="function"&&(Rt=new ResizeObserver(g=>{let A=g[0]&&g[0].contentRect.width,L=A>0&&A<C;L!==G&&(G=L,T==="auto"&&U())}),Rt.observe(Z));let Te={get data(){return M},get columns(){return h},rowKey:f,locale:u,get filters(){return w},onHighlightRows:g=>pt(g),onSelectRow:g=>{F.add(String(g)),pt([String(g)]),Ue()},onOpenRow:typeof i.onRowClick=="function"||typeof i.onOpenRow=="function"?g=>dt(g):void 0,onFiltersChange:g=>{w=g.slice(),x=1,U(),i.onFiltersChange&&i.onFiltersChange(w.slice())},onSortChange:g=>{v=g?{key:g.key,direction:g.direction==="desc"?"desc":"asc"}:null,x=1,U(),i.onSortChange&&i.onSortChange(v)}},Mt=Ze(Te,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions}),gt=Zt({tools:()=>Mt,data:()=>M,columns:()=>h.map(g=>({key:g.key,label:g.label})),rowKey:f,locale:u,customRules:i.customRules||[],parseIntent:i.parseIntent,historyLimit:i.historyLimit||20,onResult:g=>{i.onAgentResult&&i.onAgentResult({success:g.success,message:g.message,tool:g.tool})},onError:i.onAgentError}),Et={status:{state:"unsupported",registered:[],errors:[]},unregister(){}};i.webmcp&&(Et=en(()=>Mt,{onStatusChange:g=>{i.onWebMCPStatusChange&&i.onWebMCPStatusChange(g),Z.dispatchEvent(new CustomEvent("yuktai:webmcp",{detail:g,bubbles:!0}))}}));let Qe=tn({data:M,columns:h,rowKey:f,referenceDate:i.referenceDate,onOpenRow:Te.onOpenRow,bind:{getData:()=>M,getFilters:()=>w,getSort:()=>v,getHighlightIds:()=>Array.from(H),setFilters:g=>Te.onFiltersChange(g),setSort:g=>Te.onSortChange(g),setHighlightIds:g=>pt(g),selectRow:g=>Te.onSelectRow(g)}}),mt=null;i.ai&&(mt=lr(cn,gt,{locale:u,inputLanguage:i.inputLanguage||(u==="te"?"te-IN":"en-IN"),examples:i.assistantExamples,webmcp:()=>Et.status,showWebMCP:!!i.webmcp}),i.webmcp&&Z.addEventListener("yuktai:webmcp",()=>mt&&mt.refreshStatus()));let gn=null;if(i.agentic){let g=typeof i.agentic=="object"?i.agentic:{};gn=an(cn,Qe,g)}let K={element:Z,host:Z,get tools(){return Mt},agent:gt,agentic:Qe,get webmcpStatus(){return Et.status},refresh(g){return Array.isArray(g)&&(M=g.slice(),F.clear(),H.clear(),x=1),U(),K},setData(g,A){return Array.isArray(A)&&(k=ko(A,g||M),h=Le(k),Mt=Ze(Te,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions})),K.refresh(g)},getData:()=>M.slice(),getRows:()=>Ge(),getPageRows(){let g=Ge(),{start:A,end:L}=je(g.length);return g.slice(A,L)},getSelectedRows:()=>M.filter(g=>F.has(W(g))),getSelectedKeys:()=>Array.from(F),select(g,A=!0){return[].concat(g).forEach(L=>A?F.add(String(L)):F.delete(String(L))),U(),Ue(),K},clearSelection(){return F.clear(),U(),Ue(),K},search(g){return E=String(g||"").trim(),Ae.value=E,x=1,U(),ye.length},setFilters(g){return Te.onFiltersChange(Array.isArray(g)?g:[]),K},addFilter(g){return gt.executeTool("filter",g)},getFilters:()=>w.slice(),clearFilters(){return Te.onFiltersChange([]),$t(l==="te"?"\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C36\u0C3E\u0C30\u0C41":"Filters cleared"),K},sortBy(g,A="asc"){return Te.onSortChange(g?{key:g,direction:A}:null),K},clearSort(){return Te.onSortChange(null),K},getSort:()=>v?{...v}:null,highlight(g,A){return pt(g,A===void 0?m:A),K},clearHighlight(){return pt([],!1),K},getHighlightIds:()=>Array.from(H),goToPage(g){return Ke(Number(g)||1),K},nextPage(){return Ke(x+1),K},prevPage(){return Ke(x-1),K},getPage:()=>({page:x,pageSize:$,pages:je(ye.length).pages,total:ye.length}),setPageSize(g){return $=Number(g)||$,S.includes($)||(S.push($),S.sort((A,L)=>A-L)),x=1,U(),K},setTheme(g){return I=xo.includes(g)?g:"default",U(),K},getTheme:()=>I,setView(g){return T=["table","card","auto"].includes(g)?g:"auto",U(),K},setLoading(g){return R=!!g,U(),K},openRow:g=>dt(g),async ask(g){return(await Qe.ask(g)).answer},askDetailed:g=>Qe.ask(g),assistantAsk:g=>gt.ask(g),executeTool:(g,A)=>gt.executeTool(g,A),biSummary:()=>qe(Ge(),h),anomalies:()=>ze(Ge(),h,{rowKey:f}),async runTasks(g){return(await Qe.ask(g)).answer},reset(){return Qe.reset(),E="",Ae.value="",U(),K},exportCSV(g=i.exportFileName||"yuktai-grid-export.csv"){let A=F.size?M.filter(P=>F.has(W(P))):Ge(),L="\uFEFF"+[k.map(P=>ar(P.label)).join(","),...A.map(P=>k.map(O=>ar(P[O.key])).join(","))].join(`\r
|
|
542
|
+
`);return kt(g,L,"text/csv;charset=utf-8"),re(`${A.length} row(s) exported`),A.length},destroy(){clearTimeout(pn),clearTimeout(dn),Rt&&Rt.disconnect(),Et.unregister(),mt&&mt.destroy(),gn&&gn.destroy(),Z.remove()}};return typeof i.onReady=="function"&&i.onReady(K),U(),K}var ta={en:{title:"Ask the grid",hint:"Type or speak: a word to search, \u201Csort by <column>\u201D, \u201Chow many\u201D, \u201Cclear filters\u201D, \u201Copen <name>\u201D.",placeholder:"Ask the grid\u2026",ask:"Ask",listen:"Speak",stop:"Stop",listening:"Listening\u2026",noVoice:"Voice input is not available in this browser. Type your question instead.",history:"History",clear:"Clear history",webmcp:{unsupported:"WebMCP: not available in this browser (no document.modelContext).",registering:"WebMCP: registering tools\u2026",ready:"WebMCP: tools ready",partial:"WebMCP: some tools failed",error:"WebMCP: registration failed"}},te:{title:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C28\u0C41 \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F",hint:"\u0C1F\u0C48\u0C2A\u0C4D \u0C1A\u0C47\u0C2F\u0C02\u0C21\u0C3F \u0C32\u0C47\u0C26\u0C3E \u0C2E\u0C3E\u0C1F\u0C4D\u0C32\u0C3E\u0C21\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, \u201C\u0C0E\u0C28\u0C4D\u0C28\u0C3F\u201D, \u201C\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F\u201D.",placeholder:"\u0C17\u0C4D\u0C30\u0C3F\u0C21\u0C4D\u200C\u0C28\u0C41 \u0C05\u0C21\u0C17\u0C02\u0C21\u0C3F\u2026",ask:"\u0C05\u0C21\u0C41\u0C17\u0C41",listen:"\u0C2E\u0C3E\u0C1F\u0C4D\u0C32\u0C3E\u0C21\u0C41",stop:"\u0C06\u0C2A\u0C41",listening:"\u0C35\u0C3F\u0C02\u0C1F\u0C41\u0C28\u0C4D\u0C28\u0C3E\u0C28\u0C41\u2026",noVoice:"\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 \u0C32\u0C47\u0C26\u0C41. \u0C1F\u0C48\u0C2A\u0C4D \u0C1A\u0C47\u0C2F\u0C02\u0C21\u0C3F.",history:"\u0C1A\u0C30\u0C3F\u0C24\u0C4D\u0C30",clear:"\u0C1A\u0C30\u0C3F\u0C24\u0C4D\u0C30 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F",webmcp:{unsupported:"WebMCP: \u0C08 \u0C2C\u0C4D\u0C30\u0C4C\u0C1C\u0C30\u0C4D\u200C\u0C32\u0C4B \u0C32\u0C47\u0C26\u0C41.",registering:"WebMCP: \u0C28\u0C2E\u0C4B\u0C26\u0C41 \u0C1A\u0C47\u0C38\u0C4D\u0C24\u0C4B\u0C02\u0C26\u0C3F\u2026",ready:"WebMCP: \u0C38\u0C3F\u0C26\u0C4D\u0C27\u0C02",partial:"WebMCP: \u0C15\u0C4A\u0C28\u0C4D\u0C28\u0C3F \u0C35\u0C3F\u0C2B\u0C32\u0C02",error:"WebMCP: \u0C35\u0C3F\u0C2B\u0C32\u0C02"}}};function lr(e,t,n={}){let r=ta[n.locale==="te"?"te":"en"],a=j("yv-ask"),i=j("yv-hint"),o=c("input",{id:a,class:"yv-input",type:"text",placeholder:r.placeholder,autocomplete:"off","aria-describedby":i}),l=c("button",{type:"submit",class:"yv-btn yv-primary"},q("spark",16),r.ask),s=typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition),u=c("button",{type:"button",class:"yv-btn","aria-pressed":"false"},q("mic",16),r.listen),p=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),f=c("ol"),b=c("details",{class:"yv-history"},c("summary",null,r.history),f,c("button",{type:"button",class:"yv-btn yv-small","data-clear-history":""},r.clear)),d=n.showWebMCP?c("p",{class:"yv-muted",style:"margin:8px 0 0"}):null,S=n.examples||(n.locale==="te"?["\u0C0E\u0C28\u0C4D\u0C28\u0C3F","\u0C2B\u0C3F\u0C32\u0C4D\u0C1F\u0C30\u0C4D\u0C32\u0C41 \u0C24\u0C40\u0C38\u0C47\u0C2F\u0C3F"]:["how many","clear filters","clear sort"]),y=c("div",{class:"yv-chips"},...S.map(v=>c("button",{type:"button",class:"yv-chip","data-example":v},v))),m=c("form",{class:"yv-row",role:"search","aria-label":r.title},c("label",{for:a,class:"yv-sr"},r.title),o,l,u),C=c("section",{class:"yv-box yv-assistant","aria-label":r.title},c("h3",null,q("chat",16)," ",r.title),c("p",{id:i,class:"yv-muted",style:"margin:0 0 8px"},r.hint),m,y,p,b,d);e.appendChild(C);async function M(v){let E=String(v||"").trim();if(E){l.disabled=!0;try{let x=await t.ask(E);p.textContent=x.message,p.className=`yv-answer ${x.success?"":"yv-fail"}`}finally{l.disabled=!1}}}let k=t.subscribe(v=>{f.replaceChildren(...v.history.slice().reverse().map(E=>c("li",null,c("span",{class:E.result.success?"yv-ok":"yv-fail"},E.result.success?"\u2713 ":"\u2717 "),E.result.message,c("span",{class:"yv-muted"},` (${E.tool})`)))),b.querySelector("summary").textContent=`${r.history} (${v.history.length})`});m.addEventListener("submit",v=>{v.preventDefault(),M(o.value)}),C.addEventListener("click",v=>{let E=v.target.closest("[data-example],[data-clear-history]");E&&(E.hasAttribute("data-example")?(o.value=E.getAttribute("data-example"),M(o.value)):(t.clearHistory(),p.textContent=""))});let h=null;u.addEventListener("click",()=>{if(!s){p.textContent=r.noVoice;return}if(h){h.stop();return}h=new s,h.lang=n.inputLanguage||"en-IN",h.interimResults=!1,h.maxAlternatives=1,u.setAttribute("aria-pressed","true"),u.lastChild.textContent=r.stop,p.textContent=r.listening,h.onresult=v=>{let E=v.results[0][0].transcript;o.value=E,M(E)},h.onerror=v=>{p.textContent=`${r.noVoice} (${v.error})`},h.onend=()=>{h=null,u.setAttribute("aria-pressed","false"),u.lastChild.textContent=r.listen};try{h.start()}catch(v){p.textContent=`${r.noVoice} (${v.message})`,h=null}}),s||(u.title=r.noVoice);function w(){if(!d||!n.webmcp)return;let v=n.webmcp();d.textContent=r.webmcp[v.state]+(v.registered&&v.registered.length?` (${v.registered.length})`:"")}return w(),{element:C,ask:M,refreshStatus:w,destroy(){k(),h&&h.stop(),C.remove()}}}var To=[{id:"copilot",label:"Copilot",icon:"wand"},{id:"qa",label:"QA report",icon:"check"},{id:"forms",label:"Forms",icon:"form"},{id:"design",label:"Design",icon:"layout"},{id:"ask",label:"Ask page",icon:"chat"},{id:"voice",label:"Voice",icon:"mic"}],na=[["en-IN","English (India)"],["en-US","English (US)"],["te-IN","\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41 (Telugu)"],["hi-IN","\u0939\u093F\u0928\u094D\u0926\u0940 (Hindi)"],["ta-IN","\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD (Tamil)"],["kn-IN","\u0C95\u0CA8\u0CCD\u0CA8\u0CA1 (Kannada)"],["ml-IN","\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02 (Malayalam)"],["mr-IN","\u092E\u0930\u093E\u0920\u0940 (Marathi)"],["bn-IN","\u09AC\u09BE\u0982\u09B2\u09BE (Bengali)"],["gu-IN","\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0 (Gujarati)"]],cr=e=>c("span",{class:`yv-badge yv-sev-${e}`},e);function ur(e,t){return c("div",null,c("div",{class:"yv-score"},c("strong",null,String(e)),c("span",{class:"yv-muted"},"/ 100")),c("div",{class:"yv-meter",role:"img","aria-label":`Score ${e} out of 100`},c("span",{style:`width:${Math.max(0,Math.min(100,e))}%`})),c("p",{style:"margin:0 0 6px"},t))}function At(e){let t=(e||[]).filter(Boolean);return t.length?c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>re(`${wo(t)} element(s) outlined on the page`)},q("eye",14),"Show on page"):null}function sn(e,t={}){let n=e==null?null:typeof e=="string"?document.querySelector(e):e;if(e!=null&&!n)throw new Error("mountAgenticPanel: container not found");let r=j("yv-tabs"),a=c("section",{class:`yv-box yv-agentic-panel${t.theme?" yv-theme-"+t.theme:""}`,"data-yuktai-panel":"","aria-label":t.title||"Page tools"}),i=c("div",{class:"yv-tabs",role:"tablist","aria-label":"Page tools",id:r}),o={};To.forEach(k=>{let h=`${r}-${k.id}`,w=`${h}-panel`;i.append(c("button",{type:"button",class:"yv-tab",role:"tab",id:h,"aria-controls":w,"aria-selected":"false",tabindex:-1,"data-tab":k.id},q(k.icon,15)," ",k.label)),o[k.id]=c("div",{role:"tabpanel",id:w,"aria-labelledby":h,hidden:!0,tabindex:0})}),a.append(i,...Object.values(o)),n&&n.appendChild(a);let l={},s=null;function u(k,h){o[k]||(k="qa"),s=k,i.querySelectorAll("[role=tab]").forEach(w=>{let v=w.getAttribute("data-tab")===k;w.setAttribute("aria-selected",String(v)),w.tabIndex=v?0:-1,v&&h&&w.focus()}),Object.entries(o).forEach(([w,v])=>v.hidden=w!==k),l[k]||(l[k]=!0,M[k](o[k]))}i.addEventListener("click",k=>{let h=k.target.closest("[role=tab]");h&&u(h.getAttribute("data-tab"),!0)}),i.addEventListener("keydown",k=>{let h=To.map(x=>x.id),w=k.target.closest&&k.target.closest("[role=tab]"),v=h.indexOf(w?w.getAttribute("data-tab"):s),E=null;k.key==="ArrowRight"?E=h[(v+1)%h.length]:k.key==="ArrowLeft"?E=h[(v-1+h.length)%h.length]:k.key==="Home"?E=h[0]:k.key==="End"&&(E=h[h.length-1]),E&&(k.preventDefault(),k.stopPropagation(),u(E,!0))});let p=null;function f(k){let h=c("ul",{class:"yv-list"}),w=c("p",{class:"yv-status",role:"status","aria-live":"polite"}),v=c("div",{class:"yv-answer","aria-live":"polite"}),E=c("button",{type:"button",class:"yv-btn","aria-pressed":"false"},q("eye",16),"Watch page");p=qt({defaultLang:t.defaultLang,debounceMs:600,onUpdate:$=>x($)});function x($){let I=$.report;E.setAttribute("aria-pressed",String($.watching)),w.textContent=I?`${I.summary} Fixes applied: ${$.appliedFixes}.${$.watching?" Watching for page changes.":""}`:"Scan the page to see issues.",h.replaceChildren(...(I?I.issues.slice(0,40):[]).map(T=>c("li",{class:"yv-item"},c("p",null,cr(T.severity)," ",c("b",null,T.message)),c("p",{class:"yv-muted"},`WCAG ${T.wcag} \xB7 `,c("code",null,T.selector)),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>v.textContent=p.explain(T.id)},q("info",14),"Explain"),T.autoFixable?c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>re(p.applyFix(T.id).message)},q("wand",14),"Fix"):null,At([T.selector])))))}k.append(c("p",{class:"yv-muted"},"Finds accessibility problems, explains them in plain English, and applies safe fixes you can undo."),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-primary",onclick:()=>p.scan()},q("search",16),"Scan page"),E,c("button",{type:"button",class:"yv-btn",onclick:()=>re(`${p.applyAllFixes().filter($=>$.applied).length} fix(es) applied`)},q("wand",16),"Apply all safe fixes"),c("button",{type:"button",class:"yv-btn",onclick:()=>re(`${p.undoAll()} change(s) undone`)},q("undo",16),"Undo all")),w,v,h),E.addEventListener("click",()=>p.getState().watching?p.stop():p.start()),x(p.getState())}function b(k){let h=c("div",{"aria-live":"polite"}),w=null,v=()=>{w=be(t.auditOptions||{});let E=w.issues;h.replaceChildren(ur(w.score,w.summary),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:async()=>re(await vo(wt(w))?"Markdown report copied":"Copy failed")},q("copy",14),"Copy Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>kt("yuktai-qa-report.md",wt(w),"text/markdown;charset=utf-8")},q("download",14),"Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>kt("yuktai-qa-report.json",zt(w),"application/json")},q("download",14),"JSON")),c("details",{class:"yv-history"},c("summary",null,`Checks (${w.checks.filter(x=>x.passed).length}/${w.checks.length} passed)`),c("ul",{class:"yv-steps"},...w.checks.map(x=>c("li",null,c("span",{class:x.passed?"yv-ok":"yv-fail"},x.passed?"\u2713 ":"\u2717 "),x.title||x.rule,x.issueCount?` \u2014 ${x.issueCount} issue(s)`:"")))),c("ul",{class:"yv-list"},...E.slice(0,60).map(x=>c("li",{class:"yv-item"},c("p",null,cr(x.severity)," ",c("b",null,x.message)),c("p",null,c("b",null,"Fix: "),x.fix),c("p",{class:"yv-muted"},`${x.rule} \xB7 WCAG ${x.wcag} \xB7 `,c("code",null,x.selector)),At([x.selector])))),E.length>60?c("p",{class:"yv-muted"},`${E.length-60} more issue(s) in the downloaded report.`):null),re(w.summary)};k.append(c("p",{class:"yv-muted"},"15 WCAG checks on this page with a 0\u2013100 score. Heuristic: still test with a keyboard and a screen reader."),c("button",{type:"button",class:"yv-btn yv-primary",onclick:v},q("check",16),"Run QA audit"),h)}function d(k){let h=c("input",{type:"checkbox",id:j("yv-senior"),checked:t.seniorFriendly!==!1}),w=c("div",{"aria-live":"polite"}),v=()=>{let E=nt({seniorFriendly:h.checked,maxFieldsPerStep:t.maxFieldsPerStep||8});if(!E.length)return w.replaceChildren(c("p",{class:"yv-answer"},"There are no forms on this page.")),re("No forms found");w.replaceChildren(...E.map(x=>c("div",{class:"yv-item",style:"margin-top:10px"},ur(x.score,x.summary),c("ul",{class:"yv-steps"},...x.findings.map($=>c("li",null,c("span",{class:`yv-badge yv-sev-${$.level==="problem"?"serious":"minor"}`},$.level)," ",$.message,c("br"),c("span",{class:"yv-muted"},$.suggestion)))),At(x.findings.map($=>$.selector))))),re(`${E.length} form(s) reviewed`)};k.append(c("p",{class:"yv-muted"},"Checks labels, autocomplete, error messages and senior-friendly tips."),c("div",{class:"yv-row"},c("label",{class:"yv-check",for:h.id},h),c("label",{for:h.id},"Senior-friendly checks"),c("button",{type:"button",class:"yv-btn yv-primary",onclick:v},q("form",16),"Review forms")),w)}function S(k){let h=j("yv-min"),w=c("input",{id:h,class:"yv-input",type:"number",min:10,max:24,value:t.minFontSize||16,style:"width:90px"}),v=c("div",{"aria-live":"polite"}),E=()=>{let x=_t({minFontSize:Number(w.value)||16,maxLineLength:t.maxLineLength||90});v.replaceChildren(ur(x.score,x.summary),c("div",{class:"yv-cats"},...Object.entries(x.categories).map(([$,I])=>c("div",{class:"yv-cat"},c("span",{class:"yv-muted"},$),c("strong",null,String(I.score)),c("span",{class:"yv-muted"},`${I.findings} finding(s)`)))),c("ul",{class:"yv-list"},...x.findings.slice(0,40).map($=>c("li",{class:"yv-item"},c("p",null,cr($.severity)," ",c("b",null,$.category),": ",$.message),c("p",{class:"yv-muted"},$.suggestion),At([$.selector]))))),re(x.summary)};k.append(c("p",{class:"yv-muted"},"Hierarchy, readability, interaction, clutter and consistency. Heuristic, not a visual-design certification."),c("div",{class:"yv-row"},c("label",{for:h},"Minimum text size (px)"),w,c("button",{type:"button",class:"yv-btn yv-primary",onclick:E},q("layout",16),"Review design")),v)}function y(k){let h=j("yv-pq"),w=c("input",{id:h,class:"yv-input",type:"text",placeholder:"What is this page about?",autocomplete:"off"}),v=c("div",{"aria-live":"polite"}),E=null,x=async()=>{let T=w.value.trim()||"What is this page about?",R=await Ht(T,{summarize:t.summarize}),G=[c("div",{class:"yv-answer"},R.answer)];R.suggestions.length&&G.push(c("ul",{class:"yv-steps"},...R.suggestions.map(F=>c("li",null,F))));let N=At(R.targets);if(N&&G.push(N),R.intent==="unknown"){E?E.rebuild():E=Bt({includePage:!0,documents:t.documents});let F=await E.ask(T,{generate:t.generate});G.push(c("h4",{style:"margin:12px 0 4px"},F.generated?"Answer (your model)":"From the page text"),c("div",{class:"yv-answer"},F.answer))}v.replaceChildren(...G),re(R.answer)},$=c("form",{class:"yv-row"},c("label",{for:h,class:"yv-sr"},"Ask about this page"),w,c("button",{type:"submit",class:"yv-btn yv-primary"},"Ask"));$.addEventListener("submit",T=>{T.preventDefault(),x()});let I=["What is this page about?","Which fields have no label?","Which images have no alt text?","Show the page structure","How many links are there?","Tell me about the forms"];k.append(c("p",{class:"yv-muted"},"Answers from this page only, offline. Pass generate() to use your own model."),$,c("div",{class:"yv-chips"},...I.map(T=>c("button",{type:"button",class:"yv-chip",onclick:()=>(w.value=T,x())},T))),v)}let m=null;function C(k){let h=j("yv-lang"),w=c("select",{id:h,class:"yv-input",style:"width:auto"},...na.map(([N,F])=>c("option",{value:N,selected:N===(t.voiceLang||"en-IN")},F))),v=c("button",{type:"button",class:"yv-btn yv-primary","aria-pressed":"false"},q("mic",16),"Start listening"),E=j("yv-cmd"),x=c("input",{id:E,class:"yv-input",type:"text",placeholder:"Type a command, e.g. make text bigger",autocomplete:"off"}),$=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),I=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition),T=()=>{m&&m.stop(),m=Xt({lang:w.value,speak:t.speak!==!1,initial:t.getSettings?t.getSettings():void 0,apply:t.applySettings,onTranscript:(N,F)=>{$.textContent=`Heard: \u201C${N}\u201D
|
|
543
|
+
${F?F.say:"Not a voice command. Try: make text bigger, high contrast on, dark mode, next row, reset."}`,t.onVoiceCommand&&t.onVoiceCommand(N,F)}})};T(),w.addEventListener("change",()=>{let N=v.getAttribute("aria-pressed")==="true";T(),N&&m.start()}),v.addEventListener("click",()=>{if(v.getAttribute("aria-pressed")==="true"){m.stop(),v.setAttribute("aria-pressed","false"),v.lastChild.textContent="Start listening";return}if(!m.start()){$.textContent="Speech recognition is not available in this browser. Typed commands below still work.";return}v.setAttribute("aria-pressed","true"),v.lastChild.textContent="Stop listening",$.textContent="Listening\u2026 say \u201Cmake text bigger\u201D or \u201Cnext row\u201D."});let R=c("form",{class:"yv-row"},c("label",{for:E,class:"yv-sr"},"Type a voice command"),x,c("button",{type:"submit",class:"yv-btn"},"Run"));R.addEventListener("submit",async N=>{N.preventDefault(),x.value.trim()&&await m.handle(x.value)});let G=["make text bigger","make text smaller","high contrast on","dark mode","reduce motion","dyslexia font","next row","previous row","first row","reset","\u0C2A\u0C46\u0C26\u0C4D\u0C26 \u0C05\u0C15\u0C4D\u0C37\u0C30\u0C3E\u0C32\u0C41","\u0C39\u0C48 \u0C15\u0C3E\u0C02\u0C1F\u0C4D\u0C30\u0C3E\u0C38\u0C4D\u0C1F\u0C4D","\u0C24\u0C30\u0C4D\u0C35\u0C3E\u0C24\u0C3F \u0C35\u0C30\u0C41\u0C38"];k.append(c("p",{class:"yv-muted"},I?"Speak accessibility commands in English or Telugu. Text size moves 80\u2013130% in 10% steps.":"Your browser has no speech recognition. You can still type the same commands."),c("div",{class:"yv-row"},c("label",{for:h},"Language"),w,v),R,c("div",{class:"yv-chips"},...G.map(N=>c("button",{type:"button",class:"yv-chip",onclick:()=>(x.value=N,m.handle(N))},N))),$)}let M={copilot:f,qa:b,forms:d,design:S,ask:y,voice:C};return u(t.defaultTab||"qa",!1),{element:a,select:k=>u(k,!1),get tab(){return s},get copilot(){return p},destroy(){p&&p.stop(),m&&m.stop(),a.remove()}}}var dr="yuktai-a11y-prefs",Tt=[.8,.9,1,1.1,1.2,1.3],ra=[["none","None"],["deuteranopia","Deuteranopia (red-green)"],["protanopia","Protanopia (red-green)"],["tritanopia","Tritanopia (blue-yellow)"],["achromatopsia","Achromatopsia (no colour)"]],oa=[["highContrast","High contrast","Stronger text and borders","contrast"],["darkMode","Dark mode","Light text on a dark page","moon"],["reduceMotion","Reduce motion","Stop animations and transitions","motion"],["largeTargets","Large targets","Buttons and links at least 44\xD744","target"],["dyslexiaFont","Dyslexia-friendly font","Easier letters and wider spacing","reading"],["speechEnabled","Speak on focus","Read out each control you Tab to","speaker"],["autoFix","Auto-fix page","Add missing ARIA, labels and alt text; watch new content","wand"],["showSkipLinks","Skip links","\u201CSkip to main content\u201D on Tab","skip"]];function ia(){try{let e=localStorage.getItem(dr);return e?JSON.parse(e):{}}catch{return{}}}function aa(e){try{let t={};["highContrast","darkMode","reduceMotion","largeTargets","speechEnabled","colorBlindMode","dyslexiaFont","fontSizeMultiplier"].forEach(n=>t[n]=e[n]),localStorage.setItem(dr,JSON.stringify(t))}catch{}}function So(e={}){let t={position:"left",title:"Accessibility",showPageTools:!1,...e},n=t.position==="right"?"right":"left",r=rn(t.primaryColor,"#005A9C"),a={enabled:!0,autoFix:!0,showSkipLinks:!0,showPreferencePanel:!1,...at,...t.config||{}},i={...a,...ia()},o,l,s,u,p,f,b,d="";async function S(T,R){i={...i,...T,enabled:!0},aa(i);try{d=await _e.execute({...i}),i.autoFix||_e.stopObserver()}catch(G){console.error("[yuktai] accessibility engine failed",G),d="Some settings could not be applied. See the browser console."}return C(),R||re("Accessibility settings updated"),d}async function y(){try{localStorage.removeItem(dr)}catch{}return i={...a},await S(i,!0),re("Accessibility settings reset"),i}function m(){let T=j("yv-a11y-title"),R=j("yv-font"),G=j("yv-cb"),N=c("section",{class:"yv-dialog",role:"dialog","aria-modal":"false","aria-labelledby":T,"data-yuktai-panel":""}),F=oa.map(([W,Y,Z,St])=>{let Ae=j("yv-opt"),ln=c("input",{id:Ae,type:"checkbox",role:"switch","data-setting":W,"aria-describedby":`${Ae}-d`});return c("div",{class:"yv-option"},c("span",{class:"yv-option-icon"},q(St,18)),c("span",{class:"yv-option-copy"},c("label",{for:Ae},c("b",null,Y)),c("small",{id:`${Ae}-d`},Z)),c("span",{class:"yv-switch"},ln,c("span",{"aria-hidden":"true"})))}),H=c("div",{class:"yv-steps-bar",role:"group","aria-labelledby":R},...Tt.map(W=>c("button",{type:"button",class:"yv-step","data-font":W,"aria-label":`${Math.round(W*100)} percent`,"aria-pressed":"false"}))),pe=c("select",{id:G,class:"yv-input","data-colorblind":""},...ra.map(([W,Y])=>c("option",{value:W},Y)));return N.append(c("header",{class:"yv-dialog-head"},c("div",null,c("div",{class:"yv-muted",style:"font-weight:800;font-size:.75em;letter-spacing:.05em"},"YUKTAI"),c("h2",{id:T},t.title),c("p",{class:"yv-muted",style:"margin:2px 0 0"},"Saved on this device. Works on every page.")),c("button",{type:"button",class:"yv-btn yv-icon","data-close":"","aria-label":"Close accessibility settings",html:de("close")})),c("div",{class:"yv-dialog-body"},...F,c("div",{style:"padding:12px 0;border-bottom:1px solid var(--yv-border)"},c("div",{style:"display:flex;justify-content:space-between"},c("b",{id:R},"Text size"),c("strong",{"data-font-value":""})),c("div",{class:"yv-row",style:"flex-wrap:nowrap;margin-top:6px"},c("button",{type:"button",class:"yv-btn yv-icon","data-font-step":"-1","aria-label":"Smaller text",html:de("minus",16)}),H,c("button",{type:"button",class:"yv-btn yv-icon","data-font-step":"1","aria-label":"Bigger text",html:de("plus",16)}))),c("div",{style:"padding:12px 0"},c("label",{for:G},c("b",null,"Colour-blind filter")),pe),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn","data-reset":""},q("reset",16),"Reset all"),c("button",{type:"button",class:"yv-btn yv-primary","data-close":""},q("check",16),"Done")),c("p",{class:"yv-status",role:"status","aria-live":"polite","data-status":""}))),N.addEventListener("change",W=>{let Y=W.target;Y.matches("[data-setting]")?S({[Y.getAttribute("data-setting")]:Y.checked}):Y.matches("[data-colorblind]")&&S({colorBlindMode:Y.value})}),N.addEventListener("click",W=>{let Y=W.target.closest("button");if(Y){if(Y.hasAttribute("data-close"))return w();if(Y.hasAttribute("data-reset"))return y();if(Y.hasAttribute("data-font"))return M(Number(Y.getAttribute("data-font")));if(Y.hasAttribute("data-font-step")){let Z=Tt.indexOf(Number(i.fontSizeMultiplier||1));return M(Tt[Math.min(Tt.length-1,Math.max(0,(Z<0?2:Z)+Number(Y.getAttribute("data-font-step"))))])}}}),N.addEventListener("keydown",W=>k(W,N,w)),N}function C(){if(!u)return;u.querySelectorAll("[data-setting]").forEach(N=>N.checked=!!i[N.getAttribute("data-setting")]&&i[N.getAttribute("data-setting")]!==!1);let T=u.querySelector('[data-setting="showSkipLinks"]');T&&(T.checked=i.showSkipLinks!==!1);let R=Number(i.fontSizeMultiplier||1);u.querySelector("[data-font-value]").textContent=`${Math.round(R*100)}%`,u.querySelectorAll("[data-font]").forEach(N=>N.setAttribute("aria-pressed",String(Math.abs(Number(N.getAttribute("data-font"))-R)<.001))),u.querySelector("[data-colorblind]").value=i.colorBlindMode||"none";let G=/(\d+) fixes applied/.exec(d);u.querySelector("[data-status]").textContent=G?`${G[1]} automatic accessibility fix(es) applied on this page.`:d}function M(T){Tt.some(R=>Math.abs(R-T)<.001)&&(S({fontSizeMultiplier:T},!0),re(`Text size ${Math.round(T*100)} percent`))}function k(T,R,G){if(T.key==="Escape"){T.preventDefault(),T.stopPropagation(),G();return}if(T.key!=="Tab")return;let N=Array.from(R.querySelectorAll("button,input,select,textarea,[tabindex]:not([tabindex='-1'])")).filter(F=>!F.disabled&&F.offsetParent!==null);N.length&&(T.shiftKey&&document.activeElement===N[0]?(T.preventDefault(),N[N.length-1].focus()):!T.shiftKey&&document.activeElement===N[N.length-1]&&(T.preventDefault(),N[0].focus()))}function h(){l||I(),!u&&(x(),b=document.activeElement,u=m(),$().appendChild(u),l.setAttribute("aria-expanded","true"),C(),u.querySelector("[data-close]").focus(),document.addEventListener("pointerdown",v,!0))}function w(){u&&(u.remove(),u=null,l.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",v,!0),(b&&document.contains(b)?b:l).focus())}function v(T){u&&!u.contains(T.target)&&!o.contains(T.target)&&w(),p&&!p.contains(T.target)&&!o.contains(T.target)&&x()}function E(T){if(l||I(),p){T&&f&&f.select(T);return}w(),b=document.activeElement;let R=j("yv-tools-title");p=c("section",{class:"yv-dialog yv-wide",role:"dialog","aria-modal":"false","aria-labelledby":R,"data-yuktai-panel":""});let G=c("div",{class:"yv-dialog-body"});p.append(c("header",{class:"yv-dialog-head"},c("h2",{id:R},t.toolsTitle||"Page tools"),c("button",{type:"button",class:"yv-btn yv-icon","aria-label":"Close page tools",html:de("close"),onclick:()=>x()})),G),$().appendChild(p),f=sn(G,{defaultTab:T||t.defaultTab||"qa",voiceLang:t.voiceLang,generate:t.generate,summarize:t.summarize,defaultLang:t.defaultLang,getSettings:()=>({...i}),applySettings:N=>S(N,!0)}),s&&s.setAttribute("aria-expanded","true"),p.addEventListener("keydown",N=>k(N,p,x)),p.querySelector("[role=tab][aria-selected=true]").focus(),document.addEventListener("pointerdown",v,!0)}function x(){p&&(f&&f.destroy(),f=null,p.remove(),p=null,s&&s.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",v,!0),(b&&document.contains(b)?b:s||l).focus())}let $=()=>document.documentElement||document.body;function I(){!Pe()||l||!document.body||(on(r,n),o=c("div",{class:"yv-fabs","data-yuktai-fabs":""}),l=c("button",{type:"button",class:"yv-fab","aria-label":"Accessibility settings",title:"Accessibility settings","aria-haspopup":"dialog","aria-expanded":"false",html:de("accessibility",26)}),l.addEventListener("click",()=>u?w():h()),o.append(l),t.showPageTools&&(s=c("button",{type:"button",class:"yv-fab yv-fab-alt","aria-label":"Page tools: QA, forms, design, ask, voice",title:"Page tools","aria-haspopup":"dialog","aria-expanded":"false",html:de("tools",24)}),s.addEventListener("click",()=>p?x():E()),o.prepend(s)),$().appendChild(o),t.applyOnLoad!==!1&&S({},!0))}return{init:I,open:h,close:w,openTools:E,closeTools:x,apply:T=>S(T||{}),reset:y,getSettings:()=>({...i}),destroy(){w(),x(),o&&o.remove(),l=s=o=null}}}var Co="5.3.0";(function(){if(!Pe()||window.yuktai&&window.yuktai.__vanillaInitialized)return;let t=window.YUKTAI_CONFIG||{},n=rn(t.primaryColor,"#005A9C"),r=t.position==="right"?"right":"left",a=So(t),i=()=>on(n,r),o=s=>(...u)=>(i(),s(...u)),l={__vanillaInitialized:!0,version:Co,init:()=>a.init(),open:()=>a.open(),close:()=>a.close(),openTools:s=>a.openTools(s),closeTools:()=>a.closeTools(),apply:s=>a.apply(s),reset:()=>a.reset(),getSettings:()=>a.getSettings(),renderGrid:o(Ao),mountAgenticGridBar:o(an),mountAgenticPanel:o(sn),mountGridAssistant:o(lr),createAgenticGrid:tn,createGridAgent:Zt,parseGridIntent:nr,registerWebMCP:en,icon:de,iconNames:yo.slice(),iconContrast:xt,pickGlyphColor:or,...er,runPageQA:()=>be().summary,getCapabilities:()=>({version:Co,inlineSVG:!0,grid:!0,gridAssistant:!0,agenticGrid:!0,ruleBasedBI:!0,taskRunner:!0,anomalyChecks:!0,pageQA:!0,a11yCopilot:!0,formsReview:!0,designReview:!0,pageQandA:!0,localPageSearch:!0,voiceCommands:!0,voice:!!(window.SpeechRecognition||window.webkitSpeechRecognition),speech:"speechSynthesis"in window,webMCP:!!(document.modelContext&&typeof document.modelContext.registerTool=="function"),modelConnected:!1})};window.yuktai=l,t.autoInit!==!1&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>a.init(),{once:!0}):a.init())})();})();
|