@yuktishaalaa/yuktai 5.3.2 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/dist/chunk-7BGINZ5U.mjs +1 -0
- package/dist/icons.d.mts +268 -1
- package/dist/icons.d.ts +268 -1
- package/dist/icons.js +1 -1
- package/dist/icons.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +52 -52
- package/dist/index.mjs +24 -24
- package/package.json +1 -1
- package/vanilla/index.js +94 -3
- package/vanilla/index.min.js +22 -22
- package/dist/chunk-LV252EOY.mjs +0 -1
package/vanilla/index.min.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
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 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=
|
|
4
|
+
"use strict";(()=>{var Go=Object.defineProperty;var zo=(e,t)=>{for(var n in t)Go(e,n,{get:t[n],enumerable:!0})};var er={};zo(er,{AUDIT_RULES:()=>tt,DEFAULT_A11Y_SETTINGS:()=>at,FONT_MAX:()=>Jn,FONT_MIN:()=>Yn,FONT_STEP:()=>Jt,accessibleName:()=>fe,aggregate:()=>Be,analyzePage:()=>Gn,answerGridQuestion:()=>Nt,applyGridFilters:()=>$e,askAboutPage:()=>qt,askInsight:()=>Pt,auditToJSON:()=>Dt,auditToMarkdown:()=>xt,clearFilters:()=>wn,clearSort:()=>An,comparePeriods:()=>Ln,contrastRatio:()=>et,countGrid:()=>yn,createA11yCopilot:()=>Ht,createContextIndex:()=>Bt,createGridTools:()=>Ze,createVoiceA11yController:()=>Xt,detectAnomalies:()=>He,detectPageIntent:()=>zn,executeGridQuery:()=>Re,filterGrid:()=>xn,findMentionedColumn:()=>ge,getColumns:()=>bn,getRow:()=>vn,getRowId:()=>ee,gridPassages:()=>Dn,groupBy:()=>En,highlightRows:()=>Xe,moveGridRowFocus:()=>Zn,openRow:()=>ft,pagePassages:()=>On,parseAmount:()=>yt,parseColor:()=>Ne,parseGridQuery:()=>Ie,parseVoiceA11yCommand:()=>Xn,planTasks:()=>bt,readFormFields:()=>Fn,relativeLuminance:()=>zt,reviewDesign:()=>Vt,reviewForm:()=>Pn,reviewForms:()=>nt,runGridQuery:()=>Cn,runQaAudit:()=>ye,runTasks:()=>Gt,searchGrid:()=>fn,selectRow:()=>mt,sortGrid:()=>kn,summarizeRows:()=>qe,toGridToolColumns:()=>Le,tokenize:()=>rt,trend:()=>In,wcagPlugin:()=>_e});var Oo={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 me(e){return Oo[e.locale??"en"]}function we(e,t){return{success:!0,message:e,data:t}}function Q(e,t){return{success:!1,message:t,error:{code:e}}}var wr=["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 Sr(e){return(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>String(n).trim()).filter(Boolean)}function mn(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 Do(e,t){return e[t]}function Ho(e,t,n){let r=Do(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,m]=t.value,y=l(p),u=l(m);return y!==null&&u!==null&&s>=Math.min(y,u)&&s<=Math.max(y,u)}let d=l(t.value);if(d===null)return!1;switch(t.operator){case"equals":return s===d;case"greaterThan":return s>d;case"lessThan":return s<d;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 qo(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 $e(e,t,n){return n.length?Tr({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 Tr(e,t){return e.data.filter(n=>t.every(r=>{let a=mn(e,r.key);return a?Ho(n,r,a):!0}))}function fn(e,t){var o;let n=me(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),we(n.found(a.length),a)}function yn(e){return we(me(e).count(e.data.length),e.data.length)}function bn(e){return we(me(e).columns,e.columns)}function vn(e,t){let n=me(e),r=String(t??"").trim();if(!r)return Q("INVALID_INPUT",n.noIds);let a=Lt(e,r);return a?we(n.rowFound,a):Q("NOT_FOUND",n.notFound(r))}function Xe(e,t){let n=me(e),r=Sr(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),we(n.highlighted(a.length),a))}function mt(e,t){let n=me(e),r=String(t??"").trim();return r?e.onSelectRow?Lt(e,r)?(e.onSelectRow(r),we(n.selected(r),r)):Q("NOT_FOUND",n.notFound(r)):Q("NOT_SUPPORTED",n.notSupported("select")):Q("INVALID_INPUT",n.noIds)}function ft(e,t){let n=me(e),r=String(t??"").trim();return r?e.onOpenRow?Lt(e,r)?(e.onOpenRow(r),we(n.opened(r),r)):Q("NOT_FOUND",n.notFound(r)):Q("NOT_SUPPORTED",n.notSupported("open")):Q("INVALID_INPUT",n.noIds)}function xn(e,t){let n=me(e),r=mn(e,(t==null?void 0:t.key)??"");if(!r)return Q("INVALID_INPUT",n.unknownColumn(String((t==null?void 0:t.key)??"")));if(!wr.includes(t.operator))return Q("INVALID_INPUT",n.badOperator(String(t.operator)));let a={...t,key:r.key};if(!qo(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=Tr(e,i).length;return e.onFiltersChange(i),we(n.filtered(o),{filters:i,count:o})}function wn(e){let t=me(e);return e.onFiltersChange?(e.onFiltersChange([]),we(t.filtersCleared,[])):Q("NOT_SUPPORTED",t.notSupported("clear filters"))}function kn(e,t,n="asc"){let r=me(e),a=mn(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),we(r.sorted(a.label,n),i)}function An(e){let t=me(e);return e.onSortChange?(e.onSortChange(null),we(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."},xr={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 Vo(e,t){try{return t()}catch{return Q("INTERNAL",me(e).internal)}}function Ze(e,t={}){let n=t.name??"yuktai_grid",r=xr[e.locale??"en"],a=s=>{var d;return((d=t.descriptions)==null?void 0:d[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=>fn(e,String(s.query??""))},{id:"count",available:!0,schema:{type:"object",properties:{}},run:()=>yn(e)},{id:"columns",available:!0,schema:{type:"object",properties:{}},run:()=>bn(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,Sr(s.ids))},{id:"select",available:!!e.onSelectRow,schema:{type:"object",properties:i,required:["id"]},run:s=>mt(e,String(s.id??""))},{id:"open",available:!!e.onOpenRow,schema:{type:"object",properties:i,required:["id"]},run:s=>ft(e,String(s.id??""))},{id:"filter",available:!!e.onFiltersChange,schema:{type:"object",properties:{key:{type:"string",enum:o},operator:{type:"string",enum:wr},value:{description:"Text or number; for 'between' an array of two numbers or dates"}},required:["key","operator","value"]},run:s=>xn(e,{key:String(s.key??""),operator:String(s.operator??""),value:s.value})},{id:"clear_filters",available:!!e.onFiltersChange,schema:{type:"object",properties:{}},run:()=>wn(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:xr.en[s.id],description:a(s.id),label:r[s.id],inputSchema:s.schema,execute:d=>Vo(e,()=>s.run(d??{}))}))}var Te=e=>String(e??"").normalize("NFC").toLowerCase().replace(/\s+/g," ").trim(),_o=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 yt(e){let t=Te(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 $r(e){let t=new Set([Te(e.label),Te(e.key),Te(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=` ${Te(e)} `,a;for(let i of t)if(!(n&&(i.type??"text")!==n))for(let o of $r(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 jo=/amount|balance|total|price|salary|value|due|revenue|cost|fee|sales|outstanding|paid/i;function Sn(e){let t=e.filter(n=>n.type==="number");return t.find(n=>jo.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|కంటే ఎక్కువ)/,Tn=/(<=|=<|<|\bunder\b|\bbelow\b|\bless than\b|\blower than\b|\bat most\b|\bmaximum\b|\bmax\b|\bup to\b|కంటే తక్కువ)/,Mr=/\b(after|since|from)\b/,Wo=/\b(before|until|till)\b/,Uo="(?:\\s*(?:k|thousand|lakhs?|lacs?|crores?|cr|mn|million|m|bn|billion))?",Mn=`(?:\u20B9|rs\\.?\\s*|\\$)?\\s*-?\\d[\\d,]*(?:\\.\\d+)?${Uo}`;function Ie(e,t,n={}){var T;let r={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""},a=Te(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 b=ge(l[1],t);b&&(r.sort={key:b.key,direction:/^desc/.test(l[2]??"")?"desc":"asc"},a=a.replace(l[0]," "))}else if(s){let b=ge(s[2],t,"number")??ge(s[2],t)??Sn(t);if(b){let h=/top|highest|largest|biggest|most/.test(s[1]);r.sort={key:b.key,direction:h?"desc":"asc"},a=a.replace(new RegExp(`\\b${s[1]}\\b`)," "),!o&&/top|bottom/.test(s[1])&&(r.limit=10)}}let d=new RegExp(`\\bbetween\\s+(${Mn}|\\d{4}-\\d{2}-\\d{2})\\s+(?:and|to|-)\\s+(${Mn}|\\d{4}-\\d{2}-\\d{2})`,"u"),p;for(;p=a.match(d);){let b=a.slice(Math.max(0,(p.index??0)-40),p.index??0),h=/\d{4}-\d{2}-\d{2}/.test(p[1]),M=h?ge(b,t,"date")??t.find(f=>f.type==="date"):ge(b,t,"number")??Sn(t),R=h?p[1]:yt(p[1]),k=h?p[2]:yt(p[2]);M&&R!==null&&k!==null&&(r.filters.push({key:M.key,operator:"between",value:[R,k]}),i.push(`${M.label} between ${p[1]} and ${p[2]}`)),a=a.replace(p[0]," ")}let m=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(b=>b.trim()).filter(Boolean),y=t.filter(b=>(b.type??"text")==="text"),u=new Map;for(let b of y){let h=new Set;for(let M of(n.data??[]).slice(0,5e3)){let R=Te(M[b.key]);if(R&&R.length<=40&&h.add(R),h.size>300)break}h.size&&h.size<=300&&u.set(b.key,h)}for(let b of m){let h=r.filters.length,M=ge(b,t),R=b.match(new RegExp(Mn,"u")),k=b.match(/\d{4}-\d{2}-\d{2}/);if(k&&(Mr.test(b)||Wo.test(b)||It.test(b)||Tn.test(b))){let f=((M==null?void 0:M.type)==="date"?M:void 0)??t.find(x=>x.type==="date");if(f){let x=Mr.test(b)||It.test(b);r.filters.push({key:f.key,operator:x?"greaterThan":"lessThan",value:k[0]}),i.push(`${f.label} ${x?"after":"before"} ${k[0]}`)}}else if(R&&(It.test(b)||Tn.test(b)||(M==null?void 0:M.type)==="number"&&/\b(is|equals?)\b|=/.test(b))){let f=(M==null?void 0:M.type)==="number"?M:void 0;f||(f=Sn(t),f&&r.notes.push(`Assumed "${b}" refers to ${f.label}.`));let x=yt(R[0]);if(f&&x!==null){let v=/at least|minimum|\bmin\b|>=|=>|at most|maximum|\bmax\b|up to|<=|=</.test(b);It.test(b)?(r.filters.push({key:f.key,operator:"greaterThan",value:v?x-1e-9:x}),i.push(`${f.label} ${v?"\u2265":">"} ${x.toLocaleString("en-IN")}`)):Tn.test(b)?(r.filters.push({key:f.key,operator:"lessThan",value:v?x+1e-9:x}),i.push(`${f.label} ${v?"\u2264":"<"} ${x.toLocaleString("en-IN")}`)):(r.filters.push({key:f.key,operator:"equals",value:x}),i.push(`${f.label} = ${x.toLocaleString("en-IN")}`))}}else{let f=b.match(/\b(?:starts?|starting|begins?|beginning)\s+with\s+(.+)$/),x=b.match(/\b(?:ends?|ending)\s+with\s+(.+)$/),v=b.match(/\b(?:contains?|containing|including|includes?|mentions?)\s+(.+)$/),E=b.match(/\b(?:is|equals?|=|:)\s+(.+)$/),w=f??x??v??E;if(w){let C=M??y[0],I=w[1].replace(/^["'“‘]|["'”’]$/g,"").trim();if(C&&I){let S=f?"startsWith":x?"endsWith":v?"contains":"equals";r.filters.push({key:C.key,operator:S,value:I}),i.push(`${C.label} ${S==="equals"?"is":S==="contains"?"contains":S==="startsWith"?"starts with":"ends with"} "${I}"`),M||r.notes.push(`Assumed "${b}" refers to ${C.label}.`)}}}if(r.filters.length===h)for(let[f,x]of u){let v="";for(let E of x){if(E.length<2||E.length<=v.length)continue;let w=E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(^|[^\\p{L}\\p{M}\\p{N}])${w}($|[^\\p{L}\\p{M}\\p{N}])`,"u").test(b)&&(v=E)}if(v){let E=t.find(w=>w.key===f);r.filters.push({key:f,operator:"equals",value:v}),i.push(`${E.label} is "${v}"`)}}if(r.filters.length===h){let f=b.split(/\s+/).filter(v=>!_o.has(v)&&!/^(top|first|bottom|last|lowest|highest|by|desc|asc|sort(ed)?)$/.test(v)),x=f.length>0&&f.every(v=>t.some(E=>$r(E).includes(v)));if(f.length&&!x&&!(M&&f.length===1)){let v=f.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 b=((T=t.find(h=>h.key===r.sort.key))==null?void 0:T.label)??r.sort.key;i.push(`sorted by ${b} ${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 Re(e,t,n){let r=$e(e,t,n.filters);for(let a of n.search)r=r.filter(i=>t.some(o=>Te(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 Cn(e,t,n={}){var l,s,d;let r=Ie(e,t.columns,{data:t.data}),a=Re(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&&((d=t.onHighlightRows)==null||d.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 Cr(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 He(e,t,n={}){let r=n.factor??1.5,a=[],i=t.filter(d=>d.type==="number"&&(!n.columns||n.columns.includes(d.key))),o=d=>d.toLocaleString("en-IN",{maximumFractionDigits:2});for(let d of i){let p=e.map(M=>Number(M[d.key])).filter(M=>Number.isFinite(M));if(p.length<5)continue;let m=[...p].sort((M,R)=>M-R),y=Cr(m,.25),u=Cr(m,.75),T=u-y;if(T===0)continue;let b=y-r*T,h=u+r*T;for(let M of e){let R=Number(M[d.key]);!Number.isFinite(R)||R>=b&&R<=h||a.push({rowId:ee(M,n.rowKey),column:d.key,label:d.label,value:R,kind:R>h?"high":"low",reason:`${d.label} ${o(R)} is far ${R>h?"above":"below"} the typical range (${o(y)}\u2013${o(u)}).`})}}let l=n.rowKey??"id",s=new Map;for(let d of e){let p=JSON.stringify(t.filter(u=>u.key!==l).map(u=>Te(d[u.key]))),m=ee(d,n.rowKey),y=s.get(p);y!==void 0?a.push({rowId:m,column:l,label:"Row",value:m,kind:"duplicate",reason:`Row ${m} has the same values as row ${y}.`}):s.set(p,m)}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,d)=>s+d,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 d=String(s??"").trim();d&&o.set(d,(o.get(d)??0)+1)}if(o.size===0||o.size>Math.max(8,e.length/3))continue;let l=Array.from(o.entries()).sort((s,d)=>d[1]-s[1]).slice(0,4);n.push(`${a.label}: ${l.map(([s,d])=>`${s} (${d})`).join(", ")}.`)}}return n.join(`
|
|
5
|
+
`)}function Nt(e,t){var a;let n=Te(e);if(/unusual|anomal|outlier|odd|strange|suspicious|duplicate|అసాధారణ/.test(n)){let i=He(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: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
|
|
10
|
-
`):`No issue "${
|
|
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=$e(t.data,t.columns,t.filters??[]);return{kind:"summary",message:qe(i,t.columns),ids:[],rows:i}}let r=Cn(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},Rr=e=>{let t=e instanceof Date?e.getTime():new Date(String(e??"")).getTime();return Number.isFinite(t)?t:null};function Be(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:Be(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 Rn(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?Rn(r,t.period,1):new Date(Math.max(n.getTime()+1,r.getTime()+1)),i=Rn(r,t.period,-1),o=t.toDate===!1?r:new Date(i.getTime()+(a.getTime()-r.getTime())),l=t.agg??"sum",s=new Map,d=new Map;for(let y of e){let u=Rr(y[t.dateKey]);if(u===null)continue;let T=u>=r.getTime()&&u<a.getTime()?s:u>=i.getTime()&&u<o.getTime()?d:null;if(!T)continue;let b=t.groupKey?String(y[t.groupKey]??"\u2014"):"All",h=l==="count"?1:Ft(y[t.metricKey]);h!==null&&T.set(b,[...T.get(b)??[],h])}let p=new Set([...s.keys(),...d.keys()]),m=Array.from(p).map(y=>{let u=Be(s.get(y)??[],l),T=Be(d.get(y)??[],l);return{group:y,current:u,previous:T,change:u-T,changePct:T===0?null:(u-T)/Math.abs(T)*100}});return{period:t.period,current:{from:r,to:a},previous:{from:i,to:o},rows:m}}function In(e,t,n,r,a="sum"){let i=new Map;for(let o of e){let l=Rr(o[t]),s=a==="count"?1:Ft(o[n]);if(l===null||s===null)continue;let d=Er(new Date(l),r).getTime();i.set(d,[...i.get(d)??[],s])}return Array.from(i.entries()).sort((o,l)=>o[0]-l[0]).map(([o,l])=>({start:new Date(o),value:Be(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}),$n=e=>e===null?"new":`${e>0?"+":""}${e.toFixed(1)}%`;function Pt(e,t,n,r={}){var k;let a=e.toLowerCase(),i=n.filter(f=>f.type==="number"),o=ge(a,n,"number")??i.find(f=>/amount|revenue|sales|total|value/i.test(`${f.key} ${f.label}`))??i[0],l=n.find(f=>f.type==="date")??n.find(f=>/date|time|day|created|month/i.test(`${f.key} ${f.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])??"",d=ge(s,n,"text"),p=/how many|number of|count/.test(a),m=p?"count":/average|avg|mean/.test(a)?"avg":/\btotal\b|\bsum\b/.test(a)?"sum":o&&Qo.test(`${o.key} ${o.label}`)?"avg":"sum",y=/drop|decline|decrease|fell|fall|down|worst|lost|shrink|reduc/.test(a),u=/increase|growth|grew|rise|rose|up\b|best|improv|gain/.test(a),T=/lowest|least|smallest|bottom|worst|minimum/.test(a),b=Yo(a);if(!o&&!p)return{kind:"unknown",answer:"I couldn't find a numeric column to analyse.",table:[]};let h=p?"rows":o.label;if(b&&l&&(u||y||/change|compare|vs|versus/.test(a))){let f=r.referenceDate?new Date(r.referenceDate):new Date,x=b.shift?Rn(f,b.period,b.shift):f,E=[...Ln(t,{dateKey:l.key,metricKey:(o==null?void 0:o.key)??l.key,groupKey:d==null?void 0:d.key,agg:m,period:b.period,referenceDate:x,toDate:b.shift===0}).rows].sort((F,q)=>y?F.change-q.change:q.change-F.change),w=E.map(F=>({[(d==null?void 0:d.label)??"Group"]:F.group,Current:ae(F.current),Previous:ae(F.previous),Change:ae(F.change),"Change %":$n(F.changePct)}));if(!E.length)return{kind:"period-change",answer:`No ${h} data in this ${b.period} or the one before.`,table:w};let C=E[0],I=`${b.shift?"last":"this"} ${b.period} vs the ${b.period} before`,S=C.change===0?"did not change":C.change<0?`dropped ${ae(Math.abs(C.change))}`:`rose ${ae(C.change)}`,$=`${h} ${S} (${ae(C.previous)} \u2192 ${ae(C.current)}, ${$n(C.changePct)}) \u2014 ${I}.`,G=y&&C.change>=0||u&&C.change<=0;return{kind:"period-change",answer:d?G?`No ${d.label.toLowerCase()} ${y?"dropped":"grew"}. Closest is ${C.group}: ${$}`:`${C.group}: ${$}`:$,table:w}}if(/trend|over time|month by month|week by week/.test(a)&&l&&o){let f=/week/.test(a)?"week":/day|daily/.test(a)?"day":/year/.test(a)?"year":"month",x=In(t,l.key,o.key,f,m),v=x.map(I=>({Period:I.start.toISOString().slice(0,10),[o.label]:ae(I.value)}));if(x.length<2)return{kind:"trend",answer:`Not enough ${f}s of data for a trend.`,table:v};let E=x[0].value,w=x[x.length-1].value,C=x.reduce((I,S)=>S.value>I.value?S:I);return{kind:"trend",answer:`${o.label} went from ${ae(E)} to ${ae(w)} over ${x.length} ${f}s (${$n(E?(w-E)/Math.abs(E)*100:null)}). Peak: ${ae(C.value)} in the ${f} of ${C.start.toISOString().slice(0,10)}.`,table:v}}if(d){let f=En(t,d.key,(o==null?void 0:o.key)??null,m),x=T?[...f].reverse():f,v=x.map(w=>({[d.label]:w.group,[`${m} of ${h}`]:ae(w.value),Rows:w.count}));if(!x.length)return{kind:"group",answer:"No data.",table:v};let E=x[0];return{kind:"group",answer:`${E.group} has the ${T?"lowest":"highest"} ${m==="sum"?"total":m==="avg"?"average":m} ${h}: ${ae(E.value)} (across ${x.length} ${d.label.toLowerCase()} groups).`,table:v}}let M=p?t.map(()=>1):t.map(f=>Ft(f[o.key])).filter(f=>f!==null),R=Be(M,m);return{kind:"total",answer:`${m==="avg"?"Average":m==="count"?"Count of":m==="sum"?"Total":m} ${h}: ${ae(R)} across ${t.length} row(s).`,table:[{Metric:h,Aggregation:m,Value:ae(R)}]}}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 bt(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 b,h,M,R,k,f,x,v,E;let r=bt(e),{columns:a,data:i}=t,o=[...t.filters??[]],l=[],s=null,d=[],p=()=>Re(i,a,{filters:o,search:l,sort:s,limit:null,notes:[],explanation:""}),m={rows:p().length,filters:[...o]},y=[],u=()=>({...t,filters:o});for(let w=0;w<r.length;w++){let C=r[w],I=Xo(C.text),S;try{switch(C.action){case"clear":{o=[],l=[],s=null,d=[],(b=t.onFiltersChange)==null||b.call(t,[]),(h=t.onSortChange)==null||h.call(t,null),(M=t.onHighlightRows)==null||M.call(t,[]),S={...C,success:!0,message:`Cleared filters, sorting and highlights. ${i.length} row(s) shown.`};break}case"filter":{let $=Ie(I,a,{data:i});if(!$.filters.length&&!$.search.length&&!$.sort){S={...C,success:!0,message:`Showing ${p().length} row(s) with the current filters.`};break}for(let F of $.filters)o=[...o.filter(q=>q.key!==F.key),F];l=[...l,...$.search],$.sort&&(s=$.sort,(R=t.onSortChange)==null||R.call(t,s)),(k=t.onFiltersChange)==null||k.call(t,o);let G=p(),N=G.map(F=>ee(F,t.rowKey)).filter(Boolean);$.search.length&&N.length&&(d=N,(f=t.onHighlightRows)==null||f.call(t,N)),S={...C,success:!0,message:`${G.length} row(s) now shown. ${$.explanation}`,ids:N};break}case"highlight":{let $=p(),G=Ie(I,a,{data:$}),F=(G.filters.length||G.search.length?Re($,a,{...G,sort:null,limit:G.limit}):$).map(pe=>ee(pe,t.rowKey)).filter(Boolean);if(!F.length){S={...C,success:!1,message:`Nothing to highlight for "${I||"all rows"}".`};break}let q=Xe(u(),F);q.success&&(d=q.data??F),S={...C,success:q.success,message:q.success?`Highlighted ${d.length} row(s)${I?` matching "${I}"`:""}.`:q.message,ids:d};break}case"sort":{let G=Ie(C.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(C.text)?"desc":"asc"})}if(!G){S={...C,success:!1,message:`Which column should I sort by? Columns: ${a.map(F=>F.label).join(", ")}.`};break}s=G,(x=t.onSortChange)==null||x.call(t,s);let N=((v=a.find(F=>F.key===s.key))==null?void 0:v.label)??s.key;S={...C,success:!0,message:`Sorted by ${N} (${s.direction==="desc"?"high \u2192 low":"low \u2192 high"}).`};break}case"count":{S={...C,success:!0,message:`${p().length} row(s) shown${d.length?`, ${d.length} highlighted`:""}.`};break}case"anomalies":{let $=p(),G=He($,a,{rowKey:t.rowKey}),N=Array.from(new Set(G.map(F=>F.rowId)));if(N.length){let F=Xe(u(),N);F.success&&(d=F.data??N)}S={...C,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 $=p(),N=$.find(pe=>I&&ee(pe,t.rowKey).toLowerCase()===I.toLowerCase())??Re($,a,Ie(I,a,{data:$}))[0]??(I?void 0:$[0]);if(!N){S={...C,success:!1,message:`No row matches "${I}".`};break}let F=ee(N,t.rowKey),q=C.action==="open"?ft(u(),F):mt(u(),F);S={...C,success:q.success,message:q.message,ids:[F]};break}case"summarize":{let $=p();S={...C,success:!0,message:`${Ir(m,$.length,o,s,d,a)}
|
|
8
|
+
${qe($,a)}`};break}}}catch($){S={...C,success:!1,message:`This step failed: ${$ instanceof Error?$.message:String($)}`}}y.push(S),(E=n.onStep)==null||E.call(n,S,w,r.length)}let T=p().length;return{steps:y,before:m,after:{rows:T,filters:o,sort:s,highlighted:d},summary:Ir(m,T,o,s,d,a)}}function Ir(e,t,n,r,a,i){var d;let o=[`Rows: ${e.rows} \u2192 ${t}.`],l=n.filter(p=>!e.filters.some(m=>JSON.stringify(m)===JSON.stringify(p))),s=e.filters.filter(p=>!n.some(m=>JSON.stringify(p)===JSON.stringify(m)));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 ${((d=i.find(p=>p.key===r.key))==null?void 0:d.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 Ve(e){return typeof e=="object"&&e!==null&&e.nodeType===9}function he(e){return e||(ke()?document:null)}function D(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 Me(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 fe(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)}"]`),d=te(s==null?void 0:s.textContent);if(d)return d}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],d=s===void 0?1:s.endsWith("%")?Number(s.slice(0,-1))/100:Number(s);return[i,o,l,d].some(p=>!Number.isFinite(p))?null:{r:i,g:o,b:l,a:d}}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 zt(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=zt(r),i=zt(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']",Ot="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 ye(e={}){let t=he(e.root),n=new Set(e.skip??[]),r=[],a={},i=t?Ve(t)?t:t.ownerDocument:null,o=(l,s,d,p,m=!1)=>{if(n.has(l))return;let y=tt[l],u=a[l]=(a[l]??0)+1;r.push({id:`${l}-${u}`,rule:l,severity:y.severity,wcag:y.wcag,message:d,why:y.why,fix:p,selector:s?Me(s):"document",snippet:s?ne(s.outerHTML,120):"",autoFixable:m,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 h of D(t,"img"))if(!(h.getAttribute("role")==="presentation"||h.getAttribute("role")==="none")&&!h.hasAttribute("alt")&&!h.getAttribute("aria-label")&&!h.getAttribute("aria-labelledby")){let M=h.getAttribute("title");o("image-alt",h,`Image has no alt text${h.getAttribute("src")?` (${ne(h.getAttribute("src")??"",40)})`:""}.`,M?`Use the title as alt: alt="${ne(M,40)}".`:'Describe the image in alt, or use alt="" if it is purely decorative.',!!M)}let l=D(t,"h1,h2,h3,h4,h5,h6"),s=0;for(let h of l){let M=Number(h.tagName[1]);s>0&&M>s+1&&o("heading-order",h,`Heading jumps from h${s} to h${M}: "${ne(h.textContent??"",40)}".`,`Change it to h${s+1}, or add the missing level above it.`),s=M}let d=l.filter(h=>h.tagName==="H1");d.length===0?o("single-h1",null,"The page has no h1.","Add one h1 that names the page."):d.length>1&&o("single-h1",d[1],`The page has ${d.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=D(t,"input,select,textarea").filter(h=>{let M=(h.getAttribute("type")??"text").toLowerCase();return!["hidden","submit","button","reset","image"].includes(M)});for(let h of p){if(!fe(h)){let M=h.getAttribute("placeholder")||h.getAttribute("name");o("form-label",h,`Form field has no label${M?` (placeholder/name: "${ne(M,30)}")`:""}.`,M?`Add a visible <label>. Quick fix: aria-label="${ne(M,30)}".`:"Add a visible <label for=\u2026> describing what to enter.",!!M)}h.getAttribute("aria-invalid")==="true"&&(h.getAttribute("aria-describedby")||h.getAttribute("aria-errormessage")||o("form-error",h,"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 h of D(t,"button,[role='button'],input[type='submit'],input[type='button']"))if(!fe(h)){let M=h.getAttribute("title");o("button-name",h,"Button has no accessible name.",M?`Use the title as the name: aria-label="${M}".`:"Add visible text or an aria-label that says what the button does.",!!M)}for(let h of D(t,"a[href]"))if(!fe(h)){let M=h.getAttribute("title");o("link-name",h,`Link has no text (${ne(h.getAttribute("href")??"",40)}).`,M?`Use the title as the name: aria-label="${M}".`:"Add link text that says where it goes.",!!M)}for(let h of D(t,"[tabindex]"))Number(h.getAttribute("tabindex"))>0&&o("positive-tabindex",h,`tabindex="${h.getAttribute("tabindex")}" overrides the natural tab order.`,'Use tabindex="0" and fix the order in the HTML instead.',!0);let m="a[href],button,input,select,textarea,summary";for(let h of D(t,"[onclick],[role='button'],[role='link']"))h.matches(m)||h.hasAttribute("tabindex")||o("keyboard-access",h,`<${h.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 y=new Map;for(let h of Array.from(t.querySelectorAll("[id]")))h.closest("[data-yuktai-panel]")||y.set(h.id,(y.get(h.id)??0)+1);for(let[h,M]of y)M>1&&o("duplicate-id",t.querySelector(`[id="${h.replace(/"/g,'\\"')}"]`),`id="${h}" is used ${M} times.`,"Give each element a unique id.");let u=e.maxContrastChecks??600,T=0;for(let h of D(t,"body *")){if(T>=u)break;if(!vt(h)||["SCRIPT","STYLE","NOSCRIPT","OPTION"].includes(h.tagName))continue;T++;let M=Ne(window.getComputedStyle(h).color),R=Fr(h);if(!M||!R)continue;let k=et(M,R),f=Pr(h)?3:4.5;k<f&&o("color-contrast",h,`Contrast ${k}:1 is below ${f}:1 for "${ne(h.textContent??"",30)}".`,`Darken the text or lighten the background until the ratio is at least ${f}:1.`)}let b=e.minTargetSize??24;for(let h of D(t,Ot)){let M=h.getBoundingClientRect();M.width===0&&M.height===0||h.tagName==="A"&&h.closest("p,li,td")||(M.width<b||M.height<b)&&o("target-size",h,`Target is ${Math.round(M.width)}\xD7${Math.round(M.height)}px (minimum ${b}\xD7${b}).`,`Increase padding so it's at least ${b}\xD7${b}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(d=>!n.has(d)).map(d=>{let p=e.filter(m=>m.rule===d).length;return{rule:d,title:tt[d].title,passed:p===0,issueCount:p}}),a=0;for(let d of r){let p=ri[tt[d.rule].severity];a+=Math.min(25,d.issueCount*p)}let i=Math.max(0,100-a),o=r.filter(d=>!d.passed),l=e.filter(d=>d.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 xt(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 Dt(e){return JSON.stringify({...e,issues:e.issues.map(({element:t,...n})=>n)},null,2)}function Ht(e={}){let t=null,n=null,r=null,a=!1,i=[],o=()=>({report:t,watching:n!==null,appliedFixes:i.length}),l=()=>{var y;return(y=e.onUpdate)==null?void 0:y.call(e,o())},s=y=>t==null?void 0:t.issues.find(u=>u.id===y),d=(y,u,T)=>{i.push({element:y,attribute:u,previous:y.getAttribute(u)}),y.setAttribute(u,T)};function p(y){let u=y.element,T=(b,h)=>({issueId:y.id,applied:b,message:h});if(!y.autoFixable||!u)return T(!1,"This needs a human decision \u2014 see the suggested fix.");switch(y.rule){case"html-lang":{let b=e.defaultLang||(ke()?navigator.language:"")||"en";return d(u,"lang",b),T(!0,`Set lang="${b}" on <html>.`)}case"image-alt":{let b=u.getAttribute("title");if(!b)break;return d(u,"alt",b),T(!0,`Used the image title as alt text: "${b}".`)}case"form-label":{let b=u.getAttribute("placeholder")||u.getAttribute("name");if(!b)break;let h=b.replace(/[_-]+/g," ").trim();return d(u,"aria-label",h),T(!0,`Added aria-label="${h}". A visible <label> is still better.`)}case"button-name":case"link-name":{let b=u.getAttribute("title");if(!b)break;return d(u,"aria-label",b),T(!0,`Added aria-label="${b}".`)}case"positive-tabindex":return d(u,"tabindex","0"),T(!0,"Changed tabindex to 0 so the natural order applies.");case"keyboard-access":{d(u,"tabindex","0"),u.getAttribute("role")||d(u,"role","button");let b=h=>{let M=h.key;(M==="Enter"||M===" ")&&(h.preventDefault(),u.click())};return u.addEventListener("keydown",b),i.push({element:u,attribute:"",previous:null,listener:b}),T(!0,"Made it focusable and added Enter/Space support.")}default:break}return T(!1,"No safe automatic fix for this one \u2014 see the suggested fix.")}function m(){if(t=ye(e),e.autoApply){a=!0;let y=t.issues.filter(u=>u.autoFixable).map(p);a=!1,y.some(u=>u.applied)&&(t=ye(e))}return l(),t}return{start(){if(!ke()||n)return;let y=he(e.root),u=Ve(y)?y.body:y;u&&(n=new MutationObserver(T=>{a||!T.some(h=>{var M,R;return!((R=(M=h.target).closest)!=null&&R.call(M,"[data-yuktai-panel]"))})||(r&&clearTimeout(r),r=setTimeout(m,e.debounceMs??600))}),n.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["alt","aria-label","aria-invalid","tabindex","lang","title"]}),m())},stop(){n==null||n.disconnect(),n=null,r&&clearTimeout(r),r=null,l()},scan:m,explain(y){let u=s(y);return u?[`${u.message}`,`Why it matters: ${u.why}`,`How to fix: ${u.fix}`,`Standard: WCAG ${u.wcag} (${u.severity}).`,u.autoFixable?"I can apply a safe fix for this in the browser.":"This one needs a change in your code."].join(`
|
|
10
|
+
`):`No issue "${y}" in the current report. Run a scan first.`},applyFix(y){let u=s(y);if(!u)return{issueId:y,applied:!1,message:"Issue not found. Run a scan first."};a=!0;let T=p(u);return a=!1,T.applied&&m(),T},applyAllFixes(){t||m(),a=!0;let y=((t==null?void 0:t.issues)??[]).filter(u=>u.autoFixable).map(p);return a=!1,m(),y},undoAll(){let y=i.length;for(a=!0;i.length;){let u=i.pop();u.listener?u.element.removeEventListener("keydown",u.listener):u.previous===null?u.element.removeAttribute(u.attribute):u.element.setAttribute(u.attribute,u.previous)}return a=!1,m(),y},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 D(e,"input,select,textarea").filter(t=>!["hidden","submit","button","reset","image"].includes((t.getAttribute("type")??"text").toLowerCase())).map(t=>({label:fe(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:Me(t),element:t}))}function Pn(e,t={}){var y;let n=t.seniorFriendly!==!1,r=t.maxFieldsPerStep??8,a=Fn(e),i=[],o=(u,T,b,h)=>i.push({level:u,message:T,suggestion:b,field:(h==null?void 0:h.label)||(h==null?void 0:h.name),selector:h==null?void 0:h.selector});for(let u of a){let T=u.element,b=u.label||u.name||u.type,h=T.getAttribute("placeholder");!u.label&&h?o("problem",`"${h}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts and aren't read by every screen reader. Add a visible label above the field.",u):u.label?!u.hasVisibleLabel&&h&&!T.getAttribute("aria-label")?o("problem",`"${b}" uses only a placeholder as its label.`,"Placeholders disappear when typing starts. Add a visible label above the field.",u):ii.test(u.label)&&o("improvement",`The label "${u.label}" is unclear.`,'Say exactly what is needed, e.g. "Mobile number (10 digits)".',u):o("problem",`A ${u.type} field${u.name?` ("${u.name}")`:""} has no label.`,"Add a visible <label> that says exactly what to enter.",u),u.required&&u.label&&!/\*|required|mandatory|తప్పనిసరి|आवश्यक/i.test(u.label)&&o("improvement",`"${b}" is required but the label doesn't say so.`,'Add "(required)" to the label so everyone knows before submitting.',u);let M=`${u.name} ${u.label}`;for(let[R,k,f]of si)if(R.test(M)){T.getAttribute("autocomplete")||o("improvement",`"${b}" has no autocomplete hint.`,`Add autocomplete="${k}" so browsers can fill it in (WCAG 1.3.5).`,u),f&&u.type==="text"&&o("improvement",`"${b}" uses type="text".`,`Use type="${f}" for the right mobile keyboard and validation.`,u);break}if(T.getAttribute("aria-invalid")==="true"&&!T.getAttribute("aria-describedby")&&!T.getAttribute("aria-errormessage")&&o("problem",`"${b}" shows an error that isn't connected to the field.`,"Link the error text with aria-describedby and explain how to fix it.",u),n){let R=parseFloat(window.getComputedStyle(T).fontSize)||16;R<16&&o("improvement",`"${b}" text is ${R}px.`,"Use at least 16px in inputs; it is easier to read and stops mobile browsers from zooming.",u)}}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=D(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 u=te(fe(l[l.length-1]));ai.test(u)&&o("improvement",`The button says "${u}".`,'Name the result, e.g. "Send message" or "Book appointment".')}!D(e,"[role='alert'],[aria-live]",{includeHidden:!0}).length&&a.some(u=>u.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(u=>u.level==="problem").length,d=i.length-s,p=Math.max(0,100-s*15-d*4),m=e.getAttribute("aria-label")||te((y=e.querySelector("legend,h1,h2,h3"))==null?void 0:y.textContent)||e.getAttribute("name")||e.getAttribute("id")||"Form";return{name:ne(m,50),selector:Me(e),fields:a,findings:i,score:p,summary:i.length===0?`"${ne(m,40)}" looks clear: ${a.length} labelled field(s), nothing to fix.`:`"${ne(m,40)}" has ${a.length} field(s): ${s} problem(s) and ${d} suggestion(s). Score ${p}/100.`}}function nt(e={}){let t=he(e.root);return t?D(t,"form,[role='form']").map(n=>Pn(n,e)):[]}function Gn(e){var p;let t=he(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=Ve(t)?t:t.ownerDocument,a=D(t,"h1,h2,h3,h4,h5,h6").map(m=>({level:Number(m.tagName[1]),text:ne(m.textContent??"",80)})),i={};for(let[m,y]of Object.entries({header:"header,[role='banner']",navigation:"nav,[role='navigation']",main:"main,[role='main']",search:"search,[role='search']",footer:"footer,[role='contentinfo']"}))i[m]=D(t,y).length;let o=D(t,"input,select,textarea").filter(m=>!["hidden","submit","button","reset","image"].includes((m.getAttribute("type")??"text").toLowerCase())),l=o.filter(m=>!fe(m)).map(m=>({type:m.tagName==="INPUT"?m.getAttribute("type")??"text":m.tagName.toLowerCase(),hint:m.getAttribute("placeholder")||m.getAttribute("name")||"",selector:Me(m)})),s=D(t,"img:not([alt])").map(m=>({src:m.getAttribute("src")??"",selector:Me(m)})),d={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:D(t,"a[href]").length,buttons:D(t,"button,[role='button'],input[type='submit']").length,images:D(t,"img").length,forms:D(t,"form,[role='form']").length,tables:D(t,"table,[role='grid'],[role='table']").length,fields:o.length},unlabeledFields:l,imagesWithoutAlt:s,purpose:""};return d.purpose=ci(d,o),d}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")} ${fe(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 di=[["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 zn(e){for(let[t,n]of di)if(n.test(e))return t;return"unknown"}async function qt(e,t={}){var a;let n=Gn(t.root),r=zn(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
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=
|
|
15
|
-
`),
|
|
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
|
|
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=he(t.root),s=te((a=l&&Ve(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 ui=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&&!ui.has(t))}function On(e,t=600){let n=he(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 D(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 Dn(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?[]:On(e.root),...e.rows&&e.columns?Dn(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 d of new Set(s))r.set(d,(r.get(d)??0)+1);a=n.reduce((s,d)=>s+d.length,0)/Math.max(1,n.length)}i();function o(s,d=5){let p=rt(s);if(!p.length)return[];let m=n.length;return n.map((u,T)=>{let b=0;for(let h of p){let M=0;for(let k of u)(k===h||h.length>=4&&k.startsWith(h)||k.length>=4&&h.startsWith(k))&&M++;if(!M)continue;let R=Math.log(1+(m-(r.get(h)??1)+.5)/((r.get(h)??1)+.5));b+=R*(M*2.2/(M+1.2*(.25+.75*(u.length/(a||1)))))}return{...t[T],score:b}}).filter(u=>u.score>0).sort((u,T)=>T.score-u.score).slice(0,d)}async function l(s,d={}){let p=o(s,d.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(d.generate)try{let T=p.map((h,M)=>`[${M+1}] ${h.text}`).join(`
|
|
15
|
+
`),b=await d.generate(s,T);if(b!=null&&b.trim())return{answer:b.trim(),hits:p,generated:!0}}catch{}let m=new Set(rt(s)),y=p.flatMap(T=>T.text.split(new RegExp("(?<=[.!?\u0964])\\s+|\\.\\s+(?=\\p{Lu})","u")).map(b=>({s:b.trim(),h:T}))).map(({s:T,h:b})=>({s:T,h:b,overlap:rt(T).filter(h=>m.has(h)).length})).filter(T=>T.s&&T.overlap>0).sort((T,b)=>b.overlap-T.overlap).slice(0,3);return{answer:y.length?y.map(T=>T.h.source==="grid"?`Row ${T.h.ref}: ${T.s}`:T.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 zr={high:12,medium:6,low:2};function Vt(e={}){let t=he(e.root),n=[],r=(l,s,d,p,m)=>n.push({category:l,severity:s,message:d,suggestion:p,selector:m?Me(m):void 0});if(t&&ke()){let l=e.minFontSize??14,s=e.maxLineLength??90,d=S=>window.getComputedStyle(S),p=D(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 m=S=>{let $=D(t,S)[0];return $&&parseFloat(d($).fontSize)||0},[y,u,T]=[m("h1"),m("h2"),m("h3")];y&&u&&u>=y&&r("hierarchy","medium",`h2 (${u}px) is as large as or larger than h1 (${y}px).`,"Make each heading level visibly smaller than the one above it."),u&&T&&T>u&&r("hierarchy","low",`h3 (${T}px) is larger than h2 (${u}px).`,"Keep heading sizes in descending order.");let b=ye({root:e.root,skip:["color-contrast","target-size","duplicate-id","page-title","html-lang","form-error","positive-tabindex"]});for(let S of b.issues.filter($=>$.rule==="heading-order").slice(0,3))r("hierarchy","low",S.message,S.fix,S.element);let h=0,M;for(let S of D(t,"p,li,td,span,a,label,small,div").slice(0,1500)){if(!vt(S))continue;(parseFloat(d(S).fontSize)||16)<l&&(h++,M??=S)}h&&r("readability",h>10?"high":"medium",`${h} text element(s) are smaller than ${l}px, e.g. "${ne((M==null?void 0:M.textContent)??"",30)}".`,`Use at least ${l}px for body text (16px for senior-friendly pages).`,M);for(let S of D(t,"p").slice(0,200)){let $=d(S),G=parseFloat($.fontSize)||16,N=S.getBoundingClientRect().width,F=N/(G*.5);if(N>0&&F>s&&(S.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).`,S);break}let q=parseFloat($.lineHeight);if(Number.isFinite(q)&&q/G<1.3){r("readability","low",`Line height is ${(q/G).toFixed(2)}\xD7 the font size.`,"Use line-height of at least 1.5 for body text (WCAG 1.4.12).",S);break}}let R=ye({root:e.root,skip:["html-lang","page-title","image-alt","heading-order","single-h1","landmark-main","form-label","button-name","link-name","positive-tabindex","keyboard-access","duplicate-id","form-error","target-size"]});R.issues.length&&r("readability",R.issues.length>5?"high":"medium",`${R.issues.length} text element(s) have weak contrast. ${R.issues[0].message}`,"Raise contrast to at least 4.5:1 for body text.",R.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 f=D(t,Ot).filter(S=>{let $=S.getBoundingClientRect();return $.width>0&&$.height>0&&($.width<24||$.height<24)&&!(S.tagName==="A"&&S.closest("p,li"))});f.length&&r("interaction",f.length>5?"high":"medium",`${f.length} control(s) are smaller than 24\xD724px.`,"Give controls at least 24\xD724px, ideally 44\xD744px for touch and seniors.",f[0]);let x=window.innerHeight||800,v=D(t,Gr).filter(S=>{let $=S.getBoundingClientRect();return $.height>0&&$.top<x});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=D(t,"button,a[href],[role='button']").filter(S=>{let $=S.getBoundingClientRect();if($.height===0||$.top>x)return!1;let G=d(S).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 w=new Set,C=new Set;for(let S of D(t,"body *").slice(0,2e3)){if(!vt(S))continue;let $=d(S);w.add($.fontFamily.split(",")[0].replace(/["']/g,"").trim().toLowerCase()),C.add(Math.round(parseFloat($.fontSize)||0))}w.size>4&&r("consistency","low",`${w.size} different font families are used.`,"Stick to 1\u20132 font families (e.g. one Telugu + one Latin)."),C.size>10&&r("consistency","low",`${C.size} different font sizes are used.`,"Use a small type scale (5\u20137 sizes) for a calmer page.");let I=D(t,"img:not([width]):not([height])").filter(S=>!d(S).aspectRatio||d(S).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 d=n.filter(p=>p.category===s);return l[s]={score:Math.max(0,100-d.reduce((p,m)=>p+zr[m.severity]*2,0)),findings:d.length},l},{}),i=Math.max(0,100-n.reduce((l,s)=>l+zr[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),d=!!(o.style.boxShadow&&o.style.boxShadow!=="none")||!!o.style.borderColor||!!o.style.backgroundColor||!!o.style.textDecoration;/:focus-visible/.test(o.selectorText)&&(!s||d)&&(t=!0),s&&!d&&e.push(o.selectorText)}};for(let r of Array.from(document.styleSheets))try{n(r.cssRules)}catch{}return t?[]:e}function Or(){var t;let e=window;return e.Rewriter||((t=e.ai)==null?void 0:t.rewriter)||null}async function Hn(){try{let e=Or();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=Or();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 Dr(){var r;if(!await Hn())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 Hr(){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 qr="yuktai-summary-box";function Br(){var t;let e=window;return e.Summarizer||((t=e.ai)==null?void 0:t.summarizer)||null}async function qn(){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 hi(){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 Vr(){if(!await qn())return{success:!1,summary:"",error:"Chrome Built-in AI Summarizer not available. Enable via chrome://flags."};let t=hi();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(),mi(a.trim()),{success:!0,summary:a.trim()}}catch(n){return{success:!1,summary:"",error:n instanceof Error?n.message:"Summary failed"}}}function mi(e){_t();let t=document.createElement("div");t.id=qr,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",_t),t.appendChild(n),t.appendChild(r),document.body.prepend(t)}function _t(){let e=document.getElementById(qr);e&&e.remove()}var _r=[{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"}],jt="en";function fi(){let e=window;return e.Translator||e.translation||null}async function yi(e){try{let t=window;if(!fi())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 bi(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 jr(e){var n;if(e===jt)return{success:!0,language:e,fixed:0};if(e==="en")return Bn(),jt="en",{success:!0,language:"en",fixed:0};if(!await yi(e))return{success:!1,language:e,fixed:0,error:`Translation to ${e} not available. Enable via chrome://flags.`};try{let r=await bi(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(),jt=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)}jt="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,Wt=!1,ot=null;function Vn(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function xi(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 wi(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=Wr(),n=t.indexOf(document.activeElement),r=t[n+1]||t[0];r&&r.focus();break}case"tab-back":{let t=Wr(),n=t.indexOf(document.activeElement),r=t[n-1]||t[t.length-1];r&&r.focus();break}case"stop-voice":{_n();break}}}function Wr(){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(!Vn())return!1;if(Wt)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=xi(r);if(a){wi(a.action);let i={success:!0,command:r,action:a.label};if(ot&&ot(i),a.action==="stop-voice")return}},ce.onend=()=>{Wt&&(ce==null||ce.start())},ce.onerror=n=>{n.error!=="no-speech"&&ot&&ot({success:!1,command:"",action:"",error:`Voice error: ${n.error}`})},ce.start(),Wt=!0,ki(),!0}function _n(){Wt=!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 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
|
|
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 jn(){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 Si(e){var d,p,m,y,u,T,b;let t=[],n=(d=e.innerText)==null?void 0:d.trim();n&&t.push(`element text: "${n}"`);let r=(p=e.placeholder)==null?void 0:p.trim();r&&t.push(`placeholder: "${r}"`);let a=(m=e.getAttribute("name"))==null?void 0:m.trim();a&&t.push(`name: "${a}"`);let i=(y=e.getAttribute("type"))==null?void 0:y.trim();i&&t.push(`type: "${i}"`);let o=e.id;if(o){let h=document.querySelector(`label[for="${o}"]`);h&&t.push(`label: "${(u=h.innerText)==null?void 0:u.trim()}"`)}let l=(b=(T=e.parentElement)==null?void 0:T.innerText)==null?void 0:b.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 Ti(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 Jr(){if(!await
|
|
78
|
+
`.trim();return(await e.write(n)).trim().replace(/^["']|["']$/g,"").replace(/\.$/,"").trim()}async function Jr(){if(!await jn())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=Si(o),d=await Ti(r,s);d&&d.length>0&&(o.dataset.yuktaiLabelOriginal=o.getAttribute("aria-label")||"",o.setAttribute("aria-label",d),a++,i.push({tag:o.tagName.toLowerCase(),label:d}))}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,Wn=null,X=null,it=null,Ut=null,Un=null,de=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"||!(de!=null&&de.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
|
|
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 _(e,t="info",n=!0){Qt&&(Qt.textContent=e),co(e,t),n&&Qn(e,t==="error"?"assertive":"polite")}function Mi(){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;
|
|
@@ -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"}),
|
|
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"}),_(`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 Ci(){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 $i(){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,d;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",_("Dialog closed","info");return}let m=t.closest("[role='menu'],[role='menubar']");m&&(m.style.display="none",_("Menu closed","info"))}if(n==="menuitem"||t.closest("[role='menu'],[role='menubar']")){let p=t.closest("[role='menu'],[role='menubar']");if(!p)return;let m=Array.from(p.querySelectorAll("[role='menuitem']:not([disabled])")),y=m.indexOf(t);e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),(r=m[(y+1)%m.length])==null||r.focus()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),(a=m[(y-1+m.length)%m.length])==null||a.focus()):e.key==="Home"?(e.preventDefault(),(i=m[0])==null||i.focus()):e.key==="End"&&(e.preventDefault(),(o=m[m.length-1])==null||o.focus())}if(n==="tab"||t.closest("[role='tablist']")){let p=t.closest("[role='tablist']");if(!p)return;let m=Array.from(p.querySelectorAll("[role='tab']:not([disabled])")),y=m.indexOf(t);if(e.key==="ArrowRight"||e.key==="ArrowDown"){e.preventDefault();let u=m[(y+1)%m.length];u==null||u.focus(),u==null||u.click()}else if(e.key==="ArrowLeft"||e.key==="ArrowUp"){e.preventDefault();let u=m[(y-1+m.length)%m.length];u==null||u.focus(),u==null||u.click()}}if(n==="option"||t.closest("[role='listbox']")){let p=t.closest("[role='listbox']");if(!p)return;let m=Array.from(p.querySelectorAll("[role='option']:not([aria-disabled='true'])")),y=m.indexOf(t);e.key==="ArrowDown"?(e.preventDefault(),(l=m[(y+1)%m.length])==null||l.focus()):e.key==="ArrowUp"?(e.preventDefault(),(s=m[(y-1+m.length)%m.length])==null||s.focus()):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.setAttribute("aria-selected","true"),m.forEach(u=>{u!==t&&u.setAttribute("aria-selected","false")}),_(`Selected: ${(d=t.textContent)==null?void 0:d.trim()}`,"success"))}e.altKey&&e.key==="a"&&(e.preventDefault(),Ri()),e.key==="Tab"&&(de!=null&&de.speechEnabled)&&setTimeout(()=>{var u;let p=document.activeElement;if(!p)return;let m=p.getAttribute("aria-label")||p.getAttribute("title")||((u=p.textContent)==null?void 0:u.trim())||p.tagName.toLowerCase(),y=p.getAttribute("role")||p.tagName.toLowerCase();Qn(`${m}, ${y}`)},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 Ri(){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(),it=null}),e.addEventListener("keydown",r=>{r.key==="Escape"&&(e.remove(),it=null)}),document.body.appendChild(e),it=e,Yt(e),
|
|
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),_("Keyboard shortcuts opened. Press Escape to close.","info")}function Ei(e){if(typeof document>"u"||!(de!=null&&de.showAuditBadge)||typeof window<"u"&&!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1"))return;Wn&&Wn.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",()=>Li(e)),document.body.appendChild(a),
|
|
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),Wn=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;
|
|
@@ -382,7 +382,7 @@ 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(),Ut=null,
|
|
385
|
+
`;let n=t.querySelector("[data-yuktai-extend]"),r=t.querySelector("[data-yuktai-dismiss]");n==null||n.addEventListener("click",()=>{t.remove(),Ut=null,_("Session extended. You have more time.","success"),de!=null&&de.timeoutWarning&&uo(de.timeoutWarning)}),r==null||r.addEventListener("click",()=>{t.remove(),Ut=null}),document.body.appendChild(t),Ut=t,Yt(t),_("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 Hn()){_("Plain English requires Chrome 127+","warning");return}_("Rewriting page in plain English...","info",!1);let n=await Dr();_(n.error?`Plain English failed: ${n.error}`:`${n.fixed} sections rewritten in plain English`,n.error?"error":"success",!1)}else Hr(),_("Original text restored","info",!1)}async function ro(e){if(e){if(!await qn()){_("Page summariser requires Chrome 127+","warning");return}_("Generating page summary...","info",!1);let n=await Vr();_(n.error?`Summary failed: ${n.error}`:"Page summary added at top",n.error?"error":"success",!1)}else _t(),_("Page summary removed","info",!1)}async function oo(e){if(e==="en"){Bn(),_("Page restored to English","info",!1);return}_(`Translating page to ${e}...`,"info",!1);let t=await jr(e);_(t.error?`Translation failed: ${t.error}`:`Page translated to ${e}`,t.error?"error":"success",!1)}async function io(e){if(e){if(!Vn()){_("Voice control not supported in this browser","warning");return}Ur(t=>{t.success&&_(`Voice: ${t.action}`,"info",!1)}),_("Voice control started. Say a command.","success",!1)}else _n(),_("Voice control stopped","info",!1)}async function ao(e){if(e){if(!await jn()){_("Smart labels requires Chrome 127+","warning");return}_("Generating smart labels...","info",!1);let n=await Jr();_(n.error?`Smart labels failed: ${n.error}`:`${n.fixed} elements labelled`,n.error?"error":"success",!1)}else Xr(),_("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
387
|
<filter id="${Kt.deuteranopia}">
|
|
388
388
|
<feColorMatrix type="matrix"
|
|
@@ -397,7 +397,7 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
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),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=`
|
|
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.";de=e,Ni(e),Fi(),Pi(),Ci(),$i(),e.showSkipLinks!==!1&&Mi(),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 _(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,m;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 y=o.getAttribute("name"),u=o.getAttribute("content")||"";y==="viewport"&&u.includes("user-scalable=no")&&(o.setAttribute("content",u.replace("user-scalable=no","user-scalable=yes")),a(l,"user-scalable=yes restored","serious",o)),y==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(u)&&(o.setAttribute("content",u.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 y=o.getAttribute("title")||"button";o.setAttribute("aria-label",y),a(l,`aria-label="${y}" (empty button)`,"critical",o)}o.hasAttribute("disabled")&&!o.getAttribute("aria-disabled")&&(o.setAttribute("aria-disabled","true"),t.fixed++)}if(l==="a"){let y=o;so(o)||(o.setAttribute("aria-label",o.getAttribute("title")||"link"),a(l,"aria-label added (empty link)","critical",o)),y.target==="_blank"&&!((p=y.rel)!=null&&p.includes("noopener"))&&(y.rel="noopener noreferrer",t.fixed++)}if(to.has(l)){let y=o;if(!(!!(y.labels&&y.labels.length)||!!o.getAttribute("title")||y.type==="hidden"||y.type==="submit"||y.type==="button"||y.type==="reset")&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")){let T=o.getAttribute("placeholder")||o.getAttribute("name")||l;o.setAttribute("aria-label",T),a(l,`aria-label="${T}"`,"serious",o)}if(o.hasAttribute("required")&&!o.getAttribute("aria-required")&&(o.setAttribute("aria-required","true"),t.fixed++),l==="input"&&!y.autocomplete){let T=y.name||"",b=y.type==="email"||T.includes("email")?"email":y.type==="tel"||T.includes("tel")?"tel":y.type==="password"?"current-password":"";b&&(y.autocomplete=b,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")&&!!((m=o.parentElement)!=null&&m.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 d=o.getAttribute("role")||"";d==="tab"&&!o.getAttribute("aria-selected")&&(o.setAttribute("aria-selected","false"),t.fixed++),["alert","status","log"].includes(d)&&!o.getAttribute("aria-live")&&(o.setAttribute("aria-live",d==="alert"?"assertive":"polite"),a(l,`aria-live added on role=${d}`,"moderate",o)),d==="combobox"&&!o.getAttribute("aria-expanded")&&(o.setAttribute("aria-expanded","false"),a(l,'aria-expanded="false" on combobox',"serious",o)),(d==="checkbox"||d==="radio")&&!o.getAttribute("aria-checked")&&(o.setAttribute("aria-checked","false"),a(l,`aria-checked="false" on role=${d}`,"serious",o))}),t.renderTime=parseFloat((performance.now()-n).toFixed(2)),t},scan(){let e={fixed:0,scanned:0,renderTime:0,score:100,details:[]};if(typeof document>"u")return e;let t=performance.now(),n=document.querySelectorAll("*");e.scanned=n.length;let 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:_,speak:Qn,showVisualAlert:co,trapFocus:Yt,handlePlainEnglish:no,handleSummarisePage:ro,handleTranslate:oo,handleVoiceControl:io,handleSmartLabels:ao,SUPPORTED_LANGUAGES:_r};var Gi=/\b(off|disable|stop|remove|no more|turn off|switch off|deactivate)\b|ఆఫ్|ఆపు|తీసివేయి|बंद/i,zi=[{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"}],Oi=[[/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 Oi)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 zi){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 d,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(m=>!m.querySelector("th,[role='columnheader']"));if(!a.length)return null;let i=(d=document.activeElement)==null?void 0:d.closest(r),o=i?a.indexOf(i):-1;if(e==="open-row"){let m=o>=0?a[o]:a[0];return m.click(),m}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 d=>e.apply?e.apply(d):_e.execute(d),i=d=>{if(e.speak===!1||!ke()||!("speechSynthesis"in window))return;let p=new SpeechSynthesisUtterance(d);p.lang=e.lang??"en-IN",window.speechSynthesis.cancel(),window.speechSynthesis.speak(p)};async function o(d){var m;let p=Xn(d,t);if((m=e.onTranscript)==null||m.call(e,d,p),!p)return null;if(p.type==="grid"){let y=Zn(p.action,{root:e.gridRoot});return i(y?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 d=window,p=d.SpeechRecognition??d.webkitSpeechRecognition;return p?(n=new p,n.lang=e.lang??"en-IN",n.continuous=!0,n.interimResults=!1,n.onresult=m=>{var T;let y=m.results,u=y[y.length-1];(T=u==null?void 0:u[0])!=null&&T.transcript&&o(u[0].transcript)},n.onend=()=>{r&&(n==null||n.start())},n.onerror=m=>{(m.error==="not-allowed"||m.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 ho(){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)),Di={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 Hi(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=Hi(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 qi(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 Vi(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 _i(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=R=>typeof R=="function"?R():R,n={locale:"en",rowKey:"id",historyLimit:20,customRules:[],...e},r=ho(),a=0,i=null,o=null,l=[],s=0,d=()=>Di[n.locale==="te"?"te":"en"],p=()=>t(n.tools)||[],m=()=>({loading:a>0,lastResult:i,lastError:o,history:l.slice()}),y=()=>r.emit(m());function u(R,k,f,x,v){v===s&&(i=f),l=[...l,{id:v,tool:R,input:k,result:f,source:x,at:Date.now()}].slice(-n.historyLimit),y()}async function T(R,k,f){let x=++s,v=Vi(p(),R);if(!v){let w={success:!1,message:d().toolMissing(R),error:{code:"NOT_SUPPORTED"}};return o=new Error(w.message),n.onError&&n.onError(o),u(R,k,w,f,x),w}let E=Bi(v,k);if(E.length){let w={success:!1,message:d().missingInput(E.join(", ")),error:{code:"INVALID_INPUT"},tool:v.name};return u(v.name,k,w,f,x),n.onResult&&n.onResult(w),w}a++,y();try{let w=await v.execute(k),C=qi(w)?{...w,tool:v.name}:{success:!0,message:d().done,data:w,tool:v.name};return C.success&&(o=null),u(v.name,k,C,f,x),n.onResult&&n.onResult(C),C}catch(w){o=tr(w);let C={success:!1,message:d().failed,error:{code:"INTERNAL"},tool:v.name};return n.onError&&n.onError(o),u(v.name,k,C,f,x),C}finally{a=Math.max(0,a-1),y()}}let b=(R,k={})=>T(R,k||{},"tool");async function h(R){let k=t(n.columns)||[],f=_i(R,n.customRules);if(f){let w=++s;try{let C=await f.execute({input:R,data:t(n.data)||[],columns:k,executeTool:b}),I={success:!0,message:String(C??d().done),tool:`rule:${f.name}`};return u(`rule:${f.name}`,{text:R},I,"ask",w),n.onResult&&n.onResult(I),I}catch(C){o=tr(C),n.onError&&n.onError(o);let I={success:!1,message:d().failed,error:{code:"INTERNAL"},tool:`rule:${f.name}`};return u(`rule:${f.name}`,{text:R},I,"ask",w),I}}let x=(n.parseIntent||nr)(R,{columns:k,locale:n.locale});if(!x){let w={success:!1,message:d().notUnderstood,error:{code:"NOT_UNDERSTOOD"}};return u("ask",{text:R},w,"ask",++s),w}if(x.kind==="tool")return T(x.tool,x.input,"ask");let v=await T("search",{query:x.text},"ask");if(!v.success)return v;let E=Array.isArray(v.data)?v.data:[];if(!E.length){let w={success:!1,message:d().noMatch(x.text),error:{code:"NOT_FOUND"},tool:v.tool};return u("open",{text:x.text},w,"ask",++s),w}return T("open",{id:ee(E[0],n.rowKey)},"ask")}function M(){l=[],i=null,o=null,y()}return{ask:h,executeTool:b,clearHistory:M,subscribe:r.subscribe,getState:m,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 d of n()){if(o.signal.aborted)return;try{await i.registerTool({name:d.name,title:d.title,description:d.description,inputSchema:d.inputSchema,execute:p=>{let m=n().find(y=>y.name===d.name);return m?m.execute(p||{}):{success:!1,message:`Tool "${d.name}" is no longer available.`,error:{code:"NOT_SUPPORTED"}}}},{signal:o.signal}),l.push(d.name)}catch(p){s.push({tool:d.name,message:tr(p).message})}}o.signal.aborted||r({state:s.length===0?"ready":l.length?"partial":"error",registered:l,errors:s})})(),a)}var ji=/\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,Wi={filters:[],search:[],sort:null,limit:null,notes:[],explanation:""};function tn(e={}){let t=ho(),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,d=[],p=[],m=!1,y=()=>r?r.getFilters():o.filters,u=()=>r?r.getSort():o.sort,T=()=>r?r.getHighlightIds():o.highlightIds,b=()=>r?r.getData():a,h=I=>r?r.setFilters(I):o={...o,filters:I},M=I=>r?r.setSort(I):o={...o,sort:I},R=I=>r?r.setHighlightIds(I):o={...o,highlightIds:I};function k(){return Re(b(),i,{...Wi,filters:y(),sort:u()})}let f=()=>{let I=k();return{gridData:I,highlightIds:T().slice(),filters:y().slice(),sort:u(),answer:l,kind:s,table:d.slice(),steps:p.slice(),busy:m,visibleIds:I.map(S=>ee(S,n))}},x=()=>t.emit(f()),v=()=>({get data(){return b()},columns:i,rowKey:n,get filters(){return y()},onFiltersChange:I=>{h(I),x()},onSortChange:I=>{M(I),x()},onHighlightRows:I=>{R(I),x()},onOpenRow:e.onOpenRow,onSelectRow:I=>{r&&r.selectRow?r.selectRow(I):R([I]),x()}});async function E(I){let S=String(I??"").trim();if(!S)return f();m=!0,p=[],d=[],x();try{if(bt(S).length>1){let $=[],G=await Gt(S,v(),{onStep:N=>{$.push(N),p=$.slice(),x()}});s="tasks",l=G.summary}else if(ji.test(S)){let $=$e(b(),i,y()),G=Pt(S,$,i,{referenceDate:e.referenceDate});s="insight",l=G.answer,d=G.table||[]}else{let $=Nt(S,v());s=$.kind,l=$.message}}catch($){console.error("[yuktai] ask failed",$),s=null,l="Something went wrong while answering. Please rephrase the question."}finally{m=!1,x()}return f()}function w(){h([]),M(null),R([]),l="",s=null,d=[],p=[],x()}function C(I={}){Array.isArray(I.data)&&(a=I.data),Array.isArray(I.columns)&&(i=Le(I.columns)),x()}return{ask:E,reset:w,update:C,subscribe:t.subscribe,getState:f,get gridData(){return k()},get highlightIds(){return T().slice()},get filters(){return y().slice()},get sort(){return u()},get answer(){return l},get kind(){return s},get table(){return d.slice()},get steps(){return p.slice()},get busy(){return m},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"/>',delete:'<path d="M4 7h16M10 11v6M14 11v6M6 7l1 13a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1l1-13M9 7V4h6v3"/>',robot:'<rect x="4" y="8" width="16" height="12" rx="3"/><path d="M12 8V4M9.5 4h5M2 13v3M22 13v3"/><circle cx="9" cy="14" r="1.3"/><circle cx="15" cy="14" r="1.3"/>',heart:'<path d="M12 20s-7.5-4.6-9.2-9.3A4.9 4.9 0 0 1 12 6.6a4.9 4.9 0 0 1 9.2 4.1C19.5 15.4 12 20 12 20z"/>',heartFilled:'<path fill="currentColor" d="M12 20s-7.5-4.6-9.2-9.3A4.9 4.9 0 0 1 12 6.6a4.9 4.9 0 0 1 9.2 4.1C19.5 15.4 12 20 12 20z"/>',hub:'<circle cx="12" cy="12" r="3"/><circle cx="5" cy="5" r="2"/><circle cx="19" cy="5" r="2"/><circle cx="5" cy="19" r="2"/><circle cx="19" cy="19" r="2"/><path d="m6.5 6.5 3.4 3.4M17.5 6.5l-3.4 3.4M6.5 17.5l3.4-3.4M17.5 17.5l-3.4-3.4"/>',code:'<path d="m8 7-5 5 5 5M16 7l5 5-5 5M14 4l-4 16"/>',text:'<path d="M3 7V5h11v2M8.5 5v14M6.5 19h4M14 12v-1.5h7V12M17.5 10.5V19M16 19h3"/>',bold:'<path d="M7 4h6a4 4 0 0 1 0 8H7zM7 12h7a4 4 0 0 1 0 8H7z"/>',italic:'<path d="M10 4h9M5 20h9M15 4 9 20"/>',underline:'<path d="M7 4v7a5 5 0 0 0 10 0V4M5 21h14"/>',alignLeft:'<path d="M4 5h16M4 9.5h9M4 14h16M4 18.5h9"/>',alignCenter:'<path d="M4 5h16M7.5 9.5h9M4 14h16M7.5 18.5h9"/>',alignRight:'<path d="M4 5h16M11 9.5h9M4 14h16M11 18.5h9"/>',alignJustify:'<path d="M4 5h16M4 9.5h16M4 14h16M4 18.5h16"/>',quote:'<path d="M4 18v-6.5A6.5 6.5 0 0 1 10.5 5M4 12h5.5v6H4zM13.5 18v-6.5A6.5 6.5 0 0 1 20 5M13.5 12H19v6h-5.5z"/>',title:'<path d="M5 6V4h14v2M12 4v16M9 20h6"/>',font:'<rect x="3" y="3" width="18" height="18" rx="3"/><path d="m8 17 4-10 4 10M9.4 13.5h5.2"/>',spellcheck:'<path d="m3 14 4-10 4 10M4.6 10.5h4.8M11 17l3 3 7-7"/>',abc:'<path d="m2 16 2.5-8L7 16M3 13.5h3M9.5 8v8h2.5a2 2 0 0 0 0-4H9.5h2a2 2 0 0 0 0-4H9.5M21 9.4a3.1 3.1 0 1 0 0 5.2"/>',pageBreak:'<path d="M6 3v5h12V3M6 21v-5h12v5M3 12h3M9 12h6M18 12h3"/>',link:'<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>',style:'<rect x="3" y="3" width="7" height="18" rx="2"/><path d="m10 7.5 4.4-2.6a2 2 0 0 1 2.7.7l3.2 5.6a2 2 0 0 1-.7 2.7L10 19"/><circle cx="6.5" cy="17" r="1"/>',lock:'<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3M12 15v2"/>',unlock:'<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 7.6-1.8M12 15v2"/>',key:'<circle cx="8" cy="15" r="4"/><path d="m11 12 9-9M17 6l3 3M14.5 8.5l2 2"/>',redo:'<path d="m15 14 5-5-5-5"/><path d="M20 9H10a6 6 0 0 0 0 12h3"/>',swap:'<path d="M7 4 3 8l4 4M3 8h14M17 12l4 4-4 4M21 16H7"/>',shuffle:'<path d="M16 3h5v5M4 20 21 3M21 16v5h-5M15 15l6 6M4 4l5 5"/>',fullscreen:'<path d="M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5"/>',fullscreenExit:'<path d="M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5"/>',merge:'<circle cx="6" cy="5" r="2"/><circle cx="6" cy="19" r="2"/><circle cx="18" cy="12" r="2"/><path d="M6 7v10M6 7c0 4 4 5 10 5"/>',join:'<circle cx="9" cy="12" r="6"/><circle cx="15" cy="12" r="6"/>',touch:'<path d="M9 11V5a1.5 1.5 0 0 1 3 0v6M12 10a1.5 1.5 0 0 1 3 0v1M15 11a1.5 1.5 0 0 1 3 0v3c0 4-2.5 7-6 7-2.5 0-4-1-5.5-3.5L4.6 14a1.5 1.5 0 0 1 2.5-1.6L9 15"/>',volumeOff:'<path d="M4 9v6h4l5 4V5L8 9H4z"/><path d="m16.5 9.5 5 5M21.5 9.5l-5 5"/>',musicOff:'<path d="M9 13v5M9 7V5l11-2v9"/><circle cx="6" cy="18" r="3"/><path d="M3 3l18 18"/>',musicVideo:'<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M10.5 15V8.5l5-1V13"/><circle cx="9" cy="15" r="1.5"/><circle cx="14" cy="13" r="1.5"/>',movie:'<rect x="3" y="9" width="18" height="11" rx="2"/><path d="m3.5 9-.6-3 16.6-3.4.6 3L3.5 9zM8.5 4.8l1.8 2.9M13.8 3.7l1.8 2.9"/>',slideshow:'<rect x="3" y="4" width="18" height="13" rx="2"/><path d="M10 8v5l4-2.5zM8 21h8M12 17v4"/>',storage:'<ellipse cx="12" cy="5" rx="8" ry="3"/><path d="M4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3"/>',api:'<path d="M3 17v-6a2.5 2.5 0 0 1 5 0v6M3 14h5M11 17V7h2.5a2.5 2.5 0 0 1 0 5H11M18 7h3M19.5 7v10M18 17h3"/>',dataObject:'<path d="M8 4H7a2 2 0 0 0-2 2v4l-2 2 2 2v4a2 2 0 0 0 2 2h1M16 4h1a2 2 0 0 1 2 2v4l2 2-2 2v4a2 2 0 0 1-2 2h-1"/>',computer:'<rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/>',phone:'<rect x="6" y="2" width="12" height="20" rx="2"/><path d="M10.5 18.5h3"/>',cloud:'<path d="M7 19a5 5 0 0 1-.6-10A6.5 6.5 0 0 1 18.6 9.5 4.8 4.8 0 0 1 17.5 19z"/>',wifi:'<path d="M2 9a15 15 0 0 1 20 0M5 12.5a10 10 0 0 1 14 0M8.5 16a5 5 0 0 1 7 0M12 19.5h.01"/>',wifiOff:'<path d="M2 9a15 15 0 0 1 20 0M5 12.5a10 10 0 0 1 14 0M8.5 16a5 5 0 0 1 7 0M12 19.5h.01M3 3l18 18"/>',searchOff:'<circle cx="11" cy="11" r="6.5"/><path d="m16 16 5 5M8.7 8.7l4.6 4.6M13.3 8.7l-4.6 4.6"/>',eyeOff:'<path d="M10.6 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-2.2 3.2M6.6 6.6C3.8 8.4 2 12 2 12s3.5 7 10 7a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M3 3l18 18"/>',bookmark:'<path d="M6 3h12v18l-6-4-6 4z"/>',school:'<path d="m2 9 10-5 10 5-10 5z"/><path d="M6 11v5c0 1.5 2.7 3 6 3s6-1.5 6-3v-5M22 9v6"/>',gavel:'<path d="m13 3.5 7.5 7.5M10 6.5l7.5 7.5M11.5 5l7 7-3 3-7-7zM10 11.5 3.5 18a1.4 1.4 0 0 0 2 2L12 13.5M13 21h8"/>',architecture:'<circle cx="12" cy="5" r="2"/><path d="M12 3V2M11 7 5.5 21M13 7l5.5 14M8 15h8"/>',brain:'<path d="M11 5.5A3 3 0 0 0 5.6 7 3 3 0 0 0 4 12a3 3 0 0 0 1.6 5A3 3 0 0 0 11 18.5zM13 5.5A3 3 0 0 1 18.4 7 3 3 0 0 1 20 12a3 3 0 0 1-1.6 5 3 3 0 0 1-5.4 1.5z"/><path d="M8 10h3M13 14h3"/>',volunteer:'<path d="M12 11s-3.5-2.2-3.5-4.6a1.8 1.8 0 0 1 3.5-.7 1.8 1.8 0 0 1 3.5.7C15.5 8.8 12 11 12 11z"/><path d="M2 15h3l3.5 1.5H13a1.5 1.5 0 0 1 0 3H9.5M5 21l1.5-1.5H14l5.5-4a1.6 1.6 0 0 0-2-2.4L14 15.6"/>',radio:'<circle cx="12" cy="12" r="9"/>',radioChecked:'<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="4" fill="currentColor"/>',upload:'<path d="M12 15V3m-5 5 5-5 5 5M4 21h16"/>',arrowDown:'<path d="M12 5v14m-6-6 6 6 6-6"/>',factCheck:'<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M7 9h4M7 13h4M7 17h2M13.5 13l2 2 3.5-3.5"/>',imageSearch:'<path d="M13 4H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"/><path d="m3 17 5-5 4 4"/><circle cx="17" cy="7" r="3"/><path d="m19.2 9.2 2.3 2.3"/>',documentScanner:'<path d="M3 7V4a1 1 0 0 1 1-1h3M17 3h3a1 1 0 0 1 1 1v3M21 17v3a1 1 0 0 1-1 1h-3M7 21H4a1 1 0 0 1-1-1v-3"/><path d="M7 8h10M7 12h10M7 16h6"/>',dashboard:'<rect x="3" y="3" width="8" height="10" rx="1.5"/><rect x="13" y="3" width="8" height="6" rx="1.5"/><rect x="3" y="15" width="8" height="6" rx="1.5"/><path d="M17 13v8M13 17h8"/>',cleaning:'<path d="m20 3-7.5 7.5"/><path d="M12.5 10.5c-2.5-1.6-6-1-7.4 1.7L3 20.5c3.2 1 7.2.4 10.2-1.6l.7-5.3c-.1-1.3-.6-2.3-1.4-3.1z"/><path d="M7.5 15.5 6 20.5M10.5 15l-1 5"/>',dragHandle:'<path d="M5 9h14M5 15h14"/>',zoomIn:'<circle cx="11" cy="11" r="6.5"/><path d="m16 16 5 5M8 11h6M11 8v6"/>',zoomOut:'<circle cx="11" cy="11" r="6.5"/><path d="m16 16 5 5M8 11h6"/>',insights:'<path d="m3 18 5-5 4 3 6-7"/><path d="M15 9h3v3"/><path d="m19 2.5.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7z"/>',explore:'<circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/>',save:'<path d="M5 3h11l5 5v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"/><path d="M7 3v5h8V3M7 21v-7h10v7"/>',label:'<path d="M4 6h11l5 6-5 6H4z"/>',keyboard:'<rect x="2" y="6" width="20" height="12" rx="2"/><path d="M6 10h.01M10 10h.01M14 10h.01M18 10h.01M6 14h.01M18 14h.01M9 14h6"/>',trendingUp:'<path d="m3 17 6-6 4 4 8-8"/><path d="M15 7h6v6"/>',trendingDown:'<path d="m3 7 6 6 4-4 8 8"/><path d="M15 17h6v-6"/>',cake:'<path d="M4 21h16M5 21v-7a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v7M5 16.5c1.5 1 2.5 1 3.5 0s2.5-1 3.5 0 2.5 1 3.5 0 2.5-1 3.5 0M12 12V8.5M12 6c-.9-.9-.9-2 0-3.3.9 1.3.9 2.4 0 3.3z"/>',barChart:'<path d="M4 20h16M7 20v-6M12 20V5M17 20V10"/>',admin:'<path d="M12 3 4 6v6c0 4.5 3.4 8 8 9 4.6-1 8-4.5 8-9V6z"/><circle cx="12" cy="10" r="2.5"/><path d="M8 16.5c1-1.8 2.4-2.5 4-2.5s3 .7 4 2.5"/>',bugReport:'<rect x="7" y="8" width="10" height="12" rx="5"/><path d="M9 8.5a3 3 0 0 1 6 0M12 12v8M7 13H3M21 13h-4M7 17l-3 1.5M17 17l3 1.5M7.5 10 5 8M16.5 10 19 8"/>',sentimentSad:'<circle cx="12" cy="12" r="9"/><path d="M8 16.5c1-1.4 2.4-2 4-2s3 .6 4 2M9 9.5h.01M15 9.5h.01"/>',integration:'<rect x="5" y="4" width="14" height="17" rx="2"/><path d="M9 4V3h6v1M10 11l-2 2 2 2M14 11l2 2-2 2"/>',namaskar:'<path d="M12 5.5V15M12 5.5c-.6-1.7-2.4-2.2-3.1-.9L7.2 11.5 4.5 14.5l3 5H10l2-3.5M12 5.5c.6-1.7 2.4-2.2 3.1-.9l1.7 6.9 2.7 3-3 5H14l-2-3.5"/>',sunrise:'<path d="M3 19h18M7 19a5 5 0 0 1 10 0M12 3v6M9.5 5.5 12 3l2.5 2.5M4.9 11.9l1.4 1.4M19.1 11.9l-1.4 1.4M2 16h2M20 16h2"/>',sunset:'<path d="M3 19h18M7 19a5 5 0 0 1 10 0M12 3v6M9.5 6.5 12 9l2.5-2.5M4.9 11.9l1.4 1.4M19.1 11.9l-1.4 1.4M2 16h2M20 16h2"/>',login:'<path d="M14 4h4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-4M10 16l4-4-4-4M14 12H3"/>',logout:'<path d="M10 4H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h4M16 16l4-4-4-4M20 12H9"/>',speed:'<path d="M4.5 18a9 9 0 1 1 15 0"/><path d="m12 14 4-5"/><circle cx="12" cy="14" r="1.2"/>',repeat:'<path d="m17 2 3 3-3 3M4 11V9a4 4 0 0 1 4-4h12M7 22l-3-3 3-3M20 13v2a4 4 0 0 1-4 4H4"/>',loader:'<path d="M12 3v3M12 18v3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M3 12h3M18 12h3M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"/>',star:'<path d="m12 3 2.8 5.7 6.2.9-4.5 4.4 1.1 6.2L12 17.3l-5.6 2.9 1.1-6.2L3 9.6l6.2-.9z"/>',shieldCheck:'<path d="M12 3 4 6v6c0 4.5 3.4 8 8 9 4.6-1 8-4.5 8-9V6z"/><path d="m8.5 12 2.5 2.5 4.5-4.5"/>'},ss=Object.keys(st);var Ui=3,rr="#ffffff",mo="#111827";function wt(e,t){let n=Ne(e),r=Ne(t);return n&&r?et(n,r):null}function or(e){let t=wt(rr,e),n=wt(mo,e);return t===null||n===null||t>=n?rr:mo}var fo=new Set;function Ki(e,t){fo.has(e)||(fo.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=wt(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;color:Canvas}}",Pe=e=>String(e).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function yo(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),d=`<svg xmlns="http://www.w3.org/2000/svg" ${t.label?`role="img" aria-label="${Pe(t.label)}"`:'aria-hidden="true"'} focusable="false" width="${Pe(r)}" height="${Pe(r)}" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round" data-variant="${a}">`;if(a==="outline")return`${d}<g stroke="${Pe(i)}" stroke-width="${l}">${n}</g></svg>`;let p=t.shape==="circle"?`<circle class="yi-bg" cx="12" cy="12" r="12" fill="${Pe(i)}"/>`:`<rect class="yi-bg" width="24" height="24" rx="6" fill="${Pe(i)}"/>`;return`${d}<style>${Ji}</style>${p}<g class="yi-glyph" color="${Pe(o)}" stroke="${Pe(o)}" stroke-width="${l}" transform="${Yi}">${n}</g></svg>`}var Ge=()=>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,W=(e="yv")=>`${e}-${++Xi}`;function rn(e,t){if(typeof e!="string"||!Ge())return t;let n=document.createElement("span");return n.style.color=e,n.style.color?e:t}var ir=()=>Ge()&&(window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||document.documentElement.hasAttribute("data-yuktai-reduce-motion")),bo=Object.keys(st);function ue(e,t=20,n,r){let a=typeof t=="object"&&t!==null?{...t}:{...r||{},size:t,label:n};return yo(e,a)}function H(e,t,n){let r=document.createElement("span");return r.className="yv-ic",r.innerHTML=ue(e,t,n),r}var je=null;function re(e){!Ge()||!e||((!je||!document.contains(je))&&(je=c("div",{id:"yuktai-vanilla-live",class:"yv-sr",role:"status","aria-live":"polite","aria-atomic":"true"}),document.body.appendChild(je)),je.textContent="",setTimeout(()=>{je&&(je.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 xo(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(!Ge()||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}
|
|
@@ -538,6 +538,6 @@ Missing landmarks: ${o.join(", ")}.`:""}`,targets:[],suggestions:o.includes("mai
|
|
|
538
538
|
.yv-status:empty{display:none}
|
|
539
539
|
@media (max-width:560px){.yv-dialog{${t}:8px;width:calc(100vw - 16px)}.yv-toolbar{align-items:stretch}.yv-search{flex-basis:100%}}
|
|
540
540
|
@media (prefers-reduced-motion:reduce){.yv-switch span,.yv-switch span::after{transition:none}}
|
|
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())})();})();
|
|
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=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"},H("spark",16),"Ask"),d=c("button",{type:"button",class:"yv-btn"},H("reset",16),"Show all rows"),p=c("p",{class:"yv-muted",style:"margin:10px 0 0",hidden:!0}),m=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),y=c("div"),u=n.examples||["salary over 1 lakh","anything unusual?","average salary by department","show salary over 80k, then sort by salary, then summarize"],T=c("div",{class:"yv-chips","aria-label":"Example questions"},...u.map(k=>c("button",{type:"button",class:"yv-chip","data-example":k},k))),b=c("form",{class:"yv-row",role:"search","aria-label":a},c("label",{for:i,class:"yv-sr"},a),l,s,d),h=c("section",{class:`yv-box yv-agentic-bar${n.theme?" yv-theme-"+n.theme:""}`,"aria-label":a},c("h3",null,H("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."),b,T,p,m,y);r.appendChild(h);function M(k){if(s.disabled=!!k.busy,h.setAttribute("aria-busy",String(!!k.busy)),!k.busy){if(m.textContent=k.answer||"",p.hidden=!k.kind,p.textContent=k.kind?`${Zi[k.kind]||k.kind} \xB7 ${k.visibleIds.length} row(s) shown`:"",y.replaceChildren(),k.table&&k.table.length){let f=Object.keys(k.table[0]),x=c("table",{class:"yv-mini"});x.innerHTML=`<caption class="yv-sr">Answer table</caption><thead><tr>${f.map(v=>`<th scope="col">${nn(v)}</th>`).join("")}</tr></thead><tbody>${k.table.map(v=>`<tr>${f.map(E=>`<td>${nn(v[E])}</td>`).join("")}</tr>`).join("")}</tbody>`,y.append(c("div",{style:"overflow-x:auto"},x))}k.steps&&k.steps.length&&y.append(c("ol",{class:"yv-steps","aria-label":"Steps"},...k.steps.map(f=>c("li",null,c("span",{class:f.success===!1?"yv-fail":"yv-ok"},f.success===!1?"\u2717 ":"\u2713 "),c("b",null,f.action),": ",f.message||f.text))))}}let R=t.subscribe(M);return b.addEventListener("submit",k=>{k.preventDefault(),t.ask(l.value)}),d.addEventListener("click",()=>{l.value="",t.reset()}),T.addEventListener("click",k=>{let f=k.target.closest("[data-example]");f&&(l.value=f.getAttribute("data-example"),t.ask(l.value))}),{element:h,ask:k=>(l.value=k,t.ask(k)),destroy(){R(),h.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"}}},wo=["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"],d=l==="te"?"te":"en",p=l==="en"||l==="te"?"en-IN":o,m=i.rowKey||"id",y=i.label||i.ariaLabel||"Data grid",u=i.pagination===!1?!1:typeof i.pagination=="object"?i.pagination:{},T=u&&u.sizeOptions||[10,20,50,100],b=i.selectable!==!1,h=i.autoScrollToHighlight!==!1,M=Number(i.mobileBreakpoint)||640,R=Array.isArray(i.data)?i.data.slice():[],k=ko(i.columns,R),f=Le(k),x=[],v=null,E="",w=1,C=Number(u&&u.pageSize||i.pageSize)||10,I=wo.includes(i.theme)?i.theme:"default",S=["table","card","auto"].includes(i.view)?i.view:"auto",$=!!i.loading,G=!1,N={r:1,c:0},F=new Set((i.selectedKeys||[]).map(String)),q=new Set((i.highlightIds||[]).map(String)),pe={grid:W("yv-grid"),title:W("yv-title"),status:W("yv-status")};T.includes(C)||T.push(C),T.sort((g,A)=>g-A);let j=g=>ee(g,m)||String(R.indexOf(g)),Y=g=>{let A=k.find(L=>L.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 Tt=c("h3",{id:pe.title,class:i.showTitle?"yv-grid-title":"yv-sr"},y);i.showTitle&&(Tt.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"},H("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"},H("download",16),s.export),Co=c("div",{class:"yv-tools"},S==="auto"||i.viewToggle?lt:null,gr),$o=c("div",{class:"yv-toolbar"},ln,pr,Co),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}),Mt=c("div",{class:"yv-pager"}),dn=c("p",{class:"yv-sr",id:pe.status,role:"status","aria-live":"polite","aria-atomic":"true"});Z.append(Tt,$o,Ee,cn,oe,Mt,dn),a.appendChild(Z);let un=null,Ct=g=>{clearTimeout(un),dn.textContent="",un=setTimeout(()=>dn.textContent=g,40)};function Ro(g,A,L,P){let z=g[L.key],O=A[L.key];if(z==null||z==="")return O==null||O===""?0:1;if(O==null||O==="")return-1;let V;return L.type==="number"?V=Number(z)-Number(O):L.type==="date"?V=new Date(z).getTime()-new Date(O).getTime():V=String(z).localeCompare(String(O),o,{numeric:!0,sensitivity:"base"}),Number.isFinite(V)||(V=String(z).localeCompare(String(O))),P==="desc"?-V:V}function ze(){let g=$e(R,f,x);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)=>Ro(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 hr(g,A,L){let P=A[g.key];if(g.render)try{let z=g.render(P,A,L);return z instanceof Node?z:document.createTextNode(z==null?"":String(z))}catch(z){return console.error("[yuktai] column render failed",g.key,z),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 dt=()=>S==="card"||S==="auto"&&G;function We(g){if(u===!1)return{pages:1,start:0,end:g};let A=Math.max(1,Math.ceil(g/C));return w=Math.min(Math.max(1,w),A),{pages:A,start:(w-1)*C,end:Math.min(g,w*C)}}let be=[];function U(){let g=ze();be=g;let{pages:A,start:L,end:P}=We(g.length),z=g.slice(L,P);Z.className=`yv-grid yv-theme-${I}${i.wrap?" yv-wrap":""}${i.className?" "+i.className:""}`,Z.setAttribute("aria-busy",String($)),pr.textContent=`${g.length.toLocaleString(p)} ${s.rows}${b?` \xB7 ${F.size.toLocaleString(p)} ${s.selected}`:""}`,lt.innerHTML=ue(dt()?"grid":"cards",18),lt.setAttribute("aria-label",dt()?s.tableView:s.cardView),lt.title=dt()?s.tableView:s.cardView,Io();let O=oe.contains(document.activeElement);oe.replaceChildren($?c("div",{class:"yv-loading",role:"status"},s.loading):dt()?Lo(z,L):Eo(z,L,g.length)),O&&!$&&fr(),No(g.length,A,L,P)}function Eo(g,A,L){let P=k,z=P.length+(b?1:0),O=c("table",{class:"yv-table",role:"grid","aria-labelledby":pe.title,"aria-rowcount":L+1,"aria-colcount":z,"aria-multiselectable":b?"true":null}),V=c("tr",{role:"row","aria-rowindex":1});if(b){let B=g.length>0&&g.every(xe=>F.has(j(xe))),ve=g.some(xe=>F.has(j(xe))),J=c("input",{type:"checkbox","data-select-page":"","aria-label":s.selectPage,tabindex:-1});J.checked=B,J.indeterminate=!B&&ve,V.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+(b?1:0),xe=v&&v.key===B.key?v.direction:null,Oe=c("th",{role:"columnheader",scope:"col","aria-colindex":J+1,"aria-sort":B.sortable?xe==="asc"?"ascending":xe==="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",ue(xe==="asc"?"sortUp":xe==="desc"?"sortDown":"sort",14)),Oe.append(Ye)}else Oe.append(B.label);V.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:z,tabindex:-1,"data-col":0},B)))}g.forEach((B,ve)=>{let J=j(B),xe=F.has(J),Oe=q.has(J),Ye=c("tr",{role:"row","aria-rowindex":A+ve+2,"aria-selected":b?String(xe):null,"data-yuktai-row-id":J,class:Oe?"yv-hl":null});if(b){let Je=c("input",{type:"checkbox","data-select":J,"aria-label":s.selectRow(Y(B)),tabindex:-1});Je.checked=xe,Ye.append(c("td",{role:"gridcell","aria-colindex":1,tabindex:-1,"data-col":0},c("label",{class:"yv-check"},Je)))}P.forEach((Je,br)=>{let vr=br+(b?1:0),hn=c("td",{role:"gridcell","aria-colindex":vr+1,tabindex:-1,"data-col":vr,class:Je.align!=="left"?`yv-align-${Je.align}`:null});hn.append(hr(Je,B,A+ve)),br===0&&Oe&&hn.append(c("span",{class:"yv-sr"},` (${s.highlighted})`)),Ye.append(hn)}),ie.append(Ye)}),O.append(c("thead",null,V),ie);let se=O.querySelectorAll("tr");N.r=Math.min(N.r,se.length-1);let le=mr(O,N.r,N.c)||mr(O,0,0);return le&&le.setAttribute("tabindex","0"),c("div",{class:"yv-tablewrap"},O)}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,z)=>{let O=j(P),V=F.has(O),ie=q.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":b?String(V):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(b){let J=c("input",{type:"checkbox","data-select":O,"aria-label":s.selectRow(Y(P))});J.checked=V,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,hr(J,P,A+z)))}),le.append(B,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"))),L.append(le)}),L}function Io(){if(Ee.replaceChildren(),!x.length){Ee.hidden=!0;return}Ee.hidden=!1,Ee.setAttribute("aria-label",s.filters(x.length)),Ee.append(c("span",{class:"yv-muted"},H("filter",15)," ",s.filters(x.length))),x.forEach((g,A)=>{let L=k.find(V=>V.key===g.key),P=Array.isArray(g.value)?g.value.map(V=>ct(L||{},V)).join(" \u2013 "):L?ct(L,g.value):String(g.value),z=`${L?L.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(z)},z,H("close",14));Ee.append(O)}),Ee.append(c("button",{type:"button",class:"yv-btn yv-small","data-clear-filters":""},s.clearFilters))}function No(g,A,L,P){if(Mt.replaceChildren(),u===!1){Mt.append(c("span",{class:"yv-muted"},s.results(g.toLocaleString(p))));return}let z=se=>se.toLocaleString(p),O=c("span",{class:"yv-muted"},g?s.showing(z(L+1),z(P),z(g)):s.showing(0,0,0)),V=c("div",{class:"yv-pages"});if(u.showSizeChanger!==!1){let se=W("yv-size"),le=c("select",{id:se,"data-page-size":""},...T.map(B=>c("option",{value:B,selected:B===C},String(B))));V.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=ue(se,18),J};V.append(ie("first",s.first,w<=1,"first"),ie("left",s.previous,w<=1,"prev"),c("span",{class:"yv-muted","aria-current":"page"},s.page(z(w),z(A))),ie("right",s.next,w>=A,"next"),ie("last",s.last,w>=A,"last")),Mt.append(O,V)}function mr(g,A,L){let P=g.querySelectorAll("tr")[A];if(!P)return null;let z=P.querySelectorAll("th,td");return z[Math.min(L,z.length-1)]||null}function Ce(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 z=P[g].querySelectorAll("th,td");A=Math.max(0,Math.min(A,z.length-1)),L.querySelectorAll('[tabindex="0"]').forEach(V=>V.setAttribute("tabindex","-1"));let O=z[A];O.setAttribute("tabindex","0"),N={r:g,c:A},O.focus()}function fr(){if(oe.querySelector("table"))Ce(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,z=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),O=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),L),V=A.querySelectorAll("tr").length-1,ie=!0;switch(g.key){case"ArrowRight":Ce(z,O+1);break;case"ArrowLeft":Ce(z,O-1);break;case"ArrowDown":Ce(z+1,O);break;case"ArrowUp":Ce(z-1,O);break;case"Home":g.ctrlKey?Ce(0,0):Ce(z,0);break;case"End":g.ctrlKey?Ce(V,999):Ce(z,999);break;case"PageDown":u!==!1&&(N={r:Math.max(1,z),c:O},Ke(w+1,!0));break;case"PageUp":u!==!1&&(N={r:Math.max(1,z),c:O},Ke(w-1,!0));break;case"Enter":case" ":{let se=L.querySelector("[data-sort]"),le=L.querySelector("input[type=checkbox]");se?yr(se.getAttribute("data-sort")):le?le.click():g.key==="Enter"&&P.hasAttribute("data-yuktai-row-id")&&typeof i.onRowClick=="function"?ut(P.getAttribute("data-yuktai-row-id")):g.key===" "&&b&&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 yr(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,w=1,oe.querySelector("table")&&oe.contains(document.activeElement)&&(N={r:0,c:N.c}),U(),Ct(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}=We(be.length),P=Math.min(Math.max(1,g),L);P===w&&!A||(w=P,U(),Ct(s.page(w,L)),A&&oe.querySelector("table")&&fr())}function ut(g){let A=R.find(L=>j(L)===String(g));return A?(typeof i.onRowClick=="function"&&i.onRowClick(A,R.indexOf(A)),typeof i.onOpenRow=="function"&&i.onOpenRow(String(g)),!0):!1}function pt(g,A=h){if(q.clear(),(g||[]).forEach(L=>q.add(typeof L=="object"&&L!==null?j(L):String(L))),A&&q.size){let L=be.length?be.findIndex(P=>q.has(j(P))):ze().findIndex(P=>q.has(j(P)));L>=0&&u!==!1&&(w=Math.floor(L/C)+1)}if(U(),A&&q.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(),w=1,U(),Ct(s.results(be.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 yr(A.getAttribute("data-sort"));if(A.matches("[data-page]")){let L=A.getAttribute("data-page"),{pages:P}=We(be.length);return Ke(L==="first"?1:L==="prev"?w-1:L==="next"?w+1:P)}if(A.matches("[data-remove-filter]")){x=x.filter((L,P)=>P!==Number(A.getAttribute("data-remove-filter"))),w=1,U(),i.onFiltersChange&&i.onFiltersChange(x.slice());return}if(A.matches("[data-clear-filters]"))return K.clearFilters();if(A.matches("[data-open]"))return ut(A.getAttribute("data-open"));if(A===lt){S=dt()?"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")&&ut(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}=We(be.length);be.slice(L,P).forEach(z=>A.checked?F.add(j(z)):F.delete(j(z))),U(),Ue()}else A.matches("[data-page-size]")&&(C=Number(A.value)||C,w=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,z=Array.prototype.indexOf.call(A.querySelectorAll("tr"),P),O=Array.prototype.indexOf.call(P.querySelectorAll("th,td"),L);z<0||O<0||(A.querySelectorAll('[tabindex="0"]').forEach(V=>V!==L&&V.setAttribute("tabindex","-1")),L.setAttribute("tabindex","0"),N={r:z,c:O})});let $t=null;typeof ResizeObserver=="function"&&($t=new ResizeObserver(g=>{let A=g[0]&&g[0].contentRect.width,L=A>0&&A<M;L!==G&&(G=L,S==="auto"&&U())}),$t.observe(Z));let Se={get data(){return R},get columns(){return f},rowKey:m,locale:d,get filters(){return x},onHighlightRows:g=>pt(g),onSelectRow:g=>{F.add(String(g)),pt([String(g)]),Ue()},onOpenRow:typeof i.onRowClick=="function"||typeof i.onOpenRow=="function"?g=>ut(g):void 0,onFiltersChange:g=>{x=g.slice(),w=1,U(),i.onFiltersChange&&i.onFiltersChange(x.slice())},onSortChange:g=>{v=g?{key:g.key,direction:g.direction==="desc"?"desc":"asc"}:null,w=1,U(),i.onSortChange&&i.onSortChange(v)}},Rt=Ze(Se,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions}),gt=Zt({tools:()=>Rt,data:()=>R,columns:()=>f.map(g=>({key:g.key,label:g.label})),rowKey:m,locale:d,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(()=>Rt,{onStatusChange:g=>{i.onWebMCPStatusChange&&i.onWebMCPStatusChange(g),Z.dispatchEvent(new CustomEvent("yuktai:webmcp",{detail:g,bubbles:!0}))}}));let Qe=tn({data:R,columns:f,rowKey:m,referenceDate:i.referenceDate,onOpenRow:Se.onOpenRow,bind:{getData:()=>R,getFilters:()=>x,getSort:()=>v,getHighlightIds:()=>Array.from(q),setFilters:g=>Se.onFiltersChange(g),setSort:g=>Se.onSortChange(g),setHighlightIds:g=>pt(g),selectRow:g=>Se.onSelectRow(g)}}),ht=null;i.ai&&(ht=lr(cn,gt,{locale:d,inputLanguage:i.inputLanguage||(d==="te"?"te-IN":"en-IN"),examples:i.assistantExamples,webmcp:()=>Et.status,showWebMCP:!!i.webmcp}),i.webmcp&&Z.addEventListener("yuktai:webmcp",()=>ht&&ht.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 Rt},agent:gt,agentic:Qe,get webmcpStatus(){return Et.status},refresh(g){return Array.isArray(g)&&(R=g.slice(),F.clear(),q.clear(),w=1),U(),K},setData(g,A){return Array.isArray(A)&&(k=ko(A,g||R),f=Le(k),Rt=Ze(Se,{name:i.toolName||"yuktai_grid",descriptions:i.toolDescriptions})),K.refresh(g)},getData:()=>R.slice(),getRows:()=>ze(),getPageRows(){let g=ze(),{start:A,end:L}=We(g.length);return g.slice(A,L)},getSelectedRows:()=>R.filter(g=>F.has(j(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,w=1,U(),be.length},setFilters(g){return Se.onFiltersChange(Array.isArray(g)?g:[]),K},addFilter(g){return gt.executeTool("filter",g)},getFilters:()=>x.slice(),clearFilters(){return Se.onFiltersChange([]),Ct(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 Se.onSortChange(g?{key:g,direction:A}:null),K},clearSort(){return Se.onSortChange(null),K},getSort:()=>v?{...v}:null,highlight(g,A){return pt(g,A===void 0?h:A),K},clearHighlight(){return pt([],!1),K},getHighlightIds:()=>Array.from(q),goToPage(g){return Ke(Number(g)||1),K},nextPage(){return Ke(w+1),K},prevPage(){return Ke(w-1),K},getPage:()=>({page:w,pageSize:C,pages:We(be.length).pages,total:be.length}),setPageSize(g){return C=Number(g)||C,T.includes(C)||(T.push(C),T.sort((A,L)=>A-L)),w=1,U(),K},setTheme(g){return I=wo.includes(g)?g:"default",U(),K},getTheme:()=>I,setView(g){return S=["table","card","auto"].includes(g)?g:"auto",U(),K},setLoading(g){return $=!!g,U(),K},openRow:g=>ut(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(ze(),f),anomalies:()=>He(ze(),f,{rowKey:m}),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?R.filter(P=>F.has(j(P))):ze(),L="\uFEFF"+[k.map(P=>ar(P.label)).join(","),...A.map(P=>k.map(z=>ar(P[z.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(un),$t&&$t.disconnect(),Et.unregister(),ht&&ht.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=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"},H("spark",16),r.ask),s=typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition),d=c("button",{type:"button",class:"yv-btn","aria-pressed":"false"},H("mic",16),r.listen),p=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),m=c("ol"),y=c("details",{class:"yv-history"},c("summary",null,r.history),m,c("button",{type:"button",class:"yv-btn yv-small","data-clear-history":""},r.clear)),u=n.showWebMCP?c("p",{class:"yv-muted",style:"margin:8px 0 0"}):null,T=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"]),b=c("div",{class:"yv-chips"},...T.map(v=>c("button",{type:"button",class:"yv-chip","data-example":v},v))),h=c("form",{class:"yv-row",role:"search","aria-label":r.title},c("label",{for:a,class:"yv-sr"},r.title),o,l,d),M=c("section",{class:"yv-box yv-assistant","aria-label":r.title},c("h3",null,H("chat",16)," ",r.title),c("p",{id:i,class:"yv-muted",style:"margin:0 0 8px"},r.hint),h,b,p,y,u);e.appendChild(M);async function R(v){let E=String(v||"").trim();if(E){l.disabled=!0;try{let w=await t.ask(E);p.textContent=w.message,p.className=`yv-answer ${w.success?"":"yv-fail"}`}finally{l.disabled=!1}}}let k=t.subscribe(v=>{m.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})`)))),y.querySelector("summary").textContent=`${r.history} (${v.history.length})`});h.addEventListener("submit",v=>{v.preventDefault(),R(o.value)}),M.addEventListener("click",v=>{let E=v.target.closest("[data-example],[data-clear-history]");E&&(E.hasAttribute("data-example")?(o.value=E.getAttribute("data-example"),R(o.value)):(t.clearHistory(),p.textContent=""))});let f=null;d.addEventListener("click",()=>{if(!s){p.textContent=r.noVoice;return}if(f){f.stop();return}f=new s,f.lang=n.inputLanguage||"en-IN",f.interimResults=!1,f.maxAlternatives=1,d.setAttribute("aria-pressed","true"),d.lastChild.textContent=r.stop,p.textContent=r.listening,f.onresult=v=>{let E=v.results[0][0].transcript;o.value=E,R(E)},f.onerror=v=>{p.textContent=`${r.noVoice} (${v.error})`},f.onend=()=>{f=null,d.setAttribute("aria-pressed","false"),d.lastChild.textContent=r.listen};try{f.start()}catch(v){p.textContent=`${r.noVoice} (${v.message})`,f=null}}),s||(d.title=r.noVoice);function x(){if(!u||!n.webmcp)return;let v=n.webmcp();u.textContent=r.webmcp[v.state]+(v.registered&&v.registered.length?` (${v.registered.length})`:"")}return x(),{element:M,ask:R,refreshStatus:x,destroy(){k(),f&&f.stop(),M.remove()}}}var So=[{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 dr(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(`${xo(t)} element(s) outlined on the page`)},H("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=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={};So.forEach(k=>{let f=`${r}-${k.id}`,x=`${f}-panel`;i.append(c("button",{type:"button",class:"yv-tab",role:"tab",id:f,"aria-controls":x,"aria-selected":"false",tabindex:-1,"data-tab":k.id},H(k.icon,15)," ",k.label)),o[k.id]=c("div",{role:"tabpanel",id:x,"aria-labelledby":f,hidden:!0,tabindex:0})}),a.append(i,...Object.values(o)),n&&n.appendChild(a);let l={},s=null;function d(k,f){o[k]||(k="qa"),s=k,i.querySelectorAll("[role=tab]").forEach(x=>{let v=x.getAttribute("data-tab")===k;x.setAttribute("aria-selected",String(v)),x.tabIndex=v?0:-1,v&&f&&x.focus()}),Object.entries(o).forEach(([x,v])=>v.hidden=x!==k),l[k]||(l[k]=!0,R[k](o[k]))}i.addEventListener("click",k=>{let f=k.target.closest("[role=tab]");f&&d(f.getAttribute("data-tab"),!0)}),i.addEventListener("keydown",k=>{let f=So.map(w=>w.id),x=k.target.closest&&k.target.closest("[role=tab]"),v=f.indexOf(x?x.getAttribute("data-tab"):s),E=null;k.key==="ArrowRight"?E=f[(v+1)%f.length]:k.key==="ArrowLeft"?E=f[(v-1+f.length)%f.length]:k.key==="Home"?E=f[0]:k.key==="End"&&(E=f[f.length-1]),E&&(k.preventDefault(),k.stopPropagation(),d(E,!0))});let p=null;function m(k){let f=c("ul",{class:"yv-list"}),x=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"},H("eye",16),"Watch page");p=Ht({defaultLang:t.defaultLang,debounceMs:600,onUpdate:C=>w(C)});function w(C){let I=C.report;E.setAttribute("aria-pressed",String(C.watching)),x.textContent=I?`${I.summary} Fixes applied: ${C.appliedFixes}.${C.watching?" Watching for page changes.":""}`:"Scan the page to see issues.",f.replaceChildren(...(I?I.issues.slice(0,40):[]).map(S=>c("li",{class:"yv-item"},c("p",null,cr(S.severity)," ",c("b",null,S.message)),c("p",{class:"yv-muted"},`WCAG ${S.wcag} \xB7 `,c("code",null,S.selector)),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>v.textContent=p.explain(S.id)},H("info",14),"Explain"),S.autoFixable?c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>re(p.applyFix(S.id).message)},H("wand",14),"Fix"):null,At([S.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()},H("search",16),"Scan page"),E,c("button",{type:"button",class:"yv-btn",onclick:()=>re(`${p.applyAllFixes().filter(C=>C.applied).length} fix(es) applied`)},H("wand",16),"Apply all safe fixes"),c("button",{type:"button",class:"yv-btn",onclick:()=>re(`${p.undoAll()} change(s) undone`)},H("undo",16),"Undo all")),x,v,f),E.addEventListener("click",()=>p.getState().watching?p.stop():p.start()),w(p.getState())}function y(k){let f=c("div",{"aria-live":"polite"}),x=null,v=()=>{x=ye(t.auditOptions||{});let E=x.issues;f.replaceChildren(dr(x.score,x.summary),c("div",{class:"yv-row"},c("button",{type:"button",class:"yv-btn yv-small",onclick:async()=>re(await vo(xt(x))?"Markdown report copied":"Copy failed")},H("copy",14),"Copy Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>kt("yuktai-qa-report.md",xt(x),"text/markdown;charset=utf-8")},H("download",14),"Markdown"),c("button",{type:"button",class:"yv-btn yv-small",onclick:()=>kt("yuktai-qa-report.json",Dt(x),"application/json")},H("download",14),"JSON")),c("details",{class:"yv-history"},c("summary",null,`Checks (${x.checks.filter(w=>w.passed).length}/${x.checks.length} passed)`),c("ul",{class:"yv-steps"},...x.checks.map(w=>c("li",null,c("span",{class:w.passed?"yv-ok":"yv-fail"},w.passed?"\u2713 ":"\u2717 "),w.title||w.rule,w.issueCount?` \u2014 ${w.issueCount} issue(s)`:"")))),c("ul",{class:"yv-list"},...E.slice(0,60).map(w=>c("li",{class:"yv-item"},c("p",null,cr(w.severity)," ",c("b",null,w.message)),c("p",null,c("b",null,"Fix: "),w.fix),c("p",{class:"yv-muted"},`${w.rule} \xB7 WCAG ${w.wcag} \xB7 `,c("code",null,w.selector)),At([w.selector])))),E.length>60?c("p",{class:"yv-muted"},`${E.length-60} more issue(s) in the downloaded report.`):null),re(x.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},H("check",16),"Run QA audit"),f)}function u(k){let f=c("input",{type:"checkbox",id:W("yv-senior"),checked:t.seniorFriendly!==!1}),x=c("div",{"aria-live":"polite"}),v=()=>{let E=nt({seniorFriendly:f.checked,maxFieldsPerStep:t.maxFieldsPerStep||8});if(!E.length)return x.replaceChildren(c("p",{class:"yv-answer"},"There are no forms on this page.")),re("No forms found");x.replaceChildren(...E.map(w=>c("div",{class:"yv-item",style:"margin-top:10px"},dr(w.score,w.summary),c("ul",{class:"yv-steps"},...w.findings.map(C=>c("li",null,c("span",{class:`yv-badge yv-sev-${C.level==="problem"?"serious":"minor"}`},C.level)," ",C.message,c("br"),c("span",{class:"yv-muted"},C.suggestion)))),At(w.findings.map(C=>C.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:f.id},f),c("label",{for:f.id},"Senior-friendly checks"),c("button",{type:"button",class:"yv-btn yv-primary",onclick:v},H("form",16),"Review forms")),x)}function T(k){let f=W("yv-min"),x=c("input",{id:f,class:"yv-input",type:"number",min:10,max:24,value:t.minFontSize||16,style:"width:90px"}),v=c("div",{"aria-live":"polite"}),E=()=>{let w=Vt({minFontSize:Number(x.value)||16,maxLineLength:t.maxLineLength||90});v.replaceChildren(dr(w.score,w.summary),c("div",{class:"yv-cats"},...Object.entries(w.categories).map(([C,I])=>c("div",{class:"yv-cat"},c("span",{class:"yv-muted"},C),c("strong",null,String(I.score)),c("span",{class:"yv-muted"},`${I.findings} finding(s)`)))),c("ul",{class:"yv-list"},...w.findings.slice(0,40).map(C=>c("li",{class:"yv-item"},c("p",null,cr(C.severity)," ",c("b",null,C.category),": ",C.message),c("p",{class:"yv-muted"},C.suggestion),At([C.selector]))))),re(w.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:f},"Minimum text size (px)"),x,c("button",{type:"button",class:"yv-btn yv-primary",onclick:E},H("layout",16),"Review design")),v)}function b(k){let f=W("yv-pq"),x=c("input",{id:f,class:"yv-input",type:"text",placeholder:"What is this page about?",autocomplete:"off"}),v=c("div",{"aria-live":"polite"}),E=null,w=async()=>{let S=x.value.trim()||"What is this page about?",$=await qt(S,{summarize:t.summarize}),G=[c("div",{class:"yv-answer"},$.answer)];$.suggestions.length&&G.push(c("ul",{class:"yv-steps"},...$.suggestions.map(F=>c("li",null,F))));let N=At($.targets);if(N&&G.push(N),$.intent==="unknown"){E?E.rebuild():E=Bt({includePage:!0,documents:t.documents});let F=await E.ask(S,{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($.answer)},C=c("form",{class:"yv-row"},c("label",{for:f,class:"yv-sr"},"Ask about this page"),x,c("button",{type:"submit",class:"yv-btn yv-primary"},"Ask"));C.addEventListener("submit",S=>{S.preventDefault(),w()});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,c("div",{class:"yv-chips"},...I.map(S=>c("button",{type:"button",class:"yv-chip",onclick:()=>(x.value=S,w())},S))),v)}let h=null;function M(k){let f=W("yv-lang"),x=c("select",{id:f,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"},H("mic",16),"Start listening"),E=W("yv-cmd"),w=c("input",{id:E,class:"yv-input",type:"text",placeholder:"Type a command, e.g. make text bigger",autocomplete:"off"}),C=c("div",{class:"yv-answer",role:"status","aria-live":"polite"}),I=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition),S=()=>{h&&h.stop(),h=Xt({lang:x.value,speak:t.speak!==!1,initial:t.getSettings?t.getSettings():void 0,apply:t.applySettings,onTranscript:(N,F)=>{C.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)}})};S(),x.addEventListener("change",()=>{let N=v.getAttribute("aria-pressed")==="true";S(),N&&h.start()}),v.addEventListener("click",()=>{if(v.getAttribute("aria-pressed")==="true"){h.stop(),v.setAttribute("aria-pressed","false"),v.lastChild.textContent="Start listening";return}if(!h.start()){C.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",C.textContent="Listening\u2026 say \u201Cmake text bigger\u201D or \u201Cnext row\u201D."});let $=c("form",{class:"yv-row"},c("label",{for:E,class:"yv-sr"},"Type a voice command"),w,c("button",{type:"submit",class:"yv-btn"},"Run"));$.addEventListener("submit",async N=>{N.preventDefault(),w.value.trim()&&await h.handle(w.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:f},"Language"),x,v),$,c("div",{class:"yv-chips"},...G.map(N=>c("button",{type:"button",class:"yv-chip",onclick:()=>(w.value=N,h.handle(N))},N))),C)}let R={copilot:m,qa:y,forms:u,design:T,ask:b,voice:M};return d(t.defaultTab||"qa",!1),{element:a,select:k=>d(k,!1),get tab(){return s},get copilot(){return p},destroy(){p&&p.stop(),h&&h.stop(),a.remove()}}}var ur="yuktai-a11y-prefs",St=[.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(ur);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(ur,JSON.stringify(t))}catch{}}function To(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,d,p,m,y,u="";async function T(S,$){i={...i,...S,enabled:!0},aa(i);try{u=await _e.execute({...i}),i.autoFix||_e.stopObserver()}catch(G){console.error("[yuktai] accessibility engine failed",G),u="Some settings could not be applied. See the browser console."}return M(),$||re("Accessibility settings updated"),u}async function b(){try{localStorage.removeItem(ur)}catch{}return i={...a},await T(i,!0),re("Accessibility settings reset"),i}function h(){let S=W("yv-a11y-title"),$=W("yv-font"),G=W("yv-cb"),N=c("section",{class:"yv-dialog",role:"dialog","aria-modal":"false","aria-labelledby":S,"data-yuktai-panel":""}),F=oa.map(([j,Y,Z,Tt])=>{let Ae=W("yv-opt"),ln=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"},H(Tt,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"})))}),q=c("div",{class:"yv-steps-bar",role:"group","aria-labelledby":$},...St.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":""},...ra.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:S},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:ue("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:$},"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:ue("minus",16)}),q,c("button",{type:"button",class:"yv-btn yv-icon","data-font-step":"1","aria-label":"Bigger text",html:ue("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":""},H("reset",16),"Reset all"),c("button",{type:"button",class:"yv-btn yv-primary","data-close":""},H("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]")?T({[Y.getAttribute("data-setting")]:Y.checked}):Y.matches("[data-colorblind]")&&T({colorBlindMode:Y.value})}),N.addEventListener("click",j=>{let Y=j.target.closest("button");if(Y){if(Y.hasAttribute("data-close"))return x();if(Y.hasAttribute("data-reset"))return b();if(Y.hasAttribute("data-font"))return R(Number(Y.getAttribute("data-font")));if(Y.hasAttribute("data-font-step")){let Z=St.indexOf(Number(i.fontSizeMultiplier||1));return R(St[Math.min(St.length-1,Math.max(0,(Z<0?2:Z)+Number(Y.getAttribute("data-font-step"))))])}}}),N.addEventListener("keydown",j=>k(j,N,x)),N}function M(){if(!d)return;d.querySelectorAll("[data-setting]").forEach(N=>N.checked=!!i[N.getAttribute("data-setting")]&&i[N.getAttribute("data-setting")]!==!1);let S=d.querySelector('[data-setting="showSkipLinks"]');S&&(S.checked=i.showSkipLinks!==!1);let $=Number(i.fontSizeMultiplier||1);d.querySelector("[data-font-value]").textContent=`${Math.round($*100)}%`,d.querySelectorAll("[data-font]").forEach(N=>N.setAttribute("aria-pressed",String(Math.abs(Number(N.getAttribute("data-font"))-$)<.001))),d.querySelector("[data-colorblind]").value=i.colorBlindMode||"none";let G=/(\d+) fixes applied/.exec(u);d.querySelector("[data-status]").textContent=G?`${G[1]} automatic accessibility fix(es) applied on this page.`:u}function R(S){St.some($=>Math.abs($-S)<.001)&&(T({fontSizeMultiplier:S},!0),re(`Text size ${Math.round(S*100)} percent`))}function k(S,$,G){if(S.key==="Escape"){S.preventDefault(),S.stopPropagation(),G();return}if(S.key!=="Tab")return;let N=Array.from($.querySelectorAll("button,input,select,textarea,[tabindex]:not([tabindex='-1'])")).filter(F=>!F.disabled&&F.offsetParent!==null);N.length&&(S.shiftKey&&document.activeElement===N[0]?(S.preventDefault(),N[N.length-1].focus()):!S.shiftKey&&document.activeElement===N[N.length-1]&&(S.preventDefault(),N[0].focus()))}function f(){l||I(),!d&&(w(),y=document.activeElement,d=h(),C().appendChild(d),l.setAttribute("aria-expanded","true"),M(),d.querySelector("[data-close]").focus(),document.addEventListener("pointerdown",v,!0))}function x(){d&&(d.remove(),d=null,l.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",v,!0),(y&&document.contains(y)?y:l).focus())}function v(S){d&&!d.contains(S.target)&&!o.contains(S.target)&&x(),p&&!p.contains(S.target)&&!o.contains(S.target)&&w()}function E(S){if(l||I(),p){S&&m&&m.select(S);return}x(),y=document.activeElement;let $=W("yv-tools-title");p=c("section",{class:"yv-dialog yv-wide",role:"dialog","aria-modal":"false","aria-labelledby":$,"data-yuktai-panel":""});let G=c("div",{class:"yv-dialog-body"});p.append(c("header",{class:"yv-dialog-head"},c("h2",{id:$},t.toolsTitle||"Page tools"),c("button",{type:"button",class:"yv-btn yv-icon","aria-label":"Close page tools",html:ue("close"),onclick:()=>w()})),G),C().appendChild(p),m=sn(G,{defaultTab:S||t.defaultTab||"qa",voiceLang:t.voiceLang,generate:t.generate,summarize:t.summarize,defaultLang:t.defaultLang,getSettings:()=>({...i}),applySettings:N=>T(N,!0)}),s&&s.setAttribute("aria-expanded","true"),p.addEventListener("keydown",N=>k(N,p,w)),p.querySelector("[role=tab][aria-selected=true]").focus(),document.addEventListener("pointerdown",v,!0)}function w(){p&&(m&&m.destroy(),m=null,p.remove(),p=null,s&&s.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",v,!0),(y&&document.contains(y)?y:s||l).focus())}let C=()=>document.documentElement||document.body;function I(){!Ge()||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:ue("accessibility",26)}),l.addEventListener("click",()=>d?x():f()),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:ue("tools",24)}),s.addEventListener("click",()=>p?w():E()),o.prepend(s)),C().appendChild(o),t.applyOnLoad!==!1&&T({},!0))}return{init:I,open:f,close:x,openTools:E,closeTools:w,apply:S=>T(S||{}),reset:b,getSettings:()=>({...i}),destroy(){x(),w(),o&&o.remove(),l=s=o=null}}}var Mo="5.3.0";(function(){if(!Ge()||window.yuktai&&window.yuktai.__vanillaInitialized)return;let t=window.YUKTAI_CONFIG||{},n=rn(t.primaryColor,"#005A9C"),r=t.position==="right"?"right":"left",a=To(t),i=()=>on(n,r),o=s=>(...d)=>(i(),s(...d)),l={__vanillaInitialized:!0,version:Mo,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:ue,iconNames:bo.slice(),iconContrast:wt,pickGlyphColor:or,...er,runPageQA:()=>ye().summary,getCapabilities:()=>({version:Mo,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())})();})();
|