aria-ease 7.0.0 → 7.0.1
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 +1 -1
- package/dist/{audit-APAPHXRO.js → audit-WBKVW7H6.js} +2 -2
- package/dist/cli.cjs +8 -8
- package/dist/cli.js +2 -2
- package/dist/index.cjs +18 -18
- package/dist/index.js +15 -15
- package/dist/src/accordion/index.cjs +1 -1
- package/dist/src/accordion/index.js +1 -1
- package/dist/src/block/index.cjs +1 -1
- package/dist/src/block/index.js +1 -1
- package/dist/src/checkbox/index.cjs +1 -1
- package/dist/src/checkbox/index.js +1 -1
- package/dist/src/combobox/index.cjs +1 -1
- package/dist/src/combobox/index.js +1 -1
- package/dist/src/menu/index.cjs +1 -1
- package/dist/src/menu/index.js +1 -1
- package/dist/src/radio/index.cjs +1 -1
- package/dist/src/radio/index.js +1 -1
- package/dist/src/tabs/index.cjs +1 -1
- package/dist/src/tabs/index.js +1 -1
- package/dist/src/toggle/index.cjs +1 -1
- package/dist/src/toggle/index.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var _t=Object.create;var
|
|
1
|
+
"use strict";var _t=Object.create;var ke=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var Q=(a,e)=>()=>(a&&(e=a(a=0)),e);var oe=(a,e)=>{for(var t in e)ke(a,t,{get:e[t],enumerable:!0})},we=(a,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of jt(e))!zt.call(a,r)&&r!==t&&ke(a,r,{get:()=>e[r],enumerable:!(s=Wt(e,r))||s.enumerable});return a},Ae=(a,e,t)=>(we(a,e,"default"),t&&we(t,e,"default")),se=(a,e,t)=>(t=a!=null?_t(Kt(a)):{},we(e||!a||!a.__esModule?ke(t,"default",{value:a,enumerable:!0}):t,a)),Jt=a=>we(ke({},"__esModule",{value:!0}),a);async function $s(){return ue||(ue=await ft.chromium.launch({headless:!0,args:["--disable-extensions","--disable-blink-features=AutomationControlled"]})),ue}async function xs(){return pe||(pe=await(await $s()).newContext({permissions:[],ignoreHTTPSErrors:!0})),pe}async function dt(){return await(await xs()).newPage()}async function gt(){pe&&(await pe.close(),pe=null),ue&&(await ue.close(),ue=null)}var ft,ue,pe,_e=Q(()=>{"use strict";ft=require("playwright"),ue=null,pe=null});function fe(a){return a==="required"||a==="recommended"||a==="optional"?a:Cs}function he(a){return a==="minimal"||a==="balanced"||a==="strict"||a==="paranoid"?a:"balanced"}function mt(a,e){return{minimal:{required:"error",recommended:"ignore",optional:"ignore"},balanced:{required:"error",recommended:"warning",optional:"ignore"},strict:{required:"error",recommended:"error",optional:"warning"},paranoid:{required:"error",recommended:"error",optional:"error"}}[e][a]}var Cs,We=Q(()=>{"use strict";Cs="required"});var ht={};oe(ht,{loadConfig:()=>Ps});function Ls(a){let e=[];if(!a||typeof a!="object")return e.push("Config must be an object"),{valid:!1,errors:e};let t=a;if(t.audit!==void 0){if(typeof t.audit!="object"||t.audit===null)e.push("audit must be an object");else if(t.audit.urls!==void 0&&(Array.isArray(t.audit.urls)?t.audit.urls.some(s=>typeof s!="string")&&e.push("audit.urls must contain only strings"):e.push("audit.urls must be an array")),t.audit.output!==void 0)if(typeof t.audit.output!="object")e.push("audit.output must be an object");else{let s=t.audit.output;s.format!==void 0&&(["json","csv","html","all"].includes(s.format)||e.push("audit.output.format must be one of: json, csv, html, all")),s.out!==void 0&&typeof s.out!="string"&&e.push("audit.output.out must be a string")}}if(t.test!==void 0)if(typeof t.test!="object"||t.test===null)e.push("test must be an object");else{t.test.disableTimeouts!==void 0&&typeof t.test.disableTimeouts!="boolean"&&e.push("test.disableTimeouts must be a boolean when provided");let s=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let r of s){let i=t.test[r];i!==void 0&&(typeof i!="number"||!Number.isFinite(i)||i<0)&&e.push(`test.${r} must be a non-negative number when provided`)}t.test.components!==void 0&&(Array.isArray(t.test.components)?t.test.components.forEach((r,i)=>{if(typeof r!="object"||r===null)e.push(`test.components[${i}] must be an object`);else{typeof r.name!="string"&&e.push(`test.components[${i}].name must be a string`),r.contractPath!==void 0&&typeof r.contractPath!="string"&&e.push(`test.components[${i}].contractPath must be a string when provided`),r.strategyPath!==void 0&&typeof r.strategyPath!="string"&&e.push(`test.components[${i}].strategyPath must be a string when provided`),r.strictness!==void 0&&!["minimal","balanced","strict","paranoid"].includes(r.strictness)&&e.push(`test.components[${i}].strictness must be one of: minimal, balanced, strict, paranoid`),r.disableTimeouts!==void 0&&typeof r.disableTimeouts!="boolean"&&e.push(`test.components[${i}].disableTimeouts must be a boolean when provided`);let n=["actionTimeoutMs","assertionTimeoutMs","navigationTimeoutMs","componentReadyTimeoutMs"];for(let o of n){let l=r[o];l!==void 0&&(typeof l!="number"||!Number.isFinite(l)||l<0)&&e.push(`test.components[${i}].${o} must be a non-negative number when provided`)}}}):e.push("test.components must be an array")),t.test.strictness!==void 0&&(["minimal","balanced","strict","paranoid"].includes(t.test.strictness)||e.push("test.strictness must be one of: minimal, balanced, strict, paranoid"))}return t.contracts!==void 0&&(Array.isArray(t.contracts)?t.contracts.forEach((s,r)=>{typeof s!="object"||s===null?e.push(`contracts[${r}] must be an object`):(typeof s.src!="string"&&e.push(`contracts[${r}].src is required and must be a string`),s.out!==void 0&&typeof s.out!="string"&&e.push(`contracts[${r}].out must be a string`))}):e.push("contracts must be an array")),{valid:e.length===0,errors:e}}async function Rs(a){try{let e=je.default.extname(a);if(e===".json"){let t=await Ke.default.readFile(a,"utf-8");return JSON.parse(t)}else if([".js",".mjs",".cjs",".ts"].includes(e)){let t=await import(a);return t.default||t}return null}catch{return null}}async function Ps(a=process.cwd()){let e=["ariaease.config.js","ariaease.config.mjs","ariaease.config.cjs","ariaease.config.json","ariaease.config.ts"],t=null,s=null,r=[];for(let i of e){let n=je.default.resolve(a,i);if(await Ke.default.pathExists(n)){if(s=n,t=await Rs(n),t===null){r.push(`Found config at ${i} but failed to load it. Check for syntax errors.`);continue}let o=Ls(t);if(!o.valid){r.push(`Config validation failed in ${i}:`),r.push(...o.errors.map(l=>` - ${l}`)),t=null;continue}break}}return{config:t||{},configPath:t?s:null,errors:r}}var je,Ke,bt=Q(()=>{"use strict";je=se(require("path"),1),Ke=se(require("fs-extra"),1)});var G={};oe(G,{default:()=>yt.default});var yt,be=Q(()=>{"use strict";Ae(G,require("playwright/test"));yt=se(require("playwright/test"),1)});var vt={};oe(vt,{MenuComponentStrategy:()=>ze});var ze,wt=Q(()=>{"use strict";be();ze=class{constructor(e,t,s=400,r=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=s;this.assertionTimeoutMs=r}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,s=e.locator(t).first();if(!await s.isVisible().catch(()=>!1))return;let i=!1,n=this.selectors.input;if(!n&&this.selectors.focusable?n=this.selectors.focusable:n||(n=this.selectors.main),n&&(await e.locator(n).first().focus(),await e.keyboard.press("Escape"),i=await(0,G.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!i&&this.selectors.main&&(await e.locator(this.selectors.main).first().click({timeout:this.actionTimeoutMs}),i=await(0,G.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),i||(await e.mouse.click(10,10),i=await(0,G.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!i)throw new Error(`\u274C FATAL: Cannot close menu between tests. Menu remains visible after trying:
|
|
2
2
|
1. Escape key
|
|
3
3
|
2. Clicking trigger
|
|
4
4
|
3. Clicking outside
|
|
5
|
-
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus()}async shouldSkipTest(e,t){if(!(e.action.some(n=>n.target==="submenu"||n.target==="submenuTrigger"||n.target==="submenuItems")||e.assertions.some(n=>n.target==="submenu"||n.target==="submenuTrigger"||n.target==="submenuItems")))return!1;let r=this.selectors.submenuTrigger;return r?await t.locator(r).count()===0:!0}getMainSelector(){return this.mainSelector}}});var
|
|
5
|
+
This indicates a problem with the menu component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear(),this.selectors.main&&await e.locator(this.selectors.main).first().focus()}async shouldSkipTest(e,t){if(!(e.action.some(n=>n.target==="submenu"||n.target==="submenuTrigger"||n.target==="submenuItems")||e.assertions.some(n=>n.target==="submenu"||n.target==="submenuTrigger"||n.target==="submenuItems")))return!1;let r=this.selectors.submenuTrigger;return r?await t.locator(r).count()===0:!0}getMainSelector(){return this.mainSelector}}});var kt={};oe(kt,{AccordionComponentStrategy:()=>Je});var Je,At=Q(()=>{"use strict";be();Je=class{constructor(e,t,s=400,r=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=s;this.assertionTimeoutMs=r}async resetState(e){if(!this.selectors.panel||!this.selectors.trigger||this.selectors.popup)return;let t=this.selectors.trigger,s=this.selectors.panel;if(!t||!s)return;let r=await e.locator(t).all();for(let i of r){let n=await i.getAttribute("aria-expanded")==="true",o=await i.getAttribute("aria-controls");if(n&&o){await i.click({timeout:this.actionTimeoutMs});let l=e.locator(`#${o}`);await(0,G.expect)(l).toBeHidden({timeout:this.assertionTimeoutMs}).catch(()=>{})}}}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Tt={};oe(Tt,{ComboboxComponentStrategy:()=>Ge});var Ge,Et=Q(()=>{"use strict";be();Ge=class{constructor(e,t,s=400,r=400){this.mainSelector=e;this.selectors=t;this.actionTimeoutMs=s;this.assertionTimeoutMs=r}async resetState(e){if(!this.selectors.popup)return;let t=this.selectors.popup,s=e.locator(t).first();if(!await s.isVisible().catch(()=>!1))return;let i=!1,n=this.selectors.input;if(!n&&this.selectors.focusable?n=this.selectors.focusable:n||(n=this.selectors.button),n&&(await e.locator(n).first().focus(),await e.keyboard.press("Escape"),i=await(0,G.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!i&&this.selectors.button&&(await e.locator(this.selectors.button).first().click({timeout:this.actionTimeoutMs}),i=await(0,G.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),i||(await e.mouse.click(10,10),i=await(0,G.expect)(s).toBeHidden({timeout:this.assertionTimeoutMs}).then(()=>!0).catch(()=>!1)),!i)throw new Error(`\u274C FATAL: Cannot close combobox popup between tests. Popup remains visible after trying:
|
|
6
6
|
1. Escape key
|
|
7
7
|
2. Clicking button
|
|
8
8
|
3. Clicking outside
|
|
9
|
-
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear()}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Mt={};
|
|
9
|
+
This indicates a problem with the combobox component's close functionality.`);this.selectors.input&&await e.locator(this.selectors.input).first().clear()}async shouldSkipTest(){return!1}getMainSelector(){return this.mainSelector}}});var Mt={};oe(Mt,{TabsComponentStrategy:()=>Xe});var Xe,St=Q(()=>{"use strict";Xe=class{constructor(e,t){this.mainSelector=e;this.selectors=t}async resetState(){}async shouldSkipTest(e,t){if(e.isVertical!==void 0&&this.selectors.tablist){let s=this.selectors.tablist,n=await t.locator(s).first().getAttribute("aria-orientation")==="vertical";if(e.isVertical!==n)return!0}return!1}getMainSelector(){return this.mainSelector}}});var Ye,$t,$e,xt=Q(()=>{"use strict";Ye=se(require("path"),1),$t=require("url"),$e=class{builtInStrategies=new Map;constructor(){this.registerBuiltInStrategies()}registerBuiltInStrategies(){this.builtInStrategies.set("menu",()=>Promise.resolve().then(()=>(wt(),vt)).then(e=>e.MenuComponentStrategy)),this.builtInStrategies.set("accordion",()=>Promise.resolve().then(()=>(At(),kt)).then(e=>e.AccordionComponentStrategy)),this.builtInStrategies.set("combobox",()=>Promise.resolve().then(()=>(Et(),Tt)).then(e=>e.ComboboxComponentStrategy)),this.builtInStrategies.set("tabs",()=>Promise.resolve().then(()=>(St(),Mt)).then(e=>e.TabsComponentStrategy))}async loadStrategy(e,t,s){try{if(t)try{let i=Ye.default.isAbsolute(t)?t:Ye.default.resolve(s||process.cwd(),t),n=await import((0,$t.pathToFileURL)(i).href),o=n.default||n;if(!o)throw new Error(`No default export found in ${t}`);return o}catch(i){throw new Error(`Failed to load custom strategy from ${t}: ${i instanceof Error?i.message:String(i)}`)}let r=this.builtInStrategies.get(e);return r?r():null}catch(r){throw new Error(`Strategy loading failed for ${e}: ${r instanceof Error?r.message:String(r)}`)}}has(e,t){return!!t||this.builtInStrategies.has(e)}}});var xe,Ce,Hs,Le,Ct=Q(()=>{"use strict";xe=require("fs"),Ce=se(require("path"),1);xt();Hs={},Le=class{static strategyRegistry=new $e;static isComponentConfig(e){return typeof e=="object"&&e!==null}static async detect(e,t,s=400,r=400,i){let n=this.isComponentConfig(t)?t:void 0,o=n?.contractPath;if(!o)throw new Error(`Contract path not found for component: ${e}`);let l=(()=>{if(Ce.default.isAbsolute(o))return o;if(i){let W=Ce.default.resolve(i,o);try{return(0,xe.readFileSync)(W,"utf-8"),W}catch{}}let _=Ce.default.resolve(process.cwd(),o);try{return(0,xe.readFileSync)(_,"utf-8"),_}catch{return new URL(o,Hs.url).pathname}})(),p=(0,xe.readFileSync)(l,"utf-8"),T=JSON.parse(p).selectors,M=await this.strategyRegistry.loadStrategy(e,n?.strategyPath,i);if(!M)return null;let H=T.main;return e==="tabs"?new M(H,T):new M(H,T,s,r)}}});var Re,Lt=Q(()=>{"use strict";Re=class{startTime=0;componentName="";staticPasses=0;staticFailures=0;staticWarnings=0;dynamicResults=[];totalTests=0;skipped=0;warnings=0;isPlaywright=!1;isCustomContract=!1;apgUrl="https://www.w3.org/WAI/ARIA/apg/";hasPrintedStaticSection=!1;hasPrintedDynamicSection=!1;constructor(e=!1,t=!1){this.isPlaywright=e,this.isCustomContract=t}log(e){process.stderr.write(e+`
|
|
10
10
|
`)}start(e,t,s){this.startTime=Date.now(),this.componentName=e,this.totalTests=t,this.hasPrintedStaticSection=!1,this.hasPrintedDynamicSection=!1,s&&(this.apgUrl=s);let r="Playwright (Real Browser)";this.log(`
|
|
11
11
|
${"\u2550".repeat(60)}`),this.log(`\u{1F50D} Testing ${e.charAt(0).toUpperCase()+e.slice(1)} Component - ${r}`),this.log(`${"\u2550".repeat(60)}
|
|
12
12
|
`)}reportStatic(e,t,s=0){this.staticPasses=e,this.staticFailures=t,this.staticWarnings=s}reportStaticTest(e,t,s,r){this.hasPrintedStaticSection||(this.log(`${"\u2500".repeat(60)}`),this.log("\u{1F9EA} Static Assertions"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedStaticSection=!0);let i=t==="pass"?"\u2713":t==="warn"?"\u26A0":t==="skip"?"\u25CB":"\u2717";this.log(` ${i} ${e}`),r&&this.log(` \u21B3 level=${r}`),(t==="fail"||t==="warn"||t==="skip")&&s&&this.log(` \u21B3 ${s}`)}reportTest(e,t,s){this.hasPrintedDynamicSection||(this.log(""),this.log(`${"\u2500".repeat(60)}`),this.log("\u2328\uFE0F Dynamic Interaction Tests"),this.log(`${"\u2500".repeat(60)}`),this.hasPrintedDynamicSection=!0);let r={description:e.description,status:t,failureMessage:s,level:e.level};t==="skip"&&(r.skipReason="Requires real browser (addEventListener events)"),this.dynamicResults.push(r);let i={pass:"\u2713",fail:"\u2717",warn:"\u26A0",skip:"\u25CB"},n=e.level?`[${e.level.toUpperCase()}] `:"";this.log(` ${i[t]} ${n}${e.description}`),t==="skip"&&!this.isPlaywright&&this.log(" \u21B3 Skipped (runs only in Playwright)"),t==="fail"&&s&&this.log(` \u21B3 ${s}`),t==="warn"&&s&&this.log(` \u21B3 ${s}`),t==="skip"&&s&&this.log(` \u21B3 ${s}`)}reportFailures(e){e.length!==0&&(this.log(`
|
|
@@ -21,21 +21,21 @@ ${"\u2500".repeat(60)}`),this.log(`\u2139\uFE0F Skipped Tests (${this.skipped})
|
|
|
21
21
|
`),this.log("These tests use native keyboard events via addEventListener,"),this.log(`which only run in Playwright (real browser).
|
|
22
22
|
`),e.forEach((t,s)=>{this.log(`${s+1}. ${t.description}`)}),this.log(`
|
|
23
23
|
\u{1F4A1} Run with Playwright for full validation:`),this.log(` testUiComponent('${this.componentName}', null, 'http://localhost:5173/test-harness?component=component_name')
|
|
24
|
-
`)}summary(e){let t=Date.now()-this.startTime,s=this.dynamicResults.filter(
|
|
24
|
+
`)}summary(e){let t=Date.now()-this.startTime,s=this.dynamicResults.filter(d=>d.status==="pass").length,r=this.dynamicResults.filter(d=>d.status==="fail").length,i=this.dynamicResults.filter(d=>d.status==="warn").length;this.skipped=this.dynamicResults.filter(d=>d.status==="skip").length,this.warnings=this.staticWarnings+i;let n=this.staticPasses+s,o=this.staticFailures+r,l=n+o+this.warnings,p=()=>{let d=`${this.componentName.charAt(0).toUpperCase()}${this.componentName.slice(1)}`;return this.isCustomContract?`${d} component validates against your custom accessibility policy \u2713`:`${d} component meets Aria-Ease baseline WAI-ARIA expectations \u2713`};return e.length>0&&this.reportFailures(e),this.reportWarnings(),this.reportSkipped(),this.log(`
|
|
25
25
|
${"\u2550".repeat(60)}`),this.log(`\u{1F4CA} Summary
|
|
26
26
|
`),o===0&&this.skipped===0&&this.warnings===0?(this.log(`\u2705 All ${l} tests passed!`),this.log(` ${p()}`)):o===0?(this.log(`\u2705 ${n}/${l} tests passed`),this.skipped>0&&this.log(`\u25CB ${this.skipped} tests skipped`),this.warnings>0&&this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings>1?"s":""}`),this.log(` ${p()}`)):(this.log(`\u274C ${o} test${o>1?"s":""} failed`),this.log(`\u2705 ${n} test${n>1?"s":""} passed`),this.warnings>0&&this.log(`\u26A0\uFE0F ${this.warnings} warning${this.warnings>1?"s":""}`),this.skipped>0&&this.log(`\u25CB ${this.skipped} test${this.skipped>1?"s":""} skipped`)),this.log(`\u23F1\uFE0F Duration: ${t}ms`),this.log(`${"\u2550".repeat(60)}
|
|
27
27
|
`),o>0?(this.log("\u{1F527} Next Steps:"),this.log(" 1. Review the failures above"),this.log(" 2. Fix ARIA attributes and keyboard handlers"),this.log(` 3. Re-run tests to verify fixes
|
|
28
28
|
`)):!this.isPlaywright&&this.skipped>0&&this.log(`\u2728 Optional: Run Playwright tests for complete validation
|
|
29
29
|
`),{passes:n,failures:o,skipped:this.skipped,duration:t}}error(e,t){this.log(`
|
|
30
|
-
\u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("")}}});var Rt={};ie(Rt,{RelativeTargetResolver:()=>oe});var oe,He=Q(()=>{"use strict";oe=class{static async resolve(e,t,s){let r=await e.locator(t).all();switch(s){case"first":return r[0];case"second":return r[1];case"last":return r[r.length-1];case"next":{let n=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])+1)%r.length;return r[n]}case"previous":{let n=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])-1+r.length)%r.length;return r[n]}default:return null}}}});var de,Ht=Q(()=>{"use strict";He();de=class{constructor(e,t,s=400){this.page=e;this.selectors=t;this.timeoutMs=s}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,t,s){try{if(e==="virtual"&&s){let i=this.selectors.main;if(!i)return{success:!1,error:"Main selector not defined for virtual focus."};let n=this.page.locator(i).first();return await n.count()?(await n.evaluate((l,p)=>{l.setAttribute("aria-activedescendant",p)},s),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return{success:!1,error:"Relative selector not defined for focus action."};let n=await oe.resolve(this.page,i,t);return n?(await n.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to focus ${e}: ${r instanceof Error?r.message:String(r)}`}}}async type(e,t){try{let s=this.selectors[e];return s?(await this.page.locator(s).first().fill(t,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to type into ${e}: ${s instanceof Error?s.message:String(s)}`}}}async click(e,t){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&t){let r=this.selectors.relative;if(!r)return{success:!1,error:"Relative selector not defined for click action."};let i=await oe.resolve(this.page,r,t);return i?(await i.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for click.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to click ${e}: ${s instanceof Error?s.message:String(s)}`}}}async keypress(e,t){try{let r={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[t]||t;if(r==="Space"?r=" ":r.includes(" ")&&(r=r.replace(/ /g,"")),e==="focusable"&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Home","End","Tab","Shift+Tab"].includes(r))return await this.page.keyboard.press(r),{success:!0};let i=this.selectors[e];if(!i)return{success:!1,error:`Selector for keypress target ${e} not found.`};let n=this.page.locator(i).first();return await n.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await n.press(r,{timeout:this.timeoutMs}),{success:!0})}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to press ${t} on ${e}: ${s instanceof Error?s.message:String(s)}`}}}async hover(e,t){try{if(e==="relative"&&t){let r=this.selectors.relative;if(!r)return{success:!1,error:"Relative selector not defined for hover action."};let i=await oe.resolve(this.page,r,t);return i?(await i.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for hover.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to hover ${e}: ${s instanceof Error?s.message:String(s)}`}}}}});var ye,Pt=Q(()=>{"use strict";be();He();ye=class{constructor(e,t,s=400){this.page=e;this.selectors=t;this.timeoutMs=s}async resolveTarget(e,t,s){try{if(e==="relative"){let i=s?this.selectors[s]:this.selectors.relative;if(!i)return{target:null,error:"Relative selector is not defined in the contract."};if(!t)return{target:null,error:"Relative target or expected value is not defined."};let n=await oe.resolve(this.page,i,t);return n?{target:n}:{target:null,error:`Target ${e} not found.`}}let r=this.selectors[e];return r?{target:this.page.locator(r).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(r){return{target:null,error:`Failed to resolve target ${e}: ${r instanceof Error?r.message:String(r)}`}}}async validateVisibility(e,t,s,r,i){try{return s?(await(0,G.expect)(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${i}".`}):(await(0,G.expect)(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${i}".`})}catch{let n=this.selectors[t]||"",o=await this.page.evaluate(l=>{let p=l?document.querySelector(l):null;if(!p)return"element not found";let g=window.getComputedStyle(p);return`display:${g.display}, visibility:${g.visibility}, opacity:${g.opacity}`},n);return s?{success:!1,failMessage:`${r} (actual: ${o})`}:{success:!1,failMessage:`${r} ${t} is still visible (actual: ${o}).`}}}async validateAttribute(e,t,s,r,i,n){if(r==="!empty"){let p=await e.getAttribute(s);return p&&p.trim()!==""?{success:!0,passMessage:`${t} has non-empty "${s}". Test: "${n}".`}:{success:!1,failMessage:`${i} ${t} "${s}" should not be empty, found "${p}".`}}if(typeof r!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",r),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(r)}`);let o=r.split(" | ").map(p=>p.trim()),l=await e.getAttribute(s);return l!==null&&o.includes(l)?{success:!0,passMessage:`${t} has expected "${s}". Test: "${n}".`}:{success:!1,failMessage:`${i} ${t} "${s}" should be "${r}", found "${l}".`}}async validateValue(e,t,s,r,i){let n=await e.inputValue().catch(()=>"");return s==="!empty"?n&&n.trim()!==""?{success:!0,passMessage:`${t} has non-empty value. Test: "${i}".`}:{success:!1,failMessage:`${r} ${t} value should not be empty, found "${n}".`}:s===""?n===""?{success:!0,passMessage:`${t} has empty value. Test: "${i}".`}:{success:!1,failMessage:`${r} ${t} value should be empty, found "${n}".`}:n===s?{success:!0,passMessage:`${t} has expected value. Test: "${i}".`}:{success:!1,failMessage:`${r} ${t} value should be "${s}", found "${n}".`}}async validateFocus(e,t,s,r,i){try{return s?(await(0,G.expect)(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${i}".`}):(await(0,G.expect)(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${i}".`})}catch{let n=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return{success:!1,failMessage:`${r} (actual focus: ${n})`}}}async validateRole(e,t,s,r,i){let n=await e.getAttribute("role");return n===s?{success:!0,passMessage:`${t} has role "${s}". Test: "${i}".`}:{success:!1,failMessage:`${r} Expected role "${s}", found "${n}".`}}async validate(e,t){if(this.page.isClosed())return{success:!1,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let{target:s,error:r}=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r||!s)return{success:!1,failMessage:r||`Target ${e.target} not found.`,target:null};if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let i=await oe.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),n=i?await i.getAttribute("id"):null,o=await s.getAttribute("aria-activedescendant");return n&&o===n?{success:!0,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:!1,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case"toBeVisible":return this.validateVisibility(s,e.target,!0,e.failureMessage||"",t);case"notToBeVisible":return this.validateVisibility(s,e.target,!1,e.failureMessage||"",t);case"toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(s,e.target,e.attribute,e.expectedValue,e.failureMessage||"",t):{success:!1,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case"toHaveValue":return e.expectedValue!==void 0?this.validateValue(s,e.target,e.expectedValue,e.failureMessage||"",t):{success:!1,failMessage:"Missing expectedValue for toHaveValue assertion"};case"toHaveFocus":return this.validateFocus(s,e.target,!0,e.failureMessage||"",t);case"notToHaveFocus":return this.validateFocus(s,e.target,!1,e.failureMessage||"",t);case"toHaveRole":return e.expectedValue!==void 0?this.validateRole(s,e.target,e.expectedValue,e.failureMessage||"",t):{success:!1,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return{success:!1,failMessage:`Unknown assertion type: ${e.assertion}`}}}}});var It={};ie(It,{runContractTestsPlaywright:()=>Is});async function Is(c,e,t,s,r){let i=s?.test?.components?.find(u=>u.name===c),n=!!i?.contractPath,o=new Re(!0,n),l={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},p=s?.test?.disableTimeouts===!0,E=i?.disableTimeouts===!0||p,M=(u,y,x)=>{if(E)return 0;let I=u??y;return typeof I!="number"||!Number.isFinite(I)||I<0?x:I},D=M(i?.actionTimeoutMs,s?.test?.actionTimeoutMs,l.actionTimeoutMs),O=M(i?.assertionTimeoutMs,s?.test?.assertionTimeoutMs,l.assertionTimeoutMs),K=M(i?.navigationTimeoutMs,s?.test?.navigationTimeoutMs,l.navigationTimeoutMs),f=M(i?.componentReadyTimeoutMs,s?.test?.componentReadyTimeoutMs,l.componentReadyTimeoutMs),m=he(t),$=i?.contractPath;if(!$)throw new Error(`Contract path not found for component: ${c}`);let U=(()=>{if(Ie.default.isAbsolute($))return $;if(r){let y=Ie.default.resolve(r,$);try{return(0,Pe.readFileSync)(y,"utf-8"),y}catch{}}let u=Ie.default.resolve(process.cwd(),$);try{return(0,Pe.readFileSync)(u,"utf-8"),u}catch{return new URL($,Ds.url).pathname}})(),A=(0,Pe.readFileSync)(U,"utf-8"),w=JSON.parse(A),B=(w.relationships?.length||0)+(w.static[0]?.assertions.length||0)+w.dynamic.length,b=w.meta?.source?.apg,S=[],d=[],h=[],k=[],T=null,N=(u,y)=>{let x=fe(y),I=mt(x,m);if(I==="error")return S.push(u),{status:"fail",level:x,detail:u};if(I==="warning")return d.push(u),{status:"warn",level:x,detail:u};let z=`${u} (ignored by strictness=${m}, level=${x})`;return k.push(z),{status:"skip",level:x,detail:z}};try{if(T=await dt(),e){try{await T.goto(e,{waitUntil:"domcontentloaded",timeout:K})}catch(a){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${a instanceof Error?a.message:String(a)}`)}await T.addStyleTag({content:"* { transition: none !important; animation: none !important; }"})}let u=await Le.detect(c,i,D,O,r);if(!u)throw new Error(`Unsupported component: ${c}`);let y=u.getMainSelector();if(!y)throw new Error(`CRITICAL: No selector found in contract for ${c}`);try{await T.locator(y).first().waitFor({state:"attached",timeout:f})}catch(a){throw new Error(`
|
|
30
|
+
\u274C Error: ${e}`),t&&this.log(` Context: ${t}`),this.log("")}}});var Rt={};oe(Rt,{RelativeTargetResolver:()=>ae});var ae,Pe=Q(()=>{"use strict";ae=class{static async resolve(e,t,s){let r=await e.locator(t).all();switch(s){case"first":return r[0];case"second":return r[1];case"last":return r[r.length-1];case"next":{let n=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])+1)%r.length;return r[n]}case"previous":{let n=(await e.evaluate(([o])=>Array.from(document.querySelectorAll(o)).indexOf(document.activeElement),[t])-1+r.length)%r.length;return r[n]}default:return null}}}});var de,Pt=Q(()=>{"use strict";Pe();de=class{constructor(e,t,s=400){this.page=e;this.selectors=t;this.timeoutMs=s}isBrowserClosedError(e){return e instanceof Error&&e.message.includes("Target page, context or browser has been closed")}async focus(e,t,s){try{if(e==="virtual"&&s){let i=this.selectors.main;if(!i)return{success:!1,error:"Main selector not defined for virtual focus."};let n=this.page.locator(i).first();return await n.count()?(await n.evaluate((l,p)=>{l.setAttribute("aria-activedescendant",p)},s),{success:!0}):{success:!1,error:"Main element not found for virtual focus."}}if(e==="relative"&&t){let i=this.selectors.relative;if(!i)return{success:!1,error:"Relative selector not defined for focus action."};let n=await ae.resolve(this.page,i,t);return n?(await n.focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for focus.`}}let r=this.selectors[e];return r?(await this.page.locator(r).first().focus({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for focus target ${e} not found.`}}catch(r){return this.isBrowserClosedError(r)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to focus ${e}: ${r instanceof Error?r.message:String(r)}`}}}async type(e,t){try{let s=this.selectors[e];return s?(await this.page.locator(s).first().fill(t,{timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for type target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to type into ${e}: ${s instanceof Error?s.message:String(s)}`}}}async click(e,t){try{if(e==="document")return await this.page.mouse.click(10,10),{success:!0};if(e==="relative"&&t){let r=this.selectors.relative;if(!r)return{success:!1,error:"Relative selector not defined for click action."};let i=await ae.resolve(this.page,r,t);return i?(await i.click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for click.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().click({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for action target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to click ${e}: ${s instanceof Error?s.message:String(s)}`}}}async keypress(e,t){try{let r={Space:"Space",Enter:"Enter",Escape:"Escape","Arrow Up":"ArrowUp","Arrow Down":"ArrowDown","Arrow Left":"ArrowLeft","Arrow Right":"ArrowRight",Home:"Home",End:"End",Tab:"Tab"}[t]||t;if(r==="Space"?r=" ":r.includes(" ")&&(r=r.replace(/ /g,"")),e==="focusable"&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Home","End","Tab","Shift+Tab"].includes(r))return await this.page.keyboard.press(r),{success:!0};let i=this.selectors[e];if(!i)return{success:!1,error:`Selector for keypress target ${e} not found.`};let n=this.page.locator(i).first();return await n.count()===0?{success:!1,error:`${e} element not found.`,shouldBreak:!0}:(await n.press(r,{timeout:this.timeoutMs}),{success:!0})}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to press ${t} on ${e}: ${s instanceof Error?s.message:String(s)}`}}}async hover(e,t){try{if(e==="relative"&&t){let r=this.selectors.relative;if(!r)return{success:!1,error:"Relative selector not defined for hover action."};let i=await ae.resolve(this.page,r,t);return i?(await i.hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Could not resolve relative target ${t} for hover.`}}let s=this.selectors[e];return s?(await this.page.locator(s).first().hover({timeout:this.timeoutMs}),{success:!0}):{success:!1,error:`Selector for hover target ${e} not found.`}}catch(s){return this.isBrowserClosedError(s)?{success:!1,error:"CRITICAL: Browser/page closed during test execution. Remaining actions skipped.",shouldBreak:!0}:{success:!1,error:`Failed to hover ${e}: ${s instanceof Error?s.message:String(s)}`}}}}});var ye,Ht=Q(()=>{"use strict";be();Pe();ye=class{constructor(e,t,s=400){this.page=e;this.selectors=t;this.timeoutMs=s}async resolveTarget(e,t,s){try{if(e==="relative"){let i=s?this.selectors[s]:this.selectors.relative;if(!i)return{target:null,error:"Relative selector is not defined in the contract."};if(!t)return{target:null,error:"Relative target or expected value is not defined."};let n=await ae.resolve(this.page,i,t);return n?{target:n}:{target:null,error:`Target ${e} not found.`}}let r=this.selectors[e];return r?{target:this.page.locator(r).first()}:{target:null,error:`Selector for assertion target ${e} not found.`}}catch(r){return{target:null,error:`Failed to resolve target ${e}: ${r instanceof Error?r.message:String(r)}`}}}async validateVisibility(e,t,s,r,i){try{return s?(await(0,G.expect)(e).toBeVisible({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is visible as expected. Test: "${i}".`}):(await(0,G.expect)(e).toBeHidden({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} is not visible as expected. Test: "${i}".`})}catch{let n=this.selectors[t]||"",o=await this.page.evaluate(l=>{let p=l?document.querySelector(l):null;if(!p)return"element not found";let d=window.getComputedStyle(p);return`display:${d.display}, visibility:${d.visibility}, opacity:${d.opacity}`},n);return s?{success:!1,failMessage:`${r} (actual: ${o})`}:{success:!1,failMessage:`${r} ${t} is still visible (actual: ${o}).`}}}async validateAttribute(e,t,s,r,i,n){if(r==="!empty"){let p=await e.getAttribute(s);return p&&p.trim()!==""?{success:!0,passMessage:`${t} has non-empty "${s}". Test: "${n}".`}:{success:!1,failMessage:`${i} ${t} "${s}" should not be empty, found "${p}".`}}if(typeof r!="string")throw console.error("[AssertionRunner] expectedValue is not a string:",r),new Error(`AssertionRunner: expectedValue for attribute assertion must be a string, but got: ${JSON.stringify(r)}`);let o=r.split(" | ").map(p=>p.trim()),l=await e.getAttribute(s);return l!==null&&o.includes(l)?{success:!0,passMessage:`${t} has expected "${s}". Test: "${n}".`}:{success:!1,failMessage:`${i} ${t} "${s}" should be "${r}", found "${l}".`}}async validateValue(e,t,s,r,i){let n=await e.inputValue().catch(()=>"");return s==="!empty"?n&&n.trim()!==""?{success:!0,passMessage:`${t} has non-empty value. Test: "${i}".`}:{success:!1,failMessage:`${r} ${t} value should not be empty, found "${n}".`}:s===""?n===""?{success:!0,passMessage:`${t} has empty value. Test: "${i}".`}:{success:!1,failMessage:`${r} ${t} value should be empty, found "${n}".`}:n===s?{success:!0,passMessage:`${t} has expected value. Test: "${i}".`}:{success:!1,failMessage:`${r} ${t} value should be "${s}", found "${n}".`}}async validateFocus(e,t,s,r,i){try{return s?(await(0,G.expect)(e).toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} has focus as expected. Test: "${i}".`}):(await(0,G.expect)(e).not.toBeFocused({timeout:this.timeoutMs}),{success:!0,passMessage:`${t} does not have focus as expected. Test: "${i}".`})}catch{let n=await this.page.evaluate(()=>{let o=document.activeElement;return o?`${o.tagName}#${o.id||"no-id"}.${o.className||"no-class"}`:"no element focused"});return{success:!1,failMessage:`${r} (actual focus: ${n})`}}}async validateRole(e,t,s,r,i){let n=await e.getAttribute("role");return n===s?{success:!0,passMessage:`${t} has role "${s}". Test: "${i}".`}:{success:!1,failMessage:`${r} Expected role "${s}", found "${n}".`}}async validate(e,t){if(this.page.isClosed())return{success:!1,failMessage:"CRITICAL: Browser/page closed before completing all tests. Increase test timeout or reduce test complexity."};let{target:s,error:r}=await this.resolveTarget(e.target,e.relativeTarget||e.expectedValue,e.selectorKey);if(r||!s)return{success:!1,failMessage:r||`Target ${e.target} not found.`,target:null};if(e.target==="input"&&e.attribute==="aria-activedescendant"&&e.expectedValue==="!empty"&&e.relativeTarget&&e.selectorKey){let i=await ae.resolve(this.page,this.selectors[e.selectorKey],e.relativeTarget),n=i?await i.getAttribute("id"):null,o=await s.getAttribute("aria-activedescendant");return n&&o===n?{success:!0,passMessage:`input[aria-activedescendant] matches id of ${e.relativeTarget}(${e.selectorKey}). Test: "${t}".`}:{success:!1,failMessage:`input[aria-activedescendant] should match id of ${e.relativeTarget}(${e.selectorKey}), found "${o}".`}}switch(e.assertion){case"toBeVisible":return this.validateVisibility(s,e.target,!0,e.failureMessage||"",t);case"notToBeVisible":return this.validateVisibility(s,e.target,!1,e.failureMessage||"",t);case"toHaveAttribute":return e.attribute&&e.expectedValue!==void 0?this.validateAttribute(s,e.target,e.attribute,e.expectedValue,e.failureMessage||"",t):{success:!1,failMessage:"Missing attribute or expectedValue for toHaveAttribute assertion"};case"toHaveValue":return e.expectedValue!==void 0?this.validateValue(s,e.target,e.expectedValue,e.failureMessage||"",t):{success:!1,failMessage:"Missing expectedValue for toHaveValue assertion"};case"toHaveFocus":return this.validateFocus(s,e.target,!0,e.failureMessage||"",t);case"notToHaveFocus":return this.validateFocus(s,e.target,!1,e.failureMessage||"",t);case"toHaveRole":return e.expectedValue!==void 0?this.validateRole(s,e.target,e.expectedValue,e.failureMessage||"",t):{success:!1,failMessage:"Missing expectedValue for toHaveRole assertion"};default:return{success:!1,failMessage:`Unknown assertion type: ${e.assertion}`}}}}});var It={};oe(It,{runContractTestsPlaywright:()=>Is});async function Is(a,e,t,s,r){let i=s?.test?.components?.find(u=>u.name===a),n=!!i?.contractPath,o=new Re(!0,n),l={actionTimeoutMs:400,assertionTimeoutMs:400,navigationTimeoutMs:3e4,componentReadyTimeoutMs:5e3},p=s?.test?.disableTimeouts===!0,T=i?.disableTimeouts===!0||p,M=(u,b,x)=>{if(T)return 0;let q=u??b;return typeof q!="number"||!Number.isFinite(q)||q<0?x:q},H=M(i?.actionTimeoutMs,s?.test?.actionTimeoutMs,l.actionTimeoutMs),_=M(i?.assertionTimeoutMs,s?.test?.assertionTimeoutMs,l.assertionTimeoutMs),W=M(i?.navigationTimeoutMs,s?.test?.navigationTimeoutMs,l.navigationTimeoutMs),f=M(i?.componentReadyTimeoutMs,s?.test?.componentReadyTimeoutMs,l.componentReadyTimeoutMs),m=he(t),S=i?.contractPath;if(!S)throw new Error(`Contract path not found for component: ${a}`);let U=(()=>{if(Ie.default.isAbsolute(S))return S;if(r){let b=Ie.default.resolve(r,S);try{return(0,He.readFileSync)(b,"utf-8"),b}catch{}}let u=Ie.default.resolve(process.cwd(),S);try{return(0,He.readFileSync)(u,"utf-8"),u}catch{return new URL(S,Ds.url).pathname}})(),A=(0,He.readFileSync)(U,"utf-8"),v=JSON.parse(A),F=(v.relationships?.length||0)+(v.static[0]?.assertions.length||0)+v.dynamic.length,y=v.meta?.source?.apg,E=[],C=[],g=[],k=[],h=null,D=(u,b)=>{let x=fe(b),q=mt(x,m);if(q==="error")return E.push(u),{status:"fail",level:x,detail:u};if(q==="warning")return C.push(u),{status:"warn",level:x,detail:u};let z=`${u} (ignored by strictness=${m}, level=${x})`;return k.push(z),{status:"skip",level:x,detail:z}};try{if(h=await dt(),e){try{await h.goto(e,{waitUntil:"domcontentloaded",timeout:W})}catch(c){throw new Error(`Failed to navigate to ${e}. Ensure dev server is running and accessible. Original error: ${c instanceof Error?c.message:String(c)}`)}await h.addStyleTag({content:"* { transition: none !important; animation: none !important; }"})}let u=await Le.detect(a,i,H,_,r);if(!u)throw new Error(`Unsupported component: ${a}`);let b=u.getMainSelector();if(!b)throw new Error(`CRITICAL: No selector found in contract for ${a}`);try{await h.locator(b).first().waitFor({state:"attached",timeout:f})}catch(c){throw new Error(`
|
|
31
31
|
\u274C CRITICAL: Component not found on page!
|
|
32
32
|
This usually means:
|
|
33
33
|
- The component didn't render
|
|
34
34
|
- The URL is incorrect
|
|
35
|
-
- The component selector '${
|
|
36
|
-
- Original error: ${a}`)}o.start(c,B,b),c==="menu"&&w.selectors.main&&await T.locator(w.selectors.main).first().waitFor({state:"visible",timeout:f}).catch(()=>{});let x=c==="menu"&&w.selectors.submenuTrigger?await T.locator(w.selectors.submenuTrigger).count()>0:!1,I=a=>a.type==="aria-reference"&&[a.from,a.to].some(L=>["submenu","submenuTrigger","submenuItems"].includes(L||""))||a.type==="contains"&&[a.parent,a.child].some(L=>["submenu","submenuTrigger","submenuItems"].includes(L||"")),z=0,Z=0,ee=0;for(let a of w.relationships||[]){if(u&&typeof u.resetState=="function")try{await u.resetState(T)}catch(P){d.push(`Warning: resetState failed before relationship test: ${P instanceof Error?P.message:String(P)}`)}let L=fe(a.level);if(Array.isArray(a.setup)&&a.setup.length>0){let W=function(v){return _.includes(v)};var ae=W;let P=new de(T,w.selectors,D),j=a.type==="aria-reference"?`${a.from}.${a.attribute} references ${a.to}`:`${a.parent} contains ${a.child}`,_=["focus","type","click","keypress","hover"],F=v=>({...v,type:W(v.type)?v.type:"click"}),V=a.setup.map(F),R=await qe(V,P,u,T,j,["submenu","submenuTrigger","submenuItems"]);if(R.skip){k.push(R.message||"Setup action skipped"),o.reportStaticTest(j,"skip",R.message,L);continue}if(!R.success){let v=`Relationship setup failed: ${R.error}`,H=N(v,a.level);H.status==="fail"&&(Z+=1),H.status==="warn"&&(ee+=1),o.reportStaticTest(j,H.status,H.detail,H.level);continue}}if(c==="menu"&&!x&&I(a)){let j=a.type==="aria-reference"?`${a.from}.${a.attribute} references ${a.to}`:`${a.parent} contains ${a.child}`,_="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";k.push(_),o.reportStaticTest(j,"skip",_,L);continue}if(a.type==="aria-reference"){let P=`${a.from}.${a.attribute} references ${a.to}`,j=w.selectors[a.from],_=w.selectors[a.to];if(!j||!_){let q=N(`Relationship selector missing: from="${a.from}" or to="${a.to}" not found in selectors.`,a.level);q.status==="fail"&&(Z+=1),q.status==="warn"&&(ee+=1),o.reportStaticTest(P,q.status,q.detail,q.level);continue}let W=T.locator(j).first(),F=T.locator(_).first(),V=await W.count()>0,R=await F.count()>0;if(!V||!R){if(c==="menu"&&I(a)){let me="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";k.push(me),o.reportStaticTest(P,"skip",me,L);continue}let q=N(`Relationship target not found: ${V?a.to:a.from}.`,a.level);q.status==="fail"&&(Z+=1),q.status==="warn"&&(ee+=1),o.reportStaticTest(P,q.status,q.detail,q.level);continue}let v=await W.getAttribute(a.attribute),H=await F.getAttribute("id");if(!H){let q=N(`Relationship target "${a.to}" must have an id for ${a.attribute} validation.`,a.level);q.status==="fail"&&(Z+=1),q.status==="warn"&&(ee+=1),o.reportStaticTest(P,q.status,q.detail,q.level);continue}if(!(v||"").split(/\s+/).filter(Boolean).includes(H)){let q=N(`Expected ${a.from} ${a.attribute} to reference id "${H}", found "${v||""}".`,a.level);q.status==="fail"&&(Z+=1),q.status==="warn"&&(ee+=1),o.reportStaticTest(P,q.status,q.detail,q.level);continue}h.push(`Relationship valid: ${a.from}.${a.attribute} -> ${a.to} (id=${H}).`),z+=1,o.reportStaticTest(P,"pass",void 0,L);continue}if(a.type==="contains"){let P=`${a.parent} contains ${a.child}`,j=w.selectors[a.parent],_=w.selectors[a.child];if(!j||!_){let v=N(`Relationship selector missing: parent="${a.parent}" or child="${a.child}" not found in selectors.`,a.level);v.status==="fail"&&(Z+=1),v.status==="warn"&&(ee+=1),o.reportStaticTest(P,v.status,v.detail,v.level);continue}let W=T.locator(j).first();if(!(await W.count()>0)){if(c==="menu"&&I(a)){let H="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";k.push(H),o.reportStaticTest(P,"skip",H,L);continue}let v=N(`Relationship parent target not found: ${a.parent}.`,a.level);v.status==="fail"&&(Z+=1),v.status==="warn"&&(ee+=1),o.reportStaticTest(P,v.status,v.detail,v.level);continue}if(await W.locator(_).count()<1){if(c==="menu"&&I(a)){let H="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";k.push(H),o.reportStaticTest(P,"skip",H,L);continue}let v=N(`Expected ${a.parent} to contain descendant matching selector for ${a.child}.`,a.level);v.status==="fail"&&(Z+=1),v.status==="warn"&&(ee+=1),o.reportStaticTest(P,v.status,v.detail,v.level);continue}h.push(`Relationship valid: ${a.parent} contains ${a.child}.`),z+=1,o.reportStaticTest(P,"pass",void 0,L)}}async function tt(a,L,P,j={}){if(!a||typeof a!="object"||!("ref"in a))return a;let _;if(a.ref==="relative"){if(!a.relativeTarget||!j.relativeBaseSelector)return;let W=P.locator(j.relativeBaseSelector),F=await W.count(),V=0;if(a.relativeTarget==="first"?V=0:a.relativeTarget==="second"?V=1:a.relativeTarget==="last"?V=F-1:isNaN(Number(a.relativeTarget))?V=0:V=Number(a.relativeTarget),V<0||V>=F)return;let R=W.nth(V);return await st(R,a.property||a.attribute)}else{if(_=L[a.ref],!_)throw new Error(`Selector for ref '${a.ref}' not found in contract selectors.`);let W=P.locator(_).first();return await st(W,a.property||a.attribute)}}async function st(a,L){if(a)return!L||L==="id"?await a.getAttribute("id")??void 0:L==="class"?await a.getAttribute("class")??void 0:L==="textContent"?await a.evaluate(P=>P.textContent??void 0):L.startsWith("aria-")?await a.getAttribute(L)??void 0:L.endsWith("*")?await a.evaluate(j=>{let _=[];for(let W of Array.from(j.attributes))W.name.startsWith("aria-")&&_.push(`${W.name}=${W.value}`);return _.join(";")}):await a.getAttribute(L)??void 0}let Nt=new ye(T,w.selectors,O);async function qe(a,L,P,j,_,W=[]){if(!Array.isArray(a)||a.length===0)return{success:!0};P&&typeof P.resetState=="function"&&await P.resetState(j);for(let F of a){let V={success:!0};try{if(F.type==="focus")F.target==="relative"&&F.relativeTarget?V=await L.focus("relative",F.relativeTarget):V=await L.focus(F.target);else if(F.type==="type"&&F.value)V=await L.type(F.target,F.value);else if(F.type==="click")V=await L.click(F.target,F.relativeTarget);else if(F.type==="keypress"&&F.key)V=await L.keypress(F.target,F.key);else if(F.type==="hover")V=await L.hover(F.target,F.relativeTarget);else continue}catch(R){V={success:!1,error:R instanceof Error?R.message:String(R)}}if(!V.success){let R=V.error||"Setup action failed";return W.some(H=>_.includes(H)||R.includes(H))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${R}`}:{success:!1,error:R}}}return{success:!0}}for(let a of w.static[0]?.assertions||[]){if(u&&typeof u.resetState=="function")try{await u.resetState(T)}catch(R){d.push(`Warning: resetState failed before static test: ${R instanceof Error?R.message:String(R)}`)}if(a.target==="relative")continue;let L=`${a.target}${a.attribute?` (${a.attribute})`:""}`,P=fe(a.level);if(c==="menu"&&a.target==="submenuTrigger"&&!x){let R=`Skipping submenu static assertion for ${a.target}: no submenu capability detected in rendered component.`;k.push(R),o.reportStaticTest(L,"skip",R,P);continue}if(Array.isArray(a.setup)&&a.setup.length>0){let H=function(ce){return v.includes(ce)};var ae=H;let R=new de(T,w.selectors,D),v=["focus","type","click","keypress","hover"],se=ce=>({...ce,type:H(ce.type)?ce.type:"click"}),X=a.setup.map(se),q=await qe(X,R,u,T,L,["submenu","submenuTrigger","submenuItems"]);if(q.skip){k.push(q.message||"Setup action skipped"),o.reportStaticTest(L,"skip",q.message,P);continue}if(!q.success){let ce=`Static setup failed: ${q.error}`,C=N(ce,a.level);C.status==="fail"&&(Z+=1),C.status==="warn"&&(ee+=1),o.reportStaticTest(L,C.status,C.detail,C.level);continue}}let j=w.selectors[a.target];if(!j){let R=`Selector for target ${a.target} not found.`,v=N(R,a.level);v.status==="fail"&&(Z+=1),v.status==="warn"&&(ee+=1),o.reportStaticTest(L,v.status,v.detail,v.level);continue}let _=T.locator(j).first();if(!(await _.count()>0)){let R=`Target ${a.target} not found.`,v=N(R,a.level);v.status==="fail"&&(Z+=1),v.status==="warn"&&(ee+=1),o.reportStaticTest(L,v.status,v.detail,v.level);continue}let F=(R,v,H)=>{let se=new RegExp(`\\[${v}(?:=["']?([^\\]"']+)["']?)?\\]`),X=R.match(se);if(!X)return!1;if(!H)return!0;let q=X[1];return q?H.split(" | ").includes(q):!1},V=a.expectedValue;if(a.expectedValue&&typeof a.expectedValue=="object"&&"ref"in a.expectedValue){let R={},v=a.relativeTarget;if(a.expectedValue.ref==="relative"&&a.target==="relative"&&v){let H=w.selectors[v];if(!H)throw new Error(`Selector for relativeTarget '${v}' not found in contract selectors.`);R.relativeBaseSelector=H}else if(a.expectedValue.ref==="relative"&&v){let H=w.selectors[v];if(!H)throw new Error(`Selector for relativeTarget '${v}' not found in contract selectors.`);R.relativeBaseSelector=H}V=await tt(a.expectedValue,w.selectors,T,R),console.log("Expected value in static check",V)}if(a.expectedValue)if(F(j,a.attribute,typeof V=="string"?V:void 0))h.push(`${a.attribute}="${V}" on ${a.target} verified by selector (already present in: ${j}).`),z+=1,o.reportStaticTest(L,"pass",void 0,P);else{let R=V??"",v=await Nt.validateAttribute(_,a.target,a.attribute,R,a.failureMessage,"Static ARIA Test");if(v.success&&v.passMessage)h.push(v.passMessage),z+=1,o.reportStaticTest(L,"pass",void 0,P);else if(!v.success&&v.failMessage){let H=N(v.failMessage,a.level);H.status==="fail"&&(Z+=1),H.status==="warn"&&(ee+=1),o.reportStaticTest(L,H.status,H.detail,H.level)}}else{let R=a.attribute.split(" | "),v=!1,H=!0;for(let se of R){let X=se.trim();if(F(j,X)){h.push(`${X} on ${a.target} verified by selector (already present in: ${j}).`),v=!0;continue}if(H=!1,await _.getAttribute(X)!==null){v=!0;break}}if(!v&&!H){let se=a.failureMessage+` None of the attributes "${a.attribute}" are present.`,X=N(se,a.level);X.status==="fail"&&(Z+=1),X.status==="warn"&&(ee+=1),o.reportStaticTest(L,X.status,X.detail,X.level)}else!H&&v?(h.push(`At least one of the attributes "${a.attribute}" exists on the element.`),z+=1,o.reportStaticTest(L,"pass",void 0,P)):(z+=1,o.reportStaticTest(L,"pass",void 0,P))}}for(let a of w.dynamic||[]){if(!T||T.isClosed()){console.warn(`
|
|
37
|
-
\u26A0\uFE0F Browser closed - skipping remaining ${
|
|
38
|
-
`),
|
|
35
|
+
- The component selector '${b}' in the contract is wrong
|
|
36
|
+
- Original error: ${c}`)}o.start(a,F,y),a==="menu"&&v.selectors.main&&await h.locator(v.selectors.main).first().waitFor({state:"visible",timeout:f}).catch(()=>{});let x=a==="menu"&&v.selectors.submenuTrigger?await h.locator(v.selectors.submenuTrigger).count()>0:!1,q=c=>c.type==="aria-reference"&&[c.from,c.to].some(L=>["submenu","submenuTrigger","submenuItems"].includes(L||""))||c.type==="contains"&&[c.parent,c.child].some(L=>["submenu","submenuTrigger","submenuItems"].includes(L||"")),z=0,ee=0,te=0;for(let c of v.relationships||[]){if(u&&typeof u.resetState=="function")try{await u.resetState(h)}catch(I){C.push(`Warning: resetState failed before relationship test: ${I instanceof Error?I.message:String(I)}`)}let L=fe(c.level);if(Array.isArray(c.setup)&&c.setup.length>0){let j=function(w){return N.includes(w)};var Z=j;let I=new de(h,v.selectors,H),K=c.type==="aria-reference"?`${c.from}.${c.attribute} references ${c.to}`:`${c.parent} contains ${c.child}`,N=["focus","type","click","keypress","hover"],V=w=>({...w,type:j(w.type)?w.type:"click"}),O=c.setup.map(V),R=await qe(O,I,u,h,K,["submenu","submenuTrigger","submenuItems"]);if(R.skip){k.push(R.message||"Setup action skipped"),o.reportStaticTest(K,"skip",R.message,L);continue}if(!R.success){let w=`Relationship setup failed: ${R.error}`,P=D(w,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(K,P.status,P.detail,P.level);continue}}if(a==="menu"&&!x&&q(c)){let K=c.type==="aria-reference"?`${c.from}.${c.attribute} references ${c.to}`:`${c.parent} contains ${c.child}`,N="Skipping submenu relationship assertion: no submenu capability detected in rendered component.";k.push(N),o.reportStaticTest(K,"skip",N,L);continue}if(c.type==="aria-reference"){let I=`${c.from}.${c.attribute} references ${c.to}`,K=v.selectors[c.from],N=v.selectors[c.to];if(!K||!N){let B=D(`Relationship selector missing: from="${c.from}" or to="${c.to}" not found in selectors.`,c.level);B.status==="fail"&&(ee+=1),B.status==="warn"&&(te+=1),o.reportStaticTest(I,B.status,B.detail,B.level);continue}let j=h.locator(K).first(),V=h.locator(N).first(),O=await j.count()>0,R=await V.count()>0;if(!O||!R){if(a==="menu"&&q(c)){let me="Skipping submenu relationship assertion in static phase: submenu elements are not present until submenu is opened.";k.push(me),o.reportStaticTest(I,"skip",me,L);continue}let B=D(`Relationship target not found: ${O?c.to:c.from}.`,c.level);B.status==="fail"&&(ee+=1),B.status==="warn"&&(te+=1),o.reportStaticTest(I,B.status,B.detail,B.level);continue}let w=await j.getAttribute(c.attribute),P=await V.getAttribute("id");if(!P){let B=D(`Relationship target "${c.to}" must have an id for ${c.attribute} validation.`,c.level);B.status==="fail"&&(ee+=1),B.status==="warn"&&(te+=1),o.reportStaticTest(I,B.status,B.detail,B.level);continue}if(!(w||"").split(/\s+/).filter(Boolean).includes(P)){let B=D(`Expected ${c.from} ${c.attribute} to reference id "${P}", found "${w||""}".`,c.level);B.status==="fail"&&(ee+=1),B.status==="warn"&&(te+=1),o.reportStaticTest(I,B.status,B.detail,B.level);continue}g.push(`Relationship valid: ${c.from}.${c.attribute} -> ${c.to} (id=${P}).`),z+=1,o.reportStaticTest(I,"pass",void 0,L);continue}if(c.type==="contains"){let I=`${c.parent} contains ${c.child}`,K=v.selectors[c.parent],N=v.selectors[c.child];if(!K||!N){let w=D(`Relationship selector missing: parent="${c.parent}" or child="${c.child}" not found in selectors.`,c.level);w.status==="fail"&&(ee+=1),w.status==="warn"&&(te+=1),o.reportStaticTest(I,w.status,w.detail,w.level);continue}let j=h.locator(K).first();if(!(await j.count()>0)){if(a==="menu"&&q(c)){let P="Skipping submenu relationship assertion in static phase: submenu container is not present until submenu is opened.";k.push(P),o.reportStaticTest(I,"skip",P,L);continue}let w=D(`Relationship parent target not found: ${c.parent}.`,c.level);w.status==="fail"&&(ee+=1),w.status==="warn"&&(te+=1),o.reportStaticTest(I,w.status,w.detail,w.level);continue}if(await j.locator(N).count()<1){if(a==="menu"&&q(c)){let P="Skipping submenu relationship assertion in static phase: submenu descendants are not present until submenu is opened.";k.push(P),o.reportStaticTest(I,"skip",P,L);continue}let w=D(`Expected ${c.parent} to contain descendant matching selector for ${c.child}.`,c.level);w.status==="fail"&&(ee+=1),w.status==="warn"&&(te+=1),o.reportStaticTest(I,w.status,w.detail,w.level);continue}g.push(`Relationship valid: ${c.parent} contains ${c.child}.`),z+=1,o.reportStaticTest(I,"pass",void 0,L)}}async function tt(c,L,I,K={}){if(!c||typeof c!="object"||!("ref"in c))return c;let N;if(c.ref==="relative"){if(!c.relativeTarget||!K.relativeBaseSelector)return;let j=I.locator(K.relativeBaseSelector),V=await j.count(),O=0;if(c.relativeTarget==="first"?O=0:c.relativeTarget==="second"?O=1:c.relativeTarget==="last"?O=V-1:isNaN(Number(c.relativeTarget))?O=0:O=Number(c.relativeTarget),O<0||O>=V)return;let R=j.nth(O);return await st(R,c.property||c.attribute)}else{if(N=L[c.ref],!N)throw new Error(`Selector for ref '${c.ref}' not found in contract selectors.`);let j=I.locator(N).first();return await st(j,c.property||c.attribute)}}async function st(c,L){if(c)return!L||L==="id"?await c.getAttribute("id")??void 0:L==="class"?await c.getAttribute("class")??void 0:L==="textContent"?await c.evaluate(I=>I.textContent??void 0):L.startsWith("aria-")?await c.getAttribute(L)??void 0:L.endsWith("*")?await c.evaluate(K=>{let N=[];for(let j of Array.from(K.attributes))j.name.startsWith("aria-")&&N.push(`${j.name}=${j.value}`);return N.join(";")}):await c.getAttribute(L)??void 0}let Nt=new ye(h,v.selectors,_);async function qe(c,L,I,K,N,j=[]){if(!Array.isArray(c)||c.length===0)return{success:!0};I&&typeof I.resetState=="function"&&await I.resetState(K);for(let V of c){let O={success:!0};try{if(V.type==="focus")V.target==="relative"&&V.relativeTarget?O=await L.focus("relative",V.relativeTarget):O=await L.focus(V.target);else if(V.type==="type"&&V.value)O=await L.type(V.target,V.value);else if(V.type==="click")O=await L.click(V.target,V.relativeTarget);else if(V.type==="keypress"&&V.key)O=await L.keypress(V.target,V.key);else if(V.type==="hover")O=await L.hover(V.target,V.relativeTarget);else continue}catch(R){O={success:!1,error:R instanceof Error?R.message:String(R)}}if(!O.success){let R=O.error||"Setup action failed";return j.some(P=>N.includes(P)||R.includes(P))?{success:!1,skip:!0,message:`Skipping test - capability not present: ${R}`}:{success:!1,error:R}}}return{success:!0}}for(let c of v.static[0]?.assertions||[]){if(u&&typeof u.resetState=="function")try{await u.resetState(h)}catch(R){C.push(`Warning: resetState failed before static test: ${R instanceof Error?R.message:String(R)}`)}if(c.target==="relative")continue;let L=`${c.target}${c.attribute?` (${c.attribute})`:""}`,I=fe(c.level);if(a==="menu"&&c.target==="submenuTrigger"&&!x){let R=`Skipping submenu static assertion for ${c.target}: no submenu capability detected in rendered component.`;k.push(R),o.reportStaticTest(L,"skip",R,I);continue}if(Array.isArray(c.setup)&&c.setup.length>0){let P=function(ce){return w.includes(ce)};var Z=P;let R=new de(h,v.selectors,H),w=["focus","type","click","keypress","hover"],re=ce=>({...ce,type:P(ce.type)?ce.type:"click"}),X=c.setup.map(re),B=await qe(X,R,u,h,L,["submenu","submenuTrigger","submenuItems"]);if(B.skip){k.push(B.message||"Setup action skipped"),o.reportStaticTest(L,"skip",B.message,I);continue}if(!B.success){let ce=`Static setup failed: ${B.error}`,$=D(ce,c.level);$.status==="fail"&&(ee+=1),$.status==="warn"&&(te+=1),o.reportStaticTest(L,$.status,$.detail,$.level);continue}}let K=v.selectors[c.target];if(!K){let R=`Selector for target ${c.target} not found.`,w=D(R,c.level);w.status==="fail"&&(ee+=1),w.status==="warn"&&(te+=1),o.reportStaticTest(L,w.status,w.detail,w.level);continue}let N=h.locator(K).first();if(!(await N.count()>0)){let R=`Target ${c.target} not found.`,w=D(R,c.level);w.status==="fail"&&(ee+=1),w.status==="warn"&&(te+=1),o.reportStaticTest(L,w.status,w.detail,w.level);continue}let V=(R,w,P)=>{let re=new RegExp(`\\[${w}(?:=["']?([^\\]"']+)["']?)?\\]`),X=R.match(re);if(!X)return!1;if(!P)return!0;let B=X[1];return B?P.split(" | ").includes(B):!1},O=c.expectedValue;if(c.expectedValue&&typeof c.expectedValue=="object"&&"ref"in c.expectedValue){let R={},w=c.relativeTarget;if(c.expectedValue.ref==="relative"&&c.target==="relative"&&w){let P=v.selectors[w];if(!P)throw new Error(`Selector for relativeTarget '${w}' not found in contract selectors.`);R.relativeBaseSelector=P}else if(c.expectedValue.ref==="relative"&&w){let P=v.selectors[w];if(!P)throw new Error(`Selector for relativeTarget '${w}' not found in contract selectors.`);R.relativeBaseSelector=P}O=await tt(c.expectedValue,v.selectors,h,R),console.log("Expected value in static check",O)}if(c.expectedValue)if(V(K,c.attribute,typeof O=="string"?O:void 0))g.push(`${c.attribute}="${O}" on ${c.target} verified by selector (already present in: ${K}).`),z+=1,o.reportStaticTest(L,"pass",void 0,I);else{let R=O??"",w=await Nt.validateAttribute(N,c.target,c.attribute,R,c.failureMessage,"Static ARIA Test");if(w.success&&w.passMessage)g.push(w.passMessage),z+=1,o.reportStaticTest(L,"pass",void 0,I);else if(!w.success&&w.failMessage){let P=D(w.failMessage,c.level);P.status==="fail"&&(ee+=1),P.status==="warn"&&(te+=1),o.reportStaticTest(L,P.status,P.detail,P.level)}}else{let R=c.attribute.split(" | "),w=!1,P=!0;for(let re of R){let X=re.trim();if(V(K,X)){g.push(`${X} on ${c.target} verified by selector (already present in: ${K}).`),w=!0;continue}if(P=!1,await N.getAttribute(X)!==null){w=!0;break}}if(!w&&!P){let re=c.failureMessage+` None of the attributes "${c.attribute}" are present.`,X=D(re,c.level);X.status==="fail"&&(ee+=1),X.status==="warn"&&(te+=1),o.reportStaticTest(L,X.status,X.detail,X.level)}else!P&&w?(g.push(`At least one of the attributes "${c.attribute}" exists on the element.`),z+=1,o.reportStaticTest(L,"pass",void 0,I)):(z+=1,o.reportStaticTest(L,"pass",void 0,I))}}for(let c of v.dynamic||[]){if(!h||h.isClosed()){console.warn(`
|
|
37
|
+
\u26A0\uFE0F Browser closed - skipping remaining ${v.dynamic.length-v.dynamic.indexOf(c)} tests
|
|
38
|
+
`),E.push(`CRITICAL: Browser/page closed before completing all tests. ${v.dynamic.length-v.dynamic.indexOf(c)} tests skipped.`);break}try{await u.resetState(h)}catch($){let J=$ instanceof Error?$.message:String($);throw o.error(J),$}let{setup:L=[],action:I,assertions:K}=c,N=fe(c.level),j=new de(h,v.selectors,H);if(Array.isArray(L)&&L.length>0){let J=function(ie){return $.includes(ie)};var Z=J;let $=["focus","type","click","keypress","hover"],le=ie=>({...ie,type:J(ie.type)?ie.type:"click"}),Be=L.map(le),ne=await qe(Be,j,u,h,c.description,["submenu","submenuTrigger","submenuItems"]);if(ne.skip){k.push(ne.message||"Setup action skipped"),o.reportTest({description:c.description,level:N},"skip",ne.message);continue}if(!ne.success){let ie=D(`Setup failed: ${ne.error}`,c.level);o.reportTest({description:c.description,level:N},ie.status,ie.detail);continue}}let V=E.length,O=C.length,R=k.length;if(await u.shouldSkipTest(c,h)){let $="Skipping test - component-specific conditions not met";k.push($),o.reportTest({description:c.description,level:N},"skip",$);continue}let P=new ye(h,v.selectors,_),re=!1,X=null;for(let $ of I){if(!h||h.isClosed()){E.push("CRITICAL: Browser/page closed during test execution. Remaining actions skipped."),re=!0;break}let J;if($.type==="focus")$.target==="relative"&&$.relativeTarget?J=await j.focus("relative",$.relativeTarget):J=await j.focus($.target);else if($.type==="type"&&$.value)J=await j.type($.target,$.value);else if($.type==="click")J=await j.click($.target,$.relativeTarget);else if($.type==="keypress"&&$.key)J=await j.keypress($.target,$.key);else if($.type==="hover")J=await j.hover($.target,$.relativeTarget);else continue;if(!J.success){if(J.error){let le=D(J.error,c.level);X={status:le.status,detail:le.detail}}re=!0;break}}if(re){o.reportTest({description:c.description,level:N},X?.status||"fail",X?.detail||E[E.length-1]);continue}for(let $ of K){let J;if($.expectedValue&&typeof $.expectedValue=="object"&&"ref"in $.expectedValue)if($.expectedValue.ref==="relative"){let{RelativeTargetResolver:Fe}=await Promise.resolve().then(()=>(Pe(),Rt)),ie=v.selectors.relative;if(!ie)throw new Error("Relative selector not defined in contract selectors.");let rt=$.relativeTarget||"first",Ve=await Fe.resolve(h,ie,rt);if(!Ve)throw new Error(`Could not resolve relative target '${rt}' for expectedValue.`);let nt=$.expectedValue.property||$.expectedValue.attribute||"id";if(nt==="textContent")J=await Ve.evaluate(ve=>ve.textContent??void 0);else{let ve=await Ve.getAttribute(nt);J=ve===null?void 0:ve}}else J=await tt($.expectedValue,v.selectors,h,{});else typeof $.expectedValue=="string"||typeof $.expectedValue>"u"?J=$.expectedValue:J="";let le={...$,expectedValue:J},Be=J??"",ne=await P.validate({...le,expectedValue:Be},c.description);if(ne.success&&ne.passMessage)g.push(ne.passMessage);else if(!ne.success&&ne.failMessage){let Fe=fe($.level||c.level);if(D(ne.failMessage,Fe).status==="skip")continue}}let B=E.length,me=C.length,ce=k.length;B>V?o.reportTest({description:c.description,level:N},"fail",E[E.length-1]):me>O?o.reportTest({description:c.description,level:N},"warn",C[C.length-1]):ce>R?o.reportTest({description:c.description,level:N},"skip",k[k.length-1]):o.reportTest({description:c.description,level:N},"pass")}o.reportStatic(z,ee,te),o.summary(E)}catch(u){if(u instanceof Error)throw u.message.includes("Executable doesn't exist")||u.message.includes("browserType.launch")?new Error(`
|
|
39
39
|
\u274C CRITICAL: Playwright browsers not found!
|
|
40
40
|
\u{1F4E6} Run: npx playwright install chromium`):u.message.includes("net::ERR_CONNECTION_REFUSED")||u.message.includes("NS_ERROR_CONNECTION_REFUSED")?new Error(`
|
|
41
41
|
\u274C CRITICAL: Cannot connect to dev server!
|
|
@@ -51,32 +51,32 @@ This usually means:
|
|
|
51
51
|
This usually means:
|
|
52
52
|
- The test timeout was too short
|
|
53
53
|
- The browser crashed
|
|
54
|
-
- An external process killed the browser`):u}finally{
|
|
54
|
+
- An external process killed the browser`):u}finally{h&&await h.close()}return{passes:g,failures:E,skipped:k,warnings:C}}var He,Ie,Ds,Dt=Q(()=>{"use strict";He=require("fs"),Ie=se(require("path"),1);_e();Ct();Lt();Pt();Ht();We();Ds={}});var Ft={};oe(Ft,{BADGE_CONFIGS:()=>Qe,displayAllBadges:()=>Vs,displayBadgeInfo:()=>qs,getBadgeMarkdown:()=>ge,promptAddBadge:()=>Bs});function ge(a){let e=Qe[a];return`[](https://github.com/aria-ease/aria-ease)`}function qs(a){let e=ge(a);console.log(Y.default.cyan(`
|
|
55
55
|
\u{1F3C5} Show your accessibility commitment!`)),console.log(Y.default.white(` Add this badge to your README.md:
|
|
56
56
|
`)),console.log(Y.default.green(" "+e)),console.log(Y.default.dim(`
|
|
57
57
|
This helps others discover accessibility tools and shows you care!
|
|
58
|
-
`))}async function Bs(
|
|
59
|
-
`),r=0;for(let i=0;i<s.length;i++){let n=s[i].trim();if(n.startsWith("[![")||n.startsWith("[!")){r=i+1;continue}if(r>0&&!n.startsWith("[![")&&!n.startsWith("[!")&&n.length>0)break;if(r===0&&n.startsWith("#")){r=i+2;break}}r===0&&(r=1),s.splice(r,0,t),await De.default.writeFile(
|
|
58
|
+
`))}async function Bs(a,e=process.cwd()){let t=qt.default.join(e,"README.md");if(!await De.default.pathExists(t)){console.log(Y.default.yellow(" \u2139\uFE0F No README.md found in current directory"));return}let r=await De.default.readFile(t,"utf-8"),i=ge(a);if(r.includes(i)||r.includes(Qe[a].fileName)){console.log(Y.default.gray(" \u2713 Badge already in README.md"));return}let n=Bt.default.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(l=>{n.question(Y.default.cyan(" Add badge to README.md now? (y/n): "),p=>{n.close(),l(p.toLowerCase().trim())})});o==="y"||o==="yes"?(await Fs(t,r,i),console.log(Y.default.green(" \u2713 Badge added to README.md!"))):console.log(Y.default.gray(" Skipped. You can add it manually anytime."))}async function Fs(a,e,t){let s=e.split(`
|
|
59
|
+
`),r=0;for(let i=0;i<s.length;i++){let n=s[i].trim();if(n.startsWith("[![")||n.startsWith("[!")){r=i+1;continue}if(r>0&&!n.startsWith("[![")&&!n.startsWith("[!")&&n.length>0)break;if(r===0&&n.startsWith("#")){r=i+2;break}}r===0&&(r=1),s.splice(r,0,t),await De.default.writeFile(a,s.join(`
|
|
60
60
|
`),"utf-8")}function Vs(){console.log(Y.default.cyan(`
|
|
61
61
|
\u{1F4CD} Available badges:`)),console.log(Y.default.white(`
|
|
62
62
|
For audits:`)),console.log(Y.default.green(" "+ge("audit"))),console.log(Y.default.white(`
|
|
63
63
|
For component testing:`)),console.log(Y.default.green(" "+ge("component"))),console.log(Y.default.white(`
|
|
64
|
-
For both (verified):`)),console.log(Y.default.green(" "+ge("verified"))),console.log("")}var De,qt,Y,Bt,Qe,Vt=Q(()=>{"use strict";De=te(require("fs-extra"),1),qt=te(require("path"),1),Y=te(require("chalk"),1),Bt=te(require("readline"),1),Qe={audit:{type:"audit",fileName:"audited-by-aria-ease.svg",label:"Audited by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/audited-by-aria-ease.svg"},component:{type:"component",fileName:"components-tested-aria-ease.svg",label:"Components tested: aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/components-tested-aria-ease.svg"},verified:{type:"verified",fileName:"verified-by-aria-ease.svg",label:"Verified by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/verified-by-aria-ease.svg"}}});var Os={};ie(Os,{cleanupTests:()=>et,createContract:()=>Ss,makeAccordionAccessible:()=>Gt,makeBlockAccessible:()=>Qt,makeCheckboxAccessible:()=>Zt,makeComboboxAccessible:()=>ss,makeMenuAccessible:()=>at,makeRadioAccessible:()=>es,makeTabsAccessible:()=>rs,makeToggleAccessible:()=>ts,testUiComponent:()=>Ze});module.exports=Jt(Os);function Gt({accordionId:c,triggersClass:e,panelsClass:t,allowMultipleOpen:s=!1,callback:r}){let i=document.querySelector(`#${c}`);if(!i)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};let n=Array.from(i.querySelectorAll(`.${e}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};let o=Array.from(i.querySelectorAll(`.${t}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(n.length!==o.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${n.length} triggers but ${o.length} panels.`),{cleanup:()=>{}};let l=new WeakMap,p=new WeakMap;function g(){n.forEach((A,w)=>{let B=o[w];A.id||(A.id=`${c}-trigger-${w}`),B.id||(B.id=`${c}-panel-${w}`),A.setAttribute("aria-controls",B.id),A.setAttribute("aria-expanded","false"),(!s||n.length<=6)&&B.setAttribute("role","region"),B.setAttribute("aria-labelledby",A.id),B.style.display="none"})}function E(A){if(A<0||A>=n.length){console.error(`[aria-ease] Invalid accordion index: ${A}`);return}let w=n[A],B=o[A];if(w.setAttribute("aria-expanded","true"),B.style.display="block",r?.onExpand)try{r.onExpand(A)}catch(b){console.error("[aria-ease] Error in accordion onExpand callback:",b)}}function M(A){if(A<0||A>=n.length){console.error(`[aria-ease] Invalid accordion index: ${A}`);return}let w=n[A],B=o[A];if(w.setAttribute("aria-expanded","false"),B.style.display="none",r?.onCollapse)try{r.onCollapse(A)}catch(b){console.error("[aria-ease] Error in accordion onCollapse callback:",b)}}function D(A){n[A].getAttribute("aria-expanded")==="true"?M(A):(s||n.forEach((b,S)=>{S!==A&&M(S)}),E(A))}function O(A){return()=>{D(A)}}function K(A){return w=>{let{key:B}=w;switch(B){case"Enter":case" ":w.preventDefault(),D(A);break;case"ArrowDown":w.preventDefault();{let b=(A+1)%n.length;n[b].focus()}break;case"ArrowUp":w.preventDefault();{let b=(A-1+n.length)%n.length;n[b].focus()}break;case"Home":w.preventDefault(),n[0].focus();break;case"End":w.preventDefault(),n[n.length-1].focus();break}}}function f(){n.forEach((A,w)=>{let B=O(w),b=K(w);A.addEventListener("click",B),A.addEventListener("keydown",b),l.set(A,b),p.set(A,B)})}function m(){n.forEach(A=>{let w=l.get(A),B=p.get(A);w&&(A.removeEventListener("keydown",w),l.delete(A)),B&&(A.removeEventListener("click",B),p.delete(A))})}function $(){m(),n.forEach((A,w)=>{M(w)})}function U(){m();let A=Array.from(i.querySelectorAll(`.${e}`)),w=Array.from(i.querySelectorAll(`.${t}`));n.length=0,n.push(...A),o.length=0,o.push(...w),g(),f()}return g(),f(),{expandItem:E,collapseItem:M,toggleItem:D,cleanup:$,refresh:U}}function Te(c){if(c.tagName!=="INPUT")return!1;let e=c.type;return["text","email","password","tel","number"].includes(e)}function Ee(c){return c.tagName==="TEXTAREA"}function it(c){return c.tagName==="BUTTON"||c.tagName==="INPUT"&&["button","submit","reset"].includes(c.type)}function Xt(c){return c.tagName==="A"}function Me(c,e,t){let s=c.length,r=(e+t+s)%s;c.item(r).focus()}function Yt(c){return c.getAttribute("data-custom-click")!==null&&c.getAttribute("data-custom-click")!==void 0}function ot(c,e,t){let s=e.item(t);switch(c.key){case"ArrowUp":case"ArrowLeft":{(!Te(s)&&!Ee(s)||(Te(s)||Ee(s))&&s.selectionStart===0)&&(c.preventDefault(),Me(e,t,-1));break}case"ArrowDown":case"ArrowRight":{if(!Te(s)&&!Ee(s))c.preventDefault(),Me(e,t,1);else if(Te(s)||Ee(s)){let r=s.value;s.selectionStart===r.length&&(c.preventDefault(),Me(e,t,1))}break}case"Escape":{c.preventDefault();break}case"Enter":case" ":{(!it(s)&&!Xt(s)&&Yt(s)||it(s))&&(c.preventDefault(),s.click());break}case"Tab":break;default:break}}function Qt({blockId:c,blockItemsClass:e}){let t=document.querySelector(`#${c}`);if(!t)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};let s=null;function r(){return s||(s=t.querySelectorAll(`.${e}`)),s}let i=r();if(!i||i.length===0)return console.error(`[aria-ease] Element with class="${e}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let n=new Map;i.forEach(p=>{if(!n.has(p)){let g=E=>{let M=t.querySelectorAll(`.${e}`),D=Array.prototype.indexOf.call(M,p);ot(E,M,D)};p.addEventListener("keydown",g),n.set(p,g)}});function o(){i.forEach(p=>{let g=n.get(p);g&&(p.removeEventListener("keydown",g),n.delete(p))})}function l(){s=null}return{cleanup:o,refresh:l}}function Zt({checkboxGroupId:c,checkboxesClass:e}){let t=document.querySelector(`#${c}`);if(!t)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let s=Array.from(t.querySelectorAll(`.${e}`));if(s.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let r=new WeakMap,i=new WeakMap;function n(){t.getAttribute("role")||t.setAttribute("role","group"),s.forEach(f=>{f.setAttribute("role","checkbox"),f.hasAttribute("aria-checked")||f.setAttribute("aria-checked","false"),f.hasAttribute("tabindex")||f.setAttribute("tabindex","0")})}function o(f){if(f<0||f>=s.length){console.error(`[aria-ease] Invalid checkbox index: ${f}`);return}let m=s[f],$=m.getAttribute("aria-checked")==="true";m.setAttribute("aria-checked",$?"false":"true")}function l(f,m){if(f<0||f>=s.length){console.error(`[aria-ease] Invalid checkbox index: ${f}`);return}s[f].setAttribute("aria-checked",m?"true":"false")}function p(f){return()=>{o(f)}}function g(f){return m=>{let{key:$}=m;switch($){case" ":m.preventDefault(),o(f);break}}}function E(){s.forEach((f,m)=>{let $=p(m),U=g(m);f.addEventListener("click",$),f.addEventListener("keydown",U),r.set(f,U),i.set(f,$)})}function M(){s.forEach(f=>{let m=r.get(f),$=i.get(f);m&&(f.removeEventListener("keydown",m),r.delete(f)),$&&(f.removeEventListener("click",$),i.delete(f))})}function D(){M()}function O(){return s.map(f=>f.getAttribute("aria-checked")==="true")}function K(){return s.map((f,m)=>f.getAttribute("aria-checked")==="true"?m:-1).filter(f=>f!==-1)}return n(),E(),{toggleCheckbox:o,setCheckboxState:l,getCheckedStates:O,getCheckedIndices:K,cleanup:D}}function at({menuId:c,menuItemsClass:e,triggerId:t,callback:s}){let r=document.querySelector(`#${c}`);if(!r)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let i=document.querySelector(`#${t}`);if(!i)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(c))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-controls",c),i.setAttribute("aria-expanded","false"),r.setAttribute("role","menu"),r.setAttribute("aria-labelledby",t);let n=new WeakMap,o=new Map,l=null,p=null;function g(){return l||(l=r.querySelectorAll(`.${e}`)),l}function E(){if(!p){let u=g();p=[];for(let y=0;y<u.length;y++){let x=u.item(y),I=U(x),z=x.getAttribute("aria-disabled")==="true";I||(x.hasAttribute("tabindex")||x.setAttribute("tabindex","-1"),z||p.push(x))}}return p}function M(u){return{length:u.length,item:x=>u[x],forEach:x=>{u.forEach(x)},[Symbol.iterator]:function*(){for(let x of u)yield x}}}function D(){g().forEach(y=>{y.setAttribute("role","menuitem");let x=y.getAttribute("data-submenu-id")??y.getAttribute("aria-controls"),I=y.hasAttribute("aria-haspopup")&&x;x&&(y.hasAttribute("data-submenu-id")||I)&&(y.setAttribute("aria-haspopup","menu"),y.setAttribute("aria-controls",x),y.hasAttribute("aria-expanded")||y.setAttribute("aria-expanded","false"))})}function O(u,y,x){let I=u.length,z=(y+x+I)%I;u.item(z).focus()}function K(u,y){u.length!==0&&u[y]?.focus()}function f(u){return u.hasAttribute("aria-controls")&&u.hasAttribute("aria-haspopup")&&u.getAttribute("role")==="menuitem"}function m(u){let y=u;for(;y&&y.getAttribute("role")==="menuitem";){let x=y.closest('[role="menu"]');if(!x)break;x.style.display="none",y.setAttribute("aria-expanded","false");let I=x.getAttribute("aria-labelledby");if(!I)break;let z=document.getElementById(I);if(!z)break;y=z}}D();function $(u,y,x){switch(u.key){case"ArrowLeft":{if(u.key==="ArrowLeft"&&i.getAttribute("role")==="menuitem"){u.preventDefault(),h();return}break}case"ArrowUp":{u.preventDefault(),O(M(E()),x,-1);break}case"ArrowRight":{if(u.key==="ArrowRight"&&f(y)){u.preventDefault();let I=y.getAttribute("aria-controls");if(I){w(I);return}}break}case"ArrowDown":{u.preventDefault(),O(M(E()),x,1);break}case"Home":{u.preventDefault(),K(E(),0);break}case"End":{u.preventDefault();let I=E();K(I,I.length-1);break}case"Escape":{u.preventDefault(),h(),i.focus(),B&&B(!1);break}case"Enter":case" ":{if(u.preventDefault(),f(y)){let I=y.getAttribute("aria-controls");if(I){w(I);return}}y.click(),h(),B&&B(!1);break}case"Tab":{h(),m(i),B&&B(!1);break}default:break}}function U(u){let y=u.parentElement;for(;y&&y!==r;){if(y.getAttribute("role")==="menu"||y.id&&r.querySelector(`[aria-controls="${y.id}"]`))return!0;y=y.parentElement}return!1}function A(u){i.setAttribute("aria-expanded",u?"true":"false")}function w(u){let y=o.get(u);if(!y){let x=r.querySelector(`[aria-controls="${u}"]`);if(!x){console.error(`[aria-ease] Submenu trigger with aria-controls="${u}" not found in menu "${c}".`);return}if(!x.id){let z=`trigger-${u}`;x.id=z,console.warn(`[aria-ease] Submenu trigger for "${u}" had no ID. Auto-generated ID: "${z}".`)}if(!document.querySelector(`#${u}`)){console.error(`[aria-ease] Submenu element with id="${u}" not found. Cannot create submenu instance.`);return}y=at({menuId:u,menuItemsClass:e,triggerId:x.id,callback:s}),o.set(u,y)}y.openMenu()}function B(u){if(s?.onOpenChange)try{s.onOpenChange(u)}catch(y){console.error("[aria-ease] Error in menu onOpenChange callback:",y)}}function b(){E().forEach((y,x)=>{if(!n.has(y)){let I=z=>$(z,y,x);y.addEventListener("keydown",I),n.set(y,I)}})}function S(){E().forEach(y=>{let x=n.get(y);x&&(y.removeEventListener("keydown",x),n.delete(y))})}function d(){A(!0),r.style.display="block";let u=E();if(b(),u&&u.length>0&&u[0].focus(),s?.onOpenChange)try{s.onOpenChange(!0)}catch(y){console.error("[aria-ease] Error in menu onOpenChange callback:",y)}}function h(){if(o.forEach(u=>u.closeMenu()),A(!1),r.style.display="none",S(),i.focus(),s?.onOpenChange)try{s.onOpenChange(!1)}catch(u){console.error("[aria-ease] Error in menu onOpenChange callback:",u)}}function k(){i.getAttribute("aria-expanded")==="true"?h():d()}function T(u){if(!(i.getAttribute("aria-expanded")==="true"))return;let x=i.contains(u.target),I=r.contains(u.target);!x&&!I&&h()}i.addEventListener("click",k),document.addEventListener("click",T);function N(){S(),i.removeEventListener("click",k),document.removeEventListener("click",T),r.style.display="none",A(!1),o.forEach(u=>u.cleanup()),o.clear()}function ae(){l=null,p=null}return{openMenu:d,closeMenu:h,cleanup:N,refresh:ae}}function es({radioGroupId:c,radiosClass:e,defaultSelectedIndex:t=0}){let s=document.querySelector(`#${c}`);if(!s)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};let r=Array.from(s.querySelectorAll(`.${e}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let i=new WeakMap,n=new WeakMap,o=t;function l(){s.getAttribute("role")||s.setAttribute("role","radiogroup"),r.forEach((f,m)=>{f.setAttribute("role","radio"),f.setAttribute("tabindex",m===o?"0":"-1"),m===o?f.setAttribute("aria-checked","true"):f.setAttribute("aria-checked","false")})}function p(f){if(f<0||f>=r.length){console.error(`[aria-ease] Invalid radio index: ${f}`);return}o>=0&&o<r.length&&(r[o].setAttribute("aria-checked","false"),r[o].setAttribute("tabindex","-1")),r[f].setAttribute("aria-checked","true"),r[f].setAttribute("tabindex","0"),r[f].focus(),o=f}function g(f){return()=>{p(f)}}function E(f){return m=>{let{key:$}=m,U=f;switch($){case"ArrowDown":case"ArrowRight":m.preventDefault(),U=(f+1)%r.length,p(U);break;case"ArrowUp":case"ArrowLeft":m.preventDefault(),U=(f-1+r.length)%r.length,p(U);break;case" ":case"Enter":m.preventDefault(),p(f);break}}}function M(){r.forEach((f,m)=>{let $=g(m),U=E(m);f.addEventListener("click",$),f.addEventListener("keydown",U),i.set(f,U),n.set(f,$)})}function D(){r.forEach(f=>{let m=i.get(f),$=n.get(f);m&&(f.removeEventListener("keydown",m),i.delete(f)),$&&(f.removeEventListener("click",$),n.delete(f))})}function O(){D()}function K(){return o}return l(),M(),{selectRadio:p,getSelectedIndex:K,cleanup:O}}function ts({toggleId:c,togglesClass:e,isSingleToggle:t=!0}){let s=document.querySelector(`#${c}`);if(!s)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let r;if(t)r=[s];else{if(!e)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(r=Array.from(s.querySelectorAll(`.${e}`)),r.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let i=new WeakMap,n=new WeakMap;function o(){r.forEach(m=>{m.tagName.toLowerCase()!=="button"&&!m.getAttribute("role")&&m.setAttribute("role","button"),m.hasAttribute("aria-pressed")||m.setAttribute("aria-pressed","false"),m.hasAttribute("tabindex")||m.setAttribute("tabindex","0")})}function l(m){if(m<0||m>=r.length){console.error(`[aria-ease] Invalid toggle index: ${m}`);return}let $=r[m],U=$.getAttribute("aria-pressed")==="true";$.setAttribute("aria-pressed",U?"false":"true")}function p(m,$){if(m<0||m>=r.length){console.error(`[aria-ease] Invalid toggle index: ${m}`);return}r[m].setAttribute("aria-pressed",$?"true":"false")}function g(m){return()=>{l(m)}}function E(m){return $=>{let{key:U}=$;switch(U){case"Enter":case" ":$.preventDefault(),l(m);break}}}function M(){r.forEach((m,$)=>{let U=g($),A=E($);m.addEventListener("click",U),m.addEventListener("keydown",A),i.set(m,A),n.set(m,U)})}function D(){r.forEach(m=>{let $=i.get(m),U=n.get(m);$&&(m.removeEventListener("keydown",$),i.delete(m)),U&&(m.removeEventListener("click",U),n.delete(m))})}function O(){D()}function K(){return r.map(m=>m.getAttribute("aria-pressed")==="true")}function f(){return r.map((m,$)=>m.getAttribute("aria-pressed")==="true"?$:-1).filter(m=>m!==-1)}return o(),M(),{toggleButton:l,setPressed:p,getPressedStates:K,getPressedIndices:f,cleanup:O}}function ss({comboboxInputId:c,comboboxButtonId:e,listBoxId:t,listBoxItemsClass:s,callback:r}){let i=document.getElementById(`${c}`);if(!i)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let n=document.getElementById(`${t}`);if(!n)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let o=e?document.getElementById(`${e}`):null,l=-1;i.setAttribute("role","combobox"),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-controls",t),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-haspopup","listbox"),n.setAttribute("role","listbox");let p=null;function g(){return p||(p=n.querySelectorAll(`.${s}`)),Array.from(p).filter(d=>!d.hidden&&d.style.display!=="none")}function E(){return i.getAttribute("aria-expanded")==="true"}function M(d){let h=g();if(d>=0&&d<h.length){let k=h[d],T=k.id||`${t}-option-${d}`;if(k.id||(k.id=T),i.setAttribute("aria-activedescendant",T),typeof k.scrollIntoView=="function"&&k.scrollIntoView({block:"nearest",behavior:"smooth"}),r?.onActiveDescendantChange)try{r.onActiveDescendantChange(T,k)}catch(N){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",N)}}else i.setAttribute("aria-activedescendant","");l=d}function D(){if(i.setAttribute("aria-expanded","true"),n.style.display="block",r?.onOpenChange)try{r.onOpenChange(!0)}catch(d){console.error("[aria-ease] Error in combobox onOpenChange callback:",d)}}function O(){if(i.setAttribute("aria-expanded","false"),i.setAttribute("aria-activedescendant",""),n.style.display="none",l=-1,r?.onOpenChange)try{r.onOpenChange(!1)}catch(d){console.error("[aria-ease] Error in combobox onOpenChange callback:",d)}}function K(d){let h=d.textContent?.trim()||"";if(i.value=h,d.setAttribute("aria-selected","true"),O(),r?.onSelect)try{r.onSelect(d)}catch(k){console.error("[aria-ease] Error in combobox onSelect callback:",k)}}function f(d){let h=g(),k=E();switch(d.key){case"ArrowDown":if(d.preventDefault(),!k){D();return}if(h.length===0)return;{let T=l>=h.length-1?0:l+1;M(T)}break;case"ArrowUp":if(d.preventDefault(),!k)return;if(h.length>0){let T=l<=0?h.length-1:l-1;M(T)}break;case"Enter":k&&l>=0&&l<h.length&&(d.preventDefault(),K(h[l]));break;case"Escape":if(k)d.preventDefault(),O();else if(i.value&&(d.preventDefault(),i.value="",i.setAttribute("aria-activedescendant",""),g().forEach(N=>{N.getAttribute("aria-selected")==="true"&&N.setAttribute("aria-selected","false")}),r?.onClear))try{r.onClear()}catch(N){console.error("[aria-ease] Error in combobox onClear callback:",N)}break;case"Home":k&&h.length>0&&(d.preventDefault(),M(0));break;case"End":k&&h.length>0&&(d.preventDefault(),M(h.length-1));break;case"Tab":k&&l>=0&&l<h.length&&K(h[l]),k&&O();break}}function m(d){let h=d.target;if(h.classList.contains(s)){let T=g().indexOf(h);T>=0&&M(T)}}function $(d){let h=d.target;h.classList.contains(s)&&(d.preventDefault(),K(h))}function U(d){let h=d.target;!i.contains(h)&&!n.contains(h)&&(!o||!o.contains(h))&&O()}function A(){E()?O():(D(),i.focus())}function w(d){(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),A())}i.addEventListener("keydown",f),n.addEventListener("mousemove",m),n.addEventListener("mousedown",$),document.addEventListener("mousedown",U),o&&(o.setAttribute("tabindex","-1"),o.setAttribute("aria-label","Toggle options"),o.addEventListener("click",A),o.addEventListener("keydown",w));function B(){let d=n.querySelectorAll(`.${s}`);if(d.length===0)return;let h=null;for(let k of d)if(k.getAttribute("aria-selected")==="true"){h=k.textContent?.trim()||null;break}!h&&i.value&&(h=i.value.trim()),d.forEach((k,T)=>{k.setAttribute("role","option");let N=k.textContent?.trim()||"";h&&N===h?k.setAttribute("aria-selected","true"):k.setAttribute("aria-selected","false");let ae=k.getAttribute("id");if(!ae||ae===""){let u=`${t}-option-${T}`;k.id=u,k.setAttribute("id",u)}})}B();function b(){i.removeEventListener("keydown",f),n.removeEventListener("mousemove",m),n.removeEventListener("mousedown",$),document.removeEventListener("mousedown",U),o&&(o.removeEventListener("click",A),o.removeEventListener("keydown",w))}function S(){p=null,B(),l=-1,M(-1)}return{cleanup:b,refresh:S,openListbox:D,closeListbox:O}}function rs({tabListId:c,tabsClass:e,tabPanelsClass:t,orientation:s="horizontal",activateOnFocus:r=!0,callback:i}){let n=document.querySelector(`#${c}`);if(!n)return console.error(`[aria-ease] Element with id="${c}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};let o=Array.from(n.querySelectorAll(`.${e}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};let l=Array.from(document.querySelectorAll(`.${t}`));if(l.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(o.length!==l.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${o.length} tabs but ${l.length} panels.`),{cleanup:()=>{}};let p=new WeakMap,g=new WeakMap,E=new WeakMap,M=0;function D(){n.setAttribute("role","tablist"),n.setAttribute("aria-orientation",s),o.forEach((b,S)=>{let d=l[S];b.id||(b.id=`${c}-tab-${S}`),d.id||(d.id=`${c}-panel-${S}`),b.setAttribute("role","tab"),b.setAttribute("aria-controls",d.id),b.setAttribute("aria-selected","false"),b.setAttribute("tabindex","-1"),d.setAttribute("role","tabpanel"),d.setAttribute("aria-labelledby",b.id),d.hidden=!0,d.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||d.setAttribute("tabindex","0")}),O(0,!1)}function O(b,S=!0){if(b<0||b>=o.length){console.error(`[aria-ease] Invalid tab index: ${b}`);return}let d=M;o.forEach((T,N)=>{let ae=l[N];T.setAttribute("aria-selected","false"),T.setAttribute("tabindex","-1"),ae.hidden=!0});let h=o[b],k=l[b];if(h.setAttribute("aria-selected","true"),h.setAttribute("tabindex","0"),k.hidden=!1,S&&h.focus(),M=b,i?.onTabChange&&d!==b)try{i.onTabChange(b,d)}catch(T){console.error("[aria-ease] Error in tabs onTabChange callback:",T)}}function K(b){let S=o.findIndex(k=>k===document.activeElement),d=S!==-1?S:M,h=d;switch(b){case"first":h=0;break;case"last":h=o.length-1;break;case"next":h=(d+1)%o.length;break;case"prev":h=(d-1+o.length)%o.length;break}if(o[h].focus(),o[h].setAttribute("tabindex","0"),o[M].setAttribute("tabindex","-1"),r)O(h,!1);else{let k=M;o.forEach((T,N)=>{N===h?T.setAttribute("tabindex","0"):N!==k&&T.setAttribute("tabindex","-1")})}}function f(b){return()=>{O(b)}}function m(b){return S=>{let{key:d}=S,h=!1;if(s==="horizontal")switch(d){case"ArrowLeft":S.preventDefault(),K("prev"),h=!0;break;case"ArrowRight":S.preventDefault(),K("next"),h=!0;break}else switch(d){case"ArrowUp":S.preventDefault(),K("prev"),h=!0;break;case"ArrowDown":S.preventDefault(),K("next"),h=!0;break}if(!h)switch(d){case"Home":S.preventDefault(),K("first");break;case"End":S.preventDefault(),K("last");break;case" ":case"Enter":r||(S.preventDefault(),O(b));break;case"F10":if(S.shiftKey&&i?.onContextMenu){S.preventDefault();try{i.onContextMenu(b,o[b])}catch(k){console.error("[aria-ease] Error in tabs onContextMenu callback:",k)}}break}}}function $(b){return S=>{if(i?.onContextMenu){S.preventDefault();try{i.onContextMenu(b,o[b])}catch(d){console.error("[aria-ease] Error in tabs onContextMenu callback:",d)}}}}function U(){o.forEach((b,S)=>{let d=f(S),h=m(S),k=$(S);b.addEventListener("click",d),b.addEventListener("keydown",h),i?.onContextMenu&&(b.addEventListener("contextmenu",k),E.set(b,k)),p.set(b,h),g.set(b,d)})}function A(){o.forEach(b=>{let S=p.get(b),d=g.get(b),h=E.get(b);S&&(b.removeEventListener("keydown",S),p.delete(b)),d&&(b.removeEventListener("click",d),g.delete(b)),h&&(b.removeEventListener("contextmenu",h),E.delete(b))})}function w(){A(),o.forEach((b,S)=>{let d=l[S];b.removeAttribute("role"),b.removeAttribute("aria-selected"),b.removeAttribute("aria-controls"),b.removeAttribute("tabindex"),d.removeAttribute("role"),d.removeAttribute("aria-labelledby"),d.removeAttribute("tabindex"),d.hidden=!1}),n.removeAttribute("role"),n.removeAttribute("aria-orientation")}function B(){A();let b=Array.from(n.querySelectorAll(`.${e}`)),S=Array.from(document.querySelectorAll(`.${t}`));o.length=0,o.push(...b),l.length=0,l.push(...S),D(),U()}return D(),U(),{activateTab:O,cleanup:w,refresh:B}}var ut={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:ns},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...is(),...ct()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ls},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:us},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:ps},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:fs},"activeOption.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]}],assertion:os},"activeOption.last":{requires:["activeOption.first"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowUp"}]}],assertion:as},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:cs},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:ct},"selectedOption.first":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"first"}]}],assertion:()=>lt("first")},"selectedOption.last":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"last"}]}],assertion:()=>lt("last")}};function ns(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect combobox main to have aria-expanded='true'."}]}function is(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect combobox main to have aria-expanded='false'."}]}function os(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"first",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function as(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"last",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the last option."}]}function cs(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function ct(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function lt(c){return[{target:"relative",relativeTarget:c,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${c} option to have aria-selected='true'.`}]}function ls(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function us(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function ps(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function fs(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var pt={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:ds},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:gs},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ms},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:hs},"activeItem.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[]}],assertion:bs},"activeItem.last":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"ArrowUp"}]}],assertion:ys},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:vs},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ws},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:As},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:ks},"submenuActiveItem.first":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:Ts}};function ds(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect menu main to have aria-expanded='true'."}]}function gs(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect menu main to have aria-expanded='false'."}]}function ms(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function hs(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function bs(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"first",failureMessage:"First menu item should have focus."}]}function ys(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"last",failureMessage:"Last menu item should have focus."}]}function vs(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect submenu trigger to have aria-expanded='true'."}]}function ws(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect submenu trigger to have aria-expanded='false'."}]}function As(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function ks(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function Ts(){return[{target:"submenuItems",assertion:"toHaveFocus",failureMessage:"First interactive item in the submenu should have focus after Right Arrow open the submenu."}]}function Es(c,e){return e.some(t=>c.capabilities.includes(t))}function Se(c,e){Array.isArray(c)&&c.length&&!c[0].when&&(c=[{when:["keyboard"],steps:()=>c}]);for(let t of c)if(Es(e,t.when))return t.steps(e);throw new Error(`No setup strategy matches capabilities: ${e.capabilities.join(", ")}`)}var Ms={combobox:ut,menu:pt},Oe=class{constructor(e){this.jsonContract=e}toJSON(){return this.jsonContract}},Ue=class{constructor(e){this.componentName=e;this.statePack=Ms[e]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(e){return this.metaValue=e,this}selectors(e){return this.selectorsValue=e,this}relationships(e){let t=this.statePack,s={capabilities:["keyboard"]},r=(n,o=new Set)=>{if(o.has(n))return[];o.add(n);let l=t[n];if(!l)return[];let p=[];if(Array.isArray(l.requires))for(let g of l.requires)p=p.concat(r(g,o));return l.setup&&(p=p.concat(Se(l.setup,s))),p};return e({ariaReference:(n,o,l)=>({requires:p=>{let g=r(p,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"required",setup:g}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"optional",setup:g}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"recommended",setup:g})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"recommended"})}),contains:(n,o)=>({requires:l=>{let p=r(l,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"required",setup:p}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"optional",setup:p}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"recommended",setup:p})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"recommended"})})}),this}static(e){return e({target:s=>{let r=n=>{let o=this.statePack,l={capabilities:["keyboard"]},p=(g,E=new Set)=>{if(E.has(g))return[];E.add(g);let M=o[g];if(!M)return[];let D=[];if(Array.isArray(M.requires))for(let O of M.requires)D=D.concat(p(O,E));return M.setup&&(D=D.concat(Se(M.setup,l))),D};return p(n,new Set)},i=(n,o,l)=>({required:()=>this.staticAssertions.push({target:s,attribute:n,expectedValue:o,failureMessage:"",level:"required",setup:l}),optional:()=>this.staticAssertions.push({target:s,attribute:n,expectedValue:o,failureMessage:"",level:"optional",setup:l}),recommended:()=>this.staticAssertions.push({target:s,attribute:n,expectedValue:o,failureMessage:"",level:"recommended",setup:l})});return{has:(n,o)=>({...i(n,o),requires:p=>{let g=r(p);return i(n,o,g)}})}}}),this}when(e){return new Ne(this,this.statePack,e)}addDynamicTest(e){this.dynamicTests.push(e)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?[{assertions:this.staticAssertions}]:[],dynamic:this.dynamicTests}}},Ne=class{constructor(e,t,s){this.parent=e;this.statePack=t;this.event=s}_as;_on;_given=[];_then=[];_desc="";_level="required";as(e){return this._as=e,this}on(e){return this._on=e,this}given(e){return this._given=Array.isArray(e)?e:[e],this}then(e){return this._then=Array.isArray(e)?e:[e],this}describe(e){return this._desc=e,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let s={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},r=(l,p=new Set)=>{if(p.has(l))return[];p.add(l);let g=this.statePack[l];if(!g)return[];let E=[];if(Array.isArray(g.requires))for(let M of g.requires)E=E.concat(r(M,p));return g.setup&&(E=E.concat(Se(g.setup,s))),E},i=[];for(let l of this._given)i.push(...r(l));let n=[];for(let l of this._then){let p=this.statePack[l];if(p&&p.assertion!==void 0){let g=p.assertion;if(typeof g=="function")try{g=g()}catch(E){throw new Error(`Error calling assertion function for state '${l}': ${E.message}`)}Array.isArray(g)?n.push(...g):n.push(g)}}let o=[{type:this._as,target:this._on,key:this._as==="keypress"?this.event:void 0}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,action:o,assertions:n,...i.length?{setup:i}:{}})}};function Ss(c,e){let t=new Ue(c);return e(t),new Oe(t.build())}_e();We();var Ot=te(require("path"),1);async function Ze(c,e,t={}){if(!c||typeof c!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let s={violations:[]};async function r(g){try{let E=await fetch(g,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(E.ok||E.status===304)return g}catch{return null}return null}let i=he(t.strictness),n={},o=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:g}=await Promise.resolve().then(()=>(bt(),ht)),E=await g(process.cwd());if(n=E.config,E.configPath&&(o=Ot.default.dirname(E.configPath)),t.strictness===void 0){let M=n.test?.components?.find(D=>D?.name===c)?.strictness;i=he(M??n.test?.strictness)}}catch{t.strictness===void 0&&(i="balanced")}let l;try{if(e){let g=await r(e);if(g){console.log(`\u{1F3AD} Running Playwright tests on ${g}`);let{runContractTestsPlaywright:E}=await Promise.resolve().then(()=>(Dt(),It));l=await E(c,g,i,n,o)}else throw new Error(`\u274C Dev server not running at ${e}
|
|
65
|
-
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(
|
|
64
|
+
For both (verified):`)),console.log(Y.default.green(" "+ge("verified"))),console.log("")}var De,qt,Y,Bt,Qe,Vt=Q(()=>{"use strict";De=se(require("fs-extra"),1),qt=se(require("path"),1),Y=se(require("chalk"),1),Bt=se(require("readline"),1),Qe={audit:{type:"audit",fileName:"audited-by-aria-ease.svg",label:"Audited by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/audited-by-aria-ease.svg"},component:{type:"component",fileName:"components-tested-aria-ease.svg",label:"Components tested: aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/components-tested-aria-ease.svg"},verified:{type:"verified",fileName:"verified-by-aria-ease.svg",label:"Verified by aria-ease",markdownUrl:"https://cdn.jsdelivr.net/gh/aria-ease/aria-ease@main/badges/verified-by-aria-ease.svg"}}});var Os={};oe(Os,{cleanupTests:()=>et,createContract:()=>Ss,makeAccordionAccessible:()=>Gt,makeBlockAccessible:()=>Qt,makeCheckboxAccessible:()=>Zt,makeComboboxAccessible:()=>ss,makeMenuAccessible:()=>at,makeRadioAccessible:()=>es,makeTabsAccessible:()=>rs,makeToggleAccessible:()=>ts,testUiComponent:()=>Ze});module.exports=Jt(Os);function Gt({accordionId:a,triggersClass:e,panelsClass:t,allowMultipleOpen:s=!1,callback:r}){if(a==="")return console.error("[aria-ease] 'accordionId' should not be an empty string. Provide an id to the accordion container element that exists before calling makeAccordionAccessible."),{cleanup:()=>{}};let i=document.querySelector(`#${a}`);if(!i)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the accordion container exists before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'triggersClass' should not be an empty string. Provide a class name that exists on the accordion trigger elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let n=Array.from(i.querySelectorAll(`.${e}`));if(n.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure accordion triggers exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(t==="")return console.error("[aria-ease] 'panelsClass' should not be an empty string. Provide a class name that exists on the accordion panel elements before calling makeAccordionAccessible."),{cleanup:()=>{}};let o=Array.from(i.querySelectorAll(`.${t}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure accordion panels exist before calling makeAccordionAccessible.`),{cleanup:()=>{}};if(n.length!==o.length)return console.error(`[aria-ease] Accordion trigger/panel mismatch: found ${n.length} triggers but ${o.length} panels.`),{cleanup:()=>{}};let l=new WeakMap,p=new WeakMap;function d(){n.forEach((A,v)=>{let F=o[v];A.id||(A.id=`${a}-trigger-${v}`),F.id||(F.id=`${a}-panel-${v}`),A.setAttribute("aria-controls",F.id),A.setAttribute("aria-expanded","false"),(!s||n.length<=6)&&F.setAttribute("role","region"),F.setAttribute("aria-labelledby",A.id),F.style.display="none"})}function T(A){if(A<0||A>=n.length){console.error(`[aria-ease] Invalid accordion index: ${A}`);return}let v=n[A],F=o[A];if(v.setAttribute("aria-expanded","true"),F.style.display="block",r?.onExpand)try{r.onExpand(A)}catch(y){console.error("[aria-ease] Error in accordion onExpand callback:",y)}}function M(A){if(A<0||A>=n.length){console.error(`[aria-ease] Invalid accordion index: ${A}`);return}let v=n[A],F=o[A];if(v.setAttribute("aria-expanded","false"),F.style.display="none",r?.onCollapse)try{r.onCollapse(A)}catch(y){console.error("[aria-ease] Error in accordion onCollapse callback:",y)}}function H(A){n[A].getAttribute("aria-expanded")==="true"?M(A):(s||n.forEach((y,E)=>{E!==A&&M(E)}),T(A))}function _(A){return()=>{H(A)}}function W(A){return v=>{let{key:F}=v;switch(F){case"Enter":case" ":v.preventDefault(),H(A);break;case"ArrowDown":v.preventDefault();{let y=(A+1)%n.length;n[y].focus()}break;case"ArrowUp":v.preventDefault();{let y=(A-1+n.length)%n.length;n[y].focus()}break;case"Home":v.preventDefault(),n[0].focus();break;case"End":v.preventDefault(),n[n.length-1].focus();break}}}function f(){n.forEach((A,v)=>{let F=_(v),y=W(v);A.addEventListener("click",F),A.addEventListener("keydown",y),l.set(A,y),p.set(A,F)})}function m(){n.forEach(A=>{let v=l.get(A),F=p.get(A);v&&(A.removeEventListener("keydown",v),l.delete(A)),F&&(A.removeEventListener("click",F),p.delete(A))})}function S(){m(),n.forEach((A,v)=>{M(v)})}function U(){m();let A=Array.from(i.querySelectorAll(`.${e}`)),v=Array.from(i.querySelectorAll(`.${t}`));n.length=0,n.push(...A),o.length=0,o.push(...v),d(),f()}return d(),f(),{expandItem:T,collapseItem:M,toggleItem:H,cleanup:S,refresh:U}}function Te(a){if(a.tagName!=="INPUT")return!1;let e=a.type;return["text","email","password","tel","number"].includes(e)}function Ee(a){return a.tagName==="TEXTAREA"}function it(a){return a.tagName==="BUTTON"||a.tagName==="INPUT"&&["button","submit","reset"].includes(a.type)}function Xt(a){return a.tagName==="A"}function Me(a,e,t){let s=a.length,r=(e+t+s)%s;a.item(r).focus()}function Yt(a){return a.getAttribute("data-custom-click")!==null&&a.getAttribute("data-custom-click")!==void 0}function ot(a,e,t){let s=e.item(t);switch(a.key){case"ArrowUp":case"ArrowLeft":{(!Te(s)&&!Ee(s)||(Te(s)||Ee(s))&&s.selectionStart===0)&&(a.preventDefault(),Me(e,t,-1));break}case"ArrowDown":case"ArrowRight":{if(!Te(s)&&!Ee(s))a.preventDefault(),Me(e,t,1);else if(Te(s)||Ee(s)){let r=s.value;s.selectionStart===r.length&&(a.preventDefault(),Me(e,t,1))}break}case"Escape":{a.preventDefault();break}case"Enter":case" ":{(!it(s)&&!Xt(s)&&Yt(s)||it(s))&&(a.preventDefault(),s.click());break}case"Tab":break;default:break}}function Qt({blockId:a,blockItemsClass:e}){if(a==="")return console.error("[aria-ease] 'blockId' should not be an empty string. Provide an id to the block container element that exists before calling makeBlockAccessible."),{cleanup:()=>{}};let t=document.querySelector(`#${a}`);if(!t)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the block element exists before calling makeBlockAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'blockItemsClass' should not be an empty string. Provide a class name that exists on the block item elements before calling makeBlockAccessible."),{cleanup:()=>{}};let s=null;function r(){return s||(s=t.querySelectorAll(`.${e}`)),s}let i=r();if(!i||i.length===0)return console.error(`[aria-ease] Element with class="${e}" not found. Make sure the block items exist before calling makeBlockAccessible.`),{cleanup:()=>{}};let n=new Map;i.forEach(p=>{if(!n.has(p)){let d=T=>{let M=t.querySelectorAll(`.${e}`),H=Array.prototype.indexOf.call(M,p);ot(T,M,H)};p.addEventListener("keydown",d),n.set(p,d)}});function o(){i.forEach(p=>{let d=n.get(p);d&&(p.removeEventListener("keydown",d),n.delete(p))})}function l(){s=null}return{cleanup:o,refresh:l}}function Zt({checkboxGroupId:a,checkboxesClass:e}){if(a==="")return console.error("[aria-ease] 'checkboxGroupId' should not be an empty string. Provide an id to the checkbox group container element that exists before calling makeCheckboxAccessible."),{cleanup:()=>{}};let t=document.querySelector(`#${a}`);if(!t)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the checkbox group container exists before calling makeCheckboxAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'checkboxesClass' should not be an empty string. Provide a class name that exists on the checkbox elements before calling makeCheckboxAccessible."),{cleanup:()=>{}};let s=Array.from(t.querySelectorAll(`.${e}`));if(s.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure checkboxes exist before calling makeCheckboxAccessible.`),{cleanup:()=>{}};let r=new WeakMap,i=new WeakMap;function n(){t.getAttribute("role")||t.setAttribute("role","group"),s.forEach(f=>{f.setAttribute("role","checkbox"),f.hasAttribute("aria-checked")||f.setAttribute("aria-checked","false"),f.hasAttribute("tabindex")||f.setAttribute("tabindex","0")})}function o(f){if(f<0||f>=s.length){console.error(`[aria-ease] Invalid checkbox index: ${f}`);return}let m=s[f],S=m.getAttribute("aria-checked")==="true";m.setAttribute("aria-checked",S?"false":"true")}function l(f,m){if(f<0||f>=s.length){console.error(`[aria-ease] Invalid checkbox index: ${f}`);return}s[f].setAttribute("aria-checked",m?"true":"false")}function p(f){return()=>{o(f)}}function d(f){return m=>{let{key:S}=m;switch(S){case" ":m.preventDefault(),o(f);break}}}function T(){s.forEach((f,m)=>{let S=p(m),U=d(m);f.addEventListener("click",S),f.addEventListener("keydown",U),r.set(f,U),i.set(f,S)})}function M(){s.forEach(f=>{let m=r.get(f),S=i.get(f);m&&(f.removeEventListener("keydown",m),r.delete(f)),S&&(f.removeEventListener("click",S),i.delete(f))})}function H(){M()}function _(){return s.map(f=>f.getAttribute("aria-checked")==="true")}function W(){return s.map((f,m)=>f.getAttribute("aria-checked")==="true"?m:-1).filter(f=>f!==-1)}return n(),T(),{toggleCheckbox:o,setCheckboxState:l,getCheckedStates:_,getCheckedIndices:W,cleanup:H}}function at({menuId:a,menuItemsClass:e,triggerId:t,callback:s}){if(a==="")return console.error("[aria-ease] 'menuId' should not be an empty string. Provide an id of the menu element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let r=document.querySelector(`#${a}`);if(!r)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the menu element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(t==="")return console.error("[aria-ease] 'triggerId' should not be an empty string. Provide an id of the trigger button element before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};let i=document.querySelector(`#${t}`);if(!i)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the trigger button element exists before calling makeMenuAccessible.`),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'menuItemsClass' should not be an empty string. Provide a class name to at least a menu item that exists before calling makeMenuAccessible."),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};if(!/^[\w-]+$/.test(a))return console.error("[aria-ease] Invalid menuId: must be alphanumeric"),{openMenu:()=>{},closeMenu:()=>{},cleanup:()=>{}};i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-controls",a),i.setAttribute("aria-expanded","false"),r.setAttribute("role","menu"),r.setAttribute("aria-labelledby",t);let n=new WeakMap,o=new Map,l=null,p=null;function d(){return l||(l=r.querySelectorAll(`.${e}`)),l}function T(){if(!p){let u=d();p=[];for(let b=0;b<u.length;b++){let x=u.item(b),q=U(x),z=x.getAttribute("aria-disabled")==="true";q||(x.hasAttribute("tabindex")||x.setAttribute("tabindex","-1"),z||p.push(x))}}return p}function M(u){return{length:u.length,item:x=>u[x],forEach:x=>{u.forEach(x)},[Symbol.iterator]:function*(){for(let x of u)yield x}}}function H(){d().forEach(b=>{b.setAttribute("role","menuitem");let x=b.getAttribute("data-submenu-id")??b.getAttribute("aria-controls"),q=b.hasAttribute("aria-haspopup")&&x;x&&(b.hasAttribute("data-submenu-id")||q)&&(b.setAttribute("aria-haspopup","menu"),b.setAttribute("aria-controls",x),b.hasAttribute("aria-expanded")||b.setAttribute("aria-expanded","false"))})}function _(u,b,x){let q=u.length,z=(b+x+q)%q;u.item(z).focus()}function W(u,b){u.length!==0&&u[b]?.focus()}function f(u){return u.hasAttribute("aria-controls")&&u.hasAttribute("aria-haspopup")&&u.getAttribute("role")==="menuitem"}function m(u){let b=u;for(;b&&b.getAttribute("role")==="menuitem";){let x=b.closest('[role="menu"]');if(!x)break;x.style.display="none",b.setAttribute("aria-expanded","false");let q=x.getAttribute("aria-labelledby");if(!q)break;let z=document.getElementById(q);if(!z)break;b=z}}H();function S(u,b,x){switch(u.key){case"ArrowLeft":{if(u.key==="ArrowLeft"&&i.getAttribute("role")==="menuitem"){u.preventDefault(),g();return}break}case"ArrowUp":{u.preventDefault(),_(M(T()),x,-1);break}case"ArrowRight":{if(u.key==="ArrowRight"&&f(b)){u.preventDefault();let q=b.getAttribute("aria-controls");if(q){v(q);return}}break}case"ArrowDown":{u.preventDefault(),_(M(T()),x,1);break}case"Home":{u.preventDefault(),W(T(),0);break}case"End":{u.preventDefault();let q=T();W(q,q.length-1);break}case"Escape":{u.preventDefault(),g(),i.focus(),F&&F(!1);break}case"Enter":case" ":{if(u.preventDefault(),f(b)){let q=b.getAttribute("aria-controls");if(q){v(q);return}}b.click(),g(),F&&F(!1);break}case"Tab":{g(),m(i),F&&F(!1);break}default:break}}function U(u){let b=u.parentElement;for(;b&&b!==r;){if(b.getAttribute("role")==="menu"||b.id&&r.querySelector(`[aria-controls="${b.id}"]`))return!0;b=b.parentElement}return!1}function A(u){i.setAttribute("aria-expanded",u?"true":"false")}function v(u){let b=o.get(u);if(!b){let x=r.querySelector(`[aria-controls="${u}"]`);if(!x){console.error(`[aria-ease] Submenu trigger with aria-controls="${u}" not found in menu "${a}".`);return}if(!x.id){let z=`trigger-${u}`;x.id=z,console.warn(`[aria-ease] Submenu trigger for "${u}" had no ID. Auto-generated ID: "${z}".`)}if(!document.querySelector(`#${u}`)){console.error(`[aria-ease] Submenu element with id="${u}" not found. Cannot create submenu instance.`);return}b=at({menuId:u,menuItemsClass:e,triggerId:x.id,callback:s}),o.set(u,b)}b.openMenu()}function F(u){if(s?.onOpenChange)try{s.onOpenChange(u)}catch(b){console.error("[aria-ease] Error in menu onOpenChange callback:",b)}}function y(){T().forEach((b,x)=>{if(!n.has(b)){let q=z=>S(z,b,x);b.addEventListener("keydown",q),n.set(b,q)}})}function E(){T().forEach(b=>{let x=n.get(b);x&&(b.removeEventListener("keydown",x),n.delete(b))})}function C(){A(!0),r.style.display="block";let u=T();if(y(),u&&u.length>0&&u[0].focus(),s?.onOpenChange)try{s.onOpenChange(!0)}catch(b){console.error("[aria-ease] Error in menu onOpenChange callback:",b)}}function g(){if(o.forEach(u=>u.closeMenu()),A(!1),r.style.display="none",E(),i.focus(),s?.onOpenChange)try{s.onOpenChange(!1)}catch(u){console.error("[aria-ease] Error in menu onOpenChange callback:",u)}}function k(){i.getAttribute("aria-expanded")==="true"?g():C()}function h(u){if(!(i.getAttribute("aria-expanded")==="true"))return;let x=i.contains(u.target),q=r.contains(u.target);!x&&!q&&g()}i.addEventListener("click",k),document.addEventListener("click",h);function D(){E(),i.removeEventListener("click",k),document.removeEventListener("click",h),r.style.display="none",A(!1),o.forEach(u=>u.cleanup()),o.clear()}function Z(){l=null,p=null}return{openMenu:C,closeMenu:g,cleanup:D,refresh:Z}}function es({radioGroupId:a,radiosClass:e,defaultSelectedIndex:t=0}){if(a==="")return console.error("[aria-ease] 'radioGroupId' should not be an empty string. Provide an id to the radio group container element that exists before calling makeRadioAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${a}`);if(!s)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the radio group container exists before calling makeRadioAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'radiosClass' should not be an empty string. Provide a class name that exists on the radio button elements before calling makeRadioAccessible."),{cleanup:()=>{}};let r=Array.from(s.querySelectorAll(`.${e}`));if(r.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure radio buttons exist before calling makeRadioAccessible.`),{cleanup:()=>{}};let i=new WeakMap,n=new WeakMap,o=t;function l(){s.getAttribute("role")||s.setAttribute("role","radiogroup"),r.forEach((f,m)=>{f.setAttribute("role","radio"),f.setAttribute("tabindex",m===o?"0":"-1"),m===o?f.setAttribute("aria-checked","true"):f.setAttribute("aria-checked","false")})}function p(f){if(f<0||f>=r.length){console.error(`[aria-ease] Invalid radio index: ${f}`);return}o>=0&&o<r.length&&(r[o].setAttribute("aria-checked","false"),r[o].setAttribute("tabindex","-1")),r[f].setAttribute("aria-checked","true"),r[f].setAttribute("tabindex","0"),r[f].focus(),o=f}function d(f){return()=>{p(f)}}function T(f){return m=>{let{key:S}=m,U=f;switch(S){case"ArrowDown":case"ArrowRight":m.preventDefault(),U=(f+1)%r.length,p(U);break;case"ArrowUp":case"ArrowLeft":m.preventDefault(),U=(f-1+r.length)%r.length,p(U);break;case" ":case"Enter":m.preventDefault(),p(f);break}}}function M(){r.forEach((f,m)=>{let S=d(m),U=T(m);f.addEventListener("click",S),f.addEventListener("keydown",U),i.set(f,U),n.set(f,S)})}function H(){r.forEach(f=>{let m=i.get(f),S=n.get(f);m&&(f.removeEventListener("keydown",m),i.delete(f)),S&&(f.removeEventListener("click",S),n.delete(f))})}function _(){H()}function W(){return o}return l(),M(),{selectRadio:p,getSelectedIndex:W,cleanup:_}}function ts({toggleId:a,togglesClass:e,isSingleToggle:t=!0}){if(a==="")return console.error("[aria-ease] 'toggleId' should not be an empty string. Provide an id to the toggle element or toggle container before calling makeToggleAccessible."),{cleanup:()=>{}};let s=document.querySelector(`#${a}`);if(!s)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the toggle element exists before calling makeToggleAccessible.`),{cleanup:()=>{}};let r;if(t)r=[s];else{if(!e)return console.error("[aria-ease] togglesClass is required when isSingleToggle is false."),{cleanup:()=>{}};if(r=Array.from(s.querySelectorAll(`.${e}`)),r.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure toggle buttons exist before calling makeToggleAccessible.`),{cleanup:()=>{}}}let i=new WeakMap,n=new WeakMap;function o(){r.forEach(m=>{m.tagName.toLowerCase()!=="button"&&!m.getAttribute("role")&&m.setAttribute("role","button"),m.hasAttribute("aria-pressed")||m.setAttribute("aria-pressed","false"),m.hasAttribute("tabindex")||m.setAttribute("tabindex","0")})}function l(m){if(m<0||m>=r.length){console.error(`[aria-ease] Invalid toggle index: ${m}`);return}let S=r[m],U=S.getAttribute("aria-pressed")==="true";S.setAttribute("aria-pressed",U?"false":"true")}function p(m,S){if(m<0||m>=r.length){console.error(`[aria-ease] Invalid toggle index: ${m}`);return}r[m].setAttribute("aria-pressed",S?"true":"false")}function d(m){return()=>{l(m)}}function T(m){return S=>{let{key:U}=S;switch(U){case"Enter":case" ":S.preventDefault(),l(m);break}}}function M(){r.forEach((m,S)=>{let U=d(S),A=T(S);m.addEventListener("click",U),m.addEventListener("keydown",A),i.set(m,A),n.set(m,U)})}function H(){r.forEach(m=>{let S=i.get(m),U=n.get(m);S&&(m.removeEventListener("keydown",S),i.delete(m)),U&&(m.removeEventListener("click",U),n.delete(m))})}function _(){H()}function W(){return r.map(m=>m.getAttribute("aria-pressed")==="true")}function f(){return r.map((m,S)=>m.getAttribute("aria-pressed")==="true"?S:-1).filter(m=>m!==-1)}return o(),M(),{toggleButton:l,setPressed:p,getPressedStates:W,getPressedIndices:f,cleanup:_}}function ss({comboboxInputId:a,comboboxButtonId:e,listBoxId:t,listBoxItemsClass:s,callback:r}){if(a==="")return console.error("[aria-ease] 'comboboxInputId' should not be an empty string. Provide an id to the combobox input element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let i=document.getElementById(`${a}`);if(!i)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the combobox input element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(t==="")return console.error("[aria-ease] 'listBoxId' should not be an empty string. Provide an id to the combobox listbox element that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};let n=document.getElementById(`${t}`);if(!n)return console.error(`[aria-ease] Element with id="${t}" not found. Make sure the combobox listbox element exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};if(s==="")return console.error("[aria-ease] 'listboxItemsClass' class should not be an empty string. Provide a class name to at least a listbox option that exists before calling makeComboboxAccessible."),{cleanup:()=>{}};if(!document.querySelectorAll(s))return console.error(`[aria-ease] Listbox option(s) with class="${s}" not found. Make sure at least a combobox listbox option exists before calling makeComboboxAccessible.`),{cleanup:()=>{}};let l=e?document.getElementById(`${e}`):null,p=-1;i.setAttribute("role","combobox"),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-controls",t),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-haspopup","listbox"),n.setAttribute("role","listbox");let d=null;function T(){return d||(d=n.querySelectorAll(`.${s}`)),Array.from(d).filter(g=>!g.hidden&&g.style.display!=="none")}function M(){return i.getAttribute("aria-expanded")==="true"}function H(g){let k=T();if(g>=0&&g<k.length){let h=k[g],D=h.id||`${t}-option-${g}`;if(h.id||(h.id=D),i.setAttribute("aria-activedescendant",D),typeof h.scrollIntoView=="function"&&h.scrollIntoView({block:"nearest",behavior:"smooth"}),r?.onActiveDescendantChange)try{r.onActiveDescendantChange(D,h)}catch(Z){console.error("[aria-ease] Error in combobox onActiveDescendantChange callback:",Z)}}else i.setAttribute("aria-activedescendant","");p=g}function _(){if(i.setAttribute("aria-expanded","true"),n.style.display="block",r?.onOpenChange)try{r.onOpenChange(!0)}catch(g){console.error("[aria-ease] Error in combobox onOpenChange callback:",g)}}function W(){if(i.setAttribute("aria-expanded","false"),i.setAttribute("aria-activedescendant",""),n.style.display="none",p=-1,r?.onOpenChange)try{r.onOpenChange(!1)}catch(g){console.error("[aria-ease] Error in combobox onOpenChange callback:",g)}}function f(g){let k=g.textContent?.trim()||"";if(i.value=k,g.setAttribute("aria-selected","true"),W(),r?.onSelect)try{r.onSelect(g)}catch(h){console.error("[aria-ease] Error in combobox onSelect callback:",h)}}function m(g){let k=T(),h=M();switch(g.key){case"ArrowDown":if(g.preventDefault(),!h){_();return}if(k.length===0)return;{let D=p>=k.length-1?0:p+1;H(D)}break;case"ArrowUp":if(g.preventDefault(),!h)return;if(k.length>0){let D=p<=0?k.length-1:p-1;H(D)}break;case"Enter":h&&p>=0&&p<k.length&&(g.preventDefault(),f(k[p]));break;case"Escape":if(h)g.preventDefault(),W();else if(i.value&&(g.preventDefault(),i.value="",i.setAttribute("aria-activedescendant",""),T().forEach(Z=>{Z.getAttribute("aria-selected")==="true"&&Z.setAttribute("aria-selected","false")}),r?.onClear))try{r.onClear()}catch(Z){console.error("[aria-ease] Error in combobox onClear callback:",Z)}break;case"Home":h&&k.length>0&&(g.preventDefault(),H(0));break;case"End":h&&k.length>0&&(g.preventDefault(),H(k.length-1));break;case"Tab":h&&p>=0&&p<k.length&&f(k[p]),h&&W();break}}function S(g){let k=g.target;if(k.classList.contains(s)){let D=T().indexOf(k);D>=0&&H(D)}}function U(g){let k=g.target;k.classList.contains(s)&&(g.preventDefault(),f(k))}function A(g){let k=g.target;!i.contains(k)&&!n.contains(k)&&(!l||!l.contains(k))&&W()}function v(){M()?W():(_(),i.focus())}function F(g){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),v())}i.addEventListener("keydown",m),n.addEventListener("mousemove",S),n.addEventListener("mousedown",U),document.addEventListener("mousedown",A),l&&(l.setAttribute("tabindex","-1"),l.setAttribute("aria-label","Toggle options"),l.addEventListener("click",v),l.addEventListener("keydown",F));function y(){let g=n.querySelectorAll(`.${s}`);if(g.length===0)return;let k=null;for(let h of g)if(h.getAttribute("aria-selected")==="true"){k=h.textContent?.trim()||null;break}!k&&i.value&&(k=i.value.trim()),g.forEach((h,D)=>{h.setAttribute("role","option");let Z=h.textContent?.trim()||"";k&&Z===k?h.setAttribute("aria-selected","true"):h.setAttribute("aria-selected","false");let u=h.getAttribute("id");if(!u||u===""){let b=`${t}-option-${D}`;h.id=b,h.setAttribute("id",b)}})}y();function E(){i.removeEventListener("keydown",m),n.removeEventListener("mousemove",S),n.removeEventListener("mousedown",U),document.removeEventListener("mousedown",A),l&&(l.removeEventListener("click",v),l.removeEventListener("keydown",F))}function C(){d=null,y(),p=-1,H(-1)}return{cleanup:E,refresh:C,openListbox:_,closeListbox:W}}function rs({tabListId:a,tabsClass:e,tabPanelsClass:t,orientation:s="horizontal",activateOnFocus:r=!0,callback:i}){if(a==="")return console.error("[aria-ease] 'tabListId' should not be an empty string. Provide an id to the tab list container element that exists before calling makeTabsAccessible."),{cleanup:()=>{}};let n=document.querySelector(`#${a}`);if(!n)return console.error(`[aria-ease] Element with id="${a}" not found. Make sure the tab list container exists before calling makeTabsAccessible.`),{cleanup:()=>{}};if(e==="")return console.error("[aria-ease] 'tabsClass' should not be an empty string. Provide a class name that exists on the tab button elements before calling makeTabsAccessible."),{cleanup:()=>{}};let o=Array.from(n.querySelectorAll(`.${e}`));if(o.length===0)return console.error(`[aria-ease] No elements with class="${e}" found. Make sure tab buttons exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(t==="")return console.error("[aria-ease] 'tabPanelsClass' should not be an empty string. Provide a class name that exists on the tab panel elements before calling makeTabsAccessible."),{cleanup:()=>{}};let l=Array.from(document.querySelectorAll(`.${t}`));if(l.length===0)return console.error(`[aria-ease] No elements with class="${t}" found. Make sure tab panels exist before calling makeTabsAccessible.`),{cleanup:()=>{}};if(o.length!==l.length)return console.error(`[aria-ease] Tab/panel mismatch: found ${o.length} tabs but ${l.length} panels.`),{cleanup:()=>{}};let p=new WeakMap,d=new WeakMap,T=new WeakMap,M=0;function H(){n.setAttribute("role","tablist"),n.setAttribute("aria-orientation",s),o.forEach((y,E)=>{let C=l[E];y.id||(y.id=`${a}-tab-${E}`),C.id||(C.id=`${a}-panel-${E}`),y.setAttribute("role","tab"),y.setAttribute("aria-controls",C.id),y.setAttribute("aria-selected","false"),y.setAttribute("tabindex","-1"),C.setAttribute("role","tabpanel"),C.setAttribute("aria-labelledby",y.id),C.hidden=!0,C.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')||C.setAttribute("tabindex","0")}),_(0,!1)}function _(y,E=!0){if(y<0||y>=o.length){console.error(`[aria-ease] Invalid tab index: ${y}`);return}let C=M;o.forEach((h,D)=>{let Z=l[D];h.setAttribute("aria-selected","false"),h.setAttribute("tabindex","-1"),Z.hidden=!0});let g=o[y],k=l[y];if(g.setAttribute("aria-selected","true"),g.setAttribute("tabindex","0"),k.hidden=!1,E&&g.focus(),M=y,i?.onTabChange&&C!==y)try{i.onTabChange(y,C)}catch(h){console.error("[aria-ease] Error in tabs onTabChange callback:",h)}}function W(y){let E=o.findIndex(k=>k===document.activeElement),C=E!==-1?E:M,g=C;switch(y){case"first":g=0;break;case"last":g=o.length-1;break;case"next":g=(C+1)%o.length;break;case"prev":g=(C-1+o.length)%o.length;break}if(o[g].focus(),o[g].setAttribute("tabindex","0"),o[M].setAttribute("tabindex","-1"),r)_(g,!1);else{let k=M;o.forEach((h,D)=>{D===g?h.setAttribute("tabindex","0"):D!==k&&h.setAttribute("tabindex","-1")})}}function f(y){return()=>{_(y)}}function m(y){return E=>{let{key:C}=E,g=!1;if(s==="horizontal")switch(C){case"ArrowLeft":E.preventDefault(),W("prev"),g=!0;break;case"ArrowRight":E.preventDefault(),W("next"),g=!0;break}else switch(C){case"ArrowUp":E.preventDefault(),W("prev"),g=!0;break;case"ArrowDown":E.preventDefault(),W("next"),g=!0;break}if(!g)switch(C){case"Home":E.preventDefault(),W("first");break;case"End":E.preventDefault(),W("last");break;case" ":case"Enter":r||(E.preventDefault(),_(y));break;case"F10":if(E.shiftKey&&i?.onContextMenu){E.preventDefault();try{i.onContextMenu(y,o[y])}catch(k){console.error("[aria-ease] Error in tabs onContextMenu callback:",k)}}break}}}function S(y){return E=>{if(i?.onContextMenu){E.preventDefault();try{i.onContextMenu(y,o[y])}catch(C){console.error("[aria-ease] Error in tabs onContextMenu callback:",C)}}}}function U(){o.forEach((y,E)=>{let C=f(E),g=m(E),k=S(E);y.addEventListener("click",C),y.addEventListener("keydown",g),i?.onContextMenu&&(y.addEventListener("contextmenu",k),T.set(y,k)),p.set(y,g),d.set(y,C)})}function A(){o.forEach(y=>{let E=p.get(y),C=d.get(y),g=T.get(y);E&&(y.removeEventListener("keydown",E),p.delete(y)),C&&(y.removeEventListener("click",C),d.delete(y)),g&&(y.removeEventListener("contextmenu",g),T.delete(y))})}function v(){A(),o.forEach((y,E)=>{let C=l[E];y.removeAttribute("role"),y.removeAttribute("aria-selected"),y.removeAttribute("aria-controls"),y.removeAttribute("tabindex"),C.removeAttribute("role"),C.removeAttribute("aria-labelledby"),C.removeAttribute("tabindex"),C.hidden=!1}),n.removeAttribute("role"),n.removeAttribute("aria-orientation")}function F(){A();let y=Array.from(n.querySelectorAll(`.${e}`)),E=Array.from(document.querySelectorAll(`.${t}`));o.length=0,o.push(...y),l.length=0,l.push(...E),H(),U()}return H(),U(),{activateTab:_,cleanup:v,refresh:F}}var ut={"popup.open":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]},{when:["pointer"],steps:()=>[{type:"click",target:"button"}]}],assertion:ns},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:[...is(),...ct()]},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ls},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:us},"input.filled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:"test"}]}],assertion:ps},"input.notFilled":{setup:[{when:["keyboard","textInput"],steps:()=>[{type:"type",target:"input",value:""}]}],assertion:fs},"activeOption.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowDown"}]}],assertion:os},"activeOption.last":{requires:["activeOption.first"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"input",key:"ArrowUp"}]}],assertion:as},"activeDescendant.notEmpty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:cs},"activeDescendant.Empty":{requires:[],setup:[{when:["keyboard"],steps:()=>[]}],assertion:ct},"selectedOption.first":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"first"}]}],assertion:()=>lt("first")},"selectedOption.last":{requires:["popup.open"],setup:[{when:["pointer"],steps:()=>[{type:"click",target:"relative",relativeTarget:"last"}]}],assertion:()=>lt("last")}};function ns(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect combobox main to have aria-expanded='true'."}]}function is(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect combobox main to have aria-expanded='false'."}]}function os(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"first",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the first option."}]}function as(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:{ref:"relative",relativeTarget:"last",property:"id"},failureMessage:"Expected aria-activedescendant on main to match the id of the last option."}]}function cs(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"!empty",failureMessage:"Expected aria-activedescendant on main to not be empty."}]}function ct(){return[{target:"main",assertion:"toHaveAttribute",attribute:"aria-activedescendant",expectedValue:"",failureMessage:"Expected aria-activedescendant on main to be empty."}]}function lt(a){return[{target:"relative",relativeTarget:a,assertion:"toHaveAttribute",attribute:"aria-selected",expectedValue:"true",failureMessage:`Expected ${a} option to have aria-selected='true'.`}]}function ls(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected main to be focused."}]}function us(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected main to not have focused."}]}function ps(){return[{target:"input",assertion:"toHaveValue",expectedValue:"test",failureMessage:"Expected input to have the value 'test'."}]}function fs(){return[{target:"input",assertion:"toHaveValue",expectedValue:"",failureMessage:"Expected input to have the value ''."}]}var pt={"popup.open":{setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"Enter"}]},{when:["pointer"],steps:()=>[{type:"click",target:"main"}]}],assertion:ds},"popup.closed":{setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:gs},"main.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"main"}]}],assertion:ms},"main.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:hs},"activeItem.first":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[]}],assertion:bs},"activeItem.last":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"main",key:"ArrowUp"}]}],assertion:ys},"submenu.open":{requires:["popup.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowRight"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:vs},"submenu.closed":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[{type:"keypress",target:"submenuTrigger",key:"ArrowLeft"}]},{when:["pointer"],steps:()=>[{type:"click",target:"submenuTrigger"}]}],assertion:ws},"submenuTrigger.focused":{setup:[{when:["keyboard"],steps:()=>[{type:"focus",target:"submenuTrigger"}]}],assertion:ks},"submenuTrigger.notFocused":{setup:[{when:["keyboard"],steps:()=>[]}],assertion:As},"submenuActiveItem.first":{requires:["submenu.open"],setup:[{when:["keyboard"],steps:()=>[]},{when:["pointer"],steps:()=>[]}],assertion:Ts}};function ds(){return[{target:"popup",assertion:"toBeVisible",failureMessage:"Expected popup to be visible"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect menu main to have aria-expanded='true'."}]}function gs(){return[{target:"popup",assertion:"notToBeVisible",failureMessage:"Expected popup to be closed"},{target:"main",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect menu main to have aria-expanded='false'."}]}function ms(){return[{target:"main",assertion:"toHaveFocus",failureMessage:"Expected menu main to be focused."}]}function hs(){return[{target:"main",assertion:"notToHaveFocus",failureMessage:"Expected menu main to not have focused."}]}function bs(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"first",failureMessage:"First menu item should have focus."}]}function ys(){return[{target:"relative",assertion:"toHaveFocus",expectedValue:"last",failureMessage:"Last menu item should have focus."}]}function vs(){return[{target:"submenu",assertion:"toBeVisible",failureMessage:"Expected submenu to be visible"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"true",failureMessage:"Expect submenu trigger to have aria-expanded='true'."}]}function ws(){return[{target:"submenu",assertion:"notToBeVisible",failureMessage:"Expected submenu to be closed"},{target:"submenuTrigger",assertion:"toHaveAttribute",attribute:"aria-expanded",expectedValue:"false",failureMessage:"Expect submenu trigger to have aria-expanded='false'."}]}function ks(){return[{target:"submenuTrigger",assertion:"toHaveFocus",failureMessage:"Expected submenu trigger to be focused."}]}function As(){return[{target:"submenuTrigger",assertion:"notToHaveFocus",failureMessage:"Expected submenu trigger to not have focused."}]}function Ts(){return[{target:"submenuItems",assertion:"toHaveFocus",failureMessage:"First interactive item in the submenu should have focus after Right Arrow open the submenu."}]}function Es(a,e){return e.some(t=>a.capabilities.includes(t))}function Se(a,e){Array.isArray(a)&&a.length&&!a[0].when&&(a=[{when:["keyboard"],steps:()=>a}]);for(let t of a)if(Es(e,t.when))return t.steps(e);throw new Error(`No setup strategy matches capabilities: ${e.capabilities.join(", ")}`)}var Ms={combobox:ut,menu:pt},Oe=class{constructor(e){this.jsonContract=e}toJSON(){return this.jsonContract}},Ue=class{constructor(e){this.componentName=e;this.statePack=Ms[e]||{}}metaValue={};selectorsValue={};relationshipInvariants=[];staticAssertions=[];dynamicTests=[];statePack;meta(e){return this.metaValue=e,this}selectors(e){return this.selectorsValue=e,this}relationships(e){let t=this.statePack,s={capabilities:["keyboard"]},r=(n,o=new Set)=>{if(o.has(n))return[];o.add(n);let l=t[n];if(!l)return[];let p=[];if(Array.isArray(l.requires))for(let d of l.requires)p=p.concat(r(d,o));return l.setup&&(p=p.concat(Se(l.setup,s))),p};return e({ariaReference:(n,o,l)=>({requires:p=>{let d=r(p,new Set);return{required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"required",setup:d}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"optional",setup:d}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"recommended",setup:d})}},required:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"aria-reference",from:n,attribute:o,to:l,level:"recommended"})}),contains:(n,o)=>({requires:l=>{let p=r(l,new Set);return{required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"required",setup:p}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"optional",setup:p}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"recommended",setup:p})}},required:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"required"}),optional:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"optional"}),recommended:()=>this.relationshipInvariants.push({type:"contains",parent:n,child:o,level:"recommended"})})}),this}static(e){return e({target:s=>{let r=n=>{let o=this.statePack,l={capabilities:["keyboard"]},p=(d,T=new Set)=>{if(T.has(d))return[];T.add(d);let M=o[d];if(!M)return[];let H=[];if(Array.isArray(M.requires))for(let _ of M.requires)H=H.concat(p(_,T));return M.setup&&(H=H.concat(Se(M.setup,l))),H};return p(n,new Set)},i=(n,o,l)=>({required:()=>this.staticAssertions.push({target:s,attribute:n,expectedValue:o,failureMessage:"",level:"required",setup:l}),optional:()=>this.staticAssertions.push({target:s,attribute:n,expectedValue:o,failureMessage:"",level:"optional",setup:l}),recommended:()=>this.staticAssertions.push({target:s,attribute:n,expectedValue:o,failureMessage:"",level:"recommended",setup:l})});return{has:(n,o)=>({...i(n,o),requires:p=>{let d=r(p);return i(n,o,d)}})}}}),this}when(e){return new Ne(this,this.statePack,e)}addDynamicTest(e){this.dynamicTests.push(e)}build(){return{meta:this.metaValue,selectors:this.selectorsValue,relationships:this.relationshipInvariants.length?this.relationshipInvariants:void 0,static:this.staticAssertions.length?[{assertions:this.staticAssertions}]:[],dynamic:this.dynamicTests}}},Ne=class{constructor(e,t,s){this.parent=e;this.statePack=t;this.event=s}_as;_on;_given=[];_then=[];_desc="";_level="required";as(e){return this._as=e,this}on(e){return this._on=e,this}given(e){return this._given=Array.isArray(e)?e:[e],this}then(e){return this._then=Array.isArray(e)?e:[e],this}describe(e){return this._desc=e,this}required(){return this._level="required",this._finalize(),this.parent}optional(){return this._level="optional",this._finalize(),this.parent}recommended(){return this._level="recommended",this._finalize(),this.parent}_finalize(){let s={capabilities:[{keypress:"keyboard",click:"pointer",type:"textInput",focus:"keyboard",hover:"pointer"}[this._as||"keyboard"]||this._as||"keyboard"]},r=(l,p=new Set)=>{if(p.has(l))return[];p.add(l);let d=this.statePack[l];if(!d)return[];let T=[];if(Array.isArray(d.requires))for(let M of d.requires)T=T.concat(r(M,p));return d.setup&&(T=T.concat(Se(d.setup,s))),T},i=[];for(let l of this._given)i.push(...r(l));let n=[];for(let l of this._then){let p=this.statePack[l];if(p&&p.assertion!==void 0){let d=p.assertion;if(typeof d=="function")try{d=d()}catch(T){throw new Error(`Error calling assertion function for state '${l}': ${T.message}`)}Array.isArray(d)?n.push(...d):n.push(d)}}let o=[{type:this._as,target:this._on,key:this._as==="keypress"?this.event:void 0}];this.parent.addDynamicTest({description:this._desc||"",level:this._level,action:o,assertions:n,...i.length?{setup:i}:{}})}};function Ss(a,e){let t=new Ue(a);return e(t),new Oe(t.build())}_e();We();var Ot=se(require("path"),1);async function Ze(a,e,t={}){if(!a||typeof a!="string")throw new Error("\u274C testUiComponent requires a valid componentName (string)");if(!e)throw new Error("\u274C testUiComponent requires a URL");if(e&&typeof e!="string")throw new Error("\u274C testUiComponent url parameter must be a string");let s={violations:[]};async function r(d){try{let T=await fetch(d,{method:"HEAD",signal:AbortSignal.timeout(1e3)});if(T.ok||T.status===304)return d}catch{return null}return null}let i=he(t.strictness),n={},o=typeof process<"u"?process.cwd():"";if(typeof process<"u"&&typeof process.cwd=="function")try{let{loadConfig:d}=await Promise.resolve().then(()=>(bt(),ht)),T=await d(process.cwd());if(n=T.config,T.configPath&&(o=Ot.default.dirname(T.configPath)),t.strictness===void 0){let M=n.test?.components?.find(H=>H?.name===a)?.strictness;i=he(M??n.test?.strictness)}}catch{t.strictness===void 0&&(i="balanced")}let l;try{if(e){let d=await r(e);if(d){console.log(`\u{1F3AD} Running Playwright tests on ${d}`);let{runContractTestsPlaywright:T}=await Promise.resolve().then(()=>(Dt(),It));l=await T(a,d,i,n,o)}else throw new Error(`\u274C Dev server not running at ${e}
|
|
65
|
+
Please start your dev server and try again.`)}else throw new Error("\u274C URL is required for component testing. Please provide a URL to run full accessibility tests with testUiComponent.")}catch(d){throw d instanceof Error?d:new Error(`\u274C Contract test execution failed: ${String(d)}`)}let p={violations:s.violations,raw:s,contract:l};if(l.failures.length>0&&e==="Playwright")throw new Error(`
|
|
66
66
|
\u274C ${l.failures.length} accessibility contract test${l.failures.length>1?"s":""} failed (Playwright mode)
|
|
67
67
|
\u2705 ${l.passes.length} test${l.passes.length>1?"s":""} passed
|
|
68
68
|
|
|
69
69
|
\u{1F4CB} Review the detailed test report above for specific failures.
|
|
70
|
-
\u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(s.violations.length>0){let
|
|
70
|
+
\u{1F4A1} Contract tests validate ARIA attributes and keyboard interactions per W3C APG guidelines.`);if(s.violations.length>0){let d=s.violations.length,T=s.violations.map(M=>`
|
|
71
71
|
- ${M.id}: ${M.description}
|
|
72
72
|
Impact: ${M.impact}
|
|
73
73
|
Affected elements: ${M.nodes.length}
|
|
74
74
|
Help: ${M.helpUrl}`).join(`
|
|
75
75
|
`);throw new Error(`
|
|
76
|
-
\u274C ${
|
|
77
|
-
${
|
|
76
|
+
\u274C ${d} axe accessibility violation${d>1?"s":""} detected
|
|
77
|
+
${T}
|
|
78
78
|
|
|
79
79
|
\u{1F4CB} Full details available in result.violations`)}return p}var Ut=async()=>({passes:[],failures:[],skipped:[]});typeof window>"u"&&(Ut=async()=>{console.log(`\u{1F680} Running component accessibility tests...
|
|
80
|
-
`);let{exec:
|
|
80
|
+
`);let{exec:a}=await import("child_process"),e=(await import("chalk")).default;return new Promise((t,s)=>{a("npx vitest --run --reporter verbose",async(r,i,n)=>{if(console.log(i),n&&console.error(n),!r||r.code===0){try{let{displayBadgeInfo:l,promptAddBadge:p}=await Promise.resolve().then(()=>(Vt(),Ft));l("component"),await p("component",process.cwd()),console.log(e.dim(`
|
|
81
81
|
`+"\u2500".repeat(60))),console.log(e.cyan("\u{1F499} Found aria-ease helpful?")),console.log(e.white(" \u2022 Star us on GitHub: ")+e.blue.underline("https://github.com/aria-ease/aria-ease")),console.log(e.white(" \u2022 Share feedback: ")+e.blue.underline("https://github.com/aria-ease/aria-ease/discussions")),console.log(e.dim("\u2500".repeat(60)+`
|
|
82
82
|
`))}catch(l){console.error("Warning: Could not display badge prompt:",l)}t({passes:[],failures:[],skipped:[]}),process.exit(0)}else{let l=r?.code||1;s(new Error(`Tests failed with code ${l}`)),process.exit(l)}})})});async function et(){await gt()}0&&(module.exports={cleanupTests,createContract,makeAccordionAccessible,makeBlockAccessible,makeCheckboxAccessible,makeComboboxAccessible,makeMenuAccessible,makeRadioAccessible,makeTabsAccessible,makeToggleAccessible,testUiComponent});
|