@ctrl/dom 0.1.6 → 0.1.8
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/testing-library/_chunks/aria-snapshot-diff-Cj1v4fL1.js +14 -0
- package/dist/testing-library/_chunks/{aria-snapshot-diff--o7AL030.cjs → aria-snapshot-diff-Do-cz8cJ.cjs} +7 -7
- package/dist/testing-library/agent.cjs +1 -1
- package/dist/testing-library/agent.js +1 -1
- package/dist/testing-library/index.cjs +1 -1
- package/dist/testing-library/index.js +1 -1
- package/dist/testing-library/types/pretty-dom.d.ts +2 -1
- package/dist/testing-library/types/pretty-format.d.ts +125 -0
- package/dist/testing-library/types/screen.d.ts +2 -1
- package/package.json +6 -4
- package/dist/testing-library/_chunks/aria-snapshot-diff-BV9IkeNc.js +0 -14
|
@@ -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,attr as u,matches as d,serializeNode as f,setFailureSnapshot as p}from"@ctrl/dom/internal";import{readFileSync as m}from"node:fs";import{roleSupportsProp as h}from"@ctrl/dom/aria";import{ariaCheckedState as g,ariaPressedState as _,computeAccessibleNameImpl as v,computeAriaBusy as ee,computeAriaCurrent as y,computeAriaExpanded as b,computeAriaSelected as x,computeHeadingLevel as S,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=m(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&&d(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}p(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=u(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&&u(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(h(t,`aria-checked`)){let t=g(e);t===!0?i.push(`[checked]`):t===`mixed`&&i.push(`[checked=mixed]`)}C(e)&&i.push(`[disabled]`);let a=b(e);a===!0?i.push(`[expanded]`):a===!1&&i.push(`[expanded=false]`),n&&i.push(`[active]`);let o=t===`heading`?S(e):levelAttr(e);o!==void 0&&i.push(`[level=${o}]`);let s=_(e);s===!0?i.push(`[pressed]`):s===`mixed`?i.push(`[pressed=mixed]`):s===!1&&i.push(`[pressed=false]`),x(e)===!0&&i.push(`[selected]`);let c=y(e);return c===!0?i.push(`[current]`):typeof c==`string`&&c!==``&&i.push(`[current=${c}]`),ee(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(v(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=u(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?f(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,14 +1,14 @@
|
|
|
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;
|
|
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 c=Symbol.for(`ctrl-dom.agent.lastBodySnapshot`);function recordBodySnapshot(e,t){e!=null&&Object.defineProperty(e,c,{value:t,configurable:!0,writable:!0,enumerable:!1})}function lastBodySnapshot(e){return e?.[c]}function resetBodySnapshot(e){e!=null&&Object.hasOwn(e,c)&&delete e[c]}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 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 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 u=/* @__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 d=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`,`progressbar`,`meter`,`scrollbar`,`separator`]);function nodeValue(e,n){if(!d.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(u.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 f=/* @__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&&f.has(e.role)}let p=null;function loadPrettyFormat(){return p??=(0,n.createRequire)(require("url").pathToFileURL(__filename).href)(`pretty-format`)}const m=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 h={open:``,close:``},g={comment:h,content:h,prop:h,tag:h,value:h},_={comment:{open:`\x1B[90m`,close:`\x1B[39m`},content:{open:`\x1B[0m`,close:`\x1B[0m`},prop:{open:`\x1B[33m`,close:`\x1B[39m`},tag:{open:`\x1B[36m`,close:`\x1B[39m`},value:{open:`\x1B[32m`,close:`\x1B[39m`}},v=/* @__PURE__ */ new Set([`callToJSON`,`compareKeys`,`escapeRegex`,`escapeString`,`highlight`,`indent`,`maxDepth`,`min`,`plugins`,`printBasicPrototype`,`printFunctionName`,`theme`]),y=Symbol(`delegate`),b=/^((HTML|SVG)\w*)?Element$/,x=/* @__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 b.test(i)||isCustomElement(n);let e=x.get(r);return e===void 0&&x.set(r,e=b.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 printNode(e,n,r,i){if(!pluginHandles(e))throw y;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,c=e.type===t.DOCUMENT_FRAGMENT_NODE?``:printProps(e,n,s),l=printChildren(e,n,s,i);return o.open+`<`+a+(c&&o.close+c+n.spacingOuter+r+o.open)+(l?`>`+o.close+l+n.spacingOuter+r+o.open+`</`+a:(c&&!n.min?``:` `)+`/`)+`>`+o.close}function makePrintConfig(e,t){for(let t of Object.keys(e))if(!v.has(t))return null;if(e.plugins!==void 0||e.theme!==void 0||e.min&&e.indent!==void 0&&e.indent!==0)return null;let n=!!e.min,r=e.indent===void 0?2:e.indent,i=getConfig().defaultIgnore;return{colors:e.highlight?_: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?` `:`
|
|
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?` `:`
|
|
5
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=
|
|
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(``),
|
|
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
|
+
`)!==-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(`
|
|
8
8
|
|
|
9
|
-
`));return r.name=`TestingLibraryElementError`,r}let r=prettyDOM(t),i=Error([e,`Ignored nodes: comments, ${
|
|
9
|
+
`));return r.name=`TestingLibraryElementError`,r}let r=prettyDOM(t),i=Error([e,`Ignored nodes: comments, ${O.defaultIgnore}\n${r}`].filter(Boolean).join(`
|
|
10
10
|
|
|
11
|
-
`));return i.name=`TestingLibraryElementError`,i},_disableExpensiveErrorDiagnostics:!1,computedStyleSupportsPseudoElements:!1};function runWithExpensiveErrorDiagnosticsDisabled(e){try{return
|
|
11
|
+
`));return i.name=`TestingLibraryElementError`,i},_disableExpensiveErrorDiagnostics:!1,computedStyleSupportsPseudoElements:!1};function runWithExpensiveErrorDiagnosticsDisabled(e){try{return O._disableExpensiveErrorDiagnostics=!0,e()}finally{O._disableExpensiveErrorDiagnostics=!1}}function configure(e){typeof e==`function`&&(e=e(O)),O={...O,...e}}function getConfig(){return O}function diffAriaSnapshots(e,t){let n=diffLines(e.split(`
|
|
12
12
|
`),t.split(`
|
|
13
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}Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return implOf}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return agentElementSummary}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return checkContainerType}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return advanceFakeTimersByTime}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return __exportAll}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return __name}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return getDocument}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return yamlValue}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return matchesSelector}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return nodeKey}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return runWithExpensiveErrorDiagnosticsDisabled}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return resetBodySnapshot}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return
|
|
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}Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return implOf}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return agentElementSummary}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return checkContainerType}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return advanceFakeTimersByTime}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return __exportAll}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return __name}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return getDocument}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return yamlValue}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return matchesSelector}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return nodeKey}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return runWithExpensiveErrorDiagnosticsDisabled}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return resetBodySnapshot}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return ariaSnapshotTree}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return budgetLines}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return lastBodySnapshot}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return hiddenReason}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return getConfig}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return jestFakeTimersAreEnabled}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return getWindowFromNode}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return ariaSnapshot}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return envMaxLines}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return diffLines}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return logDOM}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return describeElement}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return configure}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return prettyDOM}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return diffAriaSnapshots}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return ariaSnapshotLines}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return nodeProps}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return envDebugFormat}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return truncate}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return quote}});
|
|
@@ -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-Do-cz8cJ.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-Cj1v4fL1.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,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-Do-cz8cJ.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 labelControl(e,n){let r=(0,t.attr)(e,`for`);if(r!==null){if(r===``)return null;let e=n().get(r)??null;return e!==null&&isLabelable(e)?e:null}for(let n=e.first;n!==null;n=(0,t.nextInTree)(n,e))if(isLabelable(n))return n;return null}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;labelsByControl;containerIds;constructor(e){this.container=e,this.labelsByControl=null,this.containerIds=null}labelsOf(e){if(!isLabelable(e))return a;let n=this.labelsByControl;return n===null&&(n=this.labelsByControl=buildLabelMap((0,t.treeRoot)(e))),n.get(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 buildLabelMap(e){let n=/* @__PURE__ */ new Map,r=null,getIds=()=>r??=buildIdMap(e,!0);for(let r=e;r!==null;r=(0,t.nextInTree)(r,e)){if(r.type!==t.ELEMENT_NODE||r.tag!==t.T.label||r.ns!==t.HTML_NS)continue;let e=labelControl(r,getIds);if(e===null)continue;let i=n.get(e);i===void 0?n.set(e,[r]):i.push(r)}return n}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.attr)(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 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
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.attr)(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.attr)(e,`aria-current`)??!1}function computeAriaExpanded(e){return checkBooleanAttribute(e,`aria-expanded`)}function computeHeadingLevelImpl(e){let n=(0,t.attr)(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.attr)(e,`aria-valuenow`);return n===null?void 0:+n}function computeAriaValueMax(e){let n=(0,t.attr)(e,`aria-valuemax`);return n===null?void 0:+n}function computeAriaValueMin(e){let n=(0,t.attr)(e,`aria-valuemin`);return n===null?void 0:+n}function computeAriaValueText(e){let n=(0,t.attr)(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.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,E as r,M as i,N as a,O as o,T as s,_ as c,a as l,c as u,h as d,i as f,j as p,k as m,l as h,o as g,p as _,r as v,s as y,t as b,v as x,w as S,x as C,y as w}from"./_chunks/aria-snapshot-diff-
|
|
1
|
+
import{A as e,C as t,D as n,E as r,M as i,N as a,O as o,T as s,_ as c,a as l,c as u,h as d,i as f,j as p,k as m,l as h,o as g,p as _,r as v,s as y,t as b,v as x,w as S,x as C,y as w}from"./_chunks/aria-snapshot-diff-Cj1v4fL1.js";import{$impl as T,ELEMENT_NODE as E,F_HTML as ee,HTML_NS as D,T as O,TEXT_NODE as te,asciiLowercase as k,attr as A,describeCall as j,describeNode as ne,getComputedStyleOverride as re,nextInTree as M,tracePromise as ie,traceSync as ae,tracing as N,treeRoot as oe}from"@ctrl/dom/internal";import{roleSupportsProp as se}from"@ctrl/dom/aria";import{computeAccessibleDescriptionImpl as ce,computeAccessibleNameImpl as P,implicitRole as le,isInaccessibleImpl as F,isInaccessibleWithStyle as ue,isSubtreeInaccessibleImpl as de,isVisibilityHidden as fe,tlRole as I,tlRoleMatches as L}from"@ctrl/dom/aria/internal";import{AsyncLocalStorage as pe}from"node:async_hooks";function isLabelable(e){if(e.type!==E||e.ns!==D)return!1;switch(e.tag){case O.button:case O.meter:case O.output:case O.progress:case O.select:case O.textarea:return!0;case O.input:{let t=A(e,`type`);return t===null||k(t)!==`hidden`}}return!1}function isLabelledNodeName(e){if(e.prefix!==null)return!1;switch(k(e.name)){case`button`:case`meter`:case`output`:case`progress`:case`select`:case`textarea`:case`input`:return!0}return!1}function labelControl(e,t){let n=A(e,`for`);if(n!==null){if(n===``)return null;let e=t().get(n)??null;return e!==null&&isLabelable(e)?e:null}for(let t=e.first;t!==null;t=M(t,e))if(isLabelable(t))return t;return null}function buildIdMap(e,t){let n=/* @__PURE__ */ new Map;t&&e.type===E&&e.id!==``&&n.set(e.id,e);for(let t=e.first;t!==null;t=M(t,e))t.type===E&&t.id!==``&&!n.has(t.id)&&n.set(t.id,t);return n}var LabelContext=class{container;labelsByControl;containerIds;constructor(e){this.container=e,this.labelsByControl=null,this.containerIds=null}labelsOf(e){if(!isLabelable(e))return R;let t=this.labelsByControl;return t===null&&(t=this.labelsByControl=buildLabelMap(oe(e))),t.get(e)??R}byIdInContainer(e){let t=this.containerIds;return t===null&&(t=this.containerIds=buildIdMap(this.container,!1)),t.get(e)??null}};const R=[];function buildLabelMap(e){let t=/* @__PURE__ */ new Map,n=null,getIds=()=>n??=buildIdMap(e,!0);for(let n=e;n!==null;n=M(n,e)){if(n.type!==E||n.tag!==O.label||n.ns!==D)continue;let e=labelControl(n,getIds);if(e===null)continue;let r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function getTextContent(e){if(e.type===E&&isLabelledNodeName(e))return``;if(e.type===te)return e.data;let t=``;for(let n=e.first;n!==null;n=n.next)t+=getTextContent(n);return t}function getLabelContentImpl(e){if(e.tag===O.label&&e.ns===D)return getTextContent(e);let t=e.node;return t.value||t.textContent}const me=/* @__PURE__ */ new Set([`button`,`input`,`meter`,`output`,`progress`,`select`,`textarea`]);function labelledFormControl(e,t){for(let n=e.first;n!==null;n=M(n,e))if(n.type===E&&me.has(n.name)&&(t===`*`||s(n,t)))return n}function getLabelsImpl(e,t,n=`*`){let r=A(t,`aria-labelledby`),i=r?r.split(` `):[];return i.length?i.map(t=>{let n=e.byIdInContainer(t);return n?{content:getLabelContentImpl(n),formControl:null}:{content:``,formControl:null}}):e.labelsOf(t).map(e=>({content:getLabelContentImpl(e),formControl:labelledFormControl(e,n)}))}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$1(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)}a(matches$1,`matches`);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 he=/\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(he,` `):r,r}}const ge=getDefaultNormalizer();function makeNormalizer({trim:e,collapseWhitespace:t,normalizer:n}){if(!n)return e===void 0&&t===void 0?ge: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!==O.input||e.ns!==D)return!1;let t=A(e,`type`);if(t===null)return!1;let n=k(t);return n===`submit`||n===`button`||n===`reset`}function getNodeTextImpl(e){if(isButtonLikeInput(e))return e.node.value;let t=``;for(let n=e.first;n!==null;n=n.next)n.type===te&&(t+=n.data);return t}function getNodeText(t){let n=e(t);return n.type===E?getNodeTextImpl(n):t.matches(`input[type=submit], input[type=button], input[type=reset]`)}const _e={computedStyleSupportsPseudoElements:!0};function styleOverride(e){return re(e)}function nameOptions(e,t){return t===null?e?_e:void 0:{computedStyleSupportsPseudoElements:e,getComputedStyle:t}}const z={implicitRole(e){let t=le(e);return t===``?null:t},roleMatches:L,roleSupportsProp(e,t){return typeof e==`string`&&se(e,t)},computeAccessibleName(e,t,n){return P(e,nameOptions(t,n),5)},computeAccessibleDescription(e,t,n){return ce(e,nameOptions(t,n),5)},isInaccessible:F,isInaccessibleWithStyle:ue,isSubtreeInaccessible:de};function parentElement(e){let t=e.parent;return t!==null&&t.type===E?t:null}function isInaccessibleImpl$1(e){return z.isInaccessible(e)}a(isInaccessibleImpl$1,`isInaccessibleImpl`);function isInaccessibleChecked(e){let t=styleOverride(e);return t===null?z.isInaccessible(e):z.isInaccessibleWithStyle(e,t,null)}function isInaccessible(t,n={}){let r=e(t),i=n.isSubtreeInaccessible,a=styleOverride(r);if(i===void 0)return a===null?isInaccessibleImpl$1(r):z.isInaccessibleWithStyle(r,a,null);if(a===null?fe(r):a(t).visibility===`hidden`)return!0;for(let e=r;e!==null;e=parentElement(e))if(i(e.node))return!0;return!1}function getImplicitAriaRolesImpl(e){let t=z.implicitRole(e);return t===null?[]:[t]}function getRoles(t,{hidden:n=!1}={}){let r=e(t),i={},a=n===!1?styleOverride(r):null,o=a===null?null:/* @__PURE__ */ new Map,visit=e=>{if(n!==!1||(a===null?isInaccessibleImpl$1(e):z.isInaccessibleWithStyle(e,a,o))===!1){let t=A(e,`role`),n=t===null?getImplicitAriaRolesImpl(e):t.split(` `).slice(0,1);for(let t of n){let n=i[t];Array.isArray(n)?n.push(e.node):i[t]=[e.node]}}for(let t=e.first;t!==null;t=t.next)t.type===E&&visit(t)};return visit(r),i}const ve={format:`pretty`};function prettyRoles(t,{hidden:n,includeDescription:r}){let i=getRoles(t,{hidden:n}),a=f().computedStyleSupportsPseudoElements,o=styleOverride(e(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(t),i=`Name "${z.computeAccessibleName(n,a,o)}":\n`,s=y(t.cloneNode(!1),void 0,ve);return r?`${i}${`Description "${z.computeAccessibleDescription(n,a,o)}":\n`}${s}`:`${i}${s}`}).join(`
|
|
2
2
|
|
|
3
3
|
`)}\n\n${i}`}).join(`
|
|
4
4
|
`)}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,t){let n=A(e,t);if(n===`true`)return!0;if(n===`false`)return!1}function computeAriaSelected$1(e){return e.tag===O.option&&e.ns===D?e.node.selected:checkBooleanAttribute(e,`aria-selected`)}a(computeAriaSelected$1,`computeAriaSelected`);function computeAriaBusy$1(e){return A(e,`aria-busy`)===`true`}a(computeAriaBusy$1,`computeAriaBusy`);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$1(e){return checkBooleanAttribute(e,`aria-current`)??A(e,`aria-current`)??!1}a(computeAriaCurrent$1,`computeAriaCurrent`);function computeAriaExpanded$1(e){return checkBooleanAttribute(e,`aria-expanded`)}a(computeAriaExpanded$1,`computeAriaExpanded`);function computeHeadingLevelImpl(e){let t=A(e,`aria-level`),n=t&&Number(t);if(n)return n;if(e.ns===D)switch(e.tag){case O.h1:return 1;case O.h2:return 2;case O.h3:return 3;case O.h4:return 4;case O.h5:return 5;case O.h6:return 6}}function computeAriaValueNow(e){let t=A(e,`aria-valuenow`);return t===null?void 0:+t}function computeAriaValueMax(e){let t=A(e,`aria-valuemax`);return t===null?void 0:+t}function computeAriaValueMin(e){let t=A(e,`aria-valuemin`);return t===null?void 0:+t}function computeAriaValueText(e){let t=A(e,`aria-valuetext`);return t===null?void 0:t}const B=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(n))&&(s.hidden=!0,o=`Element is inaccessible. This means that the element and all its children are invisible to screen readers.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// Difference: upstream imports these from pretty-format, which @ctrl/dom does not install (./pretty-format.d.ts).
|
|
2
|
+
import * as prettyFormat from './pretty-format.js'
|
|
2
3
|
import {AriaSnapshotOptions} from './aria-snapshot.js'
|
|
3
4
|
|
|
4
5
|
export interface PrettyDOMOptions extends prettyFormat.OptionsReceived {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copied from pretty-format@27.5.1 build/types.d.ts and build/index.d.ts (MIT, Copyright (c) Facebook,
|
|
2
|
+
// Inc. and its affiliates): the types upstream's `prettyFormat` re-export and `PrettyDOMOptions`
|
|
3
|
+
// expose, here so the published declarations don't need pretty-format installed (it is an optional
|
|
4
|
+
// peer of @ctrl/dom).
|
|
5
|
+
// https://github.com/jestjs/jest/blob/v27.5.1/packages/pretty-format/src/types.ts
|
|
6
|
+
|
|
7
|
+
export declare type Colors = {
|
|
8
|
+
comment: {
|
|
9
|
+
close: string;
|
|
10
|
+
open: string;
|
|
11
|
+
};
|
|
12
|
+
content: {
|
|
13
|
+
close: string;
|
|
14
|
+
open: string;
|
|
15
|
+
};
|
|
16
|
+
prop: {
|
|
17
|
+
close: string;
|
|
18
|
+
open: string;
|
|
19
|
+
};
|
|
20
|
+
tag: {
|
|
21
|
+
close: string;
|
|
22
|
+
open: string;
|
|
23
|
+
};
|
|
24
|
+
value: {
|
|
25
|
+
close: string;
|
|
26
|
+
open: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
declare type Indent = (arg0: string) => string;
|
|
30
|
+
export declare type Refs = Array<unknown>;
|
|
31
|
+
declare type Print = (arg0: unknown) => string;
|
|
32
|
+
export declare type Theme = {
|
|
33
|
+
comment: string;
|
|
34
|
+
content: string;
|
|
35
|
+
prop: string;
|
|
36
|
+
tag: string;
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
declare type ThemeReceived = {
|
|
40
|
+
comment?: string;
|
|
41
|
+
content?: string;
|
|
42
|
+
prop?: string;
|
|
43
|
+
tag?: string;
|
|
44
|
+
value?: string;
|
|
45
|
+
};
|
|
46
|
+
export declare type CompareKeys = ((a: string, b: string) => number) | undefined;
|
|
47
|
+
export declare type Options = {
|
|
48
|
+
callToJSON: boolean;
|
|
49
|
+
compareKeys: CompareKeys;
|
|
50
|
+
escapeRegex: boolean;
|
|
51
|
+
escapeString: boolean;
|
|
52
|
+
highlight: boolean;
|
|
53
|
+
indent: number;
|
|
54
|
+
maxDepth: number;
|
|
55
|
+
min: boolean;
|
|
56
|
+
plugins: Plugins;
|
|
57
|
+
printBasicPrototype: boolean;
|
|
58
|
+
printFunctionName: boolean;
|
|
59
|
+
theme: Theme;
|
|
60
|
+
};
|
|
61
|
+
export interface PrettyFormatOptions {
|
|
62
|
+
callToJSON?: boolean;
|
|
63
|
+
compareKeys?: CompareKeys;
|
|
64
|
+
escapeRegex?: boolean;
|
|
65
|
+
escapeString?: boolean;
|
|
66
|
+
highlight?: boolean;
|
|
67
|
+
indent?: number;
|
|
68
|
+
maxDepth?: number;
|
|
69
|
+
min?: boolean;
|
|
70
|
+
plugins?: Plugins;
|
|
71
|
+
printBasicPrototype?: boolean;
|
|
72
|
+
printFunctionName?: boolean;
|
|
73
|
+
theme?: ThemeReceived;
|
|
74
|
+
}
|
|
75
|
+
export declare type OptionsReceived = PrettyFormatOptions;
|
|
76
|
+
export declare type Config = {
|
|
77
|
+
callToJSON: boolean;
|
|
78
|
+
compareKeys: CompareKeys;
|
|
79
|
+
colors: Colors;
|
|
80
|
+
escapeRegex: boolean;
|
|
81
|
+
escapeString: boolean;
|
|
82
|
+
indent: string;
|
|
83
|
+
maxDepth: number;
|
|
84
|
+
min: boolean;
|
|
85
|
+
plugins: Plugins;
|
|
86
|
+
printBasicPrototype: boolean;
|
|
87
|
+
printFunctionName: boolean;
|
|
88
|
+
spacingInner: string;
|
|
89
|
+
spacingOuter: string;
|
|
90
|
+
};
|
|
91
|
+
export declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
|
92
|
+
declare type Test = (arg0: any) => boolean;
|
|
93
|
+
export declare type NewPlugin = {
|
|
94
|
+
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
95
|
+
test: Test;
|
|
96
|
+
};
|
|
97
|
+
declare type PluginOptions = {
|
|
98
|
+
edgeSpacing: string;
|
|
99
|
+
min: boolean;
|
|
100
|
+
spacing: string;
|
|
101
|
+
};
|
|
102
|
+
export declare type OldPlugin = {
|
|
103
|
+
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
|
|
104
|
+
test: Test;
|
|
105
|
+
};
|
|
106
|
+
export declare type Plugin = NewPlugin | OldPlugin;
|
|
107
|
+
export declare type Plugins = Array<Plugin>;
|
|
108
|
+
|
|
109
|
+
export declare const DEFAULT_OPTIONS: Options;
|
|
110
|
+
/**
|
|
111
|
+
* Returns a presentation string of your `val` object
|
|
112
|
+
* @param val any potential JavaScript object
|
|
113
|
+
* @param options Custom settings
|
|
114
|
+
*/
|
|
115
|
+
export declare function format(val: unknown, options?: OptionsReceived): string;
|
|
116
|
+
export declare const plugins: {
|
|
117
|
+
AsymmetricMatcher: NewPlugin;
|
|
118
|
+
ConvertAnsi: NewPlugin;
|
|
119
|
+
DOMCollection: NewPlugin;
|
|
120
|
+
DOMElement: NewPlugin;
|
|
121
|
+
Immutable: NewPlugin;
|
|
122
|
+
ReactElement: NewPlugin;
|
|
123
|
+
ReactTestComponent: NewPlugin;
|
|
124
|
+
};
|
|
125
|
+
export default format;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// Difference: upstream imports these from pretty-format, which @ctrl/dom does not install (./pretty-format.d.ts).
|
|
2
|
+
import {OptionsReceived} from './pretty-format.js'
|
|
2
3
|
import {BoundFunctions, Queries} from './get-queries-for-element.js'
|
|
3
4
|
import * as queries from './queries.js'
|
|
4
5
|
import {AriaSnapshotOptions} from './aria-snapshot.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctrl/dom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "A fast DOM for testing React components: a drop-in replacement for jsdom and happy-dom, with Testing Library, user-event and jest-dom built in.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dom",
|
|
@@ -141,15 +141,14 @@
|
|
|
141
141
|
"dependencies": {
|
|
142
142
|
"@adobe/css-tools": "^4.4.0",
|
|
143
143
|
"@babel/code-frame": "^8.0.6",
|
|
144
|
-
"dom-accessibility-api": "^0.7.1"
|
|
145
|
-
"picocolors": "^1.1.1",
|
|
146
|
-
"pretty-format": "^30.5.1"
|
|
144
|
+
"dom-accessibility-api": "^0.7.1"
|
|
147
145
|
},
|
|
148
146
|
"peerDependencies": {
|
|
149
147
|
"@jest/globals": ">=30.0.0",
|
|
150
148
|
"@types/react": "^19.0.0",
|
|
151
149
|
"@types/react-dom": "^19.0.0",
|
|
152
150
|
"jest": ">=30.0.0",
|
|
151
|
+
"pretty-format": "^27.0.2",
|
|
153
152
|
"react": "^19.0.0",
|
|
154
153
|
"react-dom": "^19.0.0",
|
|
155
154
|
"vitest": ">=5.0.0"
|
|
@@ -167,6 +166,9 @@
|
|
|
167
166
|
"jest": {
|
|
168
167
|
"optional": true
|
|
169
168
|
},
|
|
169
|
+
"pretty-format": {
|
|
170
|
+
"optional": true
|
|
171
|
+
},
|
|
170
172
|
"react": {
|
|
171
173
|
"optional": true
|
|
172
174
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
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,attr as u,matches as d,serializeNode as f,setFailureSnapshot as p}from"@ctrl/dom/internal";import{readFileSync as m}from"node:fs";import{roleSupportsProp as h}from"@ctrl/dom/aria";import{ariaCheckedState as g,ariaPressedState as _,computeAccessibleNameImpl as v,computeAriaBusy as y,computeAriaCurrent as b,computeAriaExpanded as x,computeAriaSelected as S,computeHeadingLevel as C,isDisabledImpl as w,isDisplayInline as T,isDisplayNone as E,isInaccessibleImpl as D,isSubtreeInaccessibleImpl as O,isVisibilityHidden as k,tlRole as A}from"@ctrl/dom/aria/internal";var j=Object.defineProperty,__name=(e,t)=>j(e,`name`,{value:t,configurable:!0}),__exportAll=(e,t)=>{let n={};for(var r in e)j(n,r,{get:e[r],enumerable:!0});return t||j(n,Symbol.toStringTag,{value:`Module`}),n};const M=new URL(`./`,import.meta.url).pathname;let N;function loadDeps(){if(N!==void 0)return N;try{let t=e(import.meta.url);N={codeFrameColumns:t(`@babel/code-frame`).codeFrameColumns,picocolors:t(`picocolors`)}}catch{N=null}return N}function getCodeFrame(e){let{codeFrameColumns:t,picocolors:n}=loadDeps(),r=e.indexOf(`(`)+1,i=e.indexOf(`)`),a=e.slice(r,i),o=a.split(`:`),[s,c,l]=[o[0],parseInt(o[1],10),parseInt(o[2],10)],u=``;try{u=m(s,`utf-8`)}catch{return``}let d=t(u,{start:{line:c,column:l-1}},{highlightCode:!0,linesBelow:0});return`${n.dim(a)}\n${d}\n`}function getUserCodeFrame(){let e=loadDeps();return!e||!m||!e.codeFrameColumns?``:getCodeFrame((/* @__PURE__ */ Error()).stack.split(`
|
|
2
|
-
`).slice(1).find(e=>!e.includes(`node_modules/`)&&!e.includes(M)))}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&&d(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}p(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&&D(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 P=Symbol.for(`ctrl-dom.agent.lastBodySnapshot`);function recordBodySnapshot(e,t){e!=null&&Object.defineProperty(e,P,{value:t,configurable:!0,writable:!0,enumerable:!1})}function lastBodySnapshot(e){return e?.[P]}function resetBodySnapshot(e){e!=null&&Object.hasOwn(e,P)&&delete e[P]}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 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 t=e.name;if(e.id!==``)return`<${t} id="${e.id}">`;let n=u(e,`data-testid`);return n===null?`<${t}>`:`<${t} data-testid="${n}">`}function hiddenReason(e){let t=hiddenChainReason(e);return t===``?k(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&&u(t,`hidden`)!==null)return`hidden attribute on ${describeElement(t)}`;if(u(t,`aria-hidden`)===`true`)return`aria-hidden="true" on ${describeElement(t)}`;if(E(t))return`display: none on ${describeElement(t)}`}return``}const I=/* @__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(h(t,`aria-checked`)){let t=g(e);t===!0?i.push(`[checked]`):t===`mixed`&&i.push(`[checked=mixed]`)}w(e)&&i.push(`[disabled]`);let a=x(e);a===!0?i.push(`[expanded]`):a===!1&&i.push(`[expanded=false]`),n&&i.push(`[active]`);let o=t===`heading`?C(e):levelAttr(e);o!==void 0&&i.push(`[level=${o}]`);let s=_(e);s===!0?i.push(`[pressed]`):s===`mixed`?i.push(`[pressed=mixed]`):s===!1&&i.push(`[pressed=false]`),S(e)===!0&&i.push(`[selected]`);let c=b(e);return c===!0?i.push(`[current]`):typeof c==`string`&&c!==``&&i.push(`[current=${c}]`),y(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 L=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`,`progressbar`,`meter`,`scrollbar`,`separator`]);function nodeValue(e,t){if(!L.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&&O(e)){if(this.sawHidden=!0,!this.includeHidden)return;r=!0}let i=r;if(!r&&k(e)){if(this.sawHidden=!0,!this.includeHidden){this.visitChildren(e,t,!1,!0);return}i=!0}let a=A(e);if(I.has(a)){let n=!T(e);n&&appendBreak(t),this.visitChildren(e,t,r,!1),n&&appendBreak(t);return}let s={role:a,name:normalizeSpace(v(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=u(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 R=/* @__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&&R.has(e.role)}let z=null;function loadPrettyFormat(){return z??=e(import.meta.url)(`pretty-format`)}const B=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!==n&&(e.nodeType!==a||!e.matches(getConfig().defaultIgnore))}const V={open:``,close:``},H={comment:V,content:V,prop:V,tag:V,value:V},U={comment:{open:`\x1B[90m`,close:`\x1B[39m`},content:{open:`\x1B[0m`,close:`\x1B[0m`},prop:{open:`\x1B[33m`,close:`\x1B[39m`},tag:{open:`\x1B[36m`,close:`\x1B[39m`},value:{open:`\x1B[32m`,close:`\x1B[39m`}},W=/* @__PURE__ */ new Set([`callToJSON`,`compareKeys`,`escapeRegex`,`escapeString`,`highlight`,`indent`,`maxDepth`,`min`,`plugins`,`printBasicPrototype`,`printFunctionName`,`theme`]),G=Symbol(`delegate`),K=/^((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 K.test(o)||isCustomElement(t);let e=q.get(i);return e===void 0&&q.set(i,e=K.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 printNode(e,t,i,a){if(!pluginHandles(e))throw G;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,u=e.type===r?``:printProps(e,t,c),d=printChildren(e,t,c,a);return s.open+`<`+o+(u&&s.close+u+t.spacingOuter+i+s.open)+(d?`>`+s.close+d+t.spacingOuter+i+s.open+`</`+o:(u&&!t.min?``:` `)+`/`)+`>`+s.close}function makePrintConfig(e,t){for(let t of Object.keys(e))if(!W.has(t))return null;if(e.plugins!==void 0||e.theme!==void 0||e.min&&e.indent!==void 0&&e.indent!==0)return null;let n=!!e.min,r=e.indent===void 0?2:e.indent,i=getConfig().defaultIgnore;return{colors:e.highlight?U:H,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=e[t],s=n??filterCommentsAndDefaultIgnoreTagsTags;if(o!==void 0){let e=makePrintConfig(a,n===void 0?null:n);if(e!==null){e.compact=i;try{return printNode(o,e,``,0)}catch(e){if(e!==G)throw e}}}return formatWithPrettyFormat(e,s,a)}function formatWithPrettyFormat(e,t,n){let r=loadPrettyFormat();return r.format(e,{plugins:[createDOMElementFilter(t),r.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?f(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(``),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},testNode=e=>{let t=e.constructor.name,{nodeType:i}=e;return i===a&&(K.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 J={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, ${J.defaultIgnore}\n${r}`].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`));return i.name=`TestingLibraryElementError`,i},_disableExpensiveErrorDiagnostics:!1,computedStyleSupportsPseudoElements:!1};function runWithExpensiveErrorDiagnosticsDisabled(e){try{return J._disableExpensiveErrorDiagnostics=!0,e()}finally{J._disableExpensiveErrorDiagnostics=!1}}function configure(e){typeof e==`function`&&(e=e(J)),J={...J,...e}}function getConfig(){return J}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,B 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};
|