@ctrl/dom 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aria/_chunks/roles-list-B0OTIKQA.js +4 -0
- package/dist/aria/_chunks/roles-list-CkmykU-H.cjs +4 -0
- package/dist/aria/index.cjs +1 -1
- package/dist/aria/index.js +1 -1
- package/dist/aria/internal.cjs +1 -1
- package/dist/aria/internal.js +1 -1
- package/dist/aria/types/forms.d.ts +5 -0
- package/dist/aria/types/internal.d.ts +2 -2
- package/dist/aria/types/role.d.ts +8 -1
- package/dist/bridge/internal.js +1 -1
- package/dist/dom/_chunks/src-BbkJRbbx.js +49 -0
- package/dist/dom/index.js +1 -1
- package/dist/dom/internal.js +1 -1
- package/dist/dom/types/css/CSSStyleDeclaration.d.ts +10 -1
- package/dist/dom/types/css/cascade.d.ts +14 -4
- package/dist/dom/types/css/declarations.d.ts +5 -0
- package/dist/dom/types/css/internal.d.ts +1 -1
- package/dist/dom/types/events/listeners.d.ts +8 -1
- package/dist/dom/types/internal.d.ts +1 -1
- package/dist/dom/types/nodes/attributes.d.ts +4 -0
- package/dist/dom/types/nodes/cache.d.ts +5 -1
- package/dist/dom/types/nodes/constants.d.ts +8 -0
- package/dist/dom/types/selectors/filter.d.ts +5 -3
- package/dist/dom/types/window/clock.d.ts +5 -1
- package/dist/dom/types/window/compat.d.ts +3 -1
- package/dist/dom/types/window/geometry.d.ts +3 -9
- package/dist/jest-dom/_chunks/{matchers-CGTk9GX9.cjs → matchers-CkxM783o.cjs} +1 -1
- package/dist/jest-dom/_chunks/{matchers-Chf0yHoo.js → matchers-Dt7W4g5X.js} +1 -1
- package/dist/jest-dom/index.cjs +1 -1
- package/dist/jest-dom/index.js +1 -1
- package/dist/jest-dom/jest-globals.cjs +1 -1
- package/dist/jest-dom/jest-globals.js +1 -1
- package/dist/jest-dom/matchers.cjs +1 -1
- package/dist/jest-dom/matchers.js +1 -1
- package/dist/jest-dom/vitest.cjs +1 -1
- package/dist/jest-dom/vitest.js +1 -1
- package/dist/react/_chunks/{pure-DQzwul4s.cjs → pure-DR8LsIAA.cjs} +1 -1
- package/dist/react/_chunks/{pure-CCeTO5Mk.js → pure-ajnRI-Fp.js} +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/pure.cjs +1 -1
- package/dist/react/pure.js +1 -1
- package/dist/testing-library/_chunks/{aria-snapshot-diff-Do-cz8cJ.cjs → aria-snapshot-diff-BXYf4D_D.cjs} +1 -1
- package/dist/testing-library/_chunks/aria-snapshot-diff-DejA3Rdn.js +14 -0
- package/dist/testing-library/agent.cjs +1 -1
- package/dist/testing-library/agent.js +1 -1
- package/dist/testing-library/index.cjs +5 -5
- package/dist/testing-library/index.js +8 -8
- package/dist/user-event/index.cjs +15 -15
- package/dist/user-event/index.js +15 -15
- package/dist/user-event/types/setup/setup.d.ts +12 -2
- package/dist/user-event/types/system/pointer/mouse.d.ts +0 -3
- package/dist/vitest-environment/index.js +1 -1
- package/package.json +1 -1
- package/dist/aria/_chunks/roles-list-BXCvPLJT.cjs +0 -4
- package/dist/aria/_chunks/roles-list-rVVxaIPs.js +0 -4
- package/dist/dom/_chunks/src-sZY6a2LC.js +0 -49
- package/dist/testing-library/_chunks/aria-snapshot-diff-Cj1v4fL1.js +0 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0}),__exportAll=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};let t=require("@ctrl/dom/internal"),n=require("node:module"),r=require("node:fs"),i=require("@ctrl/dom/aria"),a=require("@ctrl/dom/aria/internal");const o=new URL(`./`,require("url").pathToFileURL(__filename).href).pathname;let s=null;const c=process.env,l=process.argv,u=!(c.NO_COLOR||l.includes(`--no-color`))&&(!!c.FORCE_COLOR||l.includes(`--color`)||process.platform===`win32`||process.stdout?.isTTY&&c.TERM!==`dumb`||!!c.CI);function dim(e){return u?`\x1b[2m${e}\x1b[22m`:e}function getCodeFrame(e){s??=(0,n.createRequire)(require("url").pathToFileURL(__filename).href)(`@babel/code-frame`).codeFrameColumns;let t=e.indexOf(`(`)+1,i=e.indexOf(`)`),a=e.slice(t,i),o=a.split(`:`),[c,l,u]=[o[0],parseInt(o[1],10),parseInt(o[2],10)],d=``;try{d=(0,r.readFileSync)(c,`utf-8`)}catch{return``}let f=s(d,{start:{line:l,column:u-1}},{highlightCode:!0,linesBelow:0});return`${dim(a)}\n${f}\n`}function getUserCodeFrame(){return getCodeFrame((/* @__PURE__ */ Error()).stack.split(`
|
|
2
2
|
`).slice(1).find(e=>!e.includes(`node_modules/`)&&!e.includes(o)))}function jestFakeTimersAreEnabled(){if(typeof jest<`u`&&jest!==null)return setTimeout._isMockFunction===!0||Object.hasOwn(setTimeout,`clock`);let e=setTimeout.clock;return e!=null&&typeof e.tick==`function`}function advanceFakeTimersByTime(e){if(typeof jest<`u`&&jest!==null){jest.advanceTimersByTime(e);return}let t=globalThis.vi;t!=null&&typeof t.advanceTimersByTime==`function`&&typeof t.isFakeTimers==`function`&&t.isFakeTimers()?t.advanceTimersByTime(e):setTimeout.clock.tick(e)}function getDocument(){if(typeof window>`u`)throw Error(`Could not find default container`);return window.document}function getWindowFromNode(e){if(e.defaultView)return e.defaultView;if(e.ownerDocument&&e.ownerDocument.defaultView)return e.ownerDocument.defaultView;if(e.window)return e.window;throw e.ownerDocument&&e.ownerDocument.defaultView===null?Error(`It looks like the window object is not available for the provided node.`):e.then instanceof Function?Error("It looks like you passed a Promise object instead of a DOM node. Did you do something like `fireEvent.click(screen.findBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`, or await the findBy query `fireEvent.click(await screen.findBy...`?"):Array.isArray(e)?Error("It looks like you passed an Array instead of a DOM node. Did you do something like `fireEvent.click(screen.getAllBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`?"):typeof e.debug==`function`&&typeof e.logTestingPlaygroundURL==`function`?Error("It looks like you passed a `screen` object. Did you do something like `fireEvent.click(screen, ...` when you meant to use a query, e.g. `fireEvent.click(screen.getBy..., `?"):Error(`The given node is not an Element, the node type is: ${typeof e}.`)}function checkContainerType(e){if(!e||typeof e.querySelector!=`function`||typeof e.querySelectorAll!=`function`)throw TypeError(`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(e)}.`)}function getTypeName(e){return typeof e==`object`?e===null?`null`:e.constructor.name:typeof e}function implOf(e){let n=e[t.$impl];if(n===void 0)throw TypeError(`@ctrl/dom/testing-library requires nodes created by @ctrl/dom.`);return n}function matchesSelector(e,n){return e.type===t.ELEMENT_NODE&&(0,t.matches)(e,n)}function envDebugFormat(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG:void 0;if(e===void 0||e===``)return null;let t=String(e).trim().toLowerCase();return t===`aria`?`aria`:t===`compact`||t===`html`?`compact`:null}function containerLabel(e){let n=e?.[t.$impl];return n===void 0?`the container`:n.type===9?`the document`:describeElement(n)}function agentErrorContext(e,t,n){return t===`aria`?`Accessibility snapshot of ${containerLabel(e)} (CTRL_DOM_DEBUG=aria):\n${ariaSnapshot(e,{maxLines:envMaxLines()??100})}`:`DOM of ${containerLabel(e)} without class/style/SVG internals (CTRL_DOM_DEBUG=compact):\n${n(e,void 0,{format:`compact`})}`}function agentElementSummary(e){return ariaSnapshot(e,{maxLines:12})}function envMaxLines(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG_LINES:void 0,t=e?Number(e):NaN;return t>0?t:void 0}function ariaSnapshot(e,t={}){let{header:n,lines:r,empty:i}=ariaSnapshotLines(e,t);return i===null?n+budgetLines(r,t.maxLines??envMaxLines()??200).join(`
|
|
3
3
|
`):n+i}(0,t.setFailureSnapshot)(e=>ariaSnapshot(e,{maxLines:2e3}));function buildTree(e,n){let r=rootImpl(e),i=new SnapshotContext(r,n),o=[],s=``;return!i.includeHidden&&r.type===t.ELEMENT_NODE&&(0,a.isInaccessibleImpl)(r)&&(s=`# hidden from the accessibility tree: ${hiddenReason(r)}\n`,i.includeHidden=!0,i.forceHidden=!0),r.type===t.ELEMENT_NODE&&r!==bodyOf(r)?i.visitElement(r,o,i.forceHidden):i.visitChildren(r,o,!1,!1),finishChildren(o,null),{root:r,ctx:i,children:o,header:s}}function ariaSnapshotTree(e,t={}){return buildTree(e,t).children}function ariaSnapshotLines(e,t={}){let{root:n,ctx:r,children:i,header:a}=buildTree(e,t),o=[];r.renderList(i,``,o);let s=o.length>0?null:r.sawHidden?`# no accessible content (hidden elements exist: pass { hidden: true })`:`# no accessible content`;return n===bodyOf(n)&&envDebugFormat()!==null&&recordBodySnapshot(n.doc,s??o.join(`
|
|
4
|
-
`)),{header:a,lines:o,empty:s}}function budgetLines(e,t){if(e.length<=t)return e;let n=e.length-t,r=e.slice(0,t);return r.push(`# … ${n} more line${n===1?``:`s`} (raise maxLines or CTRL_DOM_DEBUG_LINES)`),r}const d=Symbol.for(`ctrl-dom.agent.lastBodySnapshot`);function recordBodySnapshot(e,t){e!=null&&Object.defineProperty(e,d,{value:t,configurable:!0,writable:!0,enumerable:!1})}function lastBodySnapshot(e){return e?.[d]}function resetBodySnapshot(e){e!=null&&Object.hasOwn(e,d)&&delete e[d]}function rootImpl(e){let n=e??getDocument().body,r=n?.[t.$impl];if(r===void 0)throw TypeError(`Expected an element, document or fragment but got ${n===null?`null`:typeof n}`);if(r.type===t.DOCUMENT_NODE||r.tag===t.T.html&&r.ns===t.HTML_NS){let e=r.doc?.body;return e?e[t.$impl]:r}return r}function bodyOf(e){let n=e.doc?.body;return n?n[t.$impl]:null}function normalizeSpace(e){return e.replace(/[\t\n\f\r ]+/g,` `)}function truncate(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+`…`:e}function quote(e){return JSON.stringify(e)}const f=/^$|^[\s\-?:,[\]{}#&*!|>'"%@`]|[\s]$|:$|: | #|^(true|false|null|yes|no|on|off|~)$|^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i;function yamlValue(e){return f.test(e)?quote(e):e}function nodeKey(e,t){let n=e.role;e.name!==``&&(n+=` `+quote(truncate(e.name,t)));for(let t=0;t<e.props.length;t++)n+=` `+e.props[t];return n}function describeElement(e){let n=e.name;if(e.id!==``)return`<${n} id="${e.id}">`;let r=(0,t.attr)(e,`data-testid`);return r===null?`<${n}>`:`<${n} data-testid="${r}">`}function hiddenReason(e){let t=hiddenChainReason(e);return t===``?(0,a.isVisibilityHidden)(e)?`visibility: hidden on ${describeElement(e)}`:``:t}function hiddenChainReason(e){for(let n=e;n!==null&&n.type===t.ELEMENT_NODE;n=n.parent){if(n.ns===t.HTML_NS&&(0,t.attr)(n,`hidden`)!==null)return`hidden attribute on ${describeElement(n)}`;if((0,t.attr)(n,`aria-hidden`)===`true`)return`aria-hidden="true" on ${describeElement(n)}`;if((0,a.isDisplayNone)(n))return`display: none on ${describeElement(n)}`}return``}const p=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]);function isSkippedTag(e){if(e.ns!==t.HTML_NS)return!1;switch(e.tag){case t.T.script:case t.T.style:case t.T.template:case t.T.noscript:case t.T.head:return!0}return!1}function nodeProps(e,t,n,r){let o=[];if((0,i.roleSupportsProp)(t,`aria-checked`)){let t=(0,a.ariaCheckedState)(e);t===!0?o.push(`[checked]`):t===`mixed`&&o.push(`[checked=mixed]`)}(0,a.isDisabledImpl)(e)&&o.push(`[disabled]`);let s=(0,a.computeAriaExpanded)(e);s===!0?o.push(`[expanded]`):s===!1&&o.push(`[expanded=false]`),n&&o.push(`[active]`);let c=t===`heading`?(0,a.computeHeadingLevel)(e):levelAttr(e);c!==void 0&&o.push(`[level=${c}]`);let l=(0,a.ariaPressedState)(e);l===!0?o.push(`[pressed]`):l===`mixed`?o.push(`[pressed=mixed]`):l===!1&&o.push(`[pressed=false]`),(0,a.computeAriaSelected)(e)===!0&&o.push(`[selected]`);let u=(0,a.computeAriaCurrent)(e);return u===!0?o.push(`[current]`):typeof u==`string`&&u!==``&&o.push(`[current=${u}]`),(0,a.computeAriaBusy)(e)&&o.push(`[busy]`),r&&o.push(`[hidden]`),o}function levelAttr(e){let n=(0,t.attr)(e,`aria-level`),r=n===null?NaN:Number(n);return r>0?r:void 0}const m=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`,`progressbar`,`meter`,`scrollbar`,`separator`]);function nodeValue(e,n){if(!m.has(n))return null;let r=(0,t.attr)(e,`aria-valuetext`);if(r!==null)return r;let i=(0,t.attr)(e,`aria-valuenow`);if(i!==null)return i;if(e.ns!==t.HTML_NS)return null;if(e.tag===t.T.input||e.tag===t.T.textarea){let t=String(e.node.value??``);return t===``?null:t}return null}var SnapshotContext=class{includeHidden;forceHidden=!1;sawHidden=!1;maxText;collapseAfter;urls;active;constructor(e,n){this.includeHidden=n.hidden===!0,this.maxText=n.maxTextLength??100,this.collapseAfter=n.collapseAfter??5,this.urls=n.urls===!0;let r=e.doc?.activeElement,i=r?r[t.$impl]??null:null;this.active=i!==null&&i===bodyOf(e)?null:i}visitChildren(e,n,r,i){for(let a=e.first;a!==null;a=a.next)a.type===t.TEXT_NODE?i||appendText(n,a.data):a.type===t.ELEMENT_NODE?this.visitElement(a,n,r):a.type===t.DOCUMENT_FRAGMENT_NODE&&this.visitChildren(a,n,r,i)}visitElement(e,n,r){if(isSkippedTag(e))return;let i=r;if(!i&&(0,a.isSubtreeInaccessibleImpl)(e)){if(this.sawHidden=!0,!this.includeHidden)return;i=!0}let o=i;if(!i&&(0,a.isVisibilityHidden)(e)){if(this.sawHidden=!0,!this.includeHidden){this.visitChildren(e,n,!1,!0);return}o=!0}let s=(0,a.tlRole)(e);if(p.has(s)){let t=!(0,a.isDisplayInline)(e);t&&appendBreak(n),this.visitChildren(e,n,i,!1),t&&appendBreak(n);return}let c={role:s,name:normalizeSpace((0,a.computeAccessibleNameImpl)(e,void 0,5)).trim(),props:nodeProps(e,s,e===this.active,o&&this.includeHidden),value:nodeValue(e,s),url:null,children:[],element:e};this.urls&&s===`link`&&(c.url=(0,t.attr)(e,`href`)),(e.ns!==t.HTML_NS||e.tag!==t.T.textarea)&&this.visitChildren(e,c.children,i,!1),finishChildren(c.children,c.name),n.push(c)}renderList(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`string`){n.push(`${t}- text: ${yamlValue(truncate(i,this.maxText))}`);continue}let a=1;for(;r+a<e.length&&typeof e[r+a]!=`string`&&e[r+a].role===i.role;)a++;if(a>this.collapseAfter+1){for(let i=0;i<this.collapseAfter;i++)this.renderNode(e[r+i],t,n);n.push(`${t}- ${i.role} … (+${a-this.collapseAfter} more)`),r+=a-1}else this.renderNode(i,t,n)}}renderNode(e,t,n){let r=nodeKey(e,this.maxText),i=e.children;if(e.url===null&&(i.length===0||i.length===1&&typeof i[0]==`string`&&e.value===null)){let a=e.value??(i.length===1?i[0]:null);n.push(a===null?`${t}- ${r}`:`${t}- ${r}: ${yamlValue(truncate(a,this.maxText))}`);return}n.push(e.value===null?`${t}- ${r}:`:`${t}- ${r}: ${yamlValue(truncate(e.value,this.maxText))}`);let a=t+` `;e.url!==null&&n.push(`${a}- /url: ${yamlValue(e.url)}`),this.renderList(i,a,n)}};function appendText(e,t){if(t===``)return;let n=e.length-1;n>=0&&typeof e[n]==`string`&&e[n]!==`\0`?e[n]=e[n]+t:e.push(t)}function appendBreak(e){let t=e.length-1;t>=0&&typeof e[t]==`string`&&e[t]!==`\0`&&e.push(`\0`)}function finishChildren(e,t){let n=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`&&(r===`\0`||(r=normalizeSpace(r).trim(),r===``))||(e[n++]=r)}e.length=n,e.length>0&&typeof e[0]==`string`&&e[0]===t&&e.splice(0,1),n=0;for(let t=0;t<e.length;t++){let r=e[t];(typeof r!=`string`||!labels(e[t-1],r)&&!labels(e[t+1],r))&&(e[n++]=r)}e.length=n}const h=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`,`meter`,`progressbar`]);function labels(e,t){return e!==void 0&&typeof e!=`string`&&e.name===t&&h.has(e.role)}let g=null;function loadPrettyFormat(e){if(g!==null)return g;try{return g=(0,n.createRequire)(require("url").pathToFileURL(__filename).href)(`pretty-format`)}catch(t){throw Error(`${e} needs pretty-format, which @ctrl/dom does not install: add pretty-format@27 to the project's devDependencies.`,{cause:t})}}const _=`The prettyFormat export`,v=Object.defineProperties({},{format:{enumerable:!0,get:()=>loadPrettyFormat(_).format},default:{enumerable:!0,get:()=>loadPrettyFormat(_).default},plugins:{enumerable:!0,get:()=>loadPrettyFormat(_).plugins},DEFAULT_OPTIONS:{enumerable:!0,get:()=>loadPrettyFormat(_).DEFAULT_OPTIONS}}),shouldHighlight=()=>{if(typeof process>`u`)return!1;let e;try{let t=process.env?.COLORS;t&&(e=JSON.parse(t))}catch{}return typeof e==`boolean`?e:process.versions!==void 0&&process.versions.node!==void 0};function filterCommentsAndDefaultIgnoreTagsTags(e){return e.nodeType!==t.COMMENT_NODE&&(e.nodeType!==t.ELEMENT_NODE||!e.matches(getConfig().defaultIgnore))}const y={open:``,close:``},b={comment:y,content:y,prop:y,tag:y,value:y},x={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49],bgGray:[100,49],bgGrey:[100,49]},S={comment:`gray`,content:`reset`,prop:`yellow`,tag:`cyan`,value:`green`};function highlightColors(e){let t={};for(let n of Object.keys(S)){let r=e!==void 0&&e[n]!==void 0?e[n]:S[n],i=typeof r==`string`&&Object.hasOwn(x,r)?x[r]:void 0;if(i===void 0)throw Error(`pretty-format: Option "theme" has a key "${n}" whose value "${r}" is undefined in ansi-styles.`);t[n]={open:`\u001b[${i[0]}m`,close:`\u001b[${i[1]}m`}}return t}const C=highlightColors(void 0),w=/* @__PURE__ */ new Set([`callToJSON`,`compareKeys`,`escapeRegex`,`escapeString`,`highlight`,`indent`,`maxDepth`,`min`,`plugins`,`printBasicPrototype`,`printFunctionName`,`theme`]),T=Symbol(`delegate`),E=/^((HTML|SVG)\w*)?Element$/,D=/* @__PURE__ */ new WeakMap;function isCustomElement(e){let{tagName:t}=e;return!!(typeof t==`string`&&t.includes(`-`)||typeof e.hasAttribute==`function`&&e.hasAttribute(`is`))}function pluginHandles(e){let n=e.node,r=n.constructor,i=r?.name;switch(e.type){case t.ELEMENT_NODE:{if(!i&&!isCustomElement(n))return!1;if(typeof r!=`function`)return E.test(i)||isCustomElement(n);let e=D.get(r);return e===void 0&&D.set(r,e=E.test(i)),e||isCustomElement(n)}case t.TEXT_NODE:return i===`Text`;case t.COMMENT_NODE:return i===`Comment`;case t.DOCUMENT_FRAGMENT_NODE:return i===`DocumentFragment`}return!1}function escapeHTML(e){return e.indexOf(`<`)===-1&&e.indexOf(`>`)===-1?e:e.replace(/</g,`<`).replace(/>/g,`>`)}function printString(e,t){return t.escapeString?`"`+e.replace(/"|\\/g,`\\$&`)+`"`:`"`+e+`"`}function keepChild(e,n){return n.filterNode===null?e.type===t.COMMENT_NODE?!1:e.type===t.ELEMENT_NODE?n.scriptStyleIgnore?e.name!==`script`&&e.name!==`style`:!matchesSelector(e,n.defaultIgnore):!0:!!n.filterNode(e.node)}function tagNameLower(e){return e.node.tagName.toLowerCase()}function printProps(e,t,n){let r=e.attrs;if(r===null||r.length===0)return``;let i=[],a=/* @__PURE__ */ new Map;for(let n=0;n<r.length;n++)t.compact&&isNoiseAttribute(e,r[n].name)||(i.push(r[n].name),a.set(r[n].name,r[n].value));i.sort();let o=t.colors,s=``;for(let e=0;e<i.length;e++){let r=i[e];s+=t.spacingInner+n+o.prop.open+r+o.prop.close+`=`+o.value.open+printString(a.get(r),t)+o.value.close}return s}function isNoiseAttribute(e,n){return n===`class`||n===`style`||e.ns===t.SVG_NS&&n!==`role`&&n!==`id`&&!n.startsWith(`aria-`)&&!n.startsWith(`data-`)}function printChildren(e,n,r,i){if(n.compact&&e.ns===t.SVG_NS&&e.name===`svg`)return``;let a=``;for(let o=e.first;o!==null;o=o.next)keepChild(o,n)&&(n.compact&&o.type===t.TEXT_NODE&&o.data.trim()===``||(a+=n.spacingOuter+r+printNode(o,n,r,i)));return a}function printElement(e,t,n,r,i){let a=r.colors.tag;return a.open+`<`+e+(t&&a.close+t+r.spacingOuter+i+a.open)+(n?`>`+a.close+n+r.spacingOuter+i+a.open+`</`+e:(t&&!r.min?``:` `)+`/`)+`>`+a.close}function printNode(e,n,r,i){if(!pluginHandles(e))throw T;if(e.type===t.TEXT_NODE){let t=n.compact&&e.data.length>200?e.data.slice(0,199)+`…`:e.data;return n.colors.content.open+escapeHTML(t)+n.colors.content.close}if(e.type===t.COMMENT_NODE){let t=n.colors.comment;return t.open+`<!--`+escapeHTML(e.data)+`-->`+t.close}let a=e.type===t.DOCUMENT_FRAGMENT_NODE?`DocumentFragment`:tagNameLower(e),o=n.colors.tag;if(++i>n.maxDepth)return o.open+`<`+a+o.close+` …`+o.open+` />`+o.close;let s=r+n.indent;return printElement(a,e.type===t.DOCUMENT_FRAGMENT_NODE?``:printProps(e,n,s),printChildren(e,n,s,i),n,r)}function printForeignNode(e,n,r,i,a){if(!foreignHandles(e))throw T;if(e.nodeType===t.TEXT_NODE)return n.colors.content.open+escapeHTML(e.data)+n.colors.content.close;if(e.nodeType===t.COMMENT_NODE)return n.colors.comment.open+`<!--`+escapeHTML(e.data)+`-->`+n.colors.comment.close;let o=e.nodeType===t.DOCUMENT_FRAGMENT_NODE,s=o?`DocumentFragment`:e.tagName.toLowerCase(),c=n.colors.tag;if(++a>n.maxDepth)return c.open+`<`+s+c.close+` …`+c.open+` />`+c.close;let l=i+n.indent,u=``;if(!o){let t=Array.from(e.attributes);t.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));for(let{name:e,value:r}of t)u+=n.spacingInner+l+n.colors.prop.open+e+n.colors.prop.close+`=`+n.colors.value.open+printString(r,n)+n.colors.value.close}let d=``,f=e.childNodes||e.children;for(let e=0;e<f.length;e++)r(f[e])&&(d+=n.spacingOuter+l+printForeignNode(f[e],n,r,l,a));return printElement(s,u,d,n,i)}function foreignHandles(e){let n=e?.constructor?.name;if(!n&&!isCustomElement(e))return!1;switch(e.nodeType){case t.ELEMENT_NODE:return E.test(n)||isCustomElement(e);case t.TEXT_NODE:return n===`Text`;case t.COMMENT_NODE:return n===`Comment`;case t.DOCUMENT_FRAGMENT_NODE:return n===`DocumentFragment`}return!1}function makePrintConfig(e,t){for(let t of Object.keys(e))if(!w.has(t))throw Error(`pretty-format: Unknown option "${t}".`);if(e.min&&e.indent!==void 0&&e.indent!==0)throw Error(`pretty-format: Options "min" and "indent" cannot be used together.`);if(e.theme!==void 0){if(e.theme===null)throw Error(`pretty-format: Option "theme" must not be null.`);if(typeof e.theme!=`object`)throw Error(`pretty-format: Option "theme" must be of type "object" but instead received "${typeof e.theme}".`)}if(e.plugins!==void 0)return null;let n=!!e.min,r=e.indent===void 0?2:e.indent,i=getConfig().defaultIgnore;return{colors:e.highlight?e.theme===void 0?C:highlightColors(e.theme):b,escapeString:e.escapeString===void 0||e.escapeString,indent:n?``:Array(r+1).join(` `),maxDepth:e.maxDepth===void 0?1/0:e.maxDepth,min:n,spacingInner:n?` `:`
|
|
4
|
+
`)),{header:a,lines:o,empty:s}}function budgetLines(e,t){if(e.length<=t)return e;let n=e.length-t,r=e.slice(0,t);return r.push(`# … ${n} more line${n===1?``:`s`} (raise maxLines or CTRL_DOM_DEBUG_LINES)`),r}const d=Symbol.for(`ctrl-dom.agent.lastBodySnapshot`);function recordBodySnapshot(e,t){e!=null&&Object.defineProperty(e,d,{value:t,configurable:!0,writable:!0,enumerable:!1})}function lastBodySnapshot(e){return e?.[d]}function resetBodySnapshot(e){e!=null&&Object.hasOwn(e,d)&&delete e[d]}function rootImpl(e){let n=e??getDocument().body,r=n?.[t.$impl];if(r===void 0)throw TypeError(`Expected an element, document or fragment but got ${n===null?`null`:typeof n}`);if(r.type===t.DOCUMENT_NODE||r.tag===t.T.html&&r.ns===t.HTML_NS){let e=r.doc?.body;return e?e[t.$impl]:r}return r}function bodyOf(e){let n=e.doc?.body;return n?n[t.$impl]:null}function normalizeSpace(e){return e.replace(/[\t\n\f\r ]+/g,` `)}function truncate(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+`…`:e}function quote(e){return JSON.stringify(e)}const f=/^$|^[\s\-?:,[\]{}#&*!|>'"%@`]|[\s]$|:$|: | #|^(true|false|null|yes|no|on|off|~)$|^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i;function yamlValue(e){return f.test(e)?quote(e):e}function nodeKey(e,t){let n=e.role;e.name!==``&&(n+=` `+quote(truncate(e.name,t)));for(let t=0;t<e.props.length;t++)n+=` `+e.props[t];return n}function describeElement(e){let n=e.name;if(e.id!==``)return`<${n} id="${e.id}">`;let r=(0,t.attr)(e,`data-testid`);return r===null?`<${n}>`:`<${n} data-testid="${r}">`}function hiddenReason(e){let t=hiddenChainReason(e);return t===``?(0,a.isVisibilityHidden)(e)?`visibility: hidden on ${describeElement(e)}`:``:t}function hiddenChainReason(e){for(let n=e;n!==null&&n.type===t.ELEMENT_NODE;n=n.parent){if(n.ns===t.HTML_NS&&(0,t.attr)(n,`hidden`)!==null)return`hidden attribute on ${describeElement(n)}`;if((0,t.ariaAttr)(n,`aria-hidden`)===`true`)return`aria-hidden="true" on ${describeElement(n)}`;if((0,a.isDisplayNone)(n))return`display: none on ${describeElement(n)}`}return``}const p=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]);function isSkippedTag(e){if(e.ns!==t.HTML_NS)return!1;switch(e.tag){case t.T.script:case t.T.style:case t.T.template:case t.T.noscript:case t.T.head:return!0}return!1}function nodeProps(e,t,n,r){let o=[];if((0,i.roleSupportsProp)(t,`aria-checked`)){let t=(0,a.ariaCheckedState)(e);t===!0?o.push(`[checked]`):t===`mixed`&&o.push(`[checked=mixed]`)}(0,a.isDisabledImpl)(e)&&o.push(`[disabled]`);let s=(0,a.computeAriaExpanded)(e);s===!0?o.push(`[expanded]`):s===!1&&o.push(`[expanded=false]`),n&&o.push(`[active]`);let c=t===`heading`?(0,a.computeHeadingLevel)(e):levelAttr(e);c!==void 0&&o.push(`[level=${c}]`);let l=(0,a.ariaPressedState)(e);l===!0?o.push(`[pressed]`):l===`mixed`?o.push(`[pressed=mixed]`):l===!1&&o.push(`[pressed=false]`),(0,a.computeAriaSelected)(e)===!0&&o.push(`[selected]`);let u=(0,a.computeAriaCurrent)(e);return u===!0?o.push(`[current]`):typeof u==`string`&&u!==``&&o.push(`[current=${u}]`),(0,a.computeAriaBusy)(e)&&o.push(`[busy]`),r&&o.push(`[hidden]`),o}function levelAttr(e){let n=(0,t.ariaAttr)(e,`aria-level`),r=n===null?NaN:Number(n);return r>0?r:void 0}const m=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`,`progressbar`,`meter`,`scrollbar`,`separator`]);function nodeValue(e,n){if(!m.has(n))return null;let r=(0,t.ariaAttr)(e,`aria-valuetext`);if(r!==null)return r;let i=(0,t.ariaAttr)(e,`aria-valuenow`);if(i!==null)return i;if(e.ns!==t.HTML_NS)return null;if(e.tag===t.T.input||e.tag===t.T.textarea){let t=String(e.node.value??``);return t===``?null:t}return null}var SnapshotContext=class{includeHidden;forceHidden=!1;sawHidden=!1;maxText;collapseAfter;urls;active;constructor(e,n){this.includeHidden=n.hidden===!0,this.maxText=n.maxTextLength??100,this.collapseAfter=n.collapseAfter??5,this.urls=n.urls===!0;let r=e.doc?.activeElement,i=r?r[t.$impl]??null:null;this.active=i!==null&&i===bodyOf(e)?null:i}visitChildren(e,n,r,i){for(let a=e.first;a!==null;a=a.next)a.type===t.TEXT_NODE?i||appendText(n,a.data):a.type===t.ELEMENT_NODE?this.visitElement(a,n,r):a.type===t.DOCUMENT_FRAGMENT_NODE&&this.visitChildren(a,n,r,i)}visitElement(e,n,r){if(isSkippedTag(e))return;let i=r;if(!i&&(0,a.isSubtreeInaccessibleImpl)(e)){if(this.sawHidden=!0,!this.includeHidden)return;i=!0}let o=i;if(!i&&(0,a.isVisibilityHidden)(e)){if(this.sawHidden=!0,!this.includeHidden){this.visitChildren(e,n,!1,!0);return}o=!0}let s=(0,a.tlRole)(e);if(p.has(s)){let t=!(0,a.isDisplayInline)(e);t&&appendBreak(n),this.visitChildren(e,n,i,!1),t&&appendBreak(n);return}let c={role:s,name:normalizeSpace((0,a.computeAccessibleNameImpl)(e,void 0,5)).trim(),props:nodeProps(e,s,e===this.active,o&&this.includeHidden),value:nodeValue(e,s),url:null,children:[],element:e};this.urls&&s===`link`&&(c.url=(0,t.attr)(e,`href`)),(e.ns!==t.HTML_NS||e.tag!==t.T.textarea)&&this.visitChildren(e,c.children,i,!1),finishChildren(c.children,c.name),n.push(c)}renderList(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`string`){n.push(`${t}- text: ${yamlValue(truncate(i,this.maxText))}`);continue}let a=1;for(;r+a<e.length&&typeof e[r+a]!=`string`&&e[r+a].role===i.role;)a++;if(a>this.collapseAfter+1){for(let i=0;i<this.collapseAfter;i++)this.renderNode(e[r+i],t,n);n.push(`${t}- ${i.role} … (+${a-this.collapseAfter} more)`),r+=a-1}else this.renderNode(i,t,n)}}renderNode(e,t,n){let r=nodeKey(e,this.maxText),i=e.children;if(e.url===null&&(i.length===0||i.length===1&&typeof i[0]==`string`&&e.value===null)){let a=e.value??(i.length===1?i[0]:null);n.push(a===null?`${t}- ${r}`:`${t}- ${r}: ${yamlValue(truncate(a,this.maxText))}`);return}n.push(e.value===null?`${t}- ${r}:`:`${t}- ${r}: ${yamlValue(truncate(e.value,this.maxText))}`);let a=t+` `;e.url!==null&&n.push(`${a}- /url: ${yamlValue(e.url)}`),this.renderList(i,a,n)}};function appendText(e,t){if(t===``)return;let n=e.length-1;n>=0&&typeof e[n]==`string`&&e[n]!==`\0`?e[n]=e[n]+t:e.push(t)}function appendBreak(e){let t=e.length-1;t>=0&&typeof e[t]==`string`&&e[t]!==`\0`&&e.push(`\0`)}function finishChildren(e,t){let n=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`&&(r===`\0`||(r=normalizeSpace(r).trim(),r===``))||(e[n++]=r)}e.length=n,e.length>0&&typeof e[0]==`string`&&e[0]===t&&e.splice(0,1),n=0;for(let t=0;t<e.length;t++){let r=e[t];(typeof r!=`string`||!labels(e[t-1],r)&&!labels(e[t+1],r))&&(e[n++]=r)}e.length=n}const h=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`,`meter`,`progressbar`]);function labels(e,t){return e!==void 0&&typeof e!=`string`&&e.name===t&&h.has(e.role)}let g=null;function loadPrettyFormat(e){if(g!==null)return g;try{return g=(0,n.createRequire)(require("url").pathToFileURL(__filename).href)(`pretty-format`)}catch(t){throw Error(`${e} needs pretty-format, which @ctrl/dom does not install: add pretty-format@27 to the project's devDependencies.`,{cause:t})}}const _=`The prettyFormat export`,v=Object.defineProperties({},{format:{enumerable:!0,get:()=>loadPrettyFormat(_).format},default:{enumerable:!0,get:()=>loadPrettyFormat(_).default},plugins:{enumerable:!0,get:()=>loadPrettyFormat(_).plugins},DEFAULT_OPTIONS:{enumerable:!0,get:()=>loadPrettyFormat(_).DEFAULT_OPTIONS}}),shouldHighlight=()=>{if(typeof process>`u`)return!1;let e;try{let t=process.env?.COLORS;t&&(e=JSON.parse(t))}catch{}return typeof e==`boolean`?e:process.versions!==void 0&&process.versions.node!==void 0};function filterCommentsAndDefaultIgnoreTagsTags(e){return e.nodeType!==t.COMMENT_NODE&&(e.nodeType!==t.ELEMENT_NODE||!e.matches(getConfig().defaultIgnore))}const y={open:``,close:``},b={comment:y,content:y,prop:y,tag:y,value:y},x={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49],bgGray:[100,49],bgGrey:[100,49]},S={comment:`gray`,content:`reset`,prop:`yellow`,tag:`cyan`,value:`green`};function highlightColors(e){let t={};for(let n of Object.keys(S)){let r=e!==void 0&&e[n]!==void 0?e[n]:S[n],i=typeof r==`string`&&Object.hasOwn(x,r)?x[r]:void 0;if(i===void 0)throw Error(`pretty-format: Option "theme" has a key "${n}" whose value "${r}" is undefined in ansi-styles.`);t[n]={open:`\u001b[${i[0]}m`,close:`\u001b[${i[1]}m`}}return t}const C=highlightColors(void 0),w=/* @__PURE__ */ new Set([`callToJSON`,`compareKeys`,`escapeRegex`,`escapeString`,`highlight`,`indent`,`maxDepth`,`min`,`plugins`,`printBasicPrototype`,`printFunctionName`,`theme`]),T=Symbol(`delegate`),E=/^((HTML|SVG)\w*)?Element$/,D=/* @__PURE__ */ new WeakMap;function isCustomElement(e){let{tagName:t}=e;return!!(typeof t==`string`&&t.includes(`-`)||typeof e.hasAttribute==`function`&&e.hasAttribute(`is`))}function pluginHandles(e){let n=e.node,r=n.constructor,i=r?.name;switch(e.type){case t.ELEMENT_NODE:{if(!i&&!isCustomElement(n))return!1;if(typeof r!=`function`)return E.test(i)||isCustomElement(n);let e=D.get(r);return e===void 0&&D.set(r,e=E.test(i)),e||isCustomElement(n)}case t.TEXT_NODE:return i===`Text`;case t.COMMENT_NODE:return i===`Comment`;case t.DOCUMENT_FRAGMENT_NODE:return i===`DocumentFragment`}return!1}function escapeHTML(e){return e.indexOf(`<`)===-1&&e.indexOf(`>`)===-1?e:e.replace(/</g,`<`).replace(/>/g,`>`)}function printString(e,t){return t.escapeString?`"`+e.replace(/"|\\/g,`\\$&`)+`"`:`"`+e+`"`}function keepChild(e,n){return n.filterNode===null?e.type===t.COMMENT_NODE?!1:e.type===t.ELEMENT_NODE?n.scriptStyleIgnore?e.name!==`script`&&e.name!==`style`:!matchesSelector(e,n.defaultIgnore):!0:!!n.filterNode(e.node)}function tagNameLower(e){return e.node.tagName.toLowerCase()}function printProps(e,t,n){let r=e.attrs;if(r===null||r.length===0)return``;let i=[],a=/* @__PURE__ */ new Map;for(let n=0;n<r.length;n++)t.compact&&isNoiseAttribute(e,r[n].name)||(i.push(r[n].name),a.set(r[n].name,r[n].value));i.sort();let o=t.colors,s=``;for(let e=0;e<i.length;e++){let r=i[e];s+=t.spacingInner+n+o.prop.open+r+o.prop.close+`=`+o.value.open+printString(a.get(r),t)+o.value.close}return s}function isNoiseAttribute(e,n){return n===`class`||n===`style`||e.ns===t.SVG_NS&&n!==`role`&&n!==`id`&&!n.startsWith(`aria-`)&&!n.startsWith(`data-`)}function printChildren(e,n,r,i){if(n.compact&&e.ns===t.SVG_NS&&e.name===`svg`)return``;let a=``;for(let o=e.first;o!==null;o=o.next)keepChild(o,n)&&(n.compact&&o.type===t.TEXT_NODE&&o.data.trim()===``||(a+=n.spacingOuter+r+printNode(o,n,r,i)));return a}function printElement(e,t,n,r,i){let a=r.colors.tag;return a.open+`<`+e+(t&&a.close+t+r.spacingOuter+i+a.open)+(n?`>`+a.close+n+r.spacingOuter+i+a.open+`</`+e:(t&&!r.min?``:` `)+`/`)+`>`+a.close}function printNode(e,n,r,i){if(!pluginHandles(e))throw T;if(e.type===t.TEXT_NODE){let t=n.compact&&e.data.length>200?e.data.slice(0,199)+`…`:e.data;return n.colors.content.open+escapeHTML(t)+n.colors.content.close}if(e.type===t.COMMENT_NODE){let t=n.colors.comment;return t.open+`<!--`+escapeHTML(e.data)+`-->`+t.close}let a=e.type===t.DOCUMENT_FRAGMENT_NODE?`DocumentFragment`:tagNameLower(e),o=n.colors.tag;if(++i>n.maxDepth)return o.open+`<`+a+o.close+` …`+o.open+` />`+o.close;let s=r+n.indent;return printElement(a,e.type===t.DOCUMENT_FRAGMENT_NODE?``:printProps(e,n,s),printChildren(e,n,s,i),n,r)}function printForeignNode(e,n,r,i,a){if(!foreignHandles(e))throw T;if(e.nodeType===t.TEXT_NODE)return n.colors.content.open+escapeHTML(e.data)+n.colors.content.close;if(e.nodeType===t.COMMENT_NODE)return n.colors.comment.open+`<!--`+escapeHTML(e.data)+`-->`+n.colors.comment.close;let o=e.nodeType===t.DOCUMENT_FRAGMENT_NODE,s=o?`DocumentFragment`:e.tagName.toLowerCase(),c=n.colors.tag;if(++a>n.maxDepth)return c.open+`<`+s+c.close+` …`+c.open+` />`+c.close;let l=i+n.indent,u=``;if(!o){let t=Array.from(e.attributes);t.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));for(let{name:e,value:r}of t)u+=n.spacingInner+l+n.colors.prop.open+e+n.colors.prop.close+`=`+n.colors.value.open+printString(r,n)+n.colors.value.close}let d=``,f=e.childNodes||e.children;for(let e=0;e<f.length;e++)r(f[e])&&(d+=n.spacingOuter+l+printForeignNode(f[e],n,r,l,a));return printElement(s,u,d,n,i)}function foreignHandles(e){let n=e?.constructor?.name;if(!n&&!isCustomElement(e))return!1;switch(e.nodeType){case t.ELEMENT_NODE:return E.test(n)||isCustomElement(e);case t.TEXT_NODE:return n===`Text`;case t.COMMENT_NODE:return n===`Comment`;case t.DOCUMENT_FRAGMENT_NODE:return n===`DocumentFragment`}return!1}function makePrintConfig(e,t){for(let t of Object.keys(e))if(!w.has(t))throw Error(`pretty-format: Unknown option "${t}".`);if(e.min&&e.indent!==void 0&&e.indent!==0)throw Error(`pretty-format: Options "min" and "indent" cannot be used together.`);if(e.theme!==void 0){if(e.theme===null)throw Error(`pretty-format: Option "theme" must not be null.`);if(typeof e.theme!=`object`)throw Error(`pretty-format: Option "theme" must be of type "object" but instead received "${typeof e.theme}".`)}if(e.plugins!==void 0)return null;let n=!!e.min,r=e.indent===void 0?2:e.indent,i=getConfig().defaultIgnore;return{colors:e.highlight?e.theme===void 0?C:highlightColors(e.theme):b,escapeString:e.escapeString===void 0||e.escapeString,indent:n?``:Array(r+1).join(` `),maxDepth:e.maxDepth===void 0?1/0:e.maxDepth,min:n,spacingInner:n?` `:`
|
|
5
5
|
`,spacingOuter:n?``:`
|
|
6
6
|
`,filterNode:t,scriptStyleIgnore:i===`script, style`,defaultIgnore:i,compact:!1}}function formatDOM(e,n,r,i=!1){let a={printFunctionName:!1,highlight:shouldHighlight(),...r},o=n??filterCommentsAndDefaultIgnoreTagsTags,s=makePrintConfig(a,n===void 0?null:n);if(s===null)return formatWithPrettyFormat(e,o,a,`The "plugins" option of prettyDOM`);s.compact=i;let c=e[t.$impl];try{return c===void 0?printForeignNode(e,s,o,``,0):printNode(c,s,``,0)}catch(e){if(e!==T)throw e}return formatWithPrettyFormat(e,o,a,`Printing a node other than an element, text, comment or fragment`)}function formatWithPrettyFormat(e,t,n,r=`pretty-format's own printing`){let i=loadPrettyFormat(r);return i.format(e,{plugins:[createDOMElementFilter(t),i.plugins.DOMCollection],...n})}function prettyDOM(e,t,n={}){e||=getDocument().body;let r=typeof t==`number`?t:void 0;if(typeof t!=`number`&&(t=typeof process<`u`&&process.env!==void 0&&process.env.DEBUG_PRINT_LIMIT||7e3),t===0)return``;e.documentElement&&(e=e.documentElement);let i=typeof e;if(i===`object`?i=e.constructor.name:e={},!(`outerHTML`in e))throw TypeError(`Expected an element or document but got ${i}`);let a=n.format??envDebugFormat();if(a!==null||`format`in n){let{format:i,hidden:o,maxLines:s,maxTextLength:c,collapseAfter:l,urls:u,...d}=n;if(a===`aria`){let t=ariaSnapshot(e,{hidden:o,maxLines:s,maxTextLength:c,collapseAfter:l,urls:u});return r!==void 0&&t.length>r?`${t.slice(0,r)}...`:t}if(n=d,a===`compact`){let{filterNode:r,...i}={highlight:!1,...n},a=formatDOM(e,r,i,!0);return a.length>t?`${a.slice(0,t)}...`:a}}let{filterNode:o,...s}=n,c=formatDOM(e,o,s);return t!==void 0&&outerHTMLLength(e)>t?`${c.slice(0,t)}...`:c}function outerHTMLLength(e){let n=e[t.$impl];return n!==void 0&&n.type===t.ELEMENT_NODE?(0,t.serializeNode)(n).length:e.outerHTML.length}const logDOM=(...e)=>{let t=getUserCodeFrame();console.log(t?`${prettyDOM(...e)}\n\n${t}`:prettyDOM(...e))};function createDOMElementFilter(e){let printPropsPF=(e,t,n,r,i,a,o)=>{let s=r+n.indent,c=n.colors;return e.map(e=>{let l=t[e],u=o(l,n,s,i,a);return typeof l!=`string`&&(u.indexOf(`
|
|
7
7
|
`)!==-1&&(u=n.spacingOuter+s+u+n.spacingOuter+r),u=`{`+u+`}`),n.spacingInner+r+c.prop.open+e+c.prop.close+`=`+c.value.open+u+c.value.close}).join(``)},printText=(e,t)=>t.colors.content.open+escapeHTML(e)+t.colors.content.close,printChildrenPF=(e,n,r,i,a,o)=>e.map(e=>{let s=typeof e==`string`?printText(e,n):o(e,n,r,i,a);return s===``&&typeof e==`object`&&e&&e.nodeType!==t.TEXT_NODE?``:n.spacingOuter+r+s}).join(``),testNode=e=>{let n=e.constructor.name,{nodeType:r}=e;return r===t.ELEMENT_NODE&&(E.test(n)||isCustomElement(e))||r===t.TEXT_NODE&&n===`Text`||r===t.COMMENT_NODE&&n===`Comment`||r===t.DOCUMENT_FRAGMENT_NODE&&n===`DocumentFragment`};return{test:e=>(e?.constructor?.name||isCustomElement(e))&&testNode(e),serialize:(n,r,i,a,o,s)=>{if(n.nodeType===t.TEXT_NODE)return printText(n.data,r);if(n.nodeType===t.COMMENT_NODE){let e=r.colors.comment;return e.open+`<!--`+escapeHTML(n.data)+`-->`+e.close}let c=n.nodeType===t.DOCUMENT_FRAGMENT_NODE,l=c?`DocumentFragment`:n.tagName.toLowerCase();if(++a>r.maxDepth){let e=r.colors.tag;return e.open+`<`+l+e.close+` …`+e.open+` />`+e.close}return printElement(l,printPropsPF(c?[]:Array.from(n.attributes).map(e=>e.name).sort(),c?{}:Array.from(n.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),r,i+r.indent,a,o,s),printChildrenPF(Array.prototype.slice.call(n.childNodes||n.children).filter(e),r,i+r.indent,a,o,s),r,i)}}}let O={testIdAttribute:`data-testid`,asyncUtilTimeout:1e3,asyncWrapper:e=>e(),unstable_advanceTimersWrapper:e=>e(),eventWrapper:e=>e(),defaultHidden:!1,defaultIgnore:`script, style`,showOriginalStackTrace:!1,throwSuggestions:!1,getElementError(e,t){let n=envDebugFormat();if(n!==null){let r=Error([e,agentErrorContext(t,n,prettyDOM)].filter(Boolean).join(`
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{$impl as t,COMMENT_NODE as n,DOCUMENT_FRAGMENT_NODE as r,DOCUMENT_NODE as i,ELEMENT_NODE as a,HTML_NS as o,SVG_NS as s,T as c,TEXT_NODE as l,ariaAttr as u,attr as d,matches as f,serializeNode as p,setFailureSnapshot as m}from"@ctrl/dom/internal";import{readFileSync as h}from"node:fs";import{roleSupportsProp as g}from"@ctrl/dom/aria";import{ariaCheckedState as _,ariaPressedState as v,computeAccessibleNameImpl as y,computeAriaBusy as b,computeAriaCurrent as x,computeAriaExpanded as S,computeAriaSelected as ee,computeHeadingLevel as te,isDisabledImpl as C,isDisplayInline as w,isDisplayNone as T,isInaccessibleImpl as E,isSubtreeInaccessibleImpl as D,isVisibilityHidden as O,tlRole as k}from"@ctrl/dom/aria/internal";var A=Object.defineProperty,__name=(e,t)=>A(e,`name`,{value:t,configurable:!0}),__exportAll=(e,t)=>{let n={};for(var r in e)A(n,r,{get:e[r],enumerable:!0});return t||A(n,Symbol.toStringTag,{value:`Module`}),n};const j=new URL(`./`,import.meta.url).pathname;let M=null;const N=process.env,P=process.argv,F=!(N.NO_COLOR||P.includes(`--no-color`))&&(!!N.FORCE_COLOR||P.includes(`--color`)||process.platform===`win32`||process.stdout?.isTTY&&N.TERM!==`dumb`||!!N.CI);function dim(e){return F?`\x1b[2m${e}\x1b[22m`:e}function getCodeFrame(t){M??=e(import.meta.url)(`@babel/code-frame`).codeFrameColumns;let n=t.indexOf(`(`)+1,r=t.indexOf(`)`),i=t.slice(n,r),a=i.split(`:`),[o,s,c]=[a[0],parseInt(a[1],10),parseInt(a[2],10)],l=``;try{l=h(o,`utf-8`)}catch{return``}let u=M(l,{start:{line:s,column:c-1}},{highlightCode:!0,linesBelow:0});return`${dim(i)}\n${u}\n`}function getUserCodeFrame(){return getCodeFrame((/* @__PURE__ */ Error()).stack.split(`
|
|
2
|
+
`).slice(1).find(e=>!e.includes(`node_modules/`)&&!e.includes(j)))}function jestFakeTimersAreEnabled(){if(typeof jest<`u`&&jest!==null)return setTimeout._isMockFunction===!0||Object.hasOwn(setTimeout,`clock`);let e=setTimeout.clock;return e!=null&&typeof e.tick==`function`}function advanceFakeTimersByTime(e){if(typeof jest<`u`&&jest!==null){jest.advanceTimersByTime(e);return}let t=globalThis.vi;t!=null&&typeof t.advanceTimersByTime==`function`&&typeof t.isFakeTimers==`function`&&t.isFakeTimers()?t.advanceTimersByTime(e):setTimeout.clock.tick(e)}function getDocument(){if(typeof window>`u`)throw Error(`Could not find default container`);return window.document}function getWindowFromNode(e){if(e.defaultView)return e.defaultView;if(e.ownerDocument&&e.ownerDocument.defaultView)return e.ownerDocument.defaultView;if(e.window)return e.window;throw e.ownerDocument&&e.ownerDocument.defaultView===null?Error(`It looks like the window object is not available for the provided node.`):e.then instanceof Function?Error("It looks like you passed a Promise object instead of a DOM node. Did you do something like `fireEvent.click(screen.findBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`, or await the findBy query `fireEvent.click(await screen.findBy...`?"):Array.isArray(e)?Error("It looks like you passed an Array instead of a DOM node. Did you do something like `fireEvent.click(screen.getAllBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`?"):typeof e.debug==`function`&&typeof e.logTestingPlaygroundURL==`function`?Error("It looks like you passed a `screen` object. Did you do something like `fireEvent.click(screen, ...` when you meant to use a query, e.g. `fireEvent.click(screen.getBy..., `?"):Error(`The given node is not an Element, the node type is: ${typeof e}.`)}function checkContainerType(e){if(!e||typeof e.querySelector!=`function`||typeof e.querySelectorAll!=`function`)throw TypeError(`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(e)}.`)}function getTypeName(e){return typeof e==`object`?e===null?`null`:e.constructor.name:typeof e}function implOf(e){let n=e[t];if(n===void 0)throw TypeError(`@ctrl/dom/testing-library requires nodes created by @ctrl/dom.`);return n}function matchesSelector(e,t){return e.type===a&&f(e,t)}function envDebugFormat(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG:void 0;if(e===void 0||e===``)return null;let t=String(e).trim().toLowerCase();return t===`aria`?`aria`:t===`compact`||t===`html`?`compact`:null}function containerLabel(e){let n=e?.[t];return n===void 0?`the container`:n.type===9?`the document`:describeElement(n)}function agentErrorContext(e,t,n){return t===`aria`?`Accessibility snapshot of ${containerLabel(e)} (CTRL_DOM_DEBUG=aria):\n${ariaSnapshot(e,{maxLines:envMaxLines()??100})}`:`DOM of ${containerLabel(e)} without class/style/SVG internals (CTRL_DOM_DEBUG=compact):\n${n(e,void 0,{format:`compact`})}`}function agentElementSummary(e){return ariaSnapshot(e,{maxLines:12})}function envMaxLines(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG_LINES:void 0,t=e?Number(e):NaN;return t>0?t:void 0}function ariaSnapshot(e,t={}){let{header:n,lines:r,empty:i}=ariaSnapshotLines(e,t);return i===null?n+budgetLines(r,t.maxLines??envMaxLines()??200).join(`
|
|
3
|
+
`):n+i}m(e=>ariaSnapshot(e,{maxLines:2e3}));function buildTree(e,t){let n=rootImpl(e),r=new SnapshotContext(n,t),i=[],o=``;return!r.includeHidden&&n.type===a&&E(n)&&(o=`# hidden from the accessibility tree: ${hiddenReason(n)}\n`,r.includeHidden=!0,r.forceHidden=!0),n.type===a&&n!==bodyOf(n)?r.visitElement(n,i,r.forceHidden):r.visitChildren(n,i,!1,!1),finishChildren(i,null),{root:n,ctx:r,children:i,header:o}}function ariaSnapshotTree(e,t={}){return buildTree(e,t).children}function ariaSnapshotLines(e,t={}){let{root:n,ctx:r,children:i,header:a}=buildTree(e,t),o=[];r.renderList(i,``,o);let s=o.length>0?null:r.sawHidden?`# no accessible content (hidden elements exist: pass { hidden: true })`:`# no accessible content`;return n===bodyOf(n)&&envDebugFormat()!==null&&recordBodySnapshot(n.doc,s??o.join(`
|
|
4
|
+
`)),{header:a,lines:o,empty:s}}function budgetLines(e,t){if(e.length<=t)return e;let n=e.length-t,r=e.slice(0,t);return r.push(`# … ${n} more line${n===1?``:`s`} (raise maxLines or CTRL_DOM_DEBUG_LINES)`),r}const I=Symbol.for(`ctrl-dom.agent.lastBodySnapshot`);function recordBodySnapshot(e,t){e!=null&&Object.defineProperty(e,I,{value:t,configurable:!0,writable:!0,enumerable:!1})}function lastBodySnapshot(e){return e?.[I]}function resetBodySnapshot(e){e!=null&&Object.hasOwn(e,I)&&delete e[I]}function rootImpl(e){let n=e??getDocument().body,r=n?.[t];if(r===void 0)throw TypeError(`Expected an element, document or fragment but got ${n===null?`null`:typeof n}`);if(r.type===i||r.tag===c.html&&r.ns===o){let e=r.doc?.body;return e?e[t]:r}return r}function bodyOf(e){let n=e.doc?.body;return n?n[t]:null}function normalizeSpace(e){return e.replace(/[\t\n\f\r ]+/g,` `)}function truncate(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+`…`:e}function quote(e){return JSON.stringify(e)}const L=/^$|^[\s\-?:,[\]{}#&*!|>'"%@`]|[\s]$|:$|: | #|^(true|false|null|yes|no|on|off|~)$|^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i;function yamlValue(e){return L.test(e)?quote(e):e}function nodeKey(e,t){let n=e.role;e.name!==``&&(n+=` `+quote(truncate(e.name,t)));for(let t=0;t<e.props.length;t++)n+=` `+e.props[t];return n}function describeElement(e){let t=e.name;if(e.id!==``)return`<${t} id="${e.id}">`;let n=d(e,`data-testid`);return n===null?`<${t}>`:`<${t} data-testid="${n}">`}function hiddenReason(e){let t=hiddenChainReason(e);return t===``?O(e)?`visibility: hidden on ${describeElement(e)}`:``:t}function hiddenChainReason(e){for(let t=e;t!==null&&t.type===a;t=t.parent){if(t.ns===o&&d(t,`hidden`)!==null)return`hidden attribute on ${describeElement(t)}`;if(u(t,`aria-hidden`)===`true`)return`aria-hidden="true" on ${describeElement(t)}`;if(T(t))return`display: none on ${describeElement(t)}`}return``}const R=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]);function isSkippedTag(e){if(e.ns!==o)return!1;switch(e.tag){case c.script:case c.style:case c.template:case c.noscript:case c.head:return!0}return!1}function nodeProps(e,t,n,r){let i=[];if(g(t,`aria-checked`)){let t=_(e);t===!0?i.push(`[checked]`):t===`mixed`&&i.push(`[checked=mixed]`)}C(e)&&i.push(`[disabled]`);let a=S(e);a===!0?i.push(`[expanded]`):a===!1&&i.push(`[expanded=false]`),n&&i.push(`[active]`);let o=t===`heading`?te(e):levelAttr(e);o!==void 0&&i.push(`[level=${o}]`);let s=v(e);s===!0?i.push(`[pressed]`):s===`mixed`?i.push(`[pressed=mixed]`):s===!1&&i.push(`[pressed=false]`),ee(e)===!0&&i.push(`[selected]`);let c=x(e);return c===!0?i.push(`[current]`):typeof c==`string`&&c!==``&&i.push(`[current=${c}]`),b(e)&&i.push(`[busy]`),r&&i.push(`[hidden]`),i}function levelAttr(e){let t=u(e,`aria-level`),n=t===null?NaN:Number(t);return n>0?n:void 0}const z=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`,`progressbar`,`meter`,`scrollbar`,`separator`]);function nodeValue(e,t){if(!z.has(t))return null;let n=u(e,`aria-valuetext`);if(n!==null)return n;let r=u(e,`aria-valuenow`);if(r!==null)return r;if(e.ns!==o)return null;if(e.tag===c.input||e.tag===c.textarea){let t=String(e.node.value??``);return t===``?null:t}return null}var SnapshotContext=class{includeHidden;forceHidden=!1;sawHidden=!1;maxText;collapseAfter;urls;active;constructor(e,n){this.includeHidden=n.hidden===!0,this.maxText=n.maxTextLength??100,this.collapseAfter=n.collapseAfter??5,this.urls=n.urls===!0;let r=e.doc?.activeElement,i=r?r[t]??null:null;this.active=i!==null&&i===bodyOf(e)?null:i}visitChildren(e,t,n,i){for(let o=e.first;o!==null;o=o.next)o.type===l?i||appendText(t,o.data):o.type===a?this.visitElement(o,t,n):o.type===r&&this.visitChildren(o,t,n,i)}visitElement(e,t,n){if(isSkippedTag(e))return;let r=n;if(!r&&D(e)){if(this.sawHidden=!0,!this.includeHidden)return;r=!0}let i=r;if(!r&&O(e)){if(this.sawHidden=!0,!this.includeHidden){this.visitChildren(e,t,!1,!0);return}i=!0}let a=k(e);if(R.has(a)){let n=!w(e);n&&appendBreak(t),this.visitChildren(e,t,r,!1),n&&appendBreak(t);return}let s={role:a,name:normalizeSpace(y(e,void 0,5)).trim(),props:nodeProps(e,a,e===this.active,i&&this.includeHidden),value:nodeValue(e,a),url:null,children:[],element:e};this.urls&&a===`link`&&(s.url=d(e,`href`)),(e.ns!==o||e.tag!==c.textarea)&&this.visitChildren(e,s.children,r,!1),finishChildren(s.children,s.name),t.push(s)}renderList(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`string`){n.push(`${t}- text: ${yamlValue(truncate(i,this.maxText))}`);continue}let a=1;for(;r+a<e.length&&typeof e[r+a]!=`string`&&e[r+a].role===i.role;)a++;if(a>this.collapseAfter+1){for(let i=0;i<this.collapseAfter;i++)this.renderNode(e[r+i],t,n);n.push(`${t}- ${i.role} … (+${a-this.collapseAfter} more)`),r+=a-1}else this.renderNode(i,t,n)}}renderNode(e,t,n){let r=nodeKey(e,this.maxText),i=e.children;if(e.url===null&&(i.length===0||i.length===1&&typeof i[0]==`string`&&e.value===null)){let a=e.value??(i.length===1?i[0]:null);n.push(a===null?`${t}- ${r}`:`${t}- ${r}: ${yamlValue(truncate(a,this.maxText))}`);return}n.push(e.value===null?`${t}- ${r}:`:`${t}- ${r}: ${yamlValue(truncate(e.value,this.maxText))}`);let a=t+` `;e.url!==null&&n.push(`${a}- /url: ${yamlValue(e.url)}`),this.renderList(i,a,n)}};function appendText(e,t){if(t===``)return;let n=e.length-1;n>=0&&typeof e[n]==`string`&&e[n]!==`\0`?e[n]=e[n]+t:e.push(t)}function appendBreak(e){let t=e.length-1;t>=0&&typeof e[t]==`string`&&e[t]!==`\0`&&e.push(`\0`)}function finishChildren(e,t){let n=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`&&(r===`\0`||(r=normalizeSpace(r).trim(),r===``))||(e[n++]=r)}e.length=n,e.length>0&&typeof e[0]==`string`&&e[0]===t&&e.splice(0,1),n=0;for(let t=0;t<e.length;t++){let r=e[t];(typeof r!=`string`||!labels(e[t-1],r)&&!labels(e[t+1],r))&&(e[n++]=r)}e.length=n}const B=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`,`meter`,`progressbar`]);function labels(e,t){return e!==void 0&&typeof e!=`string`&&e.name===t&&B.has(e.role)}let V=null;function loadPrettyFormat(t){if(V!==null)return V;try{return V=e(import.meta.url)(`pretty-format`)}catch(e){throw Error(`${t} needs pretty-format, which @ctrl/dom does not install: add pretty-format@27 to the project's devDependencies.`,{cause:e})}}const H=`The prettyFormat export`,U=Object.defineProperties({},{format:{enumerable:!0,get:()=>loadPrettyFormat(H).format},default:{enumerable:!0,get:()=>loadPrettyFormat(H).default},plugins:{enumerable:!0,get:()=>loadPrettyFormat(H).plugins},DEFAULT_OPTIONS:{enumerable:!0,get:()=>loadPrettyFormat(H).DEFAULT_OPTIONS}}),shouldHighlight=()=>{if(typeof process>`u`)return!1;let e;try{let t=process.env?.COLORS;t&&(e=JSON.parse(t))}catch{}return typeof e==`boolean`?e:process.versions!==void 0&&process.versions.node!==void 0};function filterCommentsAndDefaultIgnoreTagsTags(e){return e.nodeType!==n&&(e.nodeType!==a||!e.matches(getConfig().defaultIgnore))}const W={open:``,close:``},G={comment:W,content:W,prop:W,tag:W,value:W},K={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49],bgGray:[100,49],bgGrey:[100,49]},q={comment:`gray`,content:`reset`,prop:`yellow`,tag:`cyan`,value:`green`};function highlightColors(e){let t={};for(let n of Object.keys(q)){let r=e!==void 0&&e[n]!==void 0?e[n]:q[n],i=typeof r==`string`&&Object.hasOwn(K,r)?K[r]:void 0;if(i===void 0)throw Error(`pretty-format: Option "theme" has a key "${n}" whose value "${r}" is undefined in ansi-styles.`);t[n]={open:`\u001b[${i[0]}m`,close:`\u001b[${i[1]}m`}}return t}const J=highlightColors(void 0),Y=/* @__PURE__ */ new Set([`callToJSON`,`compareKeys`,`escapeRegex`,`escapeString`,`highlight`,`indent`,`maxDepth`,`min`,`plugins`,`printBasicPrototype`,`printFunctionName`,`theme`]),X=Symbol(`delegate`),Z=/^((HTML|SVG)\w*)?Element$/,Q=/* @__PURE__ */ new WeakMap;function isCustomElement(e){let{tagName:t}=e;return!!(typeof t==`string`&&t.includes(`-`)||typeof e.hasAttribute==`function`&&e.hasAttribute(`is`))}function pluginHandles(e){let t=e.node,i=t.constructor,o=i?.name;switch(e.type){case a:{if(!o&&!isCustomElement(t))return!1;if(typeof i!=`function`)return Z.test(o)||isCustomElement(t);let e=Q.get(i);return e===void 0&&Q.set(i,e=Z.test(o)),e||isCustomElement(t)}case l:return o===`Text`;case n:return o===`Comment`;case r:return o===`DocumentFragment`}return!1}function escapeHTML(e){return e.indexOf(`<`)===-1&&e.indexOf(`>`)===-1?e:e.replace(/</g,`<`).replace(/>/g,`>`)}function printString(e,t){return t.escapeString?`"`+e.replace(/"|\\/g,`\\$&`)+`"`:`"`+e+`"`}function keepChild(e,t){return t.filterNode===null?e.type===n?!1:e.type===a?t.scriptStyleIgnore?e.name!==`script`&&e.name!==`style`:!matchesSelector(e,t.defaultIgnore):!0:!!t.filterNode(e.node)}function tagNameLower(e){return e.node.tagName.toLowerCase()}function printProps(e,t,n){let r=e.attrs;if(r===null||r.length===0)return``;let i=[],a=/* @__PURE__ */ new Map;for(let n=0;n<r.length;n++)t.compact&&isNoiseAttribute(e,r[n].name)||(i.push(r[n].name),a.set(r[n].name,r[n].value));i.sort();let o=t.colors,s=``;for(let e=0;e<i.length;e++){let r=i[e];s+=t.spacingInner+n+o.prop.open+r+o.prop.close+`=`+o.value.open+printString(a.get(r),t)+o.value.close}return s}function isNoiseAttribute(e,t){return t===`class`||t===`style`||e.ns===s&&t!==`role`&&t!==`id`&&!t.startsWith(`aria-`)&&!t.startsWith(`data-`)}function printChildren(e,t,n,r){if(t.compact&&e.ns===s&&e.name===`svg`)return``;let i=``;for(let a=e.first;a!==null;a=a.next)keepChild(a,t)&&(t.compact&&a.type===l&&a.data.trim()===``||(i+=t.spacingOuter+n+printNode(a,t,n,r)));return i}function printElement(e,t,n,r,i){let a=r.colors.tag;return a.open+`<`+e+(t&&a.close+t+r.spacingOuter+i+a.open)+(n?`>`+a.close+n+r.spacingOuter+i+a.open+`</`+e:(t&&!r.min?``:` `)+`/`)+`>`+a.close}function printNode(e,t,i,a){if(!pluginHandles(e))throw X;if(e.type===l){let n=t.compact&&e.data.length>200?e.data.slice(0,199)+`…`:e.data;return t.colors.content.open+escapeHTML(n)+t.colors.content.close}if(e.type===n){let n=t.colors.comment;return n.open+`<!--`+escapeHTML(e.data)+`-->`+n.close}let o=e.type===r?`DocumentFragment`:tagNameLower(e),s=t.colors.tag;if(++a>t.maxDepth)return s.open+`<`+o+s.close+` …`+s.open+` />`+s.close;let c=i+t.indent;return printElement(o,e.type===r?``:printProps(e,t,c),printChildren(e,t,c,a),t,i)}function printForeignNode(e,t,i,a,o){if(!foreignHandles(e))throw X;if(e.nodeType===l)return t.colors.content.open+escapeHTML(e.data)+t.colors.content.close;if(e.nodeType===n)return t.colors.comment.open+`<!--`+escapeHTML(e.data)+`-->`+t.colors.comment.close;let s=e.nodeType===r,c=s?`DocumentFragment`:e.tagName.toLowerCase(),u=t.colors.tag;if(++o>t.maxDepth)return u.open+`<`+c+u.close+` …`+u.open+` />`+u.close;let d=a+t.indent,f=``;if(!s){let n=Array.from(e.attributes);n.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));for(let{name:e,value:r}of n)f+=t.spacingInner+d+t.colors.prop.open+e+t.colors.prop.close+`=`+t.colors.value.open+printString(r,t)+t.colors.value.close}let p=``,m=e.childNodes||e.children;for(let e=0;e<m.length;e++)i(m[e])&&(p+=t.spacingOuter+d+printForeignNode(m[e],t,i,d,o));return printElement(c,f,p,t,a)}function foreignHandles(e){let t=e?.constructor?.name;if(!t&&!isCustomElement(e))return!1;switch(e.nodeType){case a:return Z.test(t)||isCustomElement(e);case l:return t===`Text`;case n:return t===`Comment`;case r:return t===`DocumentFragment`}return!1}function makePrintConfig(e,t){for(let t of Object.keys(e))if(!Y.has(t))throw Error(`pretty-format: Unknown option "${t}".`);if(e.min&&e.indent!==void 0&&e.indent!==0)throw Error(`pretty-format: Options "min" and "indent" cannot be used together.`);if(e.theme!==void 0){if(e.theme===null)throw Error(`pretty-format: Option "theme" must not be null.`);if(typeof e.theme!=`object`)throw Error(`pretty-format: Option "theme" must be of type "object" but instead received "${typeof e.theme}".`)}if(e.plugins!==void 0)return null;let n=!!e.min,r=e.indent===void 0?2:e.indent,i=getConfig().defaultIgnore;return{colors:e.highlight?e.theme===void 0?J:highlightColors(e.theme):G,escapeString:e.escapeString===void 0||e.escapeString,indent:n?``:Array(r+1).join(` `),maxDepth:e.maxDepth===void 0?1/0:e.maxDepth,min:n,spacingInner:n?` `:`
|
|
5
|
+
`,spacingOuter:n?``:`
|
|
6
|
+
`,filterNode:t,scriptStyleIgnore:i===`script, style`,defaultIgnore:i,compact:!1}}function formatDOM(e,n,r,i=!1){let a={printFunctionName:!1,highlight:shouldHighlight(),...r},o=n??filterCommentsAndDefaultIgnoreTagsTags,s=makePrintConfig(a,n===void 0?null:n);if(s===null)return formatWithPrettyFormat(e,o,a,`The "plugins" option of prettyDOM`);s.compact=i;let c=e[t];try{return c===void 0?printForeignNode(e,s,o,``,0):printNode(c,s,``,0)}catch(e){if(e!==X)throw e}return formatWithPrettyFormat(e,o,a,`Printing a node other than an element, text, comment or fragment`)}function formatWithPrettyFormat(e,t,n,r=`pretty-format's own printing`){let i=loadPrettyFormat(r);return i.format(e,{plugins:[createDOMElementFilter(t),i.plugins.DOMCollection],...n})}function prettyDOM(e,t,n={}){e||=getDocument().body;let r=typeof t==`number`?t:void 0;if(typeof t!=`number`&&(t=typeof process<`u`&&process.env!==void 0&&process.env.DEBUG_PRINT_LIMIT||7e3),t===0)return``;e.documentElement&&(e=e.documentElement);let i=typeof e;if(i===`object`?i=e.constructor.name:e={},!(`outerHTML`in e))throw TypeError(`Expected an element or document but got ${i}`);let a=n.format??envDebugFormat();if(a!==null||`format`in n){let{format:i,hidden:o,maxLines:s,maxTextLength:c,collapseAfter:l,urls:u,...d}=n;if(a===`aria`){let t=ariaSnapshot(e,{hidden:o,maxLines:s,maxTextLength:c,collapseAfter:l,urls:u});return r!==void 0&&t.length>r?`${t.slice(0,r)}...`:t}if(n=d,a===`compact`){let{filterNode:r,...i}={highlight:!1,...n},a=formatDOM(e,r,i,!0);return a.length>t?`${a.slice(0,t)}...`:a}}let{filterNode:o,...s}=n,c=formatDOM(e,o,s);return t!==void 0&&outerHTMLLength(e)>t?`${c.slice(0,t)}...`:c}function outerHTMLLength(e){let n=e[t];return n!==void 0&&n.type===a?p(n).length:e.outerHTML.length}const logDOM=(...e)=>{let t=getUserCodeFrame();console.log(t?`${prettyDOM(...e)}\n\n${t}`:prettyDOM(...e))};function createDOMElementFilter(e){let printPropsPF=(e,t,n,r,i,a,o)=>{let s=r+n.indent,c=n.colors;return e.map(e=>{let l=t[e],u=o(l,n,s,i,a);return typeof l!=`string`&&(u.indexOf(`
|
|
7
|
+
`)!==-1&&(u=n.spacingOuter+s+u+n.spacingOuter+r),u=`{`+u+`}`),n.spacingInner+r+c.prop.open+e+c.prop.close+`=`+c.value.open+u+c.value.close}).join(``)},printText=(e,t)=>t.colors.content.open+escapeHTML(e)+t.colors.content.close,printChildrenPF=(e,t,n,r,i,a)=>e.map(e=>{let o=typeof e==`string`?printText(e,t):a(e,t,n,r,i);return o===``&&typeof e==`object`&&e&&e.nodeType!==l?``:t.spacingOuter+n+o}).join(``),testNode=e=>{let t=e.constructor.name,{nodeType:i}=e;return i===a&&(Z.test(t)||isCustomElement(e))||i===l&&t===`Text`||i===n&&t===`Comment`||i===r&&t===`DocumentFragment`};return{test:e=>(e?.constructor?.name||isCustomElement(e))&&testNode(e),serialize:(t,i,a,o,s,c)=>{if(t.nodeType===l)return printText(t.data,i);if(t.nodeType===n){let e=i.colors.comment;return e.open+`<!--`+escapeHTML(t.data)+`-->`+e.close}let u=t.nodeType===r,d=u?`DocumentFragment`:t.tagName.toLowerCase();if(++o>i.maxDepth){let e=i.colors.tag;return e.open+`<`+d+e.close+` …`+e.open+` />`+e.close}return printElement(d,printPropsPF(u?[]:Array.from(t.attributes).map(e=>e.name).sort(),u?{}:Array.from(t.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{}),i,a+i.indent,o,s,c),printChildrenPF(Array.prototype.slice.call(t.childNodes||t.children).filter(e),i,a+i.indent,o,s,c),i,a)}}}let $={testIdAttribute:`data-testid`,asyncUtilTimeout:1e3,asyncWrapper:e=>e(),unstable_advanceTimersWrapper:e=>e(),eventWrapper:e=>e(),defaultHidden:!1,defaultIgnore:`script, style`,showOriginalStackTrace:!1,throwSuggestions:!1,getElementError(e,t){let n=envDebugFormat();if(n!==null){let r=Error([e,agentErrorContext(t,n,prettyDOM)].filter(Boolean).join(`
|
|
8
|
+
|
|
9
|
+
`));return r.name=`TestingLibraryElementError`,r}let r=prettyDOM(t),i=Error([e,`Ignored nodes: comments, ${$.defaultIgnore}\n${r}`].filter(Boolean).join(`
|
|
10
|
+
|
|
11
|
+
`));return i.name=`TestingLibraryElementError`,i},_disableExpensiveErrorDiagnostics:!1,computedStyleSupportsPseudoElements:!1};function runWithExpensiveErrorDiagnosticsDisabled(e){try{return $._disableExpensiveErrorDiagnostics=!0,e()}finally{$._disableExpensiveErrorDiagnostics=!1}}function configure(e){typeof e==`function`&&(e=e($)),$={...$,...e}}function getConfig(){return $}function diffAriaSnapshots(e,t){let n=diffLines(e.split(`
|
|
12
|
+
`),t.split(`
|
|
13
|
+
`)),r=new Uint8Array(n.length),i=!1;for(let e=0;e<n.length;e++){if(n[e].kind===`=`)continue;i=!0,r[e]=1;let t=indentOf(n[e].text);for(let i=e-1;i>=0&&t>0;i--){if(n[i].kind!==`=`)continue;let e=indentOf(n[i].text);e<t&&(r[i]=1,t=e)}}if(!i)return`(no changes)`;let a=[],o=-1;for(let e=0;e<n.length;e++)r[e]!==0&&(o!==-1&&e!==o+1&&a.push(` …`),a.push(`${n[e].kind===`=`?` `:n[e].kind} ${n[e].text}`),o=e);return a.join(`
|
|
14
|
+
`)}function indentOf(e){let t=0;for(;t<e.length&&e.charCodeAt(t)===32;)t++;return t}function diffLines(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length,i=t.length;for(;r>n&&i>n&&e[r-1]===t[i-1];)r--,i--;let a=[];for(let t=0;t<n;t++)a.push({kind:`=`,text:e[t]});let o=r-n,s=i-n;if(o*s>4e6){for(let t=n;t<r;t++)a.push({kind:`-`,text:e[t]});for(let e=n;e<i;e++)a.push({kind:`+`,text:t[e]})}else{let r=s+1,i=new Uint32Array((o+1)*r);for(let a=o-1;a>=0;a--)for(let o=s-1;o>=0;o--)i[a*r+o]=e[n+a]===t[n+o]?i[(a+1)*r+o+1]+1:Math.max(i[(a+1)*r+o],i[a*r+o+1]);let c=0,l=0;for(;c<o||l<s;)c<o&&l<s&&e[n+c]===t[n+l]?(a.push({kind:`=`,text:e[n+c]}),c++,l++):c<o&&(l===s||i[(c+1)*r+l]>=i[c*r+l+1])?(a.push({kind:`-`,text:e[n+c]}),c++):(a.push({kind:`+`,text:t[n+l]}),l++)}for(let t=r;t<e.length;t++)a.push({kind:`=`,text:e[t]});return a}export{implOf as A,agentElementSummary as C,checkContainerType as D,advanceFakeTimersByTime as E,__exportAll as M,__name as N,getDocument as O,yamlValue as S,matchesSelector as T,nodeKey as _,runWithExpensiveErrorDiagnosticsDisabled as a,resetBodySnapshot as b,U as c,ariaSnapshotTree as d,budgetLines as f,lastBodySnapshot as g,hiddenReason as h,getConfig as i,jestFakeTimersAreEnabled as j,getWindowFromNode as k,ariaSnapshot as l,envMaxLines as m,diffLines as n,logDOM as o,describeElement as p,configure as r,prettyDOM as s,diffAriaSnapshots as t,ariaSnapshotLines as u,nodeProps as v,envDebugFormat as w,truncate as x,quote as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/aria-snapshot-diff-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/aria-snapshot-diff-BXYf4D_D.cjs");let t=require("@ctrl/dom/internal"),n=require("@ctrl/dom/aria");var AriaTemplateError=class extends Error{constructor(e,t,n,r=-1){super(`${e} (template line ${t+1}):\n\n${n}${r>=0?`\n${` `.repeat(r)}^`:``}`),this.name=`AriaTemplateError`}};function normalizeWhitespace(e){return e.replace(/[]/g,``).replace(/[\r\n\s\t]+/g,` `).trim()}function textValue(e){let t=null;if(e.length>1&&e.startsWith(`/`)&&e.endsWith(`/`))try{t=new RegExp(e.slice(1,-1))}catch{t=null}return{raw:e,normalized:normalizeWhitespace(e),regex:t}}const r=/* @__PURE__ */ new Set([`disabled`,`expanded`,`active`,`selected`,`busy`,`hidden`]);function parseAriaTemplate(e){let t=e.split(/\r?\n/),n=1/0;for(let e=0;e<t.length;e++){let r=t[e],i=r.trim();if(i===``||i.startsWith(`#`))continue;let a=r.length-r.trimStart().length;if(r.slice(0,a).includes(` `))throw new AriaTemplateError(`Tabs cannot be used for indentation`,e,r);a<n&&(n=a)}let r={kind:`role`,role:`fragment`,name:null,attrs:[],url:null,mode:null,children:[]};if(n===1/0)throw new AriaTemplateError(`The aria snapshot template is empty`,0,e);let i=[{indent:-1,node:r,line:-1}];for(let e=0;e<t.length;e++){let r=t[e],a=r.trim();if(a===``||a.startsWith(`#`))continue;let o=r.length-r.trimStart().length-n;if(a!==`-`&&!a.startsWith(`- `))throw new AriaTemplateError(`Aria snapshot must be a YAML sequence, elements starting with "-"`,e,r,o+n);for(;i[i.length-1].indent>=o;)i.pop();let s=i[i.length-1];if(s.node===null)throw new AriaTemplateError(`"- text:" on line ${s.line+1} cannot have children`,e,r,o+n);let c=a.slice(2).trimStart(),l=r.length-c.length,u=parseItem(c,s.node,e,r,l);u!==void 0&&i.push({indent:o,node:u,line:e})}return r.children.length===1&&(r.mode===null||r.mode===`contain`)&&r.url===null?r.children[0]:r}function parseItem(e,t,n,r,i){let fail=(e,t)=>{throw new AriaTemplateError(e,n,r,i+t)};if(e===``&&fail(`Empty sequence item`,0),e.startsWith(`/`)){let n=e.indexOf(`:`);n<0&&fail("Property should be written `/name: value`",e.length);let r=e.slice(1,n).trim(),i=parseScalar(e.slice(n+1),fail,n+1);r===`children`?(i!==`contain`&&i!==`equal`&&i!==`deep-equal`&&fail(`Value of "/children" should be "contain", "equal" or "deep-equal"`,n+1),t.mode=i):r===`url`&&(t.url=textValue(i));return}let a,o=null;try{if(e[0]===`"`||e[0]===`'`){let[n,r]=readQuoted(e,0,fail),i=e.slice(r).trimStart();if(i!==``&&i[0]!==`:`&&fail(`Unexpected input after the quoted key`,r),i!==``&&(o=i.slice(1)),n===`text`&&o!==null)return textItem(t,o,fail,e.length-o.length);a=new KeyParser(n).parse(!1)}else{if(/^text:(\s|$)/.test(e))return textItem(t,e.slice(5),fail,5);let n=new KeyParser(e);a=n.parse(!0),n.pos<e.length&&(o=e.slice(n.pos+1))}}catch(t){throw t instanceof KeyError&&fail(t.message,e[0]===`"`||e[0]===`'`?0:t.pos),t}return o!==null&&o.trim()!==``&&a.children.push({kind:`text`,text:textValue(parseScalar(o,fail,e.length-o.length))}),t.children.push(a),a}function textItem(e,t,n,r){return e.children.push({kind:`text`,text:textValue(parseScalar(t,n,r))}),null}function parseScalar(e,t,n){let r=e.length-e.trimStart().length,i=e.trim();if(i[0]===`"`||i[0]===`'`){let[e,a]=readQuoted(i,0,(e,i)=>t(e,n+r+i)),o=i.slice(a).trim();return o!==``&&!o.startsWith(`#`)&&t(`Unexpected input after the quoted value`,n+r+a),e}(i===`|`||i===`>`||i.startsWith(`|`)||i.startsWith(`>`))&&t(`Block scalars are not supported in aria snapshot templates`,n+r);let a=i.search(/\s#/);return a>=0?i.slice(0,a).trim():i}function readQuoted(e,t,n){let r=e[t],i=``;for(let n=t+1;n<e.length;n++){let t=e[n];if(r===`'`){if(t===`'`){if(e[n+1]===`'`){i+=`'`,n++;continue}return[i,n+1]}i+=t}else{if(t===`"`)return[i,n+1];if(t===`\\`){let t=e[++n];t===`n`?i+=`
|
|
2
2
|
`:t===`t`?i+=` `:t===`u`?(i+=String.fromCharCode(parseInt(e.slice(n+1,n+5),16)),n+=4):i+=t??``}else i+=t}}return n(`Unterminated string`,e.length)}var KeyError=class extends Error{pos;constructor(e,t){super(e),this.pos=t}},KeyParser=class{pos=0;input;constructor(e){this.input=e}peek(){return this.input[this.pos]??``}eof(){return this.pos>=this.input.length}skipWhitespace(){for(;!this.eof()&&/\s/.test(this.peek());)this.pos++}atColon(){return this.peek()===`:`&&(this.pos+1>=this.input.length||/\s/.test(this.input[this.pos+1]))}readIdentifier(e){if(this.eof())throw new KeyError(`Unexpected end of input when expecting ${e}`,this.pos);let t=this.pos;for(;!this.eof()&&/[a-zA-Z]/.test(this.peek());)this.pos++;if(this.pos===t)throw new KeyError(`Expected ${e}`,this.pos);return this.input.slice(t,this.pos)}readString(){let e=``;for(;!this.eof();){let t=this.input[this.pos++];if(t===`\\`){let t=this.input[this.pos++]??``;t===`n`?e+=`
|
|
3
3
|
`:t===`t`?e+=` `:t===`u`?(e+=String.fromCharCode(parseInt(this.input.slice(this.pos,this.pos+4),16)),this.pos+=4):e+=t}else if(t===`"`)return e;else e+=t}throw new KeyError(`Unterminated string`,this.pos)}readRegex(){let e=this.pos,t=``,n=!1,r=!1;for(;!this.eof();){let i=this.input[this.pos++];if(n)t+=i,n=!1;else if(i===`\\`)n=!0,t+=i;else if(i===`/`&&!r)try{return new RegExp(t)}catch(t){throw new KeyError(`Invalid regular expression: ${t.message}`,e)}else i===`[`?(r=!0,t+=i):i===`]`&&r?(t+=i,r=!1):t+=i}throw new KeyError(`Unterminated regex`,this.pos)}parse(e){this.skipWhitespace();let t=this.readIdentifier(`role`);this.skipWhitespace();let n=null;this.peek()===`"`?(this.pos++,n=normalizeWhitespace(this.readString())):this.peek()===`/`&&(this.pos++,n=this.readRegex());let r={kind:`role`,role:t,name:n===``?null:n,attrs:[],url:null,mode:null,children:[]};for(;this.skipWhitespace(),this.peek()===`[`;){this.pos++,this.skipWhitespace();let e=this.pos,t=this.readIdentifier(`attribute`);this.skipWhitespace();let n=``;if(this.peek()===`=`)for(this.pos++,this.skipWhitespace();this.peek()!==`]`&&!/\s/.test(this.peek())&&!this.eof();)n+=this.input[this.pos++];if(this.skipWhitespace(),this.peek()!==`]`)throw new KeyError(`Expected ]`,this.pos);this.pos++,r.attrs.push([t,checkAttribute(t,n||`true`,e)])}if(this.skipWhitespace(),e&&this.atColon())return r;if(!this.eof())throw new KeyError(e?`Unexpected input (a key ends with ":" and a space)`:`Unexpected input`,this.pos);return r}};function checkAttribute(e,t,n){if(e===`checked`||e===`pressed`){if(t!==`true`&&t!==`false`&&t!==`mixed`)throw new KeyError(`Value of "${e}" attribute must be a boolean or "mixed"`,n);return t}if(r.has(e)){if(t!==`true`&&t!==`false`)throw new KeyError(`Value of "${e}" attribute must be a boolean`,n);return t}if(e===`level`){if(Number.isNaN(Number(t)))throw new KeyError(`Value of "level" attribute must be a number`,n);return String(Number(t))}if(e===`current`)return t;throw new KeyError(`Unsupported attribute [${e}]`,n)}function toMatchNode(e){let t=[];e.value!==null&&e.value!==``&&t.push(normalizeWhitespace(e.value));for(let n=0;n<e.children.length;n++){let r=e.children[n];t.push(typeof r==`string`?normalizeWhitespace(r):toMatchNode(r))}let n=/* @__PURE__ */ new Map;for(let t=0;t<e.props.length;t++){let r=e.props[t].slice(1,-1),i=r.indexOf(`=`);i<0?n.set(r,`true`):n.set(r.slice(0,i),r.slice(i+1))}return{role:e.role,name:normalizeWhitespace(e.name),states:n,url:e.url,children:t,props:e.props}}function stateOf(e,t){let r=e.states.get(t);if(r!==void 0)return r;switch(t){case`checked`:return(0,n.roleSupportsProp)(e.role,`aria-checked`)?`false`:void 0;case`disabled`:case`selected`:case`active`:case`busy`:case`hidden`:case`current`:return`false`}}function attrsMatch(e,t){for(let n=0;n<t.attrs.length;n++){let[r,i]=t.attrs[n],a=stateOf(e,r);if(r===`current`&&i===`true`){if(a===void 0||a===`false`)return!1}else if(a!==i)return!1}return!0}function matchesName(e,t){return t===null?!0:e===``?!1:typeof t==`string`?e===t:t.test(e)}function matchesText(e,t){return t===null||t.normalized===``?!0:e?e===t.normalized||e===t.raw||t.regex!==null&&t.regex.test(e):!1}function headerMatches(e,t){return(t.role===`fragment`||t.role===e.role)&&attrsMatch(e,t)&&matchesName(e.name,t.name)&&matchesText(e.url,t.url)}function matchesNode(e,t,n){return typeof e==`string`?t.kind===`text`&&matchesText(e,t.text):t.kind!==`role`||!headerMatches(e,t)?!1:t.mode===`contain`?containsList(e.children,t.children):t.mode===`equal`?listEqual(e.children,t.children,!1):t.mode===`deep-equal`||n?listEqual(e.children,t.children,!0):containsList(e.children,t.children)}function listEqual(e,t,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!matchesNode(e[r],t[r],n))return!1;return!0}function containsList(e,t){if(t.length>e.length)return!1;let n=0;for(let r=0;r<t.length;r++){for(;n<e.length&&!matchesNode(e[n],t[r],!1);)n++;if(n===e.length)return!1;n++}return!0}function matchesDeep(e,t){if(matchesNode(e,t,!1))return!0;if(typeof e==`string`)return!1;for(let n=0;n<e.children.length;n++)if(matchesDeep(e.children[n],t))return!0;return!1}function textRepr(t){return t.regex===null?e.S(t.normalized):t.raw}function templateKey(t){let n=t.role;typeof t.name==`string`?n+=` `+e.y(t.name):t.name!==null&&(n+=` /${t.name.source}/`);for(let e=0;e<t.attrs.length;e++)n+=t.attrs[e][1]===`true`?` [${t.attrs[e][0]}]`:` [${t.attrs[e][0]}=${t.attrs[e][1]}]`;return n}function receivedKey(t){let n=t.role;t.name!==``&&(n+=` `+e.y(e.x(t.name,100)));for(let e=0;e<t.props.length;e++)n+=` `+t.props[e];return n}function isInline(e){return e.url===null&&e.mode===null&&e.children.length===1&&e.children[0].kind===`text`}function renderTemplate(e,t,n){if(e.kind===`text`){n.push(`${t}- text: ${textRepr(e.text)}`);return}let r=templateKey(e);if(isInline(e)){n.push(`${t}- ${r}: ${textRepr(e.children[0].text)}`);return}if(e.children.length===0&&e.url===null&&e.mode===null){n.push(`${t}- ${r}`);return}n.push(`${t}- ${r}:`);let i=t+` `;e.url!==null&&n.push(`${i}- /url: ${textRepr(e.url)}`),e.mode!==null&&n.push(`${i}- /children: ${e.mode}`);for(let t=0;t<e.children.length;t++)renderTemplate(e.children[t],i,n)}var Scorer=class{memo=/* @__PURE__ */ new Map;score(e,t){if(e.kind===`text`)return typeof t==`string`?matchesText(t,e.text)?3:1:0;if(typeof t==`string`||e.role!==`fragment`&&e.role!==t.role)return 0;let n=this.memo.get(e);n===void 0&&this.memo.set(e,n=/* @__PURE__ */ new Map);let r=n.get(t);if(r!==void 0)return r;let i=2;return i+=e.name===null?1:matchesName(t.name,e.name)?2:0,attrsMatch(t,e)&&(i+=1),e.url!==null&&matchesText(t.url,e.url)&&(i+=1),i+=this.scoreList(e.children,t.children),n.set(t,i),i}scoreList(e,t){let n=this.align(e,t),r=0;for(let t=0;t<e.length;t++)n[t]!==null&&(r+=this.score(e[t],n[t]));return r}align(e,t){let n=[],r=0;for(let i=0;i<e.length;i++){let a=-1,o=0;for(let n=r;n<t.length;n++){let r=this.score(e[i],t[n]);r>o&&(a=n,o=r)}a<0?n.push(null):(n.push(t[a]),r=a+1)}return n}project(t,n,r,i){if(t.kind===`text`){let a=n;i.push(`${r}- text: ${matchesText(a,t.text)?textRepr(t.text):e.S(e.x(a,100))}`);return}let a=n,o=headerMatches(a,t)?templateKey(t):receivedKey(a),s=this.align(t.children,a.children);if(isInline(t)){let n=s[0],a=t.children[0].text;i.push(n===null?`${r}- ${o}`:`${r}- ${o}: ${matchesText(n,a)?textRepr(a):e.S(e.x(n,100))}`);return}if(t.children.length===0&&t.url===null&&t.mode===null){i.push(`${r}- ${o}`);return}i.push(`${r}- ${o}:`);let c=r+` `;t.url!==null&&i.push(`${c}- /url: ${matchesText(a.url,t.url)?textRepr(t.url):e.S(a.url??``)}`),t.mode!==null&&i.push(`${c}- /children: ${t.mode}`);for(let e=0;e<t.children.length;e++)s[e]!==null&&this.project(t.children[e],s[e],c,i)}};function forEachNode(e,t){t(e);for(let n=0;n<e.children.length;n++){let r=e.children[n];typeof r==`string`?t(r):forEachNode(r,t)}}function closestLines(e,t){let n=new Scorer,r=[];if(t.kind===`role`&&t.role===`fragment`){let i=null,a=0;if(forEachNode(e,e=>{if(typeof e==`string`)return;let r=n.scoreList(t.children,e.children);r>a&&(i=e,a=r)}),i!==null){let e=n.align(t.children,i.children);for(let i=0;i<t.children.length;i++)e[i]!==null&&n.project(t.children[i],e[i],``,r)}return r}let i=null,a=0;return forEachNode(e,e=>{let r=n.score(t,e);r>a&&(i=e,a=r)}),i!==null&&n.project(t,i,``,r),r}function pairChanges(e){let t=[];for(let n=0;n<e.length;){if(e[n].kind===`=`){t.push(e[n++]);continue}let r=n;for(;r<e.length&&e[r].kind===`-`;)r++;let i=r;for(;i<e.length&&e[i].kind===`+`;)i++;if(r-n===i-r)for(let i=0;i<r-n;i++)t.push(e[n+i],e[r+i]);else for(let r=n;r<i;r++)t.push(e[r]);n=i}return t}function matchAriaSnapshot(t,n){let r=parseAriaTemplate(n),i=e.d(t,{urls:!0}),a=[];for(let e=0;e<i.length;e++){let t=i[e];a.push(typeof t==`string`?normalizeWhitespace(t):toMatchNode(t))}let o={role:`fragment`,name:``,states:/* @__PURE__ */ new Map,url:null,children:a,props:[]},s=matchesDeep(o,r),expectedLines=()=>{let e=[];if(r.kind===`role`&&r.role===`fragment`){r.mode!==null&&e.push(`- /children: ${r.mode}`);for(let t=0;t<r.children.length;t++)renderTemplate(r.children[t],``,e)}else renderTemplate(r,``,e);return e};return{pass:s,expected:()=>expectedLines().join(`
|
|
4
4
|
`),diff:()=>pairChanges(e.n(expectedLines(),closestLines(o,r))),received:()=>e.l(t,{collapseAfter:1/0,maxLines:e.m()??100})}}function resetFailureSnapshot(t){e.b(t)}function captureFailureSnapshot(n){let r=e.w(),i=n?.body;if(r===null||i==null||i[t.$impl]===void 0)return null;if(r===`compact`){let t=e.s(i,void 0,{format:`compact`});return{format:r,text:String(t),full:``,previous:void 0}}let a=e.g(n),{lines:o,empty:s}=e.u(i),c=s??o.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{S as e,b as t,d as n,f as r,g as i,l as a,m as o,n as s,s as c,t as l,u,w as d,x as f,y as p}from"./_chunks/aria-snapshot-diff-
|
|
1
|
+
import{S as e,b as t,d as n,f as r,g as i,l as a,m as o,n as s,s as c,t as l,u,w as d,x as f,y as p}from"./_chunks/aria-snapshot-diff-DejA3Rdn.js";import{$impl as m}from"@ctrl/dom/internal";import{roleSupportsProp as h}from"@ctrl/dom/aria";var AriaTemplateError=class extends Error{constructor(e,t,n,r=-1){super(`${e} (template line ${t+1}):\n\n${n}${r>=0?`\n${` `.repeat(r)}^`:``}`),this.name=`AriaTemplateError`}};function normalizeWhitespace(e){return e.replace(/[]/g,``).replace(/[\r\n\s\t]+/g,` `).trim()}function textValue(e){let t=null;if(e.length>1&&e.startsWith(`/`)&&e.endsWith(`/`))try{t=new RegExp(e.slice(1,-1))}catch{t=null}return{raw:e,normalized:normalizeWhitespace(e),regex:t}}const g=/* @__PURE__ */ new Set([`disabled`,`expanded`,`active`,`selected`,`busy`,`hidden`]);function parseAriaTemplate(e){let t=e.split(/\r?\n/),n=1/0;for(let e=0;e<t.length;e++){let r=t[e],i=r.trim();if(i===``||i.startsWith(`#`))continue;let a=r.length-r.trimStart().length;if(r.slice(0,a).includes(` `))throw new AriaTemplateError(`Tabs cannot be used for indentation`,e,r);a<n&&(n=a)}let r={kind:`role`,role:`fragment`,name:null,attrs:[],url:null,mode:null,children:[]};if(n===1/0)throw new AriaTemplateError(`The aria snapshot template is empty`,0,e);let i=[{indent:-1,node:r,line:-1}];for(let e=0;e<t.length;e++){let r=t[e],a=r.trim();if(a===``||a.startsWith(`#`))continue;let o=r.length-r.trimStart().length-n;if(a!==`-`&&!a.startsWith(`- `))throw new AriaTemplateError(`Aria snapshot must be a YAML sequence, elements starting with "-"`,e,r,o+n);for(;i[i.length-1].indent>=o;)i.pop();let s=i[i.length-1];if(s.node===null)throw new AriaTemplateError(`"- text:" on line ${s.line+1} cannot have children`,e,r,o+n);let c=a.slice(2).trimStart(),l=r.length-c.length,u=parseItem(c,s.node,e,r,l);u!==void 0&&i.push({indent:o,node:u,line:e})}return r.children.length===1&&(r.mode===null||r.mode===`contain`)&&r.url===null?r.children[0]:r}function parseItem(e,t,n,r,i){let fail=(e,t)=>{throw new AriaTemplateError(e,n,r,i+t)};if(e===``&&fail(`Empty sequence item`,0),e.startsWith(`/`)){let n=e.indexOf(`:`);n<0&&fail("Property should be written `/name: value`",e.length);let r=e.slice(1,n).trim(),i=parseScalar(e.slice(n+1),fail,n+1);r===`children`?(i!==`contain`&&i!==`equal`&&i!==`deep-equal`&&fail(`Value of "/children" should be "contain", "equal" or "deep-equal"`,n+1),t.mode=i):r===`url`&&(t.url=textValue(i));return}let a,o=null;try{if(e[0]===`"`||e[0]===`'`){let[n,r]=readQuoted(e,0,fail),i=e.slice(r).trimStart();if(i!==``&&i[0]!==`:`&&fail(`Unexpected input after the quoted key`,r),i!==``&&(o=i.slice(1)),n===`text`&&o!==null)return textItem(t,o,fail,e.length-o.length);a=new KeyParser(n).parse(!1)}else{if(/^text:(\s|$)/.test(e))return textItem(t,e.slice(5),fail,5);let n=new KeyParser(e);a=n.parse(!0),n.pos<e.length&&(o=e.slice(n.pos+1))}}catch(t){throw t instanceof KeyError&&fail(t.message,e[0]===`"`||e[0]===`'`?0:t.pos),t}return o!==null&&o.trim()!==``&&a.children.push({kind:`text`,text:textValue(parseScalar(o,fail,e.length-o.length))}),t.children.push(a),a}function textItem(e,t,n,r){return e.children.push({kind:`text`,text:textValue(parseScalar(t,n,r))}),null}function parseScalar(e,t,n){let r=e.length-e.trimStart().length,i=e.trim();if(i[0]===`"`||i[0]===`'`){let[e,a]=readQuoted(i,0,(e,i)=>t(e,n+r+i)),o=i.slice(a).trim();return o!==``&&!o.startsWith(`#`)&&t(`Unexpected input after the quoted value`,n+r+a),e}(i===`|`||i===`>`||i.startsWith(`|`)||i.startsWith(`>`))&&t(`Block scalars are not supported in aria snapshot templates`,n+r);let a=i.search(/\s#/);return a>=0?i.slice(0,a).trim():i}function readQuoted(e,t,n){let r=e[t],i=``;for(let n=t+1;n<e.length;n++){let t=e[n];if(r===`'`){if(t===`'`){if(e[n+1]===`'`){i+=`'`,n++;continue}return[i,n+1]}i+=t}else{if(t===`"`)return[i,n+1];if(t===`\\`){let t=e[++n];t===`n`?i+=`
|
|
2
2
|
`:t===`t`?i+=` `:t===`u`?(i+=String.fromCharCode(parseInt(e.slice(n+1,n+5),16)),n+=4):i+=t??``}else i+=t}}return n(`Unterminated string`,e.length)}var KeyError=class extends Error{pos;constructor(e,t){super(e),this.pos=t}},KeyParser=class{pos=0;input;constructor(e){this.input=e}peek(){return this.input[this.pos]??``}eof(){return this.pos>=this.input.length}skipWhitespace(){for(;!this.eof()&&/\s/.test(this.peek());)this.pos++}atColon(){return this.peek()===`:`&&(this.pos+1>=this.input.length||/\s/.test(this.input[this.pos+1]))}readIdentifier(e){if(this.eof())throw new KeyError(`Unexpected end of input when expecting ${e}`,this.pos);let t=this.pos;for(;!this.eof()&&/[a-zA-Z]/.test(this.peek());)this.pos++;if(this.pos===t)throw new KeyError(`Expected ${e}`,this.pos);return this.input.slice(t,this.pos)}readString(){let e=``;for(;!this.eof();){let t=this.input[this.pos++];if(t===`\\`){let t=this.input[this.pos++]??``;t===`n`?e+=`
|
|
3
3
|
`:t===`t`?e+=` `:t===`u`?(e+=String.fromCharCode(parseInt(this.input.slice(this.pos,this.pos+4),16)),this.pos+=4):e+=t}else if(t===`"`)return e;else e+=t}throw new KeyError(`Unterminated string`,this.pos)}readRegex(){let e=this.pos,t=``,n=!1,r=!1;for(;!this.eof();){let i=this.input[this.pos++];if(n)t+=i,n=!1;else if(i===`\\`)n=!0,t+=i;else if(i===`/`&&!r)try{return new RegExp(t)}catch(t){throw new KeyError(`Invalid regular expression: ${t.message}`,e)}else i===`[`?(r=!0,t+=i):i===`]`&&r?(t+=i,r=!1):t+=i}throw new KeyError(`Unterminated regex`,this.pos)}parse(e){this.skipWhitespace();let t=this.readIdentifier(`role`);this.skipWhitespace();let n=null;this.peek()===`"`?(this.pos++,n=normalizeWhitespace(this.readString())):this.peek()===`/`&&(this.pos++,n=this.readRegex());let r={kind:`role`,role:t,name:n===``?null:n,attrs:[],url:null,mode:null,children:[]};for(;this.skipWhitespace(),this.peek()===`[`;){this.pos++,this.skipWhitespace();let e=this.pos,t=this.readIdentifier(`attribute`);this.skipWhitespace();let n=``;if(this.peek()===`=`)for(this.pos++,this.skipWhitespace();this.peek()!==`]`&&!/\s/.test(this.peek())&&!this.eof();)n+=this.input[this.pos++];if(this.skipWhitespace(),this.peek()!==`]`)throw new KeyError(`Expected ]`,this.pos);this.pos++,r.attrs.push([t,checkAttribute(t,n||`true`,e)])}if(this.skipWhitespace(),e&&this.atColon())return r;if(!this.eof())throw new KeyError(e?`Unexpected input (a key ends with ":" and a space)`:`Unexpected input`,this.pos);return r}};function checkAttribute(e,t,n){if(e===`checked`||e===`pressed`){if(t!==`true`&&t!==`false`&&t!==`mixed`)throw new KeyError(`Value of "${e}" attribute must be a boolean or "mixed"`,n);return t}if(g.has(e)){if(t!==`true`&&t!==`false`)throw new KeyError(`Value of "${e}" attribute must be a boolean`,n);return t}if(e===`level`){if(Number.isNaN(Number(t)))throw new KeyError(`Value of "level" attribute must be a number`,n);return String(Number(t))}if(e===`current`)return t;throw new KeyError(`Unsupported attribute [${e}]`,n)}function toMatchNode(e){let t=[];e.value!==null&&e.value!==``&&t.push(normalizeWhitespace(e.value));for(let n=0;n<e.children.length;n++){let r=e.children[n];t.push(typeof r==`string`?normalizeWhitespace(r):toMatchNode(r))}let n=/* @__PURE__ */ new Map;for(let t=0;t<e.props.length;t++){let r=e.props[t].slice(1,-1),i=r.indexOf(`=`);i<0?n.set(r,`true`):n.set(r.slice(0,i),r.slice(i+1))}return{role:e.role,name:normalizeWhitespace(e.name),states:n,url:e.url,children:t,props:e.props}}function stateOf(e,t){let n=e.states.get(t);if(n!==void 0)return n;switch(t){case`checked`:return h(e.role,`aria-checked`)?`false`:void 0;case`disabled`:case`selected`:case`active`:case`busy`:case`hidden`:case`current`:return`false`}}function attrsMatch(e,t){for(let n=0;n<t.attrs.length;n++){let[r,i]=t.attrs[n],a=stateOf(e,r);if(r===`current`&&i===`true`){if(a===void 0||a===`false`)return!1}else if(a!==i)return!1}return!0}function matchesName(e,t){return t===null?!0:e===``?!1:typeof t==`string`?e===t:t.test(e)}function matchesText(e,t){return t===null||t.normalized===``?!0:e?e===t.normalized||e===t.raw||t.regex!==null&&t.regex.test(e):!1}function headerMatches(e,t){return(t.role===`fragment`||t.role===e.role)&&attrsMatch(e,t)&&matchesName(e.name,t.name)&&matchesText(e.url,t.url)}function matchesNode(e,t,n){return typeof e==`string`?t.kind===`text`&&matchesText(e,t.text):t.kind!==`role`||!headerMatches(e,t)?!1:t.mode===`contain`?containsList(e.children,t.children):t.mode===`equal`?listEqual(e.children,t.children,!1):t.mode===`deep-equal`||n?listEqual(e.children,t.children,!0):containsList(e.children,t.children)}function listEqual(e,t,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!matchesNode(e[r],t[r],n))return!1;return!0}function containsList(e,t){if(t.length>e.length)return!1;let n=0;for(let r=0;r<t.length;r++){for(;n<e.length&&!matchesNode(e[n],t[r],!1);)n++;if(n===e.length)return!1;n++}return!0}function matchesDeep(e,t){if(matchesNode(e,t,!1))return!0;if(typeof e==`string`)return!1;for(let n=0;n<e.children.length;n++)if(matchesDeep(e.children[n],t))return!0;return!1}function textRepr(t){return t.regex===null?e(t.normalized):t.raw}function templateKey(e){let t=e.role;typeof e.name==`string`?t+=` `+p(e.name):e.name!==null&&(t+=` /${e.name.source}/`);for(let n=0;n<e.attrs.length;n++)t+=e.attrs[n][1]===`true`?` [${e.attrs[n][0]}]`:` [${e.attrs[n][0]}=${e.attrs[n][1]}]`;return t}function receivedKey(e){let t=e.role;e.name!==``&&(t+=` `+p(f(e.name,100)));for(let n=0;n<e.props.length;n++)t+=` `+e.props[n];return t}function isInline(e){return e.url===null&&e.mode===null&&e.children.length===1&&e.children[0].kind===`text`}function renderTemplate(e,t,n){if(e.kind===`text`){n.push(`${t}- text: ${textRepr(e.text)}`);return}let r=templateKey(e);if(isInline(e)){n.push(`${t}- ${r}: ${textRepr(e.children[0].text)}`);return}if(e.children.length===0&&e.url===null&&e.mode===null){n.push(`${t}- ${r}`);return}n.push(`${t}- ${r}:`);let i=t+` `;e.url!==null&&n.push(`${i}- /url: ${textRepr(e.url)}`),e.mode!==null&&n.push(`${i}- /children: ${e.mode}`);for(let t=0;t<e.children.length;t++)renderTemplate(e.children[t],i,n)}var Scorer=class{memo=/* @__PURE__ */ new Map;score(e,t){if(e.kind===`text`)return typeof t==`string`?matchesText(t,e.text)?3:1:0;if(typeof t==`string`||e.role!==`fragment`&&e.role!==t.role)return 0;let n=this.memo.get(e);n===void 0&&this.memo.set(e,n=/* @__PURE__ */ new Map);let r=n.get(t);if(r!==void 0)return r;let i=2;return i+=e.name===null?1:matchesName(t.name,e.name)?2:0,attrsMatch(t,e)&&(i+=1),e.url!==null&&matchesText(t.url,e.url)&&(i+=1),i+=this.scoreList(e.children,t.children),n.set(t,i),i}scoreList(e,t){let n=this.align(e,t),r=0;for(let t=0;t<e.length;t++)n[t]!==null&&(r+=this.score(e[t],n[t]));return r}align(e,t){let n=[],r=0;for(let i=0;i<e.length;i++){let a=-1,o=0;for(let n=r;n<t.length;n++){let r=this.score(e[i],t[n]);r>o&&(a=n,o=r)}a<0?n.push(null):(n.push(t[a]),r=a+1)}return n}project(t,n,r,i){if(t.kind===`text`){let a=n;i.push(`${r}- text: ${matchesText(a,t.text)?textRepr(t.text):e(f(a,100))}`);return}let a=n,o=headerMatches(a,t)?templateKey(t):receivedKey(a),s=this.align(t.children,a.children);if(isInline(t)){let n=s[0],a=t.children[0].text;i.push(n===null?`${r}- ${o}`:`${r}- ${o}: ${matchesText(n,a)?textRepr(a):e(f(n,100))}`);return}if(t.children.length===0&&t.url===null&&t.mode===null){i.push(`${r}- ${o}`);return}i.push(`${r}- ${o}:`);let c=r+` `;t.url!==null&&i.push(`${c}- /url: ${matchesText(a.url,t.url)?textRepr(t.url):e(a.url??``)}`),t.mode!==null&&i.push(`${c}- /children: ${t.mode}`);for(let e=0;e<t.children.length;e++)s[e]!==null&&this.project(t.children[e],s[e],c,i)}};function forEachNode(e,t){t(e);for(let n=0;n<e.children.length;n++){let r=e.children[n];typeof r==`string`?t(r):forEachNode(r,t)}}function closestLines(e,t){let n=new Scorer,r=[];if(t.kind===`role`&&t.role===`fragment`){let i=null,a=0;if(forEachNode(e,e=>{if(typeof e==`string`)return;let r=n.scoreList(t.children,e.children);r>a&&(i=e,a=r)}),i!==null){let e=n.align(t.children,i.children);for(let i=0;i<t.children.length;i++)e[i]!==null&&n.project(t.children[i],e[i],``,r)}return r}let i=null,a=0;return forEachNode(e,e=>{let r=n.score(t,e);r>a&&(i=e,a=r)}),i!==null&&n.project(t,i,``,r),r}function pairChanges(e){let t=[];for(let n=0;n<e.length;){if(e[n].kind===`=`){t.push(e[n++]);continue}let r=n;for(;r<e.length&&e[r].kind===`-`;)r++;let i=r;for(;i<e.length&&e[i].kind===`+`;)i++;if(r-n===i-r)for(let i=0;i<r-n;i++)t.push(e[n+i],e[r+i]);else for(let r=n;r<i;r++)t.push(e[r]);n=i}return t}function matchAriaSnapshot(e,t){let r=parseAriaTemplate(t),i=n(e,{urls:!0}),c=[];for(let e=0;e<i.length;e++){let t=i[e];c.push(typeof t==`string`?normalizeWhitespace(t):toMatchNode(t))}let l={role:`fragment`,name:``,states:/* @__PURE__ */ new Map,url:null,children:c,props:[]},u=matchesDeep(l,r),expectedLines=()=>{let e=[];if(r.kind===`role`&&r.role===`fragment`){r.mode!==null&&e.push(`- /children: ${r.mode}`);for(let t=0;t<r.children.length;t++)renderTemplate(r.children[t],``,e)}else renderTemplate(r,``,e);return e};return{pass:u,expected:()=>expectedLines().join(`
|
|
4
4
|
`),diff:()=>pairChanges(s(expectedLines(),closestLines(l,r))),received:()=>a(e,{collapseAfter:1/0,maxLines:o()??100})}}function resetFailureSnapshot(e){t(e)}function captureFailureSnapshot(e){let t=d(),n=e?.body;if(t===null||n==null||n[m]===void 0)return null;if(t===`compact`){let e=c(n,void 0,{format:`compact`});return{format:t,text:String(e),full:``,previous:void 0}}let a=i(e),{lines:s,empty:l}=u(n),f=l??s.join(`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/aria-snapshot-diff-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/aria-snapshot-diff-BXYf4D_D.cjs");let t=require("@ctrl/dom/internal"),n=require("@ctrl/dom/aria"),r=require("@ctrl/dom/aria/internal"),i=require("node:async_hooks");function isLabelable(e){if(e.type!==t.ELEMENT_NODE||e.ns!==t.HTML_NS)return!1;switch(e.tag){case t.T.button:case t.T.meter:case t.T.output:case t.T.progress:case t.T.select:case t.T.textarea:return!0;case t.T.input:{let n=(0,t.attr)(e,`type`);return n===null||(0,t.asciiLowercase)(n)!==`hidden`}}return!1}function isLabelledNodeName(e){if(e.prefix!==null)return!1;switch((0,t.asciiLowercase)(e.name)){case`button`:case`meter`:case`output`:case`progress`:case`select`:case`textarea`:case`input`:return!0}return!1}function buildIdMap(e,n){let r=/* @__PURE__ */ new Map;n&&e.type===t.ELEMENT_NODE&&e.id!==``&&r.set(e.id,e);for(let n=e.first;n!==null;n=(0,t.nextInTree)(n,e))n.type===t.ELEMENT_NODE&&n.id!==``&&!r.has(n.id)&&r.set(n.id,n);return r}var LabelContext=class{container;containerIds;sameTree;labelMap;constructor(e,t=!1){this.container=e,this.containerIds=null,this.sameTree=t,this.labelMap=null}labelsOf(e){return this.sameTree?isLabelable(e)?(this.labelMap??=(0,r.labelMapForTree)(this.container)).get(e)??a:a:(0,r.labelsOf)(e)??a}byIdInContainer(e){let t=this.containerIds;return t===null&&(t=this.containerIds=buildIdMap(this.container,!1)),t.get(e)??null}};const a=[];function getTextContent(e){if(e.type===t.ELEMENT_NODE&&isLabelledNodeName(e))return``;if(e.type===t.TEXT_NODE)return e.data;let n=``;for(let t=e.first;t!==null;t=t.next)n+=getTextContent(t);return n}function getLabelContentImpl(e){if(e.tag===t.T.label&&e.ns===t.HTML_NS)return getTextContent(e);let n=e.node;return n.value||n.textContent}const o=/* @__PURE__ */ new Set([`button`,`input`,`meter`,`output`,`progress`,`select`,`textarea`]);function labelledFormControl(n,r){for(let i=n.first;i!==null;i=(0,t.nextInTree)(i,n))if(i.type===t.ELEMENT_NODE&&o.has(i.name)&&(r===`*`||e.T(i,r)))return i}function getLabelsImpl(e,n,r=`*`){let i=(0,t.ariaAttr)(n,`aria-labelledby`),a=i?i.split(` `):[];return a.length?a.map(t=>{let n=e.byIdInContainer(t);return n?{content:getLabelContentImpl(n),formControl:null}:{content:``,formControl:null}}):e.labelsOf(n).map(e=>({content:getLabelContentImpl(e),formControl:labelledFormControl(e,r)}))}function assertNotNullOrUndefined(e){if(e==null)throw Error(`It looks like ${e} was passed instead of a matcher. Did you do something like getByText(${e})?`)}function fuzzyMatches(e,t,n,r){if(typeof e!=`string`)return!1;assertNotNullOrUndefined(n);let i=r(e);return typeof n==`string`||typeof n==`number`?i.toLowerCase().includes(n.toString().toLowerCase()):typeof n==`function`?n(i,t):matchRegExp(n,i)}function matches(e,t,n,r){if(typeof e!=`string`)return!1;assertNotNullOrUndefined(n);let i=r(e);return n instanceof Function?n(i,t):n instanceof RegExp?matchRegExp(n,i):i===String(n)}function isRegExpWhitespace(e){return e<=32?e===32||e>=9&&e<=13:e<160?!1:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function changedByNormalizing(e,t,n){let r=e.length-1,i=!1;for(let a=0;a<=r;a++){let o=e.charCodeAt(a),s=isRegExpWhitespace(o);if(s&&(t&&(a===0||a===r)||n&&(i||o!==32)))return!0;i=s}return!1}const s=/\s+/g;function getDefaultNormalizer({trim:e=!0,collapseWhitespace:t=!0}={}){return n=>{if(!changedByNormalizing(n,e,t))return n;let r=n;return r=e?r.trim():r,r=t?r.replace(s,` `):r,r}}const c=getDefaultNormalizer();function textMatcher(e,t,n){if(!e)return(e,r)=>fuzzyMatches(e,r,t,n);if(n!==c||typeof t!=`string`&&typeof t!=`number`)return(e,r)=>matches(e,r,t,n);let r=String(t);if(changedByNormalizing(r,!0,!0))return()=>!1;let i=r.length,a=r.charCodeAt(0),o=r.charCodeAt(i-1);return e=>{if(typeof e!=`string`||e.length<i)return!1;if(i!==0){let t=e.charCodeAt(0);if(t!==a&&!isRegExpWhitespace(t))return!1;let n=e.charCodeAt(e.length-1);if(n!==o&&!isRegExpWhitespace(n))return!1}return c(e)===r}}function makeNormalizer({trim:e,collapseWhitespace:t,normalizer:n}){if(!n)return e===void 0&&t===void 0?c:getDefaultNormalizer({trim:e,collapseWhitespace:t});if(e!==void 0||t!==void 0)throw Error(`trim and collapseWhitespace are not supported with a normalizer. If you want to use the default trim and collapseWhitespace logic in your normalizer, use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer`);return n}function matchRegExp(e,t){let n=e.test(t);return e.global&&e.lastIndex!==0&&(console.warn(`To match all elements we had to reset the lastIndex of the RegExp because the global flag is enabled. We encourage to remove the global flag from the RegExp.`),e.lastIndex=0),n}function isButtonLikeInput(e){if(e.tag!==t.T.input||e.ns!==t.HTML_NS)return!1;let n=(0,t.attr)(e,`type`);if(n===null)return!1;let r=(0,t.asciiLowercase)(n);return r===`submit`||r===`button`||r===`reset`}function getNodeTextImpl(e){if(isButtonLikeInput(e))return e.node.value;let n=``;for(let r=e.first;r!==null;r=r.next)r.type===t.TEXT_NODE&&(n+=r.data);return n}function getNodeText(n){let r=e.A(n);return r.type===t.ELEMENT_NODE?getNodeTextImpl(r):n.matches(`input[type=submit], input[type=button], input[type=reset]`)}const l={computedStyleSupportsPseudoElements:!0};function styleOverride(e){return(0,t.getComputedStyleOverride)(e)}function nameOptions(e,t){return t===null?e?l:void 0:{computedStyleSupportsPseudoElements:e,getComputedStyle:t}}const u={implicitRole(e){let t=(0,r.implicitRole)(e);return t===``?null:t},roleMatches:r.tlRoleMatches,roleSupportsProp(e,t){return typeof e==`string`&&(0,n.roleSupportsProp)(e,t)},computeAccessibleName(e,t,n){return(0,r.computeAccessibleNameImpl)(e,nameOptions(t,n),5)},computeAccessibleDescription(e,t,n){return(0,r.computeAccessibleDescriptionImpl)(e,nameOptions(t,n),5)},isInaccessible:r.isInaccessibleImpl,isInaccessibleWithStyle:r.isInaccessibleWithStyle,isSubtreeInaccessible:r.isSubtreeInaccessibleImpl};function parentElement(e){let n=e.parent;return n!==null&&n.type===t.ELEMENT_NODE?n:null}function isInaccessibleImpl$1(e){return u.isInaccessible(e)}e.N(isInaccessibleImpl$1,`isInaccessibleImpl`);function isInaccessibleChecked(e){let t=styleOverride(e);return t===null?u.isInaccessible(e):u.isInaccessibleWithStyle(e,t,null)}function isInaccessible(t,n={}){let i=e.A(t),a=n.isSubtreeInaccessible,o=styleOverride(i);if(a===void 0)return o===null?isInaccessibleImpl$1(i):u.isInaccessibleWithStyle(i,o,null);if(o===null?(0,r.isVisibilityHidden)(i):o(t).visibility===`hidden`)return!0;for(let e=i;e!==null;e=parentElement(e))if(a(e.node))return!0;return!1}function getImplicitAriaRolesImpl(e){let t=u.implicitRole(e);return t===null?[]:[t]}function getRoles(n,{hidden:r=!1}={}){let i=e.A(n),a={},o=r===!1?styleOverride(i):null,s=o===null?null:/* @__PURE__ */ new Map,visit=e=>{if(r!==!1||(o===null?isInaccessibleImpl$1(e):u.isInaccessibleWithStyle(e,o,s))===!1){let n=(0,t.attr)(e,`role`),r=n===null?getImplicitAriaRolesImpl(e):n.split(` `).slice(0,1);for(let t of r){let n=a[t];Array.isArray(n)?n.push(e.node):a[t]=[e.node]}}for(let n=e.first;n!==null;n=n.next)n.type===t.ELEMENT_NODE&&visit(n)};return visit(i),a}const d={format:`pretty`};function prettyRoles(t,{hidden:n,includeDescription:r}){let i=getRoles(t,{hidden:n}),a=e.i().computedStyleSupportsPseudoElements,o=styleOverride(e.A(t));return Object.entries(i).filter(([e])=>e!==`generic`).map(([t,n])=>{let i=`-`.repeat(50);return`${t}:\n\n${n.map(t=>{let n=e.A(t),i=`Name "${u.computeAccessibleName(n,a,o)}":\n`,s=e.s(t.cloneNode(!1),void 0,d);return r?`${i}${`Description "${u.computeAccessibleDescription(n,a,o)}":\n`}${s}`:`${i}${s}`}).join(`
|
|
2
2
|
|
|
3
3
|
`)}\n\n${i}`}).join(`
|
|
4
|
-
`)}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,n){let r=(0,t.attr)(e,n);if(r===`true`)return!0;if(r===`false`)return!1}function computeAriaSelected(e){return e.tag===t.T.option&&e.ns===t.HTML_NS?e.node.selected:checkBooleanAttribute(e,`aria-selected`)}function computeAriaBusy(e){return(0,t.
|
|
4
|
+
`)}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,n){let r=(0,t.attr)(e,n);if(r===`true`)return!0;if(r===`false`)return!1}function computeAriaSelected(e){return e.tag===t.T.option&&e.ns===t.HTML_NS?e.node.selected:checkBooleanAttribute(e,`aria-selected`)}function computeAriaBusy(e){return(0,t.ariaAttr)(e,`aria-busy`)===`true`}function computeAriaChecked(e){let t=e.node;if(!(`indeterminate`in t&&t.indeterminate))return`checked`in t?t.checked:checkBooleanAttribute(e,`aria-checked`)}function computeAriaPressed(e){return checkBooleanAttribute(e,`aria-pressed`)}function computeAriaCurrent(e){return checkBooleanAttribute(e,`aria-current`)??(0,t.ariaAttr)(e,`aria-current`)??!1}function computeAriaExpanded(e){return checkBooleanAttribute(e,`aria-expanded`)}function computeHeadingLevelImpl(e){let n=(0,t.ariaAttr)(e,`aria-level`),r=n&&Number(n);if(r)return r;if(e.ns===t.HTML_NS)switch(e.tag){case t.T.h1:return 1;case t.T.h2:return 2;case t.T.h3:return 3;case t.T.h4:return 4;case t.T.h5:return 5;case t.T.h6:return 6}}function computeAriaValueNow(e){let n=(0,t.ariaAttr)(e,`aria-valuenow`);return n===null?void 0:+n}function computeAriaValueMax(e){let n=(0,t.ariaAttr)(e,`aria-valuemax`);return n===null?void 0:+n}function computeAriaValueMin(e){let n=(0,t.ariaAttr)(e,`aria-valuemin`);return n===null?void 0:+n}function computeAriaValueText(e){let n=(0,t.ariaAttr)(e,`aria-valuetext`);return n===null?void 0:n}const f=getDefaultNormalizer();function escapeRegExp(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,`\\$&`)}function getRegExpMatcher(e){return new RegExp(escapeRegExp(e.toLowerCase()),`i`)}function makeSuggestion(t,n,r,{variant:i,name:a}){let o=``,s={},c=[[`Role`,`TestId`].includes(t)?r:getRegExpMatcher(r)];a&&(s.name=getRegExpMatcher(a)),t===`Role`&&isInaccessibleChecked(e.A(n))&&(s.hidden=!0,o=`Element is inaccessible. This means that the element and all its children are invisible to screen readers.
|
|
5
5
|
If you are using the aria-hidden prop, make sure this is the right choice for your case.
|
|
6
|
-
`),Object.keys(s).length>0&&c.push(s);let l=`${i}By${t}`;return{queryName:t,queryMethod:l,queryArgs:c,variant:i,warning:o,toString(){o&&console.warn(o);let[e,t]=c;return e=typeof e==`string`?`'${e}'`:e,t=t?`, { ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)} }`:``,`${l}(${e}${t})`}}}function canSuggest(e,t,n){return!(!n||t&&t.toLowerCase()!==e.toLowerCase())}function getSuggestedQuery(n,r=`get`,i){let a=e.A(n);if(e.T(a,e.i().defaultIgnore))return;let o=(0,t.attr)(a,`role`)??getImplicitAriaRolesImpl(a)?.[0];if(o!==`generic`&&canSuggest(`Role`,i,o))return makeSuggestion(`Role`,n,o,{variant:r,name:u.computeAccessibleName(a,e.i().computedStyleSupportsPseudoElements,styleOverride(a))});let s=getLabelsImpl(new LabelContext(e.A(e.O())),a).map(e=>e.content).join(` `);if(canSuggest(`LabelText`,i,s))return makeSuggestion(`LabelText`,n,s,{variant:r});let c=(0,t.attr)(a,`placeholder`);if(canSuggest(`PlaceholderText`,i,c))return makeSuggestion(`PlaceholderText`,n,c,{variant:r});let l=f(getNodeTextImpl(a));if(canSuggest(`Text`,i,l))return makeSuggestion(`Text`,n,l,{variant:r});if(canSuggest(`DisplayValue`,i,n.value))return makeSuggestion(`DisplayValue`,n,f(n.value),{variant:r});let d=(0,t.attr)(a,`alt`);if(canSuggest(`AltText`,i,d))return makeSuggestion(`AltText`,n,d,{variant:r});let p=(0,t.attr)(a,`title`);if(canSuggest(`Title`,i,p))return makeSuggestion(`Title`,n,p,{variant:r});let m=n.getAttribute(e.i().testIdAttribute);if(canSuggest(`TestId`,i,m))return makeSuggestion(`TestId`,n,m,{variant:r})}function copyStackTrace(e,t){e.stack=t.stack.replace(t.message,e.message)}function waitForImpl(t,{container:n=e.O(),timeout:r=e.i().asyncUtilTimeout,showOriginalStackTrace:a=e.i().showOriginalStackTrace,stackTraceError:o,interval:s=50,onTimeout:c=t=>(t.name===`TestingLibraryElementError`&&e.w()!==null||Object.defineProperty(t,"message",{value:e.i().getElementError(t.message,n).message}),t),mutationObserverOptions:l={subtree:!0,childList:!0,attributes:!0,characterData:!0}},u=null){if(typeof t!=`function`)throw TypeError("Received `callback` arg must be a function");return new Promise(async(d,f)=>{let p,m,h,g=!1,_=`idle`,v=setTimeout(handleTimeout,r),y=e.j();if(y){let{unstable_advanceTimersWrapper:t}=e.i();for(checkCallback();!g;){if(!e.j()){let e=/* @__PURE__ */ Error(`Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`);a||copyStackTrace(e,o),f(e);return}if(await t(async()=>{e.E(s)}),g)break;checkCallback()}}else{try{e.D(n)}catch(e){g=!0,clearTimeout(v),f(e);return}let t=u===null?null:i.AsyncLocalStorage.snapshot(),r=t===null?checkRealTimersCallback:()=>t(checkRealTimersCallback);m=setInterval(r,s);let{MutationObserver:a}=e.k(n);h=new a(r),h.observe(n,l),checkCallback()}function onDone(e,t){g=!0,clearTimeout(v),y||(clearInterval(m),h.disconnect()),e?f(e):d(t)}function checkRealTimersCallback(){if(e.j()){let e=/* @__PURE__ */ Error(`Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`);return a||copyStackTrace(e,o),f(e)}return checkCallback()}function checkCallback(){if(_!==`pending`){u!==null&&(u.data.checks=(u.data.checks??0)+1);try{let n=e.a(t);typeof n?.then==`function`?(_=`pending`,n.then(e=>{_=`resolved`,onDone(null,e)},e=>{_=`rejected`,p=e})):onDone(null,n)}catch(e){p=e}}}function handleTimeout(){let e;p?(e=p,!a&&e.name===`TestingLibraryElementError`&©StackTrace(e,o)):(e=/* @__PURE__ */ Error(`Timed out in waitFor.`),a||copyStackTrace(e,o)),onDone(c(e),null)}})}function waitFor(e,n){return(0,t.tracing)()?(0,t.tracePromise)(`testing-library.wait_for`,`waitFor(${describeCallback(e)})`,t=>waitForInSpan(e,n,t)):waitForInSpan(e,n,null)}function waitForInSpan(t,n,r){let i=/* @__PURE__ */ Error(`STACK_TRACE_MESSAGE`);return e.i().asyncWrapper(()=>waitForImpl(t,{stackTraceError:i,...n},r))}function describeCallback(e){if(typeof e!=`function`)return String(e);let t=Function.prototype.toString.call(e).replace(/\s+/g,` `).replace(/__vite_ssr_import_\d+__\./g,``).replace(/\(0, ?([\w$.]+)\)/g,`$1`).replace(/(?<![\w$.])_[a-z][\w$]*\.(?=[\w$])/g,``),n=/^(async )?\(\) ?=> ?\{ ?(?:return )?(.*?);? ?\}$/.exec(t);return n!==null&&!n[2].includes(`;`)&&(t=`${n[1]??``}() => ${n[2]}`),t.length>120?`${t.slice(0,119)}…`:t}function getElementError(t,n){return e.i().getElementError(t,n)}function getMultipleElementsFoundError(e,t){return getElementError(`${e}\n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).`,t)}function queryAllByAttribute(n,r,i,{exact:a=!0,collapseWhitespace:o,trim:s,normalizer:c}={}){let l=a
|
|
6
|
+
`),Object.keys(s).length>0&&c.push(s);let l=`${i}By${t}`;return{queryName:t,queryMethod:l,queryArgs:c,variant:i,warning:o,toString(){o&&console.warn(o);let[e,t]=c;return e=typeof e==`string`?`'${e}'`:e,t=t?`, { ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)} }`:``,`${l}(${e}${t})`}}}function canSuggest(e,t,n){return!(!n||t&&t.toLowerCase()!==e.toLowerCase())}function getSuggestedQuery(n,r=`get`,i){let a=e.A(n);if(e.T(a,e.i().defaultIgnore))return;let o=(0,t.attr)(a,`role`)??getImplicitAriaRolesImpl(a)?.[0];if(o!==`generic`&&canSuggest(`Role`,i,o))return makeSuggestion(`Role`,n,o,{variant:r,name:u.computeAccessibleName(a,e.i().computedStyleSupportsPseudoElements,styleOverride(a))});let s=getLabelsImpl(new LabelContext(e.A(e.O())),a).map(e=>e.content).join(` `);if(canSuggest(`LabelText`,i,s))return makeSuggestion(`LabelText`,n,s,{variant:r});let c=(0,t.attr)(a,`placeholder`);if(canSuggest(`PlaceholderText`,i,c))return makeSuggestion(`PlaceholderText`,n,c,{variant:r});let l=f(getNodeTextImpl(a));if(canSuggest(`Text`,i,l))return makeSuggestion(`Text`,n,l,{variant:r});if(canSuggest(`DisplayValue`,i,n.value))return makeSuggestion(`DisplayValue`,n,f(n.value),{variant:r});let d=(0,t.attr)(a,`alt`);if(canSuggest(`AltText`,i,d))return makeSuggestion(`AltText`,n,d,{variant:r});let p=(0,t.attr)(a,`title`);if(canSuggest(`Title`,i,p))return makeSuggestion(`Title`,n,p,{variant:r});let m=n.getAttribute(e.i().testIdAttribute);if(canSuggest(`TestId`,i,m))return makeSuggestion(`TestId`,n,m,{variant:r})}function copyStackTrace(e,t){e.stack=t.stack.replace(t.message,e.message)}function waitForImpl(t,{container:n=e.O(),timeout:r=e.i().asyncUtilTimeout,showOriginalStackTrace:a=e.i().showOriginalStackTrace,stackTraceError:o,interval:s=50,onTimeout:c=t=>(t.name===`TestingLibraryElementError`&&e.w()!==null||Object.defineProperty(t,"message",{value:e.i().getElementError(t.message,n).message}),t),mutationObserverOptions:l={subtree:!0,childList:!0,attributes:!0,characterData:!0}},u=null){if(typeof t!=`function`)throw TypeError("Received `callback` arg must be a function");return new Promise(async(d,f)=>{let p,m,h,g=!1,_=`idle`,v=setTimeout(handleTimeout,r),y=e.j();if(y){let{unstable_advanceTimersWrapper:t}=e.i();for(checkCallback();!g;){if(!e.j()){let e=/* @__PURE__ */ Error(`Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`);a||copyStackTrace(e,o),f(e);return}if(await t(async()=>{e.E(s)}),g)break;checkCallback()}}else{try{e.D(n)}catch(e){g=!0,clearTimeout(v),f(e);return}let t=u===null?null:i.AsyncLocalStorage.snapshot(),r=t===null?checkRealTimersCallback:()=>t(checkRealTimersCallback);m=setInterval(r,s);let{MutationObserver:a}=e.k(n);h=new a(r),h.observe(n,l),checkCallback()}function onDone(e,t){g=!0,clearTimeout(v),y||(clearInterval(m),h.disconnect()),e?f(e):d(t)}function checkRealTimersCallback(){if(e.j()){let e=/* @__PURE__ */ Error(`Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`);return a||copyStackTrace(e,o),f(e)}return checkCallback()}function checkCallback(){if(_!==`pending`){u!==null&&(u.data.checks=(u.data.checks??0)+1);try{let n=e.a(t);typeof n?.then==`function`?(_=`pending`,n.then(e=>{_=`resolved`,onDone(null,e)},e=>{_=`rejected`,p=e})):onDone(null,n)}catch(e){p=e}}}function handleTimeout(){let e;p?(e=p,!a&&e.name===`TestingLibraryElementError`&©StackTrace(e,o)):(e=/* @__PURE__ */ Error(`Timed out in waitFor.`),a||copyStackTrace(e,o)),onDone(c(e),null)}})}function waitFor(e,n){return(0,t.tracing)()?(0,t.tracePromise)(`testing-library.wait_for`,`waitFor(${describeCallback(e)})`,t=>waitForInSpan(e,n,t)):waitForInSpan(e,n,null)}function waitForInSpan(t,n,r){let i=/* @__PURE__ */ Error(`STACK_TRACE_MESSAGE`);return e.i().asyncWrapper(()=>waitForImpl(t,{stackTraceError:i,...n},r))}function describeCallback(e){if(typeof e!=`function`)return String(e);let t=Function.prototype.toString.call(e).replace(/\s+/g,` `).replace(/__vite_ssr_import_\d+__\./g,``).replace(/\(0, ?([\w$.]+)\)/g,`$1`).replace(/(?<![\w$.])_[a-z][\w$]*\.(?=[\w$])/g,``),n=/^(async )?\(\) ?=> ?\{ ?(?:return )?(.*?);? ?\}$/.exec(t);return n!==null&&!n[2].includes(`;`)&&(t=`${n[1]??``}() => ${n[2]}`),t.length>120?`${t.slice(0,119)}…`:t}function getElementError(t,n){return e.i().getElementError(t,n)}function getMultipleElementsFoundError(e,t){return getElementError(`${e}\n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).`,t)}function queryAllByAttribute(n,r,i,{exact:a=!0,collapseWhitespace:o,trim:s,normalizer:c}={}){let l=textMatcher(a,i,makeNormalizer({collapseWhitespace:o,trim:s,normalizer:c})),u=e.A(r),d=(0,t.asciiLowercase)(n),f=(0,t.prefixFlag)(d),p=(0,t.prefixFlag)(n),m=[];for(let e=u.first;e!==null;e=(0,t.nextInTree)(e,u)){if(e.type!==t.ELEMENT_NODE||e.attrs===null)continue;let r=(e.flags&t.F_HTML)!==0,i=r?f:p;if(i!==0&&(e.flags&i)===0)continue;let a=(0,t.attr)(e,r?d:n);a!==null&&l(a,e.node)&&m.push(e.node)}return m}function queryByAttribute(e,t,n,r){let i=queryAllByAttribute(e,t,n,r);if(i.length>1)throw getMultipleElementsFoundError(`Found multiple elements by [${e}=${n}]`,t);return i[0]||null}function makeSingleQuery(t,n){return(r,...i)=>{let a=t(r,...i);if(a.length>1){let t=e.w()===null?a.map(e=>getElementError(null,e).message).join(`
|
|
7
7
|
|
|
8
8
|
`):a.map(t=>e.C(t)).join(`
|
|
9
9
|
`);throw getMultipleElementsFoundError(`${n(r,...i)}
|
|
@@ -13,9 +13,9 @@ Here are the matching elements:
|
|
|
13
13
|
${t}`,r)}return a[0]||null}}function getSuggestionError(t,n){return e.i().getElementError(`A better query is available, try this:
|
|
14
14
|
${t.toString()}
|
|
15
15
|
`,n)}function makeGetAllQuery(t,n){return(r,...i)=>{let a=t(r,...i);if(!a.length)throw e.i().getElementError(n(r,...i),r);return a}}function makeFindQuery(e,n=`find`){return(r,i,a,o)=>{let find=t=>waitForInSpan(()=>e(r,i,a),{container:r,...o},t);return(0,t.tracing)()?(0,t.tracePromise)(p,(0,t.describeCall)(n,[i,a]),async e=>{let t=await find(e);return e.data.matches=matchCount(t),t}):find(null)}}const p=`testing-library.query`,matchCount=e=>Array.isArray(e)?e.length:+!!e;function traceQuery(e,n){return(r,...i)=>(0,t.tracing)()?(0,t.traceSync)(p,(0,t.describeCall)(e,i),e=>{let t=n(r,...i);return e.data.matches=matchCount(t),t}):n(r,...i)}const wrapSingleQueryWithSuggestion=(t,n,r)=>(i,...a)=>{let o=t(i,...a),[{suggest:s=e.i().throwSuggestions}={}]=a.slice(-1);if(o&&s){let e=getSuggestedQuery(o,r);if(e&&!n.endsWith(e.queryName))throw getSuggestionError(e.toString(),i)}return o},wrapAllByQueryWithSuggestion=(t,n,r)=>(i,...a)=>{let o=t(i,...a),[{suggest:s=e.i().throwSuggestions}={}]=a.slice(-1);if(o.length&&s){let e=[...new Set(o.map(e=>getSuggestedQuery(e,r)?.toString()))];if(e.length===1&&!n.endsWith(getSuggestedQuery(o[0],r).queryName))throw getSuggestionError(e[0],i)}return o};function buildQueries(e,t,n){let r=wrapSingleQueryWithSuggestion(makeSingleQuery(e,t),e.name,`query`),i=makeGetAllQuery(e,n),a=makeSingleQuery(i,t),o=wrapSingleQueryWithSuggestion(a,e.name,`get`),s=wrapAllByQueryWithSuggestion(i,e.name.replace(`query`,`get`),`getAll`),c=e.name.startsWith(`queryAll`)?e.name.slice(8):``,l=makeFindQuery(wrapAllByQueryWithSuggestion(i,e.name,`findAll`),`findAll${c}`),u=makeFindQuery(wrapSingleQueryWithSuggestion(a,e.name,`find`),`find${c}`);return[traceQuery(`query${c}`,r),traceQuery(`getAll${c}`,s),traceQuery(`get${c}`,o),l,u]}const m=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]),h=/* @__PURE__ */ e.N(e=>e,`identity`);function normalize(e){return e.replace(/\s+/g,` `).trim()}function similarity(e,t){let n=normalize(e).toLowerCase(),r=normalize(t).toLowerCase();if(n===``||r===``)return-1;if(n===r)return 0;if(n.includes(r)||r.includes(n))return 1;let i=r.split(` `);for(let e=0;e<i.length;e++)if(i[e].length>2&&n.includes(i[e]))return 2;return-1}function closeness(e,t,n,r,i=!0){if((i?matches:fuzzyMatches)(e,t,n,r))return 0;if(typeof n==`string`||typeof n==`number`){let t=similarity(r(e),String(n));return t===-1?-1:t+1}return-1}function line(t,n,r,i,a){let o={role:n,name:r,props:e.v(t,n,!1,i),value:null,url:null,children:[],element:t};return`- ${e._(o,80)} # ${a}`}function format(e,t){if(t.length===0)return``;t.sort((e,t)=>e.rank-t.rank);let n=t.slice(0,10).map(e=>e.line);return t.length>10&&n.push(`# … ${t.length-10} more`),`${e}:\n${n.join(`
|
|
16
|
-
`)}`}function nameOf(e){return normalize((0,r.computeAccessibleNameImpl)(e,void 0,5))}function roleCandidates(n,i){let a=e.A(n),o=[],s=i.name;for(let n=a.first;n!==null;n=(0,t.nextInTree)(n,a)){if(n.type!==t.ELEMENT_NODE)continue;let a=(0,r.isInaccessibleImpl)(n),c=(0,r.tlRole)(n);if((0,r.tlRoleMatches)(n,i.role,i.queryFallbacks)){let t=nameOf(n),r=s===void 0?0:closeness(t,n.node,s,h),l=i.matchesState(n);r===0&&l?a&&!i.hidden&&o.push({line:line(n,c,t,!0,`hidden: ${e.h(n)} (or pass { hidden: true })`),rank:0}):r===0?o.push({line:line(n,c,t,a&&!i.hidden,`role and name match, state is not ${i.stateHint}`),rank:1}):(!a||i.hidden)&&o.push({line:line(n,c,t,!1,r>0?`similar name`:`same role, other name`),rank:r>0?2+r:10});continue}if(s===void 0)continue;if(!m.has(c)){let e=nameOf(n);if(e===``)continue;let t=closeness(e,n.node,s,h);t>=0&&o.push({line:line(n,c,e,a&&!i.hidden,`same name, role "${c}"`),rank:2+t});continue}let l=normalize(getNodeTextImpl(n));l!==``&&closeness(l,n.node,s,h)===0&&o.push({line:`- text: ${e.y(e.x(l,80))} # in ${e.p(n)}, which has no role: give it role="${i.role}" or use getByText`,rank:2})}return format(`Closest matches`,o)}function roleOrTag(t){let n=(0,r.tlRole)(t);return m.has(n)?e.p(t):n}function textCandidates(n,r,i,a,o,s){if(typeof r==`function`)return``;let c=e.A(n),l=[],u=[];for(let n=c.first;n!==null;n=(0,t.nextInTree)(n,c)){if(n.type!==t.ELEMENT_NODE||o&&typeof o==`string`&&e.T(n,o))continue;let c=getNodeTextImpl(n),d=c.trim()===``?-1:closeness(c,n.node,r,i,s);d===0?l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(c),80))} # matches, but not selector "${a}"`,rank:0}):d>0&&l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(c),80))} # similar text in ${e.p(n)}`,rank:1+d}),d!==0&&n.first!==null&&n.first!==n.last&&(s?matches:fuzzyMatches)(n.node.textContent,n.node,r,i)&&u.push(n)}for(let t=0;t<u.length;t++){let n=u[t],r=!1;for(let e=t+1;e<u.length&&!r;e++)isAncestor(n,u[e])&&(r=!0);r||l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(n.node.textContent),80))} # text split across child elements of ${e.p(n)}: use a function matcher or getByRole`,rank:0})}return format(`Closest matches`,l)}function isAncestor(e,t){for(let n=t.parent;n!==null;n=n.parent)if(n===e)return!0;return!1}const g=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`]);function labelCandidates(n,i,a,o){if(typeof i==`function`)return``;let s=e.A(n),c=[];for(let n=s.first;n!==null;n=(0,t.nextInTree)(n,s)){if(n.type!==t.ELEMENT_NODE)continue;let s=(0,r.tlRole)(n);if(!g.has(s))continue;let l=nameOf(n),u=(0,r.isInaccessibleImpl)(n);if(l===``){let r=(0,t.attr)(n,`placeholder`),o=r?`no label, placeholder ${e.y(r)}: use getByPlaceholderText or add a <label>`:`no label: add a <label>, aria-label or aria-labelledby`;c.push({line:line(n,s,``,u,o),rank:r&&closeness(r,n.node,i,a)>=0?1:5});continue}let d=closeness(l,n.node,i,a,o);c.push({line:line(n,s,l,u,d>=0?`similar label`:`labelled control`),rank:d>=0?2+d:10})}return format(`Labelled form controls`,c)}var _=/* @__PURE__ */ e.M({findAllByLabelText:()=>x,findByLabelText:()=>S,getAllByLabelText:()=>C,getByLabelText:()=>w,queryAllByLabelText:()=>T,queryByLabelText:()=>y});function queryAllLabels(n){let r=e.A(n),i=[];for(let e=r.first;e!==null;e=(0,t.nextInTree)(e,r)){if(e.type!==t.ELEMENT_NODE||e.name!==`label`&&e.name!==`input`)continue;let n=getLabelContentImpl(e);n!==null&&i.push({node:e.node,textToMatch:n})}return i}function queryAllLabelsByText(e,t,{exact:n=!0,trim:r,collapseWhitespace:i,normalizer:a}={}){let o=n
|
|
16
|
+
`)}`}function nameOf(e){return normalize((0,r.computeAccessibleNameImpl)(e,void 0,5))}function roleCandidates(n,i){let a=e.A(n),o=[],s=i.name;for(let n=a.first;n!==null;n=(0,t.nextInTree)(n,a)){if(n.type!==t.ELEMENT_NODE)continue;let a=(0,r.isInaccessibleImpl)(n),c=(0,r.tlRole)(n);if((0,r.tlRoleMatches)(n,i.role,i.queryFallbacks)){let t=nameOf(n),r=s===void 0?0:closeness(t,n.node,s,h),l=i.matchesState(n);r===0&&l?a&&!i.hidden&&o.push({line:line(n,c,t,!0,`hidden: ${e.h(n)} (or pass { hidden: true })`),rank:0}):r===0?o.push({line:line(n,c,t,a&&!i.hidden,`role and name match, state is not ${i.stateHint}`),rank:1}):(!a||i.hidden)&&o.push({line:line(n,c,t,!1,r>0?`similar name`:`same role, other name`),rank:r>0?2+r:10});continue}if(s===void 0)continue;if(!m.has(c)){let e=nameOf(n);if(e===``)continue;let t=closeness(e,n.node,s,h);t>=0&&o.push({line:line(n,c,e,a&&!i.hidden,`same name, role "${c}"`),rank:2+t});continue}let l=normalize(getNodeTextImpl(n));l!==``&&closeness(l,n.node,s,h)===0&&o.push({line:`- text: ${e.y(e.x(l,80))} # in ${e.p(n)}, which has no role: give it role="${i.role}" or use getByText`,rank:2})}return format(`Closest matches`,o)}function roleOrTag(t){let n=(0,r.tlRole)(t);return m.has(n)?e.p(t):n}function textCandidates(n,r,i,a,o,s){if(typeof r==`function`)return``;let c=e.A(n),l=[],u=[];for(let n=c.first;n!==null;n=(0,t.nextInTree)(n,c)){if(n.type!==t.ELEMENT_NODE||o&&typeof o==`string`&&e.T(n,o))continue;let c=getNodeTextImpl(n),d=c.trim()===``?-1:closeness(c,n.node,r,i,s);d===0?l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(c),80))} # matches, but not selector "${a}"`,rank:0}):d>0&&l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(c),80))} # similar text in ${e.p(n)}`,rank:1+d}),d!==0&&n.first!==null&&n.first!==n.last&&(s?matches:fuzzyMatches)(n.node.textContent,n.node,r,i)&&u.push(n)}for(let t=0;t<u.length;t++){let n=u[t],r=!1;for(let e=t+1;e<u.length&&!r;e++)isAncestor(n,u[e])&&(r=!0);r||l.push({line:`- ${roleOrTag(n)}: ${e.y(e.x(i(n.node.textContent),80))} # text split across child elements of ${e.p(n)}: use a function matcher or getByRole`,rank:0})}return format(`Closest matches`,l)}function isAncestor(e,t){for(let n=t.parent;n!==null;n=n.parent)if(n===e)return!0;return!1}const g=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`]);function labelCandidates(n,i,a,o){if(typeof i==`function`)return``;let s=e.A(n),c=[];for(let n=s.first;n!==null;n=(0,t.nextInTree)(n,s)){if(n.type!==t.ELEMENT_NODE)continue;let s=(0,r.tlRole)(n);if(!g.has(s))continue;let l=nameOf(n),u=(0,r.isInaccessibleImpl)(n);if(l===``){let r=(0,t.attr)(n,`placeholder`),o=r?`no label, placeholder ${e.y(r)}: use getByPlaceholderText or add a <label>`:`no label: add a <label>, aria-label or aria-labelledby`;c.push({line:line(n,s,``,u,o),rank:r&&closeness(r,n.node,i,a)>=0?1:5});continue}let d=closeness(l,n.node,i,a,o);c.push({line:line(n,s,l,u,d>=0?`similar label`:`labelled control`),rank:d>=0?2+d:10})}return format(`Labelled form controls`,c)}var _=/* @__PURE__ */ e.M({findAllByLabelText:()=>x,findByLabelText:()=>S,getAllByLabelText:()=>C,getByLabelText:()=>w,queryAllByLabelText:()=>T,queryByLabelText:()=>y});function queryAllLabels(n){let r=e.A(n),i=[];for(let e=r.first;e!==null;e=(0,t.nextInTree)(e,r)){if(e.type!==t.ELEMENT_NODE||e.name!==`label`&&e.name!==`input`)continue;let n=getLabelContentImpl(e);n!==null&&i.push({node:e.node,textToMatch:n})}return i}function queryAllLabelsByText(e,t,{exact:n=!0,trim:r,collapseWhitespace:i,normalizer:a}={}){let o=textMatcher(n,t,makeNormalizer({collapseWhitespace:i,trim:r,normalizer:a}));return queryAllLabels(e).filter(({node:e,textToMatch:t})=>o(t,e)).map(({node:e})=>e)}function queryAllByLabelText(n,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:s,normalizer:c}={}){e.D(n);let l=makeNormalizer({collapseWhitespace:o,trim:s,normalizer:c}),u=textMatcher(a,r,l),d=e.A(n),f=new LabelContext(d,!0),p=[];for(let e=d.first;e!==null;e=(0,t.nextInTree)(e,d))e.type===t.ELEMENT_NODE&&((0,t.ariaAttr)(e,`aria-labelledby`)!==null||f.labelsOf(e).length!==0)&&collectLabelled(f,e,i,u,p);let m=queryAllByAttribute(`aria-label`,n,r,{exact:a,normalizer:l});for(let e=0;e<m.length;e++)p.push(m[e]);let h=Array.from(new Set(p));return i===`*`?h:h.filter(n=>e.T(n[t.$impl],i))}function collectLabelled(e,t,n,r,i){let a=getLabelsImpl(e,t,n);if(a.length===1){let e=a[0];e.formControl&&r(e.content,e.formControl.node)&&i.push(e.formControl.node),r(`${e.content||``}`,t.node)&&i.push(t.node);return}for(let e of a){if(!e.formControl)continue;let t=e.formControl.node;r(e.content,t)&&i.push(t)}let o=a.filter(e=>!!e.content).map(e=>e.content),s=t.node;r(o.join(` `),s)&&i.push(s),o.length>1&&o.forEach((e,t)=>{r(e,s)&&i.push(s);let n=[...o];n.splice(t,1),n.length>1&&r(n.join(` `),s)&&i.push(s)})}function getAllByLabelText(t,n,...r){let i=queryAllByLabelText(t,n,...r);if(!i.length){let i=queryAllLabelsByText(t,n,...r);if(i.length){let r=i.map(e=>getTagNameOfElementAssociatedWithLabelViaFor(t,e)).filter(e=>!!e);throw r.length?e.i().getElementError(r.map(e=>`Found a label with the text of: ${n}, however the element associated with this label (<${e} />) is non-labellable [https://html.spec.whatwg.org/multipage/forms.html#category-label]. If you really need to label a <${e} />, you can use aria-label or aria-labelledby instead.`).join(`
|
|
17
17
|
|
|
18
|
-
`),t):e.i().getElementError(`Found a label with the text of: ${n}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`,t)}throw e.i().getElementError(withLabelCandidates(`Unable to find a label with the text of: ${n}`,t,n,r[0]),t)}return i}function withLabelCandidates(t,n,r,i={}){if(e.w()===null)return t;let{exact:a=!0,trim:o,collapseWhitespace:s,normalizer:c}=i,l=labelCandidates(n,r,makeNormalizer({trim:o,collapseWhitespace:s,normalizer:c}),a);return l===``?t:`${t}\n\n${l}`}function getTagNameOfElementAssociatedWithLabelViaFor(t,n){let r=n.getAttribute(`for`);if(!r)return null;let i=new LabelContext(e.A(t)).byIdInContainer(r);return i?i.node.tagName.toLowerCase():null}const v=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the text of: ${t}`,`getMultipleError`),y=wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllByLabelText,v),queryAllByLabelText.name,`query`),b=makeSingleQuery(getAllByLabelText,v),x=makeFindQuery(wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`findAll`)),S=makeFindQuery(wrapSingleQueryWithSuggestion(b,getAllByLabelText.name,`find`)),C=wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`getAll`),w=wrapSingleQueryWithSuggestion(b,getAllByLabelText.name,`get`),T=wrapAllByQueryWithSuggestion(queryAllByLabelText,queryAllByLabelText.name,`queryAll`);var ee=/* @__PURE__ */ e.M({findAllByPlaceholderText:()=>O,findByPlaceholderText:()=>k,getAllByPlaceholderText:()=>E,getByPlaceholderText:()=>D,queryAllByPlaceholderText:()=>re,queryByPlaceholderText:()=>ie});function queryAllByPlaceholderText(...t){return e.D(t[0]),queryAllByAttribute(`placeholder`,...t)}const te=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the placeholder text of: ${t}`,`getMultipleError`),ne=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the placeholder text of: ${t}`,`getMissingError`),re=wrapAllByQueryWithSuggestion(queryAllByPlaceholderText,queryAllByPlaceholderText.name,`queryAll`),[ie,E,D,O,k]=buildQueries(queryAllByPlaceholderText,te,ne);var ae=/* @__PURE__ */ e.M({findAllByText:()=>P,findByText:()=>F,getAllByText:()=>M,getByText:()=>N,queryAllByText:()=>A,queryByText:()=>j});function isScriptStyleIgnore(e){return e===`script, style`||e===`script,style`}function isScriptOrStyle(e){let t=e.name;return t===`script`||t===`style`}function queryAllByText(n,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:s,ignore:c=e.i().defaultIgnore,normalizer:l}={}){e.D(n);let u=a?matches:fuzzyMatches,d=makeNormalizer({collapseWhitespace:o,trim:s,normalizer:l}),f=e.A(n),p=i===`*`,m=isScriptStyleIgnore(c),h=[],visit=t=>{(p||e.T(t,i))&&(c&&(m?isScriptOrStyle(t):e.T(t,c))||u(getNodeTextImpl(t),t.node,r,d)&&h.push(t.node))};f.type===t.ELEMENT_NODE&&visit(f);for(let e=f.first;e!==null;e=(0,t.nextInTree)(e,f))e.type===t.ELEMENT_NODE&&visit(e);return h}const oe=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the text: ${t}`,`getMultipleError`),se=/* @__PURE__ */ e.N((t,n,r={})=>{let{collapseWhitespace:i,trim:a,normalizer:o,selector:s}=r,c=makeNormalizer({collapseWhitespace:i,trim:a,normalizer:o}),l=c(n.toString()),u=l!==n.toString(),d=(s??`*`)!==`*`,f=`Unable to find an element with the text: ${u?`${l} (normalized from '${n}')`:n}${d?`, which matches selector '${s}'`:``}. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.`;if(e.w()===null)return f;let{exact:p=!0,ignore:m=e.i().defaultIgnore}=r,h=textCandidates(t,n,c,s??`*`,m,p);return h===``?f:`${f}\n\n${h}`},`getMissingError`),A=wrapAllByQueryWithSuggestion(queryAllByText,queryAllByText.name,`queryAll`),[j,M,N,P,F]=buildQueries(queryAllByText,oe,se);var ce=/* @__PURE__ */ e.M({findAllByDisplayValue:()=>B,findByDisplayValue:()=>V,getAllByDisplayValue:()=>R,getByDisplayValue:()=>z,queryAllByDisplayValue:()=>I,queryByDisplayValue:()=>L});function queryAllByDisplayValue(n,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){e.D(n);let c=i?matches:fuzzyMatches,l=makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s}),u=e.A(n),d=[];for(let e=u.first;e!==null;e=(0,t.nextInTree)(e,u)){if(e.type!==t.ELEMENT_NODE)continue;let n=e.name;if(n!==`input`&&n!==`textarea`&&n!==`select`)continue;let i=e.node;if(e.tag===t.T.select&&e.ns===t.HTML_NS){let e=i.options,n=!1;for(let i=0;i<e.length;i++){let a=e[i];if(a.selected&&c(getNodeTextImpl(a[t.$impl]),a,r,l)){n=!0;break}}n&&d.push(i)}else c(i.value,i,r,l)&&d.push(i)}return d}const le=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the display value: ${t}.`,`getMultipleError`),ue=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the display value: ${t}.`,`getMissingError`),I=wrapAllByQueryWithSuggestion(queryAllByDisplayValue,queryAllByDisplayValue.name,`queryAll`),[L,R,z,B,V]=buildQueries(queryAllByDisplayValue,le,ue);var de=/* @__PURE__ */ e.M({findAllByAltText:()=>K,findByAltText:()=>q,getAllByAltText:()=>W,getByAltText:()=>G,queryAllByAltText:()=>H,queryByAltText:()=>U});const fe=/^(img|input|area|.+-.+)$/i;function queryAllByAltText(t,n,r={}){return e.D(t),queryAllByAttribute(`alt`,t,n,r).filter(e=>fe.test(e.tagName))}const pe=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the alt text: ${t}`,`getMultipleError`),me=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the alt text: ${t}`,`getMissingError`),H=wrapAllByQueryWithSuggestion(queryAllByAltText,queryAllByAltText.name,`queryAll`),[U,W,G,K,q]=buildQueries(queryAllByAltText,pe,me);var he=/* @__PURE__ */ e.M({findAllByTitle:()=>ye,findByTitle:()=>be,getAllByTitle:()=>Y,getByTitle:()=>X,queryAllByTitle:()=>ve,queryByTitle:()=>J});function isSvgTitle(e){let n=e.parent;return(0,t.asciiLowercase)(e.prefix===null?e.name:e.prefix+`:`+e.name)===`title`&&n!==null&&n.type===t.ELEMENT_NODE&&(0,t.asciiLowercase)(n.prefix===null?n.name:n.prefix+`:`+n.name)===`svg`}function queryAllByTitle(n,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){e.D(n);let c=i?matches:fuzzyMatches,l=makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s}),u=e.A(n),d=[];for(let e=u.first;e!==null;e=(0,t.nextInTree)(e,u)){if(e.type!==t.ELEMENT_NODE)continue;let n=e.attrs===null?null:(0,t.attr)(e,`title`),i=e.name===`title`&&e.parent!==null&&e.parent.type===t.ELEMENT_NODE&&e.parent.name===`svg`;(n!==null||i)&&(c(n,e.node,r,l)||isSvgTitle(e)&&c(getNodeTextImpl(e),e.node,r,l))&&d.push(e.node)}return d}const ge=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the title: ${t}.`,`getMultipleError`),_e=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the title: ${t}.`,`getMissingError`),ve=wrapAllByQueryWithSuggestion(queryAllByTitle,queryAllByTitle.name,`queryAll`),[J,Y,X,ye,be]=buildQueries(queryAllByTitle,ge,_e);var xe=/* @__PURE__ */ e.M({findAllByRole:()=>Oe,findByRole:()=>ke,getAllByRole:()=>Ee,getByRole:()=>De,queryAllByRole:()=>we,queryByRole:()=>Te});const identity=e=>e;function assertSupported(e,t){if(!u.roleSupportsProp(e,t))throw Error(`"${t}" is not supported on role "${e}".`)}function queryAllByRole(n,r,{hidden:i=e.i().defaultHidden,name:a,description:o,queryFallbacks:s=!1,selected:c,busy:l,checked:d,pressed:f,current:p,level:m,expanded:h,value:{now:g,min:_,max:v,text:y}={}}={}){if(e.D(n),c!==void 0&&assertSupported(r,`aria-selected`),l!==void 0&&assertSupported(r,`aria-busy`),d!==void 0&&assertSupported(r,`aria-checked`),f!==void 0&&assertSupported(r,`aria-pressed`),p!==void 0&&assertSupported(r,`aria-current`),m!==void 0&&r!==`heading`)throw Error(`Role "${r}" cannot have "level" property.`);g!==void 0&&assertSupported(r,`aria-valuenow`),v!==void 0&&assertSupported(r,`aria-valuemax`),_!==void 0&&assertSupported(r,`aria-valuemin`),y!==void 0&&assertSupported(r,`aria-valuetext`),h!==void 0&&assertSupported(r,`aria-expanded`);let b={selected:c,busy:l,checked:d,pressed:f,current:p,level:m,expanded:h,valueNow:g,valueMin:_,valueMax:v,valueText:y},x=e.i().computedStyleSupportsPseudoElements,S=e.A(n),C=[],w=styleOverride(S),T=w!==null&&i===!1?/* @__PURE__ */ new Map:null;for(let e=S.first;e!==null;e=(0,t.nextInTree)(e,S))e.type===t.ELEMENT_NODE&&u.roleMatches(e,r,s)&&matchesState(e,b)&&(i===!1&&(w===null?isInaccessibleImpl$1(e):u.isInaccessibleWithStyle(e,w,T))||(a===void 0||matches(u.computeAccessibleName(e,x,w),e.node,a,identity))&&(o===void 0||matches(u.computeAccessibleDescription(e,x,w),e.node,o,identity))&&C.push(e.node));return C}function matchesState(e,t){if(t.selected!==void 0)return t.selected===computeAriaSelected(e);if(t.busy!==void 0)return t.busy===computeAriaBusy(e);if(t.checked!==void 0)return t.checked===computeAriaChecked(e);if(t.pressed!==void 0)return t.pressed===computeAriaPressed(e);if(t.current!==void 0)return t.current===computeAriaCurrent(e);if(t.expanded!==void 0)return t.expanded===computeAriaExpanded(e);if(t.level!==void 0)return t.level===computeHeadingLevelImpl(e);if(t.valueNow!==void 0||t.valueMax!==void 0||t.valueMin!==void 0||t.valueText!==void 0){let n=!0;return t.valueNow!==void 0&&(n&&=t.valueNow===computeAriaValueNow(e)),t.valueMax!==void 0&&(n&&=t.valueMax===computeAriaValueMax(e)),t.valueMin!==void 0&&(n&&=t.valueMin===computeAriaValueMin(e)),t.valueText!==void 0&&(n&&=matches(computeAriaValueText(e)??null,e.node,t.valueText,identity)),n}return!0}const getNameHint=e=>{let t=``;return t=e===void 0?``:typeof e==`string`?` and name "${e}"`:` and name \`${e}\``,t},Se=/* @__PURE__ */ e.N((e,t,{name:n}={})=>`Found multiple elements with the role "${t}"${getNameHint(n)}`,`getMultipleError`),Ce=/* @__PURE__ */ e.N((t,n,r={})=>{let{hidden:i=e.i().defaultHidden,name:a,description:o}=r;if(e.w()!==null)return agentMissingError(t,n,r,i);if(e.i()._disableExpensiveErrorDiagnostics)return`Unable to find role="${n}"${getNameHint(a)}`;let s=``;Array.from(t.children).forEach(e=>{s+=prettyRoles(e,{hidden:i,includeDescription:o!==void 0})});let c;c=s.length===0?i===!1?"There are no accessible roles. But there might be some inaccessible roles. If you wish to access them, then set the `hidden` option to `true`. Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole":`There are no available roles.`:`
|
|
18
|
+
`),t):e.i().getElementError(`Found a label with the text of: ${n}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`,t)}throw e.i().getElementError(withLabelCandidates(`Unable to find a label with the text of: ${n}`,t,n,r[0]),t)}return i}function withLabelCandidates(t,n,r,i={}){if(e.w()===null)return t;let{exact:a=!0,trim:o,collapseWhitespace:s,normalizer:c}=i,l=labelCandidates(n,r,makeNormalizer({trim:o,collapseWhitespace:s,normalizer:c}),a);return l===``?t:`${t}\n\n${l}`}function getTagNameOfElementAssociatedWithLabelViaFor(t,n){let r=n.getAttribute(`for`);if(!r)return null;let i=new LabelContext(e.A(t)).byIdInContainer(r);return i?i.node.tagName.toLowerCase():null}const v=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the text of: ${t}`,`getMultipleError`),y=wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllByLabelText,v),queryAllByLabelText.name,`query`),b=makeSingleQuery(getAllByLabelText,v),x=makeFindQuery(wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`findAll`)),S=makeFindQuery(wrapSingleQueryWithSuggestion(b,getAllByLabelText.name,`find`)),C=wrapAllByQueryWithSuggestion(getAllByLabelText,getAllByLabelText.name,`getAll`),w=wrapSingleQueryWithSuggestion(b,getAllByLabelText.name,`get`),T=wrapAllByQueryWithSuggestion(queryAllByLabelText,queryAllByLabelText.name,`queryAll`);var ee=/* @__PURE__ */ e.M({findAllByPlaceholderText:()=>O,findByPlaceholderText:()=>k,getAllByPlaceholderText:()=>E,getByPlaceholderText:()=>D,queryAllByPlaceholderText:()=>re,queryByPlaceholderText:()=>ie});function queryAllByPlaceholderText(...t){return e.D(t[0]),queryAllByAttribute(`placeholder`,...t)}const te=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the placeholder text of: ${t}`,`getMultipleError`),ne=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the placeholder text of: ${t}`,`getMissingError`),re=wrapAllByQueryWithSuggestion(queryAllByPlaceholderText,queryAllByPlaceholderText.name,`queryAll`),[ie,E,D,O,k]=buildQueries(queryAllByPlaceholderText,te,ne);var ae=/* @__PURE__ */ e.M({findAllByText:()=>P,findByText:()=>F,getAllByText:()=>M,getByText:()=>N,queryAllByText:()=>A,queryByText:()=>j});function isScriptStyleIgnore(e){return e===`script, style`||e===`script,style`}function isScriptOrStyle(e){let t=e.name;return t===`script`||t===`style`}function queryAllByText(n,r,{selector:i=`*`,exact:a=!0,collapseWhitespace:o,trim:s,ignore:c=e.i().defaultIgnore,normalizer:l}={}){e.D(n);let u=textMatcher(a,r,makeNormalizer({collapseWhitespace:o,trim:s,normalizer:l})),d=e.A(n),f=i===`*`,p=isScriptStyleIgnore(c),m=[],visit=t=>{(f||e.T(t,i))&&(c&&(p?isScriptOrStyle(t):e.T(t,c))||u(getNodeTextImpl(t),t.node)&&m.push(t.node))};d.type===t.ELEMENT_NODE&&visit(d);for(let e=d.first;e!==null;e=(0,t.nextInTree)(e,d))e.type===t.ELEMENT_NODE&&visit(e);return m}const oe=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the text: ${t}`,`getMultipleError`),se=/* @__PURE__ */ e.N((t,n,r={})=>{let{collapseWhitespace:i,trim:a,normalizer:o,selector:s}=r,c=makeNormalizer({collapseWhitespace:i,trim:a,normalizer:o}),l=c(n.toString()),u=l!==n.toString(),d=(s??`*`)!==`*`,f=`Unable to find an element with the text: ${u?`${l} (normalized from '${n}')`:n}${d?`, which matches selector '${s}'`:``}. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.`;if(e.w()===null)return f;let{exact:p=!0,ignore:m=e.i().defaultIgnore}=r,h=textCandidates(t,n,c,s??`*`,m,p);return h===``?f:`${f}\n\n${h}`},`getMissingError`),A=wrapAllByQueryWithSuggestion(queryAllByText,queryAllByText.name,`queryAll`),[j,M,N,P,F]=buildQueries(queryAllByText,oe,se);var ce=/* @__PURE__ */ e.M({findAllByDisplayValue:()=>B,findByDisplayValue:()=>V,getAllByDisplayValue:()=>R,getByDisplayValue:()=>z,queryAllByDisplayValue:()=>I,queryByDisplayValue:()=>L});function queryAllByDisplayValue(n,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){e.D(n);let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e.A(n),u=[];for(let e=l.first;e!==null;e=(0,t.nextInTree)(e,l)){if(e.type!==t.ELEMENT_NODE)continue;let n=e.name;if(n!==`input`&&n!==`textarea`&&n!==`select`)continue;let r=e.node;if(e.tag===t.T.select&&e.ns===t.HTML_NS){let e=r.options,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i.selected&&c(getNodeTextImpl(i[t.$impl]),i)){n=!0;break}}n&&u.push(r)}else c(r.value,r)&&u.push(r)}return u}const le=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the display value: ${t}.`,`getMultipleError`),ue=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the display value: ${t}.`,`getMissingError`),I=wrapAllByQueryWithSuggestion(queryAllByDisplayValue,queryAllByDisplayValue.name,`queryAll`),[L,R,z,B,V]=buildQueries(queryAllByDisplayValue,le,ue);var de=/* @__PURE__ */ e.M({findAllByAltText:()=>K,findByAltText:()=>q,getAllByAltText:()=>W,getByAltText:()=>G,queryAllByAltText:()=>H,queryByAltText:()=>U});const fe=/^(img|input|area|.+-.+)$/i;function queryAllByAltText(t,n,r={}){return e.D(t),queryAllByAttribute(`alt`,t,n,r).filter(e=>fe.test(e.tagName))}const pe=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the alt text: ${t}`,`getMultipleError`),me=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the alt text: ${t}`,`getMissingError`),H=wrapAllByQueryWithSuggestion(queryAllByAltText,queryAllByAltText.name,`queryAll`),[U,W,G,K,q]=buildQueries(queryAllByAltText,pe,me);var he=/* @__PURE__ */ e.M({findAllByTitle:()=>ye,findByTitle:()=>be,getAllByTitle:()=>Y,getByTitle:()=>X,queryAllByTitle:()=>ve,queryByTitle:()=>J});function isSvgTitle(e){let n=e.parent;return(0,t.asciiLowercase)(e.prefix===null?e.name:e.prefix+`:`+e.name)===`title`&&n!==null&&n.type===t.ELEMENT_NODE&&(0,t.asciiLowercase)(n.prefix===null?n.name:n.prefix+`:`+n.name)===`svg`}function queryAllByTitle(n,r,{exact:i=!0,collapseWhitespace:a,trim:o,normalizer:s}={}){e.D(n);let c=textMatcher(i,r,makeNormalizer({collapseWhitespace:a,trim:o,normalizer:s})),l=e.A(n),u=[];for(let e=l.first;e!==null;e=(0,t.nextInTree)(e,l)){if(e.type!==t.ELEMENT_NODE)continue;let n=e.attrs===null?null:(0,t.attr)(e,`title`),r=e.name===`title`&&e.parent!==null&&e.parent.type===t.ELEMENT_NODE&&e.parent.name===`svg`;(n!==null||r)&&(c(n,e.node)||isSvgTitle(e)&&c(getNodeTextImpl(e),e.node))&&u.push(e.node)}return u}const ge=/* @__PURE__ */ e.N((e,t)=>`Found multiple elements with the title: ${t}.`,`getMultipleError`),_e=/* @__PURE__ */ e.N((e,t)=>`Unable to find an element with the title: ${t}.`,`getMissingError`),ve=wrapAllByQueryWithSuggestion(queryAllByTitle,queryAllByTitle.name,`queryAll`),[J,Y,X,ye,be]=buildQueries(queryAllByTitle,ge,_e);var xe=/* @__PURE__ */ e.M({findAllByRole:()=>Oe,findByRole:()=>ke,getAllByRole:()=>Ee,getByRole:()=>De,queryAllByRole:()=>we,queryByRole:()=>Te});const identity=e=>e;function assertSupported(e,t){if(!u.roleSupportsProp(e,t))throw Error(`"${t}" is not supported on role "${e}".`)}function queryAllByRole(n,r,{hidden:i=e.i().defaultHidden,name:a,description:o,queryFallbacks:s=!1,selected:c,busy:l,checked:d,pressed:f,current:p,level:m,expanded:h,value:{now:g,min:_,max:v,text:y}={}}={}){if(e.D(n),c!==void 0&&assertSupported(r,`aria-selected`),l!==void 0&&assertSupported(r,`aria-busy`),d!==void 0&&assertSupported(r,`aria-checked`),f!==void 0&&assertSupported(r,`aria-pressed`),p!==void 0&&assertSupported(r,`aria-current`),m!==void 0&&r!==`heading`)throw Error(`Role "${r}" cannot have "level" property.`);g!==void 0&&assertSupported(r,`aria-valuenow`),v!==void 0&&assertSupported(r,`aria-valuemax`),_!==void 0&&assertSupported(r,`aria-valuemin`),y!==void 0&&assertSupported(r,`aria-valuetext`),h!==void 0&&assertSupported(r,`aria-expanded`);let b={selected:c,busy:l,checked:d,pressed:f,current:p,level:m,expanded:h,valueNow:g,valueMin:_,valueMax:v,valueText:y},x=e.i().computedStyleSupportsPseudoElements,S=e.A(n),C=[],w=styleOverride(S),T=w!==null&&i===!1?/* @__PURE__ */ new Map:null;for(let e=S.first;e!==null;e=(0,t.nextInTree)(e,S))e.type===t.ELEMENT_NODE&&u.roleMatches(e,r,s)&&matchesState(e,b)&&(i===!1&&(w===null?isInaccessibleImpl$1(e):u.isInaccessibleWithStyle(e,w,T))||(a===void 0||matches(u.computeAccessibleName(e,x,w),e.node,a,identity))&&(o===void 0||matches(u.computeAccessibleDescription(e,x,w),e.node,o,identity))&&C.push(e.node));return C}function matchesState(e,t){if(t.selected!==void 0)return t.selected===computeAriaSelected(e);if(t.busy!==void 0)return t.busy===computeAriaBusy(e);if(t.checked!==void 0)return t.checked===computeAriaChecked(e);if(t.pressed!==void 0)return t.pressed===computeAriaPressed(e);if(t.current!==void 0)return t.current===computeAriaCurrent(e);if(t.expanded!==void 0)return t.expanded===computeAriaExpanded(e);if(t.level!==void 0)return t.level===computeHeadingLevelImpl(e);if(t.valueNow!==void 0||t.valueMax!==void 0||t.valueMin!==void 0||t.valueText!==void 0){let n=!0;return t.valueNow!==void 0&&(n&&=t.valueNow===computeAriaValueNow(e)),t.valueMax!==void 0&&(n&&=t.valueMax===computeAriaValueMax(e)),t.valueMin!==void 0&&(n&&=t.valueMin===computeAriaValueMin(e)),t.valueText!==void 0&&(n&&=matches(computeAriaValueText(e)??null,e.node,t.valueText,identity)),n}return!0}const getNameHint=e=>{let t=``;return t=e===void 0?``:typeof e==`string`?` and name "${e}"`:` and name \`${e}\``,t},Se=/* @__PURE__ */ e.N((e,t,{name:n}={})=>`Found multiple elements with the role "${t}"${getNameHint(n)}`,`getMultipleError`),Ce=/* @__PURE__ */ e.N((t,n,r={})=>{let{hidden:i=e.i().defaultHidden,name:a,description:o}=r;if(e.w()!==null)return agentMissingError(t,n,r,i);if(e.i()._disableExpensiveErrorDiagnostics)return`Unable to find role="${n}"${getNameHint(a)}`;let s=``;Array.from(t.children).forEach(e=>{s+=prettyRoles(e,{hidden:i,includeDescription:o!==void 0})});let c;c=s.length===0?i===!1?"There are no accessible roles. But there might be some inaccessible roles. If you wish to access them, then set the `hidden` option to `true`. Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole":`There are no available roles.`:`
|
|
19
19
|
Here are the ${i===!1?`accessible`:`available`} roles:
|
|
20
20
|
|
|
21
21
|
${s.replace(/\n/g,`
|