@vitest/browser 4.1.0-beta.6 → 4.1.0

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.
@@ -0,0 +1,7 @@
1
+ import{server as e,page as t,utils as n}from"vitest/browser";import{__INTERNAL as r,getSafeTimers as i}from"vitest/internal/browser";var a=Object.defineProperty,o=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,s=(e,t,n)=>o(e,typeof t==`symbol`?t:t+``,n);function c(e,t=`'`){let n=JSON.stringify(e),r=n.substring(1,n.length-1).replace(/\\"/g,`"`);if(t===`'`)return t+r.replace(/'/g,`\\'`)+t;if(t===`"`)return t+r.replace(/"/g,`\\"`)+t;if(t==="`")return t+r.replace(/`/g,"`")+t;throw Error(`Invalid escape char`)}function l(e){let t=``;for(let n=0;n<e.length;n++)t+=d(e,n);return t}function u(e){return`"${l(e).replace(/\\ /g,` `)}"`}function d(e,t){let n=e.charCodeAt(t);return n===0?`�`:n>=1&&n<=31||n>=48&&n<=57&&(t===0||t===1&&e.charCodeAt(0)===45)?`\\${n.toString(16)} `:t===0&&n===45&&e.length===1?`\\${e.charAt(t)}`:n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122?e.charAt(t):`\\${e.charAt(t)}`}function f(e){return e.replace(/[\u200b\u00ad]/g,``).trim().replace(/\s+/g,` `)}function p(e){return e.replace(/(^|[^\\])(\\\\)*\\(['"`])/g,`$1$2$3`)}function m(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function h(e,t){return typeof e==`string`?`${JSON.stringify(e)}${t?`s`:`i`}`:m(e)}function g(e,t){return typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"${t?`s`:`i`}`:m(e)}function _(e,t,n=``){if(e.length<=t)return e;let r=[...e];return r.length>t?r.slice(0,t-n.length).join(``)+n:r.join(``)}function v(e,t){return _(e,t,`…`)}function y(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var b=function(e,t,n){return e>=t&&e<=n};function x(e){return b(e,48,57)}function ee(e){return x(e)||b(e,65,70)||b(e,97,102)}function te(e){return b(e,65,90)}function S(e){return b(e,97,122)}function ne(e){return te(e)||S(e)}function re(e){return e>=128}function ie(e){return ne(e)||re(e)||e===95}function ae(e){return ie(e)||x(e)||e===45}function oe(e){return b(e,0,8)||e===11||b(e,14,31)||e===127}function se(e){return e===10}function C(e){return se(e)||e===9||e===32}var ce=1114111,le=class extends Error{constructor(e){super(e),this.name=`InvalidCharacterError`}};function ue(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===13&&e.charCodeAt(n+1)===10&&(r=10,n++),(r===13||r===12)&&(r=10),r===0&&(r=65533),b(r,55296,56319)&&b(e.charCodeAt(n+1),56320,57343)){let t=r-55296,i=e.charCodeAt(n+1)-56320;r=2**16+t*2**10+i,n++}t.push(r)}return t}function w(e){if(e<=65535)return String.fromCharCode(e);e-=2**16;let t=Math.floor(e/2**10)+55296,n=e%2**10+56320;return String.fromCharCode(t)+String.fromCharCode(n)}function de(e){let t=ue(e),n=-1,r=[],i,a=function(e){return e>=t.length?-1:t[e]},o=function(e){if(e===void 0&&(e=1),e>3)throw`Spec Error: no more than three codepoints of lookahead.`;return a(n+e)},s=function(e){return e===void 0&&(e=1),n+=e,i=a(n),!0},c=function(){return--n,!0},l=function(e){return e===void 0&&(e=i),e===-1},u=function(){if(d(),s(),C(i)){for(;C(o());)s();return new me}else if(i===34)return m();else if(i===35)if(ae(o())||_(o(1),o(2))){let e=new Ie(``);return y(o(1),o(2),o(3))&&(e.type=`id`),e.value=ne(),e}else return new D(i);else if(i===36)return o()===61?(s(),new ke):new D(i);else if(i===39)return m();else if(i===40)return new we;else if(i===41)return new Te;else if(i===42)return o()===61?(s(),new Ae):new D(i);else if(i===43)return S()?(c(),f()):new D(i);else if(i===44)return new ye;else if(i===45)return S()?(c(),f()):o(1)===45&&o(2)===62?(s(2),new ge):b()?(c(),p()):new D(i);else if(i===46)return S()?(c(),f()):new D(i);else if(i===58)return new _e;else if(i===59)return new ve;else if(i===60)return o(1)===33&&o(2)===45&&o(3)===45?(s(3),new he):new D(i);else if(i===64)return y(o(1),o(2),o(3))?new Fe(ne()):new D(i);else if(i===91)return new Se;else if(i===92)return v()?(c(),p()):new D(i);else if(i===93)return new Ce;else if(i===94)return o()===61?(s(),new Oe):new D(i);else if(i===123)return new be;else if(i===124)return o()===61?(s(),new De):o()===124?(s(),new je):new D(i);else if(i===125)return new xe;else if(i===126)return o()===61?(s(),new Ee):new D(i);else if(x(i))return c(),f();else if(ie(i))return c(),p();else if(l())return new Me;else return new D(i)},d=function(){for(;o(1)===47&&o(2)===42;)for(s(2);;)if(s(),i===42&&o()===47){s();break}else if(l())return},f=function(){let e=re();if(y(o(1),o(2),o(3))){let t=new Ve;return t.value=e.value,t.repr=e.repr,t.type=e.type,t.unit=ne(),t}else if(o()===37){s();let t=new Be;return t.value=e.value,t.repr=e.repr,t}else{let t=new ze;return t.value=e.value,t.repr=e.repr,t.type=e.type,t}},p=function(){let e=ne();if(e.toLowerCase()===`url`&&o()===40){for(s();C(o(1))&&C(o(2));)s();return o()===34||o()===39||C(o())&&(o(2)===34||o(2)===39)?new Pe(e):h()}else if(o()===40)return s(),new Pe(e);else return new Ne(e)},m=function(e){e===void 0&&(e=i);let t=``;for(;s();){if(i===e||l())return new Le(t);if(se(i))return c(),new fe;i===92?l(o())||(se(o())?s():t+=w(g())):t+=w(i)}throw Error(`Internal error`)},h=function(){let e=new Re(``);for(;C(o());)s();if(l(o()))return e;for(;s();){if(i===41||l())return e;if(C(i)){for(;C(o());)s();return o()===41||l(o())?(s(),e):(de(),new pe)}else if(i===34||i===39||i===40||oe(i))return de(),new pe;else if(i===92)if(v())e.value+=w(g());else return de(),new pe;else e.value+=w(i)}throw Error(`Internal error`)},g=function(){if(s(),ee(i)){let e=[i];for(let t=0;t<5&&ee(o());t++)s(),e.push(i);C(o())&&s();let t=Number.parseInt(e.map(e=>String.fromCharCode(e)).join(``),16);return t>ce&&(t=65533),t}else if(l())return 65533;else return i},_=function(e,t){return!(e!==92||se(t))},v=function(){return _(i,o())},y=function(e,t,n){return e===45?ie(t)||t===45||_(t,n):ie(e)?!0:e===92?_(e,t):!1},b=function(){return y(i,o(1),o(2))},te=function(e,t,n){return e===43||e===45?!!(x(t)||t===46&&x(n)):e===46?!!x(t):!!x(e)},S=function(){return te(i,o(1),o(2))},ne=function(){let e=``;for(;s();)if(ae(i))e+=w(i);else if(v())e+=w(g());else return c(),e;throw Error(`Internal parse error`)},re=function(){let e=``,t=`integer`;for((o()===43||o()===45)&&(s(),e+=w(i));x(o());)s(),e+=w(i);if(o(1)===46&&x(o(2)))for(s(),e+=w(i),s(),e+=w(i),t=`number`;x(o());)s(),e+=w(i);let n=o(1),r=o(2),a=o(3);if((n===69||n===101)&&x(r))for(s(),e+=w(i),s(),e+=w(i),t=`number`;x(o());)s(),e+=w(i);else if((n===69||n===101)&&(r===43||r===45)&&x(a))for(s(),e+=w(i),s(),e+=w(i),s(),e+=w(i),t=`number`;x(o());)s(),e+=w(i);let c=le(e);return{type:t,value:c,repr:e}},le=function(e){return+e},de=function(){for(;s();){if(i===41||l())return;v()&&g()}},T=0;for(;!l(o());)if(r.push(u()),T++,T>t.length*2)throw Error(`I'm infinite-looping!`);return r}var T=class{constructor(){s(this,`tokenType`,``),s(this,`value`)}toJSON(){return{token:this.tokenType}}toString(){return this.tokenType}toSource(){return`${this}`}},fe=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`BADSTRING`)}},pe=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`BADURL`)}},me=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`WHITESPACE`)}toString(){return`WS`}toSource(){return` `}},he=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`CDO`)}toSource(){return`<!--`}},ge=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`CDC`)}toSource(){return`-->`}},_e=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`:`)}},ve=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`;`)}},ye=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`,`)}},E=class extends T{constructor(){super(...arguments),s(this,`value`,``),s(this,`mirror`,``)}},be=class extends E{constructor(){super(),s(this,`tokenType`,`{`),this.value=`{`,this.mirror=`}`}},xe=class extends E{constructor(){super(),s(this,`tokenType`,`}`),this.value=`}`,this.mirror=`{`}},Se=class extends E{constructor(){super(),s(this,`tokenType`,`[`),this.value=`[`,this.mirror=`]`}},Ce=class extends E{constructor(){super(),s(this,`tokenType`,`]`),this.value=`]`,this.mirror=`[`}},we=class extends E{constructor(){super(),s(this,`tokenType`,`(`),this.value=`(`,this.mirror=`)`}},Te=class extends E{constructor(){super(),s(this,`tokenType`,`)`),this.value=`)`,this.mirror=`(`}},Ee=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`~=`)}},De=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`|=`)}},Oe=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`^=`)}},ke=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`$=`)}},Ae=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`*=`)}},je=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`||`)}},Me=class extends T{constructor(){super(...arguments),s(this,`tokenType`,`EOF`)}toSource(){return``}},D=class extends T{constructor(e){super(),s(this,`tokenType`,`DELIM`),s(this,`value`,``),this.value=w(e)}toString(){return`DELIM(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e}toSource(){return this.value===`\\`?`\\
2
+ `:this.value}},O=class extends T{constructor(){super(...arguments),s(this,`value`,``)}ASCIIMatch(e){return this.value.toLowerCase()===e.toLowerCase()}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e}},Ne=class extends O{constructor(e){super(),s(this,`tokenType`,`IDENT`),this.value=e}toString(){return`IDENT(${this.value})`}toSource(){return k(this.value)}},Pe=class extends O{constructor(e){super(),s(this,`tokenType`,`FUNCTION`),s(this,`mirror`),this.value=e,this.mirror=`)`}toString(){return`FUNCTION(${this.value})`}toSource(){return`${k(this.value)}(`}},Fe=class extends O{constructor(e){super(),s(this,`tokenType`,`AT-KEYWORD`),this.value=e}toString(){return`AT(${this.value})`}toSource(){return`@${k(this.value)}`}},Ie=class extends O{constructor(e){super(),s(this,`tokenType`,`HASH`),s(this,`type`),this.value=e,this.type=`unrestricted`}toString(){return`HASH(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.type=this.type,e}toSource(){return this.type===`id`?`#${k(this.value)}`:`#${He(this.value)}`}},Le=class extends O{constructor(e){super(),s(this,`tokenType`,`STRING`),this.value=e}toString(){return`"${Ue(this.value)}"`}},Re=class extends O{constructor(e){super(),s(this,`tokenType`,`URL`),this.value=e}toString(){return`URL(${this.value})`}toSource(){return`url("${Ue(this.value)}")`}},ze=class extends T{constructor(){super(),s(this,`tokenType`,`NUMBER`),s(this,`type`),s(this,`repr`),this.type=`integer`,this.repr=``}toString(){return this.type===`integer`?`INT(${this.value})`:`NUMBER(${this.value})`}toJSON(){let e=super.toJSON();return e.value=this.value,e.type=this.type,e.repr=this.repr,e}toSource(){return this.repr}},Be=class extends T{constructor(){super(),s(this,`tokenType`,`PERCENTAGE`),s(this,`repr`),this.repr=``}toString(){return`PERCENTAGE(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.repr=this.repr,e}toSource(){return`${this.repr}%`}},Ve=class extends T{constructor(){super(),s(this,`tokenType`,`DIMENSION`),s(this,`type`),s(this,`repr`),s(this,`unit`),this.type=`integer`,this.repr=``,this.unit=``}toString(){return`DIM(${this.value},${this.unit})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.type=this.type,e.repr=this.repr,e.unit=this.unit,e}toSource(){let e=this.repr,t=k(this.unit);return t[0].toLowerCase()===`e`&&(t[1]===`-`||b(t.charCodeAt(1),48,57))&&(t=`\\65 ${t.slice(1,t.length)}`),e+t}};function k(e){e=`${e}`;let t=``,n=e.charCodeAt(0);for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i===0)throw new le(`Invalid character: the input contains U+0000.`);b(i,1,31)||i===127||r===0&&b(i,48,57)||r===1&&b(i,48,57)&&n===45?t+=`\\${i.toString(16)} `:i>=128||i===45||i===95||b(i,48,57)||b(i,65,90)||b(i,97,122)?t+=e[r]:t+=`\\${e[r]}`}return t}function He(e){e=`${e}`;let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===0)throw new le(`Invalid character: the input contains U+0000.`);r>=128||r===45||r===95||b(r,48,57)||b(r,65,90)||b(r,97,122)?t+=e[n]:t+=`\\${r.toString(16)} `}return t}function Ue(e){e=`${e}`;let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===0)throw new le(`Invalid character: the input contains U+0000.`);b(r,1,31)||r===127?t+=`\\${r.toString(16)} `:r===34||r===92?t+=`\\${e[n]}`:t+=e[n]}return t}var A=class extends Error{};function We(e,t){let n;try{n=de(e),n[n.length-1]instanceof Me||n.push(new Me)}catch(t){let n=`${t.message} while parsing selector "${e}"`,r=(t.stack||``).indexOf(t.message);throw r!==-1&&(t.stack=t.stack.substring(0,r)+n+t.stack.substring(r+t.message.length)),t.message=n,t}let r=n.find(e=>e instanceof Fe||e instanceof fe||e instanceof pe||e instanceof je||e instanceof he||e instanceof ge||e instanceof ve||e instanceof be||e instanceof xe||e instanceof Re||e instanceof Be);if(r)throw new A(`Unsupported token "${r.toSource()}" while parsing selector "${e}"`);let i=0,a=new Set;function o(){return new A(`Unexpected token "${n[i].toSource()}" while parsing selector "${e}"`)}function s(){for(;n[i]instanceof me;)i++}function c(e=i){return n[e]instanceof Ne}function l(e=i){return n[e]instanceof Le}function u(e=i){return n[e]instanceof ze}function d(e=i){return n[e]instanceof ye}function f(e=i){return n[e]instanceof we}function p(e=i){return n[e]instanceof Te}function m(e=i){return n[e]instanceof Pe}function h(e=i){return n[e]instanceof D&&n[e].value===`*`}function g(e=i){return n[e]instanceof Me}function _(e=i){return n[e]instanceof D&&[`>`,`+`,`~`].includes(n[e].value)}function v(e=i){return d(e)||p(e)||g(e)||_(e)||n[e]instanceof me}function y(){let e=[b()];for(;s(),d();)i++,e.push(b());return e}function b(){return s(),u()||l()?n[i++].value:x()}function x(){let e={simples:[]};for(s(),_()?e.simples.push({selector:{functions:[{name:`scope`,args:[]}]},combinator:``}):e.simples.push({selector:ee(),combinator:``});;){if(s(),_())e.simples[e.simples.length-1].combinator=n[i++].value,s();else if(v())break;e.simples.push({combinator:``,selector:ee()})}return e}function ee(){let e=``,r=[];for(;!v();)if(c()||h())e+=n[i++].toSource();else if(n[i]instanceof Ie)e+=n[i++].toSource();else if(n[i]instanceof D&&n[i].value===`.`)if(i++,c())e+=`.${n[i++].toSource()}`;else throw o();else if(n[i]instanceof _e)if(i++,c())if(!t.has(n[i].value.toLowerCase()))e+=`:${n[i++].toSource()}`;else{let e=n[i++].value.toLowerCase();r.push({name:e,args:[]}),a.add(e)}else if(m()){let c=n[i++].value.toLowerCase();if(t.has(c)?(r.push({name:c,args:y()}),a.add(c)):e+=`:${c}(${te()})`,s(),!p())throw o();i++}else throw o();else if(n[i]instanceof Se){for(e+=`[`,i++;!(n[i]instanceof Ce)&&!g();)e+=n[i++].toSource();if(!(n[i]instanceof Ce))throw o();e+=`]`,i++}else throw o();if(!e&&!r.length)throw o();return{css:e||void 0,functions:r}}function te(){let e=``,t=1;for(;!g()&&((f()||m())&&t++,p()&&t--,t);)e+=n[i++].toSource();return e}let S=y();if(!g())throw o();if(S.some(e=>typeof e!=`object`||!(`simples`in e)))throw new A(`Error while parsing selector "${e}"`);return{selector:S,names:Array.from(a)}}var Ge=new Set([`internal:has`,`internal:has-not`,`internal:and`,`internal:or`,`internal:chain`,`left-of`,`right-of`,`above`,`below`,`near`]),Ke=new Set([`left-of`,`right-of`,`above`,`below`,`near`]),qe=new Set([`not`,`is`,`where`,`has`,`scope`,`light`,`visible`,`text`,`text-matches`,`text-is`,`has-text`,`above`,`below`,`right-of`,`left-of`,`near`,`nth-match`]);function Je(e){let t=Ze(e),n=[];for(let e of t.parts){if(e.name===`css`||e.name===`css:light`){e.name===`css:light`&&(e.body=`:light(${e.body})`);let t=We(e.body,qe);n.push({name:`css`,body:t.selector,source:e.body});continue}if(Ge.has(e.name)){let t,r;try{let n=JSON.parse(`[${e.body}]`);if(!Array.isArray(n)||n.length<1||n.length>2||typeof n[0]!=`string`)throw new A(`Malformed selector: ${e.name}=${e.body}`);if(t=n[0],n.length===2){if(typeof n[1]!=`number`||!Ke.has(e.name))throw new A(`Malformed selector: ${e.name}=${e.body}`);r=n[1]}}catch{throw new A(`Malformed selector: ${e.name}=${e.body}`)}let i={name:e.name,source:e.body,body:{parsed:Je(t),distance:r}},a=[...i.body.parsed.parts].reverse().find(e=>e.name===`internal:control`&&e.body===`enter-frame`),o=a?i.body.parsed.parts.indexOf(a):-1;o!==-1&&Ye(i.body.parsed.parts.slice(0,o+1),n.slice(0,o+1))&&i.body.parsed.parts.splice(0,o+1),n.push(i);continue}n.push({...e,source:e.body})}if(Ge.has(n[0].name))throw new A(`"${n[0].name}" selector cannot be first`);return{capture:t.capture,parts:n}}function Ye(e,t){return j({parts:e})===j({parts:t})}function j(e,t){return typeof e==`string`?e:e.parts.map((n,r)=>{let i=!0;!t&&r!==e.capture&&(n.name===`css`||n.name===`xpath`&&n.source.startsWith(`//`)||n.source.startsWith(`..`))&&(i=!1);let a=i?`${n.name}=`:``;return`${r===e.capture?`*`:``}${a}${n.source}`}).join(` >> `)}function Xe(e,t){let n=(e,r)=>{for(let i of e.parts)t(i,r),Ge.has(i.name)&&n(i.body.parsed,!0)};n(e,!1)}function Ze(e){let t=0,n,r=0,i={parts:[]},a=()=>{let n=e.substring(r,t).trim(),a=n.indexOf(`=`),o,s;a!==-1&&n.substring(0,a).trim().match(/^[\w\-+:*]+$/)?(o=n.substring(0,a).trim(),s=n.substring(a+1)):n.length>1&&n[0]===`"`&&n[n.length-1]===`"`||n.length>1&&n[0]===`'`&&n[n.length-1]===`'`?(o=`text`,s=n):/^\(*\/\//.test(n)||n.startsWith(`..`)?(o=`xpath`,s=n):(o=`css`,s=n);let c=!1;if(o[0]===`*`&&(c=!0,o=o.substring(1)),i.parts.push({name:o,body:s}),c){if(i.capture!==void 0)throw new A(`Only one of the selectors can capture using * modifier`);i.capture=i.parts.length-1}};if(!e.includes(`>>`))return t=e.length,a(),i;let o=()=>{let n=e.substring(r,t).match(/^\s*text\s*=(.*)$/);return!!n&&!!n[1]};for(;t<e.length;){let i=e[t];i===`\\`&&t+1<e.length?t+=2:i===n?(n=void 0,t++):!n&&(i===`"`||i===`'`||i==="`")&&!o()?(n=i,t++):!n&&i===`>`&&e[t+1]===`>`?(a(),t+=2,r=t):t++}return a(),i}function M(e,t){let n=0,r=e.length===0,i=()=>e[n]||``,a=()=>{let t=i();return++n,r=n>=e.length,t},o=t=>{throw r?new A(`Unexpected end of selector while parsing selector \`${e}\``):new A(`Error while parsing selector \`${e}\` - unexpected symbol "${i()}" at position ${n}${t?` during ${t}`:``}`)};function s(){for(;!r&&/\s/.test(i());)a()}function c(e){return e>=`€`||e>=`0`&&e<=`9`||e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e>=`0`&&e<=`9`||e===`_`||e===`-`}function l(){let e=``;for(s();!r&&c(i());)e+=a();return e}function u(e){let t=a();for(t!==e&&o(`parsing quoted string`);!r&&i()!==e;)i()===`\\`&&a(),t+=a();return i()!==e&&o(`parsing quoted string`),t+=a(),t}function d(){a()!==`/`&&o(`parsing regular expression`);let t=``,n=!1;for(;!r;){if(i()===`\\`)t+=a(),r&&o(`parsing regular expression`);else if(n&&i()===`]`)n=!1;else if(!n&&i()===`[`)n=!0;else if(!n&&i()===`/`)break;t+=a()}a()!==`/`&&o(`parsing regular expression`);let s=``;for(;!r&&i().match(/[dgimsuy]/);)s+=a();try{return new RegExp(t,s)}catch(t){throw new A(`Error while parsing selector \`${e}\`: ${t.message}`)}}function f(){let e=``;return s(),e=i()===`'`||i()===`"`?u(i()).slice(1,-1):l(),e||o(`parsing property path`),e}function p(){s();let e=``;return r||(e+=a()),!r&&e!==`=`&&(e+=a()),[`=`,`*=`,`^=`,`$=`,`|=`,`~=`].includes(e)||o(`parsing operator`),e}function m(){a();let t=[];for(t.push(f()),s();i()===`.`;)a(),t.push(f()),s();if(i()===`]`)return a(),{name:t.join(`.`),jsonPath:t,op:`<truthy>`,value:null,caseSensitive:!1};let n=p(),l,m=!0;if(s(),i()===`/`){if(n!==`=`)throw new A(`Error while parsing selector \`${e}\` - cannot use ${n} in attribute with regular expression`);l=d()}else if(i()===`'`||i()===`"`)l=u(i()).slice(1,-1),s(),i()===`i`||i()===`I`?(m=!1,a()):(i()===`s`||i()===`S`)&&(m=!0,a());else{for(l=``;!r&&(c(i())||i()===`+`||i()===`.`);)l+=a();l===`true`?l=!0:l===`false`&&(l=!1)}if(s(),i()!==`]`&&o(`parsing attribute value`),a(),n!==`=`&&typeof l!=`string`)throw new A(`Error while parsing selector \`${e}\` - cannot use ${n} in attribute with non-string matching value - ${l}`);return{name:t.join(`.`),jsonPath:t,op:n,value:l,caseSensitive:m}}let h={name:``,attributes:[]};for(h.name=l(),s();i()===`[`;)h.attributes.push(m()),s();if(r||o(void 0),!h.name&&!h.attributes.length)throw new A(`Error while parsing selector \`${e}\` - selector cannot be empty`);return h}function Qe(e){return e.hasAttribute(`aria-label`)||e.hasAttribute(`aria-labelledby`)}var $e=`article:not([role]), aside:not([role]), main:not([role]), nav:not([role]), section:not([role]), [role=article], [role=complementary], [role=main], [role=navigation], [role=region]`,et=new Map([[`aria-atomic`,void 0],[`aria-busy`,void 0],[`aria-controls`,void 0],[`aria-current`,void 0],[`aria-describedby`,void 0],[`aria-details`,void 0],[`aria-dropeffect`,void 0],[`aria-flowto`,void 0],[`aria-grabbed`,void 0],[`aria-hidden`,void 0],[`aria-keyshortcuts`,void 0],[`aria-label`,new Set([`caption`,`code`,`deletion`,`emphasis`,`generic`,`insertion`,`paragraph`,`presentation`,`strong`,`subscript`,`superscript`])],[`aria-labelledby`,new Set([`caption`,`code`,`deletion`,`emphasis`,`generic`,`insertion`,`paragraph`,`presentation`,`strong`,`subscript`,`superscript`])],[`aria-live`,void 0],[`aria-owns`,void 0],[`aria-relevant`,void 0],[`aria-roledescription`,new Set([`generic`])]]);function tt(e,t){return[...et].some(([n,r])=>!r?.has(t||``)&&e.hasAttribute(n))}function nt(e){return!Number.isNaN(Number(String(e.getAttribute(`tabindex`))))}function rt(e){return!Ht(e)&&(it(e)||nt(e))}function it(e){let t=Z(e);return[`BUTTON`,`DETAILS`,`SELECT`,`TEXTAREA`].includes(t)?!0:t===`A`||t===`AREA`?e.hasAttribute(`href`):t===`INPUT`?!e.hidden:!1}var at={A:e=>e.hasAttribute(`href`)?`link`:null,AREA:e=>e.hasAttribute(`href`)?`link`:null,ARTICLE:()=>`article`,ASIDE:()=>`complementary`,BLOCKQUOTE:()=>`blockquote`,BUTTON:()=>`button`,CAPTION:()=>`caption`,CODE:()=>`code`,DATALIST:()=>`listbox`,DD:()=>`definition`,DEL:()=>`deletion`,DETAILS:()=>`group`,DFN:()=>`term`,DIALOG:()=>`dialog`,DT:()=>`term`,EM:()=>`emphasis`,FIELDSET:()=>`group`,FIGURE:()=>`figure`,FOOTER:e=>Br(e,$e)?null:`contentinfo`,FORM:e=>Qe(e)?`form`:null,H1:()=>`heading`,H2:()=>`heading`,H3:()=>`heading`,H4:()=>`heading`,H5:()=>`heading`,H6:()=>`heading`,HEADER:e=>Br(e,$e)?null:`banner`,HR:()=>`separator`,HTML:()=>`document`,IMG:e=>e.getAttribute(`alt`)===``&&!e.getAttribute(`title`)&&!tt(e)&&!nt(e)?`presentation`:`img`,INPUT:e=>{let t=e.type.toLowerCase();if(t===`search`)return e.hasAttribute(`list`)?`combobox`:`searchbox`;if([`email`,`tel`,`text`,`url`,``].includes(t)){let t=F(e,e.getAttribute(`list`))[0];return t&&Z(t)===`DATALIST`?`combobox`:`textbox`}return t===`hidden`?``:t===`file`?`button`:{button:`button`,checkbox:`checkbox`,image:`button`,number:`spinbutton`,radio:`radio`,range:`slider`,reset:`button`,submit:`button`}[t]||`textbox`},INS:()=>`insertion`,LI:()=>`listitem`,MAIN:()=>`main`,MARK:()=>`mark`,MATH:()=>`math`,MENU:()=>`list`,METER:()=>`meter`,NAV:()=>`navigation`,OL:()=>`list`,OPTGROUP:()=>`group`,OPTION:()=>`option`,OUTPUT:()=>`status`,P:()=>`paragraph`,PROGRESS:()=>`progressbar`,SECTION:e=>Qe(e)?`region`:null,SELECT:e=>e.hasAttribute(`multiple`)||e.size>1?`listbox`:`combobox`,STRONG:()=>`strong`,SUB:()=>`subscript`,SUP:()=>`superscript`,SVG:()=>`img`,TABLE:()=>`table`,TBODY:()=>`rowgroup`,TD:e=>{let t=Br(e,`table`),n=t?dt(t):``;return n===`grid`||n===`treegrid`?`gridcell`:`cell`},TEXTAREA:()=>`textbox`,TFOOT:()=>`rowgroup`,TH:e=>{if(e.getAttribute(`scope`)===`col`)return`columnheader`;if(e.getAttribute(`scope`)===`row`)return`rowheader`;let t=Br(e,`table`),n=t?dt(t):``;return n===`grid`||n===`treegrid`?`gridcell`:`cell`},THEAD:()=>`rowgroup`,TIME:()=>`time`,TR:()=>`row`,UL:()=>`list`},ot={DD:[`DL`,`DIV`],DIV:[`DL`],DT:[`DL`,`DIV`],LI:[`OL`,`UL`],TBODY:[`TABLE`],TD:[`TR`],TFOOT:[`TABLE`],TH:[`TR`],THEAD:[`TABLE`],TR:[`THEAD`,`TBODY`,`TFOOT`,`TABLE`]};function st(e){let t=at[Z(e)]?.call(at,e)||``;if(!t)return null;let n=e;for(;n;){let e=Y(n),t=ot[Z(n)];if(!t||!e||!t.includes(Z(e)))break;let r=dt(e);if((r===`none`||r===`presentation`)&&!ft(e,r))return r;n=e}return t}var ct=`alert.alertdialog.application.article.banner.blockquote.button.caption.cell.checkbox.code.columnheader.combobox.command.complementary.composite.contentinfo.definition.deletion.dialog.directory.document.emphasis.feed.figure.form.generic.grid.gridcell.group.heading.img.input.insertion.landmark.link.list.listbox.listitem.log.main.marquee.math.meter.menu.menubar.menuitem.menuitemcheckbox.menuitemradio.navigation.none.note.option.paragraph.presentation.progressbar.radio.radiogroup.range.region.roletype.row.rowgroup.rowheader.scrollbar.search.searchbox.section.sectionhead.select.separator.slider.spinbutton.status.strong.structure.subscript.superscript.switch.tab.table.tablist.tabpanel.term.textbox.time.timer.toolbar.tooltip.tree.treegrid.treeitem.widget.window`.split(`.`),lt=[`command`,`composite`,`input`,`landmark`,`range`,`roletype`,`section`,`sectionhead`,`select`,`structure`,`widget`,`window`],ut=ct.filter(e=>!lt.includes(e));function dt(e){return(e.getAttribute(`role`)||``).split(` `).map(e=>e.trim()).find(e=>ut.includes(e))||null}function ft(e,t){return tt(e,t)||rt(e)}function N(e){let t=dt(e);if(!t)return st(e);if(t===`none`||t===`presentation`){let t=st(e);if(ft(e,t))return t}return t}function pt(e){return e===null?void 0:e.toLowerCase()===`true`}function mt(e){return[`STYLE`,`SCRIPT`,`NOSCRIPT`,`TEMPLATE`].includes(Z(e))}function P(e){if(mt(e))return!0;let t=X(e),n=e.nodeName===`SLOT`;if(t?.display===`contents`&&!n){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType===1&&!P(t)||t.nodeType===3&&Ur(t))return!1;return!0}return!(e.nodeName===`OPTION`&&e.closest(`select`))&&!n&&!Vr(e,t)?!0:ht(e)}function ht(e){let t=Xt?.get(e);if(t===void 0){if(t=!1,e.parentElement&&e.parentElement.shadowRoot&&!e.assignedSlot&&(t=!0),!t){let n=X(e);t=!n||n.display===`none`||pt(e.getAttribute(`aria-hidden`))===!0}if(!t){let n=Y(e);n&&(t=ht(n))}Xt?.set(e,t)}return t}function F(e,t){if(!t)return[];let n=Rr(e);if(!n)return[];try{let e=t.split(` `).filter(e=>!!e),r=new Set;for(let t of e){let e=n.querySelector(`#${CSS.escape(t)}`);e&&r.add(e)}return[...r]}catch{return[]}}function I(e){return e.trim()}function gt(e){return e.split(`\xA0`).map(e=>e.replace(/\r\n/g,`
3
+ `).replace(/[\u200b\u00ad]/g,``).replace(/\s\s*/g,` `)).join(`\xA0`).trim()}function _t(e,t){let n=[...e.querySelectorAll(t)];for(let r of F(e,e.getAttribute(`aria-owns`)))r.matches(t)&&n.push(r),n.push(...r.querySelectorAll(t));return n}function vt(e,t){let n=t===`::before`?Zt:Qt;if(n?.has(e))return n?.get(e)||``;let r=yt(X(e,t));return n&&n.set(e,r),r}function yt(e){if(!e)return``;let t=e.content;if(t[0]===`'`&&t[t.length-1]===`'`||t[0]===`"`&&t[t.length-1]===`"`){let n=t.substring(1,t.length-1);return(e.display||`inline`)===`inline`?n:` ${n} `}return``}function bt(e){let t=e.getAttribute(`aria-labelledby`);return t===null?null:F(e,t)}function xt(e,t){let n=[`button`,`cell`,`checkbox`,`columnheader`,`gridcell`,`heading`,`link`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`option`,`radio`,`row`,`rowheader`,`switch`,`tab`,`tooltip`,`treeitem`].includes(e),r=t&&[``,`caption`,`code`,`contentinfo`,`definition`,`deletion`,`emphasis`,`insertion`,`list`,`listitem`,`mark`,`none`,`paragraph`,`presentation`,`region`,`row`,`rowgroup`,`section`,`strong`,`subscript`,`superscript`,`table`,`term`,`time`].includes(e);return n||r}function St(e,t){let n=t?qt:Kt,r=n?.get(e);return r===void 0&&(r=``,[`caption`,`code`,`definition`,`deletion`,`emphasis`,`generic`,`insertion`,`mark`,`paragraph`,`presentation`,`strong`,`subscript`,`suggestion`,`superscript`,`term`,`time`].includes(N(e)||``)||(r=gt(L(e,{includeHidden:t,visitedElements:new Set,embeddedInDescribedBy:void 0,embeddedInLabelledBy:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0,embeddedInTargetElement:`self`}))),n?.set(e,r)),r}function Ct(e,t){let n=Yt,r=n?.get(e);return r===void 0&&(r=``,r=e.hasAttribute(`aria-describedby`)?gt(F(e,e.getAttribute(`aria-describedby`)).map(e=>L(e,{includeHidden:t,visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:P(e)}})).join(` `)):e.hasAttribute(`aria-description`)?gt(e.getAttribute(`aria-description`)||``):gt(e.getAttribute(`title`)||``),n?.set(e,r)),r}var wt=[`application`,`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`slider`,`spinbutton`,`textbox`,`tree`,`columnheader`,`rowheader`,`searchbox`,`switch`,`treegrid`];function Tt(e){let t=N(e)||``;if(!t||!wt.includes(t))return`false`;let n=e.getAttribute(`aria-invalid`);return!n||n.trim()===``||n.toLocaleLowerCase()===`false`?`false`:n===`true`||n===`grammar`||n===`spelling`?n:`true`}function Et(e){return`validity`in e?e.validity?.valid===!1:!1}function Dt(e){let t=Jt,n=Jt?.get(e);if(n===void 0){n=``;let r=Tt(e)!==`false`,i=Et(e);(r||i)&&(n=F(e,e.getAttribute(`aria-errormessage`)).map(e=>gt(L(e,{visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:P(e)}}))).join(` `).trim()),t?.set(e,n)}return n}function L(e,t){if(t.visitedElements.has(e))return``;let n={...t,embeddedInTargetElement:t.embeddedInTargetElement===`self`?`descendant`:t.embeddedInTargetElement};if(!t.includeHidden){let n=!!t.embeddedInLabelledBy?.hidden||!!t.embeddedInDescribedBy?.hidden||!!t.embeddedInNativeTextAlternative?.hidden||!!t.embeddedInLabel?.hidden;if(mt(e)||!n&&P(e))return t.visitedElements.add(e),``}let r=bt(e);if(!t.embeddedInLabelledBy){let e=(r||[]).map(e=>L(e,{...t,embeddedInLabelledBy:{element:e,hidden:P(e)},embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0})).join(` `);if(e)return e}let i=N(e)||``,a=Z(e);if(t.embeddedInLabel||t.embeddedInLabelledBy||t.embeddedInTargetElement===`descendant`){let o=[...e.labels||[]].includes(e),s=(r||[]).includes(e);if(!o&&!s){if(i===`textbox`)return t.visitedElements.add(e),a===`INPUT`||a===`TEXTAREA`?e.value:e.textContent||``;if([`combobox`,`listbox`].includes(i)){t.visitedElements.add(e);let r;if(a===`SELECT`)r=[...e.selectedOptions],!r.length&&e.options.length&&r.push(e.options[0]);else{let t=i===`combobox`?_t(e,`*`).find(e=>N(e)===`listbox`):e;r=t?_t(t,`[aria-selected="true"]`).filter(e=>N(e)===`option`):[]}return!r.length&&a===`INPUT`?e.value:r.map(e=>L(e,n)).join(` `)}if([`progressbar`,`scrollbar`,`slider`,`spinbutton`,`meter`].includes(i))return t.visitedElements.add(e),e.hasAttribute(`aria-valuetext`)?e.getAttribute(`aria-valuetext`)||``:e.hasAttribute(`aria-valuenow`)?e.getAttribute(`aria-valuenow`)||``:e.getAttribute(`value`)||``;if([`menu`].includes(i))return t.visitedElements.add(e),``}}let o=e.getAttribute(`aria-label`)||``;if(I(o))return t.visitedElements.add(e),o;if(![`presentation`,`none`].includes(i)){if(a===`INPUT`&&[`button`,`submit`,`reset`].includes(e.type)){t.visitedElements.add(e);let n=e.value||``;return I(n)?n:e.type===`submit`?`Submit`:e.type===`reset`?`Reset`:e.getAttribute(`title`)||``}if(a===`INPUT`&&e.type===`image`){t.visitedElements.add(e);let n=e.labels||[];if(n.length&&!t.embeddedInLabelledBy)return Gt(n,t);let r=e.getAttribute(`alt`)||``;if(I(r))return r;let i=e.getAttribute(`title`)||``;return I(i)?i:`Submit`}if(!r&&a===`BUTTON`){t.visitedElements.add(e);let n=e.labels||[];if(n.length)return Gt(n,t)}if(!r&&a===`OUTPUT`){t.visitedElements.add(e);let n=e.labels||[];return n.length?Gt(n,t):e.getAttribute(`title`)||``}if(!r&&(a===`TEXTAREA`||a===`SELECT`||a===`INPUT`)){t.visitedElements.add(e);let n=e.labels||[];if(n.length)return Gt(n,t);let r=a===`INPUT`&&[`text`,`password`,`search`,`tel`,`email`,`url`].includes(e.type)||a===`TEXTAREA`,i=e.getAttribute(`placeholder`)||``,o=e.getAttribute(`title`)||``;return!r||o?o:i}if(!r&&a===`FIELDSET`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(Z(t)===`LEGEND`)return L(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:P(t)}});return e.getAttribute(`title`)||``}if(!r&&a===`FIGURE`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(Z(t)===`FIGCAPTION`)return L(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:P(t)}});return e.getAttribute(`title`)||``}if(a===`IMG`){t.visitedElements.add(e);let n=e.getAttribute(`alt`)||``;return I(n)?n:e.getAttribute(`title`)||``}if(a===`TABLE`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(Z(t)===`CAPTION`)return L(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:P(t)}});let r=e.getAttribute(`summary`)||``;if(r)return r}if(a===`AREA`){t.visitedElements.add(e);let n=e.getAttribute(`alt`)||``;return I(n)?n:e.getAttribute(`title`)||``}if(a===`SVG`||e.ownerSVGElement){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(Z(t)===`TITLE`&&t.ownerSVGElement)return L(t,{...n,embeddedInLabelledBy:{element:t,hidden:P(t)}})}if(e.ownerSVGElement&&a===`A`){let n=e.getAttribute(`xlink:title`)||``;if(I(n))return t.visitedElements.add(e),n}}let s=a===`SUMMARY`&&![`presentation`,`none`].includes(i);if(xt(i,t.embeddedInTargetElement===`descendant`)||s||t.embeddedInLabelledBy||t.embeddedInDescribedBy||t.embeddedInLabel||t.embeddedInNativeTextAlternative){t.visitedElements.add(e);let r=Ot(e,n);if(t.embeddedInTargetElement===`self`?I(r):r)return r}if(![`presentation`,`none`].includes(i)||a===`IFRAME`){t.visitedElements.add(e);let n=e.getAttribute(`title`)||``;if(I(n))return n}return t.visitedElements.add(e),``}function Ot(e,t){let n=[],r=(e,r)=>{if(!(r&&e.assignedSlot))if(e.nodeType===1){let r=X(e)?.display||`inline`,i=L(e,t);(r!==`inline`||e.nodeName===`BR`)&&(i=` `+i+` `),n.push(i)}else e.nodeType===3&&n.push(e.textContent||``)};n.push(vt(e,`::before`));let i=e.nodeName===`SLOT`?e.assignedNodes():[];if(i.length)for(let e of i)r(e,!1);else{for(let t=e.firstChild;t;t=t.nextSibling)r(t,!0);if(e.shadowRoot)for(let t=e.shadowRoot.firstChild;t;t=t.nextSibling)r(t,!0);for(let t of F(e,e.getAttribute(`aria-owns`)))r(t,!0)}return n.push(vt(e,`::after`)),n.join(``)}var kt=[`gridcell`,`option`,`row`,`tab`,`rowheader`,`columnheader`,`treeitem`];function At(e){return Z(e)===`OPTION`?e.selected:kt.includes(N(e)||``)?pt(e.getAttribute(`aria-selected`))===!0:!1}var jt=[`checkbox`,`menuitemcheckbox`,`option`,`radio`,`switch`,`menuitemradio`,`treeitem`];function Mt(e){let t=Nt(e);return t===`error`?!1:t}function Nt(e,t){let n=Z(e);if(n===`INPUT`&&e.indeterminate)return`mixed`;if(n===`INPUT`&&[`checkbox`,`radio`].includes(e.type))return e.checked;if(jt.includes(N(e)||``)){let t=e.getAttribute(`aria-checked`);return t===`true`?!0:t===`mixed`?`mixed`:!1}return`error`}var Pt=[`button`];function Ft(e){if(Pt.includes(N(e)||``)){let t=e.getAttribute(`aria-pressed`);if(t===`true`)return!0;if(t===`mixed`)return`mixed`}return!1}var It=[`application`,`button`,`checkbox`,`combobox`,`gridcell`,`link`,`listbox`,`menuitem`,`row`,`rowheader`,`tab`,`treeitem`,`columnheader`,`menuitemcheckbox`,`menuitemradio`,`rowheader`,`switch`];function Lt(e){if(Z(e)===`DETAILS`)return e.open;if(It.includes(N(e)||``)){let t=e.getAttribute(`aria-expanded`);return t===null?`none`:t===`true`}return`none`}var Rt=[`heading`,`listitem`,`row`,`treeitem`];function zt(e){let t={H1:1,H2:2,H3:3,H4:4,H5:5,H6:6}[Z(e)];if(t)return t;if(Rt.includes(N(e)||``)){let t=e.getAttribute(`aria-level`),n=t===null?NaN:Number(t);if(Number.isInteger(n)&&n>=1)return n}return 0}var Bt=`application.button.composite.gridcell.group.input.link.menuitem.scrollbar.separator.tab.checkbox.columnheader.combobox.grid.listbox.menu.menubar.menuitemcheckbox.menuitemradio.option.radio.radiogroup.row.rowheader.searchbox.select.slider.spinbutton.switch.tablist.textbox.toolbar.tree.treegrid.treeitem`.split(`.`);function Vt(e){return Ht(e)||Wt(e)}function Ht(e){return[`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`OPTION`,`OPTGROUP`].includes(e.tagName)&&(e.hasAttribute(`disabled`)||Ut(e))}function Ut(e){let t=e?.closest(`FIELDSET[DISABLED]`);if(!t)return!1;let n=t.querySelector(`:scope > LEGEND`);return!n||!n.contains(e)}function Wt(e){if(!e)return!1;if(Bt.includes(N(e)||``)){let t=(e.getAttribute(`aria-disabled`)||``).toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}return Wt(Y(e))}function Gt(e,t){return[...e].map(e=>L(e,{...t,embeddedInLabel:{element:e,hidden:P(e)},embeddedInNativeTextAlternative:void 0,embeddedInLabelledBy:void 0,embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0})).filter(e=>!!e).join(` `)}var Kt,qt,Jt,Yt,Xt,Zt,Qt,$t=0;function en(){++$t,Kt??=new Map,qt??=new Map,Yt??=new Map,Jt??=new Map,Xt??=new Map,Zt??=new Map,Qt??=new Map}function tn(){--$t||(Kt=void 0,qt=void 0,Yt=void 0,Jt=void 0,Xt=void 0,Zt=void 0,Qt=void 0)}function nn(e,t){let n=typeof e==`string`&&!t.caseSensitive?e.toUpperCase():e,r=typeof t.value==`string`&&!t.caseSensitive?t.value.toUpperCase():t.value;return t.op===`<truthy>`?!!n:t.op===`=`?r instanceof RegExp?typeof n==`string`&&!!n.match(r):n===r:typeof n!=`string`||typeof r!=`string`?!1:t.op===`*=`?n.includes(r):t.op===`^=`?n.startsWith(r):t.op===`$=`?n.endsWith(r):t.op===`|=`?n===r||n.startsWith(`${r}-`):t.op===`~=`?n.split(` `).includes(r):!1}function rn(e){let t=e.ownerDocument;return e.nodeName===`SCRIPT`||e.nodeName===`NOSCRIPT`||e.nodeName===`STYLE`||t.head&&t.head.contains(e)}function R(e,t){let n=e.get(t);if(n===void 0){if(n={full:``,normalized:``,immediate:[]},!rn(t)){let r=``;if(t instanceof HTMLInputElement&&(t.type===`submit`||t.type===`button`))n={full:t.value,normalized:f(t.value),immediate:[t.value]};else{for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType===Node.TEXT_NODE?(n.full+=i.nodeValue||``,r+=i.nodeValue||``):(r&&n.immediate.push(r),r=``,i.nodeType===Node.ELEMENT_NODE&&(n.full+=R(e,i).full));r&&n.immediate.push(r),t.shadowRoot&&(n.full+=R(e,t.shadowRoot).full),n.full&&(n.normalized=f(n.full))}}e.set(t,n)}return n}function an(e,t,n){if(rn(t)||!n(R(e,t)))return`none`;for(let r=t.firstChild;r;r=r.nextSibling)if(r.nodeType===Node.ELEMENT_NODE&&n(R(e,r)))return`selfAndChildren`;return t.shadowRoot&&n(R(e,t.shadowRoot))?`selfAndChildren`:`self`}function on(e,t){let n=bt(t);if(n)return n.map(t=>R(e,t));let r=t.getAttribute(`aria-label`);if(r!==null&&r.trim())return[{full:r,normalized:f(r),immediate:[r]}];let i=t.nodeName===`INPUT`&&t.type!==`hidden`;if([`BUTTON`,`METER`,`OUTPUT`,`PROGRESS`,`SELECT`,`TEXTAREA`].includes(t.nodeName)||i){let n=t.labels;if(n)return[...n].map(t=>R(e,t))}return[]}var sn=[`selected`,`checked`,`pressed`,`expanded`,`level`,`disabled`,`name`,`include-hidden`];sn.sort();function z(e,t,n){if(!t.includes(n))throw Error(`"${e}" attribute is only supported for roles: ${t.slice().sort().map(e=>`"${e}"`).join(`, `)}`)}function B(e,t){if(e.op!==`<truthy>`&&!t.includes(e.value))throw Error(`"${e.name}" must be one of ${t.map(e=>JSON.stringify(e)).join(`, `)}`)}function V(e,t){if(!t.includes(e.op))throw Error(`"${e.name}" does not support "${e.op}" matcher`)}function cn(e,t){let n={role:t};for(let r of e)switch(r.name){case`checked`:z(r.name,jt,t),B(r,[!0,!1,`mixed`]),V(r,[`<truthy>`,`=`]),n.checked=r.op===`<truthy>`?!0:r.value;break;case`pressed`:z(r.name,Pt,t),B(r,[!0,!1,`mixed`]),V(r,[`<truthy>`,`=`]),n.pressed=r.op===`<truthy>`?!0:r.value;break;case`selected`:z(r.name,kt,t),B(r,[!0,!1]),V(r,[`<truthy>`,`=`]),n.selected=r.op===`<truthy>`?!0:r.value;break;case`expanded`:z(r.name,It,t),B(r,[!0,!1]),V(r,[`<truthy>`,`=`]),n.expanded=r.op===`<truthy>`?!0:r.value;break;case`level`:if(z(r.name,Rt,t),typeof r.value==`string`&&(r.value=+r.value),r.op!==`=`||typeof r.value!=`number`||Number.isNaN(r.value))throw Error(`"level" attribute must be compared to a number`);n.level=r.value;break;case`disabled`:B(r,[!0,!1]),V(r,[`<truthy>`,`=`]),n.disabled=r.op===`<truthy>`?!0:r.value;break;case`name`:if(r.op===`<truthy>`)throw Error(`"name" attribute must have a value`);if(typeof r.value!=`string`&&!(r.value instanceof RegExp))throw TypeError(`"name" attribute must be a string or a regular expression`);n.name=r.value,n.nameOp=r.op,n.exact=r.caseSensitive;break;case`include-hidden`:B(r,[!0,!1]),V(r,[`<truthy>`,`=`]),n.includeHidden=r.op===`<truthy>`?!0:r.value;break;default:throw Error(`Unknown attribute "${r.name}", must be one of ${sn.map(e=>`"${e}"`).join(`, `)}.`)}return n}function ln(e,t,n){let r=[],i=e=>{if(N(e)===t.role&&!(t.selected!==void 0&&At(e)!==t.selected)&&!(t.checked!==void 0&&Mt(e)!==t.checked)&&!(t.pressed!==void 0&&Ft(e)!==t.pressed)&&!(t.expanded!==void 0&&Lt(e)!==t.expanded)&&!(t.level!==void 0&&zt(e)!==t.level)&&!(t.disabled!==void 0&&Vt(e)!==t.disabled)&&!(!t.includeHidden&&P(e))){if(t.name!==void 0){let r=f(St(e,!!t.includeHidden));if(typeof t.name==`string`&&(t.name=f(t.name)),n&&!t.exact&&t.nameOp===`=`&&(t.nameOp=`*=`),!nn(r,{op:t.nameOp||`=`,value:t.name,caseSensitive:!!t.exact}))return}r.push(e)}},a=e=>{let t=[];e.shadowRoot&&t.push(e.shadowRoot);for(let n of e.querySelectorAll(`*`))i(n),n.shadowRoot&&t.push(n.shadowRoot);t.forEach(a)};return a(e),r}function un(e){return{queryAll:(t,n)=>{let r=M(n),i=r.name.toLowerCase();if(!i)throw Error(`Role must not be empty`);let a=cn(r.attributes,i);en();try{return ln(t,a,e)}finally{tn()}}}}function H(e,t,n=!1){return dn(e,t,n)[0]}function dn(e,t,n=!1,r=20,i){try{return U(new pn[e](i),Je(t),n,r)}catch{return[t]}}function U(e,t,n=!1,r=20){let i=[...t.parts];for(let e=0;e<i.length-1;e++)if(i[e].name===`nth`&&i[e+1].name===`internal:control`&&i[e+1].body===`enter-frame`){let[t]=i.splice(e,1);i.splice(e+1,0,t)}let a=[],o=n?`frame-locator`:`page`;for(let t=0;t<i.length;t++){let n=i[t],s=o;if(o=`locator`,n.name===`nth`){n.body===`0`?a.push([e.generateLocator(s,`first`,``),e.generateLocator(s,`nth`,`0`)]):n.body===`-1`?a.push([e.generateLocator(s,`last`,``),e.generateLocator(s,`nth`,`-1`)]):a.push([e.generateLocator(s,`nth`,n.body)]);continue}if(n.name===`internal:text`){let{exact:t,text:r}=W(n.body);a.push([e.generateLocator(s,`text`,r,{exact:t})]);continue}if(n.name===`internal:has-text`){let{exact:t,text:r}=W(n.body);if(!t){a.push([e.generateLocator(s,`has-text`,r,{exact:t})]);continue}}if(n.name===`internal:has-not-text`){let{exact:t,text:r}=W(n.body);if(!t){a.push([e.generateLocator(s,`has-not-text`,r,{exact:t})]);continue}}if(n.name===`internal:has`){let t=U(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`has`,t)));continue}if(n.name===`internal:has-not`){let t=U(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`hasNot`,t)));continue}if(n.name===`internal:and`){let t=U(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`and`,t)));continue}if(n.name===`internal:or`){let t=U(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`or`,t)));continue}if(n.name===`internal:chain`){let t=U(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`chain`,t)));continue}if(n.name===`internal:label`){let{exact:t,text:r}=W(n.body);a.push([e.generateLocator(s,`label`,r,{exact:t})]);continue}if(n.name===`internal:role`){let t=M(n.body),r={attrs:[]};for(let e of t.attributes)e.name===`name`?(r.exact=e.caseSensitive,r.name=e.value):(e.name===`level`&&typeof e.value==`string`&&(e.value=+e.value),r.attrs.push({name:e.name===`include-hidden`?`includeHidden`:e.name,value:e.value}));a.push([e.generateLocator(s,`role`,t.name,r)]);continue}if(n.name===`internal:testid`){let{value:t}=M(n.body).attributes[0];a.push([e.generateLocator(s,`test-id`,t)]);continue}if(n.name===`internal:attr`){let{name:t,value:r,caseSensitive:i}=M(n.body).attributes[0],o=r,c=!!i;if(t===`placeholder`){a.push([e.generateLocator(s,`placeholder`,o,{exact:c})]);continue}if(t===`alt`){a.push([e.generateLocator(s,`alt`,o,{exact:c})]);continue}if(t===`title`){a.push([e.generateLocator(s,`title`,o,{exact:c})]);continue}}let c=`default`,l=i[t+1];l&&l.name===`internal:control`&&l.body===`enter-frame`&&(c=`frame`,o=`frame-locator`,t++);let u=j({parts:[n]}),d=e.generateLocator(s,c,u);if(c===`default`&&l&&[`internal:has-text`,`internal:has-not-text`].includes(l.name)){let{exact:n,text:r}=W(l.body);if(!n){let i=e.generateLocator(`locator`,l.name===`internal:has-text`?`has-text`:`has-not-text`,r,{exact:n}),o={};l.name===`internal:has-text`?o.hasText=r:o.hasNotText=r;let c=e.generateLocator(s,`default`,u,o);a.push([e.chainLocators([d,i]),c]),t++;continue}}let f;if([`xpath`,`css`].includes(n.name)){let t=j({parts:[n]},!0);f=e.generateLocator(s,c,t)}a.push([d,f].filter(Boolean))}return fn(e,a,r)}function fn(e,t,n){let r=t.map(()=>``),i=[],a=o=>{if(o===t.length)return i.push(e.chainLocators(r)),r.length<n;for(let e of t[o])if(r[o]=e,!a(o+1))return!1;return!0};return a(0),i}function W(e){let t=!1,n=e.match(/^\/(.*)\/([igm]*)$/);return n?{text:new RegExp(n[1],n[2])}:(e.endsWith(`"`)?(e=JSON.parse(e),t=!0):e.endsWith(`"s`)?(e=JSON.parse(e.substring(0,e.length-1)),t=!0):e.endsWith(`"i`)&&(e=JSON.parse(e.substring(0,e.length-1)),t=!1),{exact:t,text:e})}var pn={javascript:class{constructor(e){this.preferredQuote=e}generateLocator(e,t,n,r={}){switch(t){case`default`:return r.hasText===void 0?r.hasNotText===void 0?`locator(${this.quote(n)})`:`locator(${this.quote(n)}, { hasNotText: ${this.toHasText(r.hasNotText)} })`:`locator(${this.quote(n)}, { hasText: ${this.toHasText(r.hasText)} })`;case`frame`:return`frameLocator(${this.quote(n)})`;case`nth`:return`nth(${n})`;case`first`:return`first()`;case`last`:return`last()`;case`role`:{let e=[];mn(r.name)?e.push(`name: ${this.regexToSourceString(r.name)}`):typeof r.name==`string`&&(e.push(`name: ${this.quote(r.name)}`),r.exact&&e.push(`exact: true`));for(let{name:t,value:n}of r.attrs)e.push(`${t}: ${typeof n==`string`?this.quote(n):n}`);let t=e.length?`, { ${e.join(`, `)} }`:``;return`getByRole(${this.quote(n)}${t})`}case`has-text`:return`filter({ hasText: ${this.toHasText(n)} })`;case`has-not-text`:return`filter({ hasNotText: ${this.toHasText(n)} })`;case`has`:return`filter({ has: ${n} })`;case`hasNot`:return`filter({ hasNot: ${n} })`;case`and`:return`and(${n})`;case`or`:return`or(${n})`;case`chain`:return`locator(${n})`;case`test-id`:{let e=this.toTestIdValue(n);return e.startsWith(`'__vitest_`)&&e.endsWith(`__'`)?`page`:`getByTestId(${e})`}case`text`:return this.toCallWithExact(`getByText`,n,!!r.exact);case`alt`:return this.toCallWithExact(`getByAltText`,n,!!r.exact);case`placeholder`:return this.toCallWithExact(`getByPlaceholder`,n,!!r.exact);case`label`:return this.toCallWithExact(`getByLabel`,n,!!r.exact);case`title`:return this.toCallWithExact(`getByTitle`,n,!!r.exact);default:throw Error(`Unknown selector kind ${t}`)}}chainLocators(e){return e.join(`.`)}regexToSourceString(e){return p(String(e))}toCallWithExact(e,t,n){return mn(t)?`${e}(${this.regexToSourceString(t)})`:n?`${e}(${this.quote(t)}, { exact: true })`:`${e}(${this.quote(t)})`}toHasText(e){return mn(e)?this.regexToSourceString(e):this.quote(e)}toTestIdValue(e){return mn(e)?this.regexToSourceString(e):this.quote(e)}quote(e){return c(e,this.preferredQuote??`'`)}}};function mn(e){return e instanceof RegExp}var hn=new Map,gn=new Map,_n=10,G=_n/2,vn=1,yn=2,bn=10,xn=50,Sn=100,Cn=120,wn=140,Tn=160,En=180,Dn=200,On=250,kn=Sn+G,An=Cn+G,jn=wn+G,Mn=Tn+G,Nn=En+G,Pn=Dn+G,Fn=300,In=500,Ln=510,Rn=520,zn=530,Bn=1e4,Vn=1e7;function Hn(e,t,n){e._evaluator.begin(),en();try{return Xn(Wn(e,t,n)||Jn(e,t,n))}finally{hn.clear(),gn.clear(),tn(),e._evaluator.end()}}function Un(e){return e.filter(e=>e[0].selector[0]!==`/`)}function Wn(e,t,n){if(t.ownerDocument.documentElement===t)return[{engine:`css`,selector:`html`,score:1}];let r=(r,a)=>{let o=r===t,s=a?Kn(e,r,r===t):[];r!==t&&(s=Un(s));let c=Gn(e,r,n).map(e=>[e]),l=Zn(e,t.ownerDocument,r,[...s,...c],o);s=Un(s);let u=t=>{let n=a&&!t.length,s=[...t,...c].filter(e=>l?K(e)<K(l):!0),u=s[0];if(u)for(let t=Y(r);t;t=Y(t)){let a=i(t,n);if(!a||l&&K([...a,...u])>=K(l))continue;if(u=Zn(e,t,r,s,o),!u)return;let c=[...a,...u];(!l||K(c)<K(l))&&(l=c)}};return u(s),r===t&&s.length&&u([]),l},i=(e,t)=>{let n=t?hn:gn,i=n.get(e);return i===void 0&&(i=r(e,t),n.set(e,i)),i};return r(t,!n.noText)}function Gn(e,t,n){let r=[];for(let e of[`data-testid`,`data-test-id`,`data-test`])e!==n.testIdAttributeName&&t.getAttribute(e)&&r.push({engine:`css`,selector:`[${e}=${u(t.getAttribute(e))}]`,score:yn});if(!n.noCSSId){let e=t.getAttribute(`id`);e&&!Qn(e)&&r.push({engine:`css`,selector:qn(e),score:In})}if(r.push({engine:`css`,selector:l(t.nodeName.toLowerCase()),score:zn}),t.nodeName===`IFRAME`){for(let e of[`name`,`title`])t.getAttribute(e)&&r.push({engine:`css`,selector:`${l(t.nodeName.toLowerCase())}[${e}=${u(t.getAttribute(e))}]`,score:bn});return t.getAttribute(n.testIdAttributeName)&&r.push({engine:`css`,selector:`[${n.testIdAttributeName}=${u(t.getAttribute(n.testIdAttributeName))}]`,score:vn}),Yn([r]),r}if(t.getAttribute(n.testIdAttributeName)&&r.push({engine:`internal:testid`,selector:`[${n.testIdAttributeName}=${g(t.getAttribute(n.testIdAttributeName),!0)}]`,score:vn}),t.nodeName===`INPUT`||t.nodeName===`TEXTAREA`){let e=t;if(e.placeholder){r.push({engine:`internal:attr`,selector:`[placeholder=${g(e.placeholder,!0)}]`,score:kn});for(let t of q(e.placeholder))r.push({engine:`internal:attr`,selector:`[placeholder=${g(t.text,!1)}]`,score:Sn-t.scoreBouns})}}let i=on(e._evaluator._cacheText,t);for(let e of i){let t=e.normalized;r.push({engine:`internal:label`,selector:h(t,!0),score:An});for(let e of q(t))r.push({engine:`internal:label`,selector:h(e.text,!1),score:Cn-e.scoreBouns})}let a=N(t);return a&&![`none`,`presentation`].includes(a)&&r.push({engine:`internal:role`,selector:a,score:Ln}),t.getAttribute(`name`)&&[`BUTTON`,`FORM`,`FIELDSET`,`FRAME`,`IFRAME`,`INPUT`,`KEYGEN`,`OBJECT`,`OUTPUT`,`SELECT`,`TEXTAREA`,`MAP`,`META`,`PARAM`].includes(t.nodeName)&&r.push({engine:`css`,selector:`${l(t.nodeName.toLowerCase())}[name=${u(t.getAttribute(`name`))}]`,score:Rn}),[`INPUT`,`TEXTAREA`].includes(t.nodeName)&&t.getAttribute(`type`)!==`hidden`&&t.getAttribute(`type`)&&r.push({engine:`css`,selector:`${l(t.nodeName.toLowerCase())}[type=${u(t.getAttribute(`type`))}]`,score:Rn}),[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.nodeName)&&t.getAttribute(`type`)!==`hidden`&&r.push({engine:`css`,selector:l(t.nodeName.toLowerCase()),score:Rn+1}),Yn([r]),r}function Kn(e,t,n){if(t.nodeName===`SELECT`)return[];let r=[],i=t.getAttribute(`title`);if(i){r.push([{engine:`internal:attr`,selector:`[title=${g(i,!0)}]`,score:Pn}]);for(let e of q(i))r.push([{engine:`internal:attr`,selector:`[title=${g(e.text,!1)}]`,score:Dn-e.scoreBouns}])}let a=t.getAttribute(`alt`);if(a&&[`APPLET`,`AREA`,`IMG`,`INPUT`].includes(t.nodeName)){r.push([{engine:`internal:attr`,selector:`[alt=${g(a,!0)}]`,score:Mn}]);for(let e of q(a))r.push([{engine:`internal:attr`,selector:`[alt=${g(e.text,!1)}]`,score:Tn-e.scoreBouns}])}let o=R(e._evaluator._cacheText,t).normalized;if(o){let e=q(o);if(n){o.length<=80&&r.push([{engine:`internal:text`,selector:h(o,!0),score:Nn}]);for(let t of e)r.push([{engine:`internal:text`,selector:h(t.text,!1),score:En-t.scoreBouns}])}let i={engine:`css`,selector:l(t.nodeName.toLowerCase()),score:zn};for(let t of e)r.push([i,{engine:`internal:has-text`,selector:h(t.text,!1),score:En-t.scoreBouns}]);if(o.length<=80){let e=RegExp(`^${y(o)}$`);r.push([i,{engine:`internal:has-text`,selector:h(e,!1),score:On}])}}let s=N(t);if(s&&![`none`,`presentation`].includes(s)){let e=St(t,!1);if(e){r.push([{engine:`internal:role`,selector:`${s}[name=${g(e,!0)}]`,score:jn}]);for(let t of q(e))r.push([{engine:`internal:role`,selector:`${s}[name=${g(t.text,!1)}]`,score:wn-t.scoreBouns}])}}return Yn(r),r}function qn(e){return/^[a-z][\w\-]+$/i.test(e)?`#${e}`:`[id="${l(e)}"]`}function Jn(e,t,n){let r=t.ownerDocument,i=[];function a(n){let a=i.slice();n&&a.unshift(n);let o=a.join(` > `),s=e.parseSelector(o);return e.querySelector(s,r,!1)===t?o:void 0}function o(n){let i={engine:`css`,selector:n,score:Vn},a=e.parseSelector(n),o=e.querySelectorAll(a,r);return o.length===1?[i]:[i,{engine:`nth`,selector:String(o.indexOf(t)),score:Bn}]}for(let e=t;e&&e!==r;e=Y(e)){let t=e.nodeName.toLowerCase(),r=``;if(e.id&&!n.noCSSId){let t=qn(e.id),n=a(t);if(n)return o(n);r=t}let s=e.parentNode,c=[...e.classList];for(let e=0;e<c.length;++e){let t=`.${l(c.slice(0,e+1).join(`.`))}`,n=a(t);if(n)return o(n);!r&&s&&s.querySelectorAll(t).length===1&&(r=t)}if(s){let n=[...s.children],i=n.filter(e=>e.nodeName.toLowerCase()===t).indexOf(e)===0?l(t):`${l(t)}:nth-child(${1+n.indexOf(e)})`,c=a(i);if(c)return o(c);r||=i}else r||=l(t);i.unshift(r)}return o(a())}function Yn(e){for(let t of e)for(let e of t)e.score>xn&&e.score<Fn&&(e.score+=Math.min(_n,e.selector.length/10|0))}function Xn(e){let t=[],n=``;for(let{engine:r,selector:i}of e)t.length&&(n!==`css`||r!==`css`||i.startsWith(`:nth-match(`))&&t.push(`>>`),n=r,r===`css`?t.push(i):t.push(`${r}=${i}`);return t.join(` `)}function K(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].score*(e.length-n);return t}function Zn(e,t,n,r,i){let a=r.map(e=>({tokens:e,score:K(e)}));a.sort((e,t)=>e.score-t.score);let o=null;for(let{tokens:r}of a){let a=e.parseSelector(Xn(r)),s=e.querySelectorAll(a,t);if(s[0]===n&&s.length===1)return r;let c=s.indexOf(n);if(!i||o||c===-1||s.length>5)continue;let l={engine:`nth`,selector:String(c),score:Bn};o=[...r,l]}return o}function Qn(e){let t,n=0;for(let r=0;r<e.length;++r){let i=e[r],a;if(!(i===`-`||i===`_`)){if(a=i>=`a`&&i<=`z`?`lower`:i>=`A`&&i<=`Z`?`upper`:i>=`0`&&i<=`9`?`digit`:`other`,a===`lower`&&t===`upper`){t=a;continue}t&&t!==a&&++n,t=a}}return n>=e.length/4}function $n(e,t){if(e.length<=t)return e;e=e.substring(0,t);let n=e.match(/^(.*)\b(.+)$/);return n?n[1].trimEnd():``}function q(e){let t=[];{let n=e.match(/^([\d.,]+)[^.,\w]/),r=n?n[1].length:0;if(r){let n=$n(e.substring(r).trimStart(),80);t.push({text:n,scoreBouns:n.length<=30?2:1})}}{let n=e.match(/[^.,\w]([\d.,]+)$/),r=n?n[1].length:0;if(r){let n=$n(e.substring(0,e.length-r).trimEnd(),80);t.push({text:n,scoreBouns:n.length<=30?2:1})}}return e.length<=30?t.push({text:e,scoreBouns:0}):(t.push({text:$n(e,80),scoreBouns:0}),t.push({text:$n(e,30),scoreBouns:1})),t=t.filter(e=>e.text),t.length||t.push({text:e.substring(0,80),scoreBouns:0}),t}function er(e,t,n){let r=e.left-t.right;if(!(r<0||n!==void 0&&r>n))return r+Math.max(t.bottom-e.bottom,0)+Math.max(e.top-t.top,0)}function tr(e,t,n){let r=t.left-e.right;if(!(r<0||n!==void 0&&r>n))return r+Math.max(t.bottom-e.bottom,0)+Math.max(e.top-t.top,0)}function nr(e,t,n){let r=t.top-e.bottom;if(!(r<0||n!==void 0&&r>n))return r+Math.max(e.left-t.left,0)+Math.max(t.right-e.right,0)}function rr(e,t,n){let r=e.top-t.bottom;if(!(r<0||n!==void 0&&r>n))return r+Math.max(e.left-t.left,0)+Math.max(t.right-e.right,0)}function ir(e,t,n){let r=n===void 0?50:n,i=0;return e.left-t.right>=0&&(i+=e.left-t.right),t.left-e.right>=0&&(i+=t.left-e.right),t.top-e.bottom>=0&&(i+=t.top-e.bottom),e.top-t.bottom>=0&&(i+=e.top-t.bottom),i>r?void 0:i}var ar=[`left-of`,`right-of`,`above`,`below`,`near`];function or(e,t,n,r){let i=t.getBoundingClientRect(),a={"left-of":tr,"right-of":er,above:nr,below:rr,near:ir}[e],o;for(let e of n){if(e===t)continue;let n=a(i,e.getBoundingClientRect(),r);n!==void 0&&(o===void 0||n<o)&&(o=n)}return o}var sr=class{constructor(e){s(this,`_engines`,new Map),s(this,`_cacheQueryCSS`,new Map),s(this,`_cacheMatches`,new Map),s(this,`_cacheQuery`,new Map),s(this,`_cacheMatchesSimple`,new Map),s(this,`_cacheMatchesParents`,new Map),s(this,`_cacheCallMatches`,new Map),s(this,`_cacheCallQuery`,new Map),s(this,`_cacheQuerySimple`,new Map),s(this,`_cacheText`,new Map),s(this,`_scoreMap`),s(this,`_retainCacheCounter`,0);for(let[t,n]of e)this._engines.set(t,n);this._engines.set(`not`,ur),this._engines.set(`is`,J),this._engines.set(`where`,J),this._engines.set(`has`,cr),this._engines.set(`scope`,lr),this._engines.set(`light`,dr),this._engines.set(`visible`,fr),this._engines.set(`text`,pr),this._engines.set(`text-is`,mr),this._engines.set(`text-matches`,hr),this._engines.set(`has-text`,gr),this._engines.set(`right-of`,_r(`right-of`)),this._engines.set(`left-of`,_r(`left-of`)),this._engines.set(`above`,_r(`above`)),this._engines.set(`below`,_r(`below`)),this._engines.set(`near`,_r(`near`)),this._engines.set(`nth-match`,vr);let t=[...this._engines.keys()];t.sort();let n=[...qe];if(n.sort(),t.join(`|`)!==n.join(`|`))throw Error(`Please keep customCSSNames in sync with evaluator engines: ${t.join(`|`)} vs ${n.join(`|`)}`)}begin(){++this._retainCacheCounter}end(){--this._retainCacheCounter,this._retainCacheCounter||(this._cacheQueryCSS.clear(),this._cacheMatches.clear(),this._cacheQuery.clear(),this._cacheMatchesSimple.clear(),this._cacheMatchesParents.clear(),this._cacheCallMatches.clear(),this._cacheCallQuery.clear(),this._cacheQuerySimple.clear(),this._cacheText.clear())}_cached(e,t,n,r){e.has(t)||e.set(t,[]);let i=e.get(t),a=i.find(e=>n.every((t,n)=>e.rest[n]===t));if(a)return a.result;let o=r();return i.push({rest:n,result:o}),o}_checkSelector(e){if(!(typeof e==`object`&&e&&(Array.isArray(e)||`simples`in e&&e.simples.length)))throw Error(`Malformed selector "${e}"`);return e}matches(e,t,n){let r=this._checkSelector(t);this.begin();try{return this._cached(this._cacheMatches,e,[r,n.scope,n.pierceShadow,n.originalScope],()=>Array.isArray(r)?this._matchesEngine(J,e,r,n):(this._hasScopeClause(r)&&(n=this._expandContextForScopeMatching(n)),this._matchesSimple(e,r.simples[r.simples.length-1].selector,n)?this._matchesParents(e,r,r.simples.length-2,n):!1))}finally{this.end()}}query(e,t){let n=this._checkSelector(t);this.begin();try{return this._cached(this._cacheQuery,n,[e.scope,e.pierceShadow,e.originalScope],()=>{if(Array.isArray(n))return this._queryEngine(J,e,n);this._hasScopeClause(n)&&(e=this._expandContextForScopeMatching(e));let t=this._scoreMap;this._scoreMap=new Map;let r=this._querySimple(e,n.simples[n.simples.length-1].selector);return r=r.filter(t=>this._matchesParents(t,n,n.simples.length-2,e)),this._scoreMap.size&&r.sort((e,t)=>{let n=this._scoreMap.get(e),r=this._scoreMap.get(t);return n===r?0:n===void 0?1:r===void 0?-1:n-r}),this._scoreMap=t,r})}finally{this.end()}}_markScore(e,t){this._scoreMap&&this._scoreMap.set(e,t)}_hasScopeClause(e){return e.simples.some(e=>e.selector.functions.some(e=>e.name===`scope`))}_expandContextForScopeMatching(e){if(e.scope.nodeType!==1)return e;let t=Y(e.scope);return t?{...e,scope:t,originalScope:e.originalScope||e.scope}:e}_matchesSimple(e,t,n){return this._cached(this._cacheMatchesSimple,e,[t,n.scope,n.pierceShadow,n.originalScope],()=>{if(e===n.scope||t.css&&!this._matchesCSS(e,t.css))return!1;for(let r of t.functions)if(!this._matchesEngine(this._getEngine(r.name),e,r.args,n))return!1;return!0})}_querySimple(e,t){return t.functions.length?this._cached(this._cacheQuerySimple,t,[e.scope,e.pierceShadow,e.originalScope],()=>{let n=t.css,r=t.functions;n===`*`&&r.length&&(n=void 0);let i,a=-1;n===void 0?(a=r.findIndex(e=>this._getEngine(e.name).query!==void 0),a===-1&&(a=0),i=this._queryEngine(this._getEngine(r[a].name),e,r[a].args)):i=this._queryCSS(e,n);for(let t=0;t<r.length;t++){if(t===a)continue;let n=this._getEngine(r[t].name);n.matches!==void 0&&(i=i.filter(i=>this._matchesEngine(n,i,r[t].args,e)))}for(let t=0;t<r.length;t++){if(t===a)continue;let n=this._getEngine(r[t].name);n.matches===void 0&&(i=i.filter(i=>this._matchesEngine(n,i,r[t].args,e)))}return i}):this._queryCSS(e,t.css||`*`)}_matchesParents(e,t,n,r){return n<0?!0:this._cached(this._cacheMatchesParents,e,[t,n,r.scope,r.pierceShadow,r.originalScope],()=>{let{selector:i,combinator:a}=t.simples[n];if(a===`>`){let a=yr(e,r);return!a||!this._matchesSimple(a,i,r)?!1:this._matchesParents(a,t,n-1,r)}if(a===`+`){let a=br(e,r);return!a||!this._matchesSimple(a,i,r)?!1:this._matchesParents(a,t,n-1,r)}if(a===``){let a=yr(e,r);for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===``)break}a=yr(a,r)}return!1}if(a===`~`){let a=br(e,r);for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===`~`)break}a=br(a,r)}return!1}if(a===`>=`){let a=e;for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===``)break}a=yr(a,r)}return!1}throw Error(`Unsupported combinator "${a}"`)})}_matchesEngine(e,t,n,r){if(e.matches)return this._callMatches(e,t,n,r);if(e.query)return this._callQuery(e,n,r).includes(t);throw Error(`Selector engine should implement "matches" or "query"`)}_queryEngine(e,t,n){if(e.query)return this._callQuery(e,n,t);if(e.matches)return this._queryCSS(t,`*`).filter(r=>this._callMatches(e,r,n,t));throw Error(`Selector engine should implement "matches" or "query"`)}_callMatches(e,t,n,r){return this._cached(this._cacheCallMatches,t,[e,r.scope,r.pierceShadow,r.originalScope,...n],()=>e.matches(t,n,r,this))}_callQuery(e,t,n){return this._cached(this._cacheCallQuery,e,[n.scope,n.pierceShadow,n.originalScope,...t],()=>e.query(n,t,this))}_matchesCSS(e,t){return e.matches(t)}_queryCSS(e,t){return this._cached(this._cacheQueryCSS,t,[e.scope,e.pierceShadow,e.originalScope],()=>{let n=[];function r(i){if(n=n.concat([...i.querySelectorAll(t)]),e.pierceShadow){i.shadowRoot&&r(i.shadowRoot);for(let e of i.querySelectorAll(`*`))e.shadowRoot&&r(e.shadowRoot)}}return r(e.scope),n})}_getEngine(e){let t=this._engines.get(e);if(!t)throw Error(`Unknown selector engine "${e}"`);return t}},J={matches(e,t,n,r){if(t.length===0)throw Error(`"is" engine expects non-empty selector list`);return t.some(t=>r.matches(e,t,n))},query(e,t,n){if(t.length===0)throw Error(`"is" engine expects non-empty selector list`);let r=[];for(let i of t)r=r.concat(n.query(e,i));return t.length===1?r:xr(r)}},cr={matches(e,t,n,r){if(t.length===0)throw Error(`"has" engine expects non-empty selector list`);return r.query({...n,scope:e},t).length>0}},lr={matches(e,t,n,r){if(t.length!==0)throw Error(`"scope" engine expects no arguments`);let i=n.originalScope||n.scope;return i.nodeType===9?e===i.documentElement:e===i},query(e,t,n){if(t.length!==0)throw Error(`"scope" engine expects no arguments`);let r=e.originalScope||e.scope;if(r.nodeType===9){let e=r.documentElement;return e?[e]:[]}return r.nodeType===1?[r]:[]}},ur={matches(e,t,n,r){if(t.length===0)throw Error(`"not" engine expects non-empty selector list`);return!r.matches(e,t,n)}},dr={query(e,t,n){return n.query({...e,pierceShadow:!1},t)},matches(e,t,n,r){return r.matches(e,t,{...n,pierceShadow:!1})}},fr={matches(e,t,n,r){if(t.length)throw Error(`"visible" engine expects no arguments`);return Hr(e)}},pr={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"text" engine expects a single string`);let i=f(t[0]).toLowerCase();return an(r._cacheText,e,e=>e.normalized.toLowerCase().includes(i))===`self`}},mr={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"text-is" engine expects a single string`);let i=f(t[0]);return an(r._cacheText,e,e=>!i&&!e.immediate.length?!0:e.immediate.some(e=>f(e)===i))!==`none`}},hr={matches(e,t,n,r){if(t.length===0||typeof t[0]!=`string`||t.length>2||t.length===2&&typeof t[1]!=`string`)throw Error(`"text-matches" engine expects a regexp body and optional regexp flags`);let i=new RegExp(t[0],t.length===2?t[1]:void 0);return an(r._cacheText,e,e=>i.test(e.full))===`self`}},gr={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"has-text" engine expects a single string`);if(rn(e))return!1;let i=f(t[0]).toLowerCase();return(e=>e.normalized.toLowerCase().includes(i))(R(r._cacheText,e))}};function _r(e){return{matches(t,n,r,i){let a=n.length&&typeof n[n.length-1]==`number`?n[n.length-1]:void 0,o=a===void 0?n:n.slice(0,n.length-1);if(n.length<1+(a===void 0?0:1))throw Error(`"${e}" engine expects a selector list and optional maximum distance in pixels`);let s=or(e,t,i.query(r,o),a);return s===void 0?!1:(i._markScore(t,s),!0)}}}var vr={query(e,t,n){let r=t[t.length-1];if(t.length<2)throw Error(`"nth-match" engine expects non-empty selector list and an index argument`);if(typeof r!=`number`||r<1)throw Error(`"nth-match" engine expects a one-based index as the last argument`);let i=J.query(e,t.slice(0,t.length-1),n);return r--,r<i.length?[i[r]]:[]}};function yr(e,t){if(e!==t.scope)return t.pierceShadow?Y(e):e.parentElement||void 0}function br(e,t){if(e!==t.scope)return e.previousElementSibling||void 0}function xr(e){let t=new Map,n=[],r=[];function i(e){let r=t.get(e);if(r)return r;let a=Y(e);return a?i(a).children.push(e):n.push(e),r={children:[],taken:!1},t.set(e,r),r}for(let t of e)i(t).taken=!0;function a(e){let n=t.get(e);if(n.taken&&r.push(e),n.children.length>1){let t=new Set(n.children);n.children=[];let r=e.firstElementChild;for(;r&&n.children.length<t.size;)t.has(r)&&n.children.push(r),r=r.nextElementSibling;for(r=e.shadowRoot?e.shadowRoot.firstElementChild:null;r&&n.children.length<t.size;)t.has(r)&&n.children.push(r),r=r.nextElementSibling}n.children.forEach(a)}return n.forEach(a),r}function Sr(e,t,n){return`internal:attr=[${e}=${g(t,n?.exact||!1)}]`}function Cr(e,t){return`internal:testid=[${e}=${g(t,!0)}]`}function wr(e,t){return`internal:label=${h(e,!!t?.exact)}`}function Tr(e,t){return Sr(`alt`,e,t)}function Er(e,t){return Sr(`title`,e,t)}function Dr(e,t){return Sr(`placeholder`,e,t)}function Or(e,t){return`internal:text=${h(e,!!t?.exact)}`}function kr(e,t={}){let n=[];return t.checked!==void 0&&n.push([`checked`,String(t.checked)]),t.disabled!==void 0&&n.push([`disabled`,String(t.disabled)]),t.selected!==void 0&&n.push([`selected`,String(t.selected)]),t.expanded!==void 0&&n.push([`expanded`,String(t.expanded)]),t.includeHidden!==void 0&&n.push([`include-hidden`,String(t.includeHidden)]),t.level!==void 0&&n.push([`level`,String(t.level)]),t.name!==void 0&&n.push([`name`,g(t.name,!!t.exact)]),t.pressed!==void 0&&n.push([`pressed`,String(t.pressed)]),`internal:role=${e}${n.map(([e,t])=>`[${e}=${t}]`).join(``)}`}var Ar=class e{constructor(){s(this,`_engines`),s(this,`_evaluator`),this._evaluator=new sr(new Map),this._engines=new Map,this._engines.set(`xpath`,Lr),this._engines.set(`xpath:light`,Lr),this._engines.set(`role`,un(!1)),this._engines.set(`text`,this._createTextEngine(!0,!1)),this._engines.set(`text:light`,this._createTextEngine(!1,!1)),this._engines.set(`id`,this._createAttributeEngine(`id`,!0)),this._engines.set(`id:light`,this._createAttributeEngine(`id`,!1)),this._engines.set(`data-testid`,this._createAttributeEngine(`data-testid`,!0)),this._engines.set(`data-testid:light`,this._createAttributeEngine(`data-testid`,!1)),this._engines.set(`data-test-id`,this._createAttributeEngine(`data-test-id`,!0)),this._engines.set(`data-test-id:light`,this._createAttributeEngine(`data-test-id`,!1)),this._engines.set(`data-test`,this._createAttributeEngine(`data-test`,!0)),this._engines.set(`data-test:light`,this._createAttributeEngine(`data-test`,!1)),this._engines.set(`css`,this._createCSSEngine()),this._engines.set(`nth`,{queryAll:()=>[]}),this._engines.set(`visible`,this._createVisibleEngine()),this._engines.set(`internal:control`,this._createControlEngine()),this._engines.set(`internal:has`,this._createHasEngine()),this._engines.set(`internal:has-not`,this._createHasNotEngine()),this._engines.set(`internal:and`,{queryAll:()=>[]}),this._engines.set(`internal:or`,{queryAll:()=>[]}),this._engines.set(`internal:chain`,this._createInternalChainEngine()),this._engines.set(`internal:label`,this._createInternalLabelEngine()),this._engines.set(`internal:text`,this._createTextEngine(!0,!0)),this._engines.set(`internal:has-text`,this._createInternalHasTextEngine()),this._engines.set(`internal:has-not-text`,this._createInternalHasNotTextEngine()),this._engines.set(`internal:attr`,this._createNamedAttributeEngine()),this._engines.set(`internal:testid`,this._createNamedAttributeEngine()),this._engines.set(`internal:role`,un(!0))}static create(t){return Object.assign(e.options,t),e.singleton||=new e}queryLocatorSelector(e,t=document.documentElement,n=!0){return this.querySelector(this.parseSelector(e),t,n)}queryLocatorSelectorAll(e,t=document.documentElement){return this.querySelectorAll(this.parseSelector(e),t)}querySelector(e,t,n=!0){let r=this.querySelectorAll(e,t);if(n&&r.length>1)throw this.strictModeViolationError(e,r);return r[0]||null}queryAllByRole(e,t,n=document.documentElement){let r=this.parseSelector(kr(e,t));return this.querySelectorAll(r,n)}queryAllByLabelText(e,t,n=document.documentElement){let r=this.parseSelector(wr(e,t));return this.querySelectorAll(r,n)}queryAllByTestId(t,n=document.documentElement){let r=this.parseSelector(Cr(e.options.testIdAttribute,t));return this.querySelectorAll(r,n)}queryAllByText(e,t,n=document.documentElement){let r=this.parseSelector(Or(e,t));return this.querySelectorAll(r,n)}queryAllByTitle(e,t,n=document.documentElement){let r=this.parseSelector(Er(e,t));return this.querySelectorAll(r,n)}queryAllByPlaceholder(e,t,n=document.documentElement){let r=this.parseSelector(Dr(e,t));return this.querySelectorAll(r,n)}queryAllByAltText(e,t,n=document.documentElement){let r=this.parseSelector(Tr(e,t));return this.querySelectorAll(r,n)}queryByRole(e,t,n=document.documentElement){let r=this.parseSelector(kr(e,t));return this.querySelector(r,n,!1)}queryByLabelText(e,t,n=document.documentElement){let r=this.parseSelector(wr(e,t));return this.querySelector(r,n,!1)}queryByTestId(t,n=document.documentElement){let r=this.parseSelector(Cr(e.options.testIdAttribute,t));return this.querySelector(r,n,!1)}queryByText(e,t,n=document.documentElement){let r=this.parseSelector(Or(e,t));return this.querySelector(r,n,!1)}queryByTitle(e,t,n=document.documentElement){let r=this.parseSelector(Er(e,t));return this.querySelector(r,n,!1)}queryByPlaceholder(e,t,n=document.documentElement){let r=this.parseSelector(Dr(e,t));return this.querySelector(r,n,!1)}queryByAltText(e,t,n=document.documentElement){let r=this.parseSelector(Tr(e,t));return this.querySelector(r,n,!1)}strictModeViolationError(e,t){let n=t.slice(0,10).map(e=>({preview:this.previewNode(e),selector:this.generateSelectorSimple(e)})),r=n.map((e,t)=>`
4
+ ${t+1}) ${e.preview} aka ${H(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
5
+ ...`),this.createStacklessError(`strict mode violation: ${H(`javascript`,j(e))} resolved to ${t.length} elements:${r.join(``)}
6
+ `)}generateSelectorSimple(t,n){return Hn(this,t,{...n,testIdAttributeName:e.options.testIdAttribute})}parseSelector(e){let t=Je(e);return Xe(t,t=>{if(!this._engines.has(t.name))throw this.createStacklessError(`Unknown engine "${t.name}" while parsing selector ${e}`)}),t}previewNode(e){if(e.nodeType===Node.TEXT_NODE)return Mr(`#text=${e.nodeValue||``}`);if(e.nodeType!==Node.ELEMENT_NODE)return Mr(`<${e.nodeName.toLowerCase()} />`);let t=e,n=[];for(let e=0;e<t.attributes.length;e++){let{name:r,value:i}=t.attributes[e];r!==`style`&&(!i&&Nr.has(r)?n.push(` ${r}`):n.push(` ${r}="${i}"`))}n.sort((e,t)=>e.length-t.length);let r=v(n.join(``),500);if(Pr.has(t.nodeName))return Mr(`<${t.nodeName.toLowerCase()}${r}/>`);let i=t.childNodes,a=!1;if(i.length<=5){a=!0;for(let e=0;e<i.length;e++)a&&=i[e].nodeType===Node.TEXT_NODE}let o=a?t.textContent||``:i.length?`…`:``;return Mr(`<${t.nodeName.toLowerCase()}${r}>${v(o,50)}</${t.nodeName.toLowerCase()}>`)}querySelectorAll(e,t){if(e.capture!==void 0){if(e.parts.some(e=>e.name===`nth`))throw this.createStacklessError(`Can't query n-th element in a request with the capture.`);let n={parts:e.parts.slice(0,e.capture+1)};if(e.capture<e.parts.length-1){let t={parts:e.parts.slice(e.capture+1)},r={name:`internal:has`,body:{parsed:t},source:j(t)};n.parts.push(r)}return this.querySelectorAll(n,t)}if(!t.querySelectorAll)throw this.createStacklessError(`Node is not queryable.`);if(e.capture!==void 0)throw this.createStacklessError(`Internal error: there should not be a capture in the selector.`);if(t.nodeType===11&&e.parts.length===1&&e.parts[0].name===`css`&&e.parts[0].source===`:scope`)return[t];this._evaluator.begin();try{let n=new Set([t]);for(let r of e.parts)if(r.name===`nth`)n=this._queryNth(n,r);else if(r.name===`internal:and`){let e=this.querySelectorAll(r.body.parsed,t);n=new Set(e.filter(e=>n.has(e)))}else if(r.name===`internal:or`){let e=this.querySelectorAll(r.body.parsed,t);n=new Set(xr(new Set([...n,...e])))}else if(ar.includes(r.name))n=this._queryLayoutSelector(n,r,t);else{let e=new Set;for(let t of n){let n=this._queryEngineAll(r,t);for(let t of n)e.add(t)}n=e}return[...n]}finally{this._evaluator.end()}}_queryEngineAll(e,t){let n=this._engines.get(e.name).queryAll(t,e.body);for(let e of n)if(!(`nodeName`in e))throw this.createStacklessError(`Expected a Node but got ${Object.prototype.toString.call(e)}`);return n}_queryNth(e,t){let n=[...e],r=+t.body;return r===-1&&(r=n.length-1),new Set(n.slice(r,r+1))}_queryLayoutSelector(e,t,n){let r=t.name,i=t.body,a=[],o=this.querySelectorAll(i.parsed,n);for(let t of e){let e=or(r,t,o,i.distance);e!==void 0&&a.push({element:t,score:e})}return a.sort((e,t)=>e.score-t.score),new Set(a.map(e=>e.element))}createStacklessError(t){if(e.options.browser===`firefox`){let e=Error(`Error: ${t}`);return e.stack=``,e}let n=Error(t);return delete n.stack,n}_createTextEngine(e,t){return{queryAll:(n,r)=>{let{matcher:i,kind:a}=Ir(r,t),o=[],s=null,c=e=>{if(a===`lax`&&s&&s.contains(e))return!1;let n=an(this._evaluator._cacheText,e,i);n===`none`&&(s=e),(n===`self`||n===`selfAndChildren`&&a===`strict`&&!t)&&o.push(e)};n.nodeType===Node.ELEMENT_NODE&&c(n);let l=this._evaluator._queryCSS({scope:n,pierceShadow:e},`*`);for(let e of l)c(e);return o}}}_createAttributeEngine(e,t){let n=t=>[{simples:[{selector:{css:`[${e}=${JSON.stringify(t)}]`,functions:[]},combinator:``}]}];return{queryAll:(e,r)=>this._evaluator.query({scope:e,pierceShadow:t},n(r))}}_createCSSEngine(){return{queryAll:(e,t)=>this._evaluator.query({scope:e,pierceShadow:!0},t)}}_createNamedAttributeEngine(){return{queryAll:(e,t)=>{let n=M(t);if(n.name||n.attributes.length!==1)throw Error(`Malformed attribute selector: ${t}`);let{name:r,value:i,caseSensitive:a}=n.attributes[0],o=a?null:i.toLowerCase(),s;return s=i instanceof RegExp?e=>!!e.match(i):a?e=>e===i:e=>e.toLowerCase().includes(o),this._evaluator._queryCSS({scope:e,pierceShadow:!0},`[${r}]`).filter(e=>s(e.getAttribute(r)))}}}_createVisibleEngine(){return{queryAll:(e,t)=>e.nodeType===1&&Hr(e)===!!t?[e]:[]}}_createControlEngine(){return{queryAll:(e,t)=>{if(t===`enter-frame`&&e instanceof HTMLIFrameElement){let t=e.contentDocument?.documentElement;return t?[t]:[]}return[]}}}_createHasEngine(){return{queryAll:(e,t)=>e.nodeType===1&&this.querySelector(t.parsed,e,!1)?[e]:[]}}_createHasNotEngine(){return{queryAll:(e,t)=>e.nodeType===1?this.querySelector(t.parsed,e,!1)?[]:[e]:[]}}_createInternalChainEngine(){return{queryAll:(e,t)=>this.querySelectorAll(t.parsed,e)}}_createInternalLabelEngine(){return{queryAll:(e,t)=>{let{matcher:n}=Ir(t,!0);return this._evaluator._queryCSS({scope:e,pierceShadow:!0},`*`).filter(e=>on(this._evaluator._cacheText,e).some(e=>n(e)))}}}_createInternalHasTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=R(this._evaluator._cacheText,n),{matcher:i}=Ir(t,!0);return i(r)?[n]:[]}}}_createInternalHasNotTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=R(this._evaluator._cacheText,n),{matcher:i}=Ir(t,!0);return i(r)?[]:[n]}}}};s(Ar,`options`,{testIdAttribute:`data-testid`,browser:`chromium`}),s(Ar,`singleton`,null);var jr=Ar;function Mr(e){return e.replace(/\n/g,`↵`).replace(/\t/g,`⇆`)}var Nr=new Set([`checked`,`selected`,`disabled`,`readonly`,`multiple`]),Pr=new Set([`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`MENUITEM`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`]);function Fr(e){if(e=e.substring(1,e.length-1),!e.includes(`\\`))return e;let t=[],n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length&&n++,t.push(e[n++]);return t.join(``)}function Ir(e,t){if(e[0]===`/`&&e.lastIndexOf(`/`)>0){let t=e.lastIndexOf(`/`),n=new RegExp(e.substring(1,t),e.substring(t+1));return{matcher:e=>n.test(e.full),kind:`regex`}}let n=t?JSON.parse.bind(JSON):Fr,r=!1;return e.length>1&&e[0]===`"`&&e[e.length-1]===`"`?(e=n(e),r=!0):t&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`i`?(e=n(e.substring(0,e.length-1)),r=!1):t&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`s`?(e=n(e.substring(0,e.length-1)),r=!0):e.length>1&&e[0]===`'`&&e[e.length-1]===`'`&&(e=n(e),r=!0),e=f(e),r?t?{kind:`strict`,matcher:t=>t.normalized===e}:{matcher:t=>!e&&!t.immediate.length?!0:t.immediate.some(t=>f(t)===e),kind:`strict`}:(e=e.toLowerCase(),{kind:`lax`,matcher:t=>t.normalized.toLowerCase().includes(e)})}var Lr={queryAll(e,t){t.startsWith(`/`)&&e.nodeType!==Node.DOCUMENT_NODE&&(t=`.${t}`);let n=[],r=e.ownerDocument||e;if(!r)return n;let i=r.evaluate(t,e,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE);for(let e=i.iterateNext();e;e=i.iterateNext())e.nodeType===Node.ELEMENT_NODE&&n.push(e);return n}};function Y(e){if(e.parentElement)return e.parentElement;if(e.parentNode&&e.parentNode.nodeType===11&&e.parentNode.host)return e.parentNode.host}function Rr(e){let t=e;for(;t.parentNode;)t=t.parentNode;if(t.nodeType===11||t.nodeType===9)return t}function zr(e){for(;e.parentElement;)e=e.parentElement;return Y(e)}function Br(e,t){for(;e;){let n=e.closest(t);if(n)return n;e=zr(e)}}function X(e,t){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,t):void 0}function Vr(e,t){if(t??=X(e),!t)return!0;if(Element.prototype.checkVisibility&&jr.options.browser!==`webkit`){if(!e.checkVisibility())return!1}else{let t=e.closest(`details,summary`);if(t!==e&&t?.nodeName===`DETAILS`&&!t.open)return!1}return t.visibility===`visible`}function Hr(e){let t=X(e);if(!t)return!0;if(t.display===`contents`){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType===1&&Hr(t)||t.nodeType===3&&Ur(t))return!0;return!1}if(!Vr(e,t))return!1;let n=e.getBoundingClientRect();return n.width>0&&n.height>0}function Ur(e){let t=e.ownerDocument.createRange();t.selectNode(e);let n=t.getBoundingClientRect();return n.width>0&&n.height>0}function Z(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function Wr(e){let t=Gr().current;if(!t||t.type!==`test`)return e();let n=!1,r=Error(`STACK_TRACE_ERROR`);t.onFinished??=[],t.onFinished.push(()=>{if(!n){let e=Error(`The call was not awaited. This method is asynchronous and must be awaited; otherwise, the call will not start to avoid unhandled rejections.`);throw e.stack=r.stack?.replace(r.message,e.message),e}});let i;return{then(t,a){return n=!0,(i||=e(r)).then(t,a)},catch(t){return n=!0,(i||=e(r)).catch(t)},finally(t){return n=!0,(i||=e(r)).finally(t)},[Symbol.toStringTag]:`Promise`}}function Q(){return window.__vitest_browser_runner__}function Gr(){let e=window.__vitest_worker__;if(!e)throw Error(`Worker state is not found. This is an issue with Vitest. Please, open an issue.`);return e}function Kr(e){if(!e||!(e instanceof Element))throw Error(`Expected DOM element to be an instance of Element, received ${typeof e}`);return Jr(e)}function qr(e){return e.split(``).map(e=>{let t=e.charCodeAt(0);return e===` `||e===`#`||e===`.`||e===`:`||e===`[`||e===`]`||e===`>`||e===`+`||e===`~`||e===`\\`?`\\${e}`:t>=65536?`\\${t.toString(16).toUpperCase().padStart(6,`0`)} `:t<32||t===127||t>=128?`\\${t.toString(16).toUpperCase().padStart(2,`0`)} `:e}).join(``)}function Jr(e){let t=[],n,r=!1;for(;n=Yr(e);){n.shadowRoot&&(r=!0);let i=e.tagName;if(e.id)t.push(`#${qr(e.id)}`);else if(!e.nextElementSibling&&!e.previousElementSibling)t.push(i.toLowerCase());else{let r=0,a=0,o=0;for(let t of n.children)r++,t.tagName===i&&a++,t===e&&(o=r);a>1?t.push(`${i.toLowerCase()}:nth-child(${o})`):t.push(i.toLowerCase())}e=n}return`${Q().provider===`webdriverio`&&r?`>>>`:``}${t.reverse().join(` > `)}`}function Yr(e){let t=e.parentNode;return t instanceof ShadowRoot?t.host:t}const Xr=globalThis.performance?globalThis.performance.now.bind(globalThis.performance):Date.now;function Zr(e){if(e&&e.timeout!=null||Gr().config.browser.providerOptions.actionTimeout!=null)return e;let t=Q().runner,n=t._currentTaskStartTime;if(!n)return e;let r=t._currentTaskTimeout;if(r===0||r==null||r===1/0)return e;e||={};let i=Xr(),a=n+r,o=Math.floor(a-i);return o<=0||(e.timeout=o-100),e}function Qr(){let e=window.parent.document.querySelector(`iframe[data-vitest]`)?.parentElement;if(!e)throw Error(`Cannot find Tester element. This is a bug in Vitest. Please, open a new issue with reproduction.`);let t=e.getAttribute(`data-scale`),n=Number(t);if(Number.isNaN(n))throw TypeError(`Cannot parse scale value from Tester element (${t}). This is a bug in Vitest. Please, open a new issue with reproduction.`);return n}function $r(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function ei(e,t){return typeof e==`string`?`${JSON.stringify(e)}i`:$r(e)}const ti=Q().provider,ni=Symbol.for(`$$vitest:locator-resolved`);async function ri(e,t){if(!e)throw Error(`Expected element or locator to be defined.`);if(e instanceof Element)return Kr(e);if(ai(e))return ti===`playwright`||ni in e?e.selector:Kr(await e.findElement(t));throw Error(`Expected element or locator to be an instance of Element or Locator.`)}const ii=Symbol.for(`$$vitest:locator`);function ai(e){return!!e&&typeof e==`object`&&ii in e}function oi(e){let t;if(e.delta)t=e.delta;else switch(e.direction){case`up`:t={y:-100};break;case`down`:t={y:100};break;case`left`:t={x:-100};break;case`right`:t={x:100};break}return{delta:t,times:e.times}}r._asLocator=H;const si=Date.now,ci=[0,20,50,100,100,500];function li(e){let{setTimeout:t}=i();return new Promise(n=>t(n,e))}const $=jr.create({browser:(e=>{switch(e){case`edge`:case`chrome`:return`chromium`;case`safari`:return`webkit`;default:return e}})(e.config.browser.name),testIdAttribute:e.config.browser.locators.testIdAttribute}),ui=Symbol.for(`$$vitest:locator`);class di{_parsedSelector;_container;_pwSelector;_errorSource;constructor(){Object.defineProperty(this,ui,{enumerable:!1,writable:!1,configurable:!1,value:ui})}click(e){return this.triggerCommand(`__vitest_click`,this.selector,e)}dblClick(e){return this.triggerCommand(`__vitest_dblClick`,this.selector,e)}tripleClick(e){return this.triggerCommand(`__vitest_tripleClick`,this.selector,e)}wheel(e){return Wr(async t=>{await Q().commands.triggerCommand(`__vitest_wheel`,[this.selector,oi(e)],t);let n=Q().config.browser.name;if(n===`chromium`||n===`chrome`)return new Promise(e=>{requestAnimationFrame(()=>{e()})})})}clear(e){return this.triggerCommand(`__vitest_clear`,this.selector,e)}hover(e){return this.triggerCommand(`__vitest_hover`,this.selector,e)}unhover(e){return this.triggerCommand(`__vitest_hover`,`html > body`,e)}fill(e,t){return this.triggerCommand(`__vitest_fill`,this.selector,e,t)}upload(e,t){return Wr(async n=>{let r=(Array.isArray(e)?e:[e]).map(async e=>{if(typeof e==`string`)return e;let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(Error(`Failed to read file: ${e.name}`)),r.readAsDataURL(e)});return{name:e.name,mimeType:e.type,base64:t.slice(t.indexOf(`,`)+1)}});return Q().commands.triggerCommand(`__vitest_upload`,[this.selector,await Promise.all(r),t],n)})}dropTo(e,t={}){return this.triggerCommand(`__vitest_dragAndDrop`,this.selector,e.selector,t)}selectOptions(e,t){let n=(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?e:{element:ai(e)?e.selector:$.generateSelectorSimple(e)});return this.triggerCommand(`__vitest_selectOptions`,this.selector,n,t)}screenshot(e){return t.screenshot({...e,element:this})}mark(e,t){let n=Gr().current;return!n||!Q().activeTraceTaskIds.has(n.id)?Promise.resolve():Wr(n=>Q().commands.triggerCommand(`__vitest_markTrace`,[{name:e,selector:this.selector,stack:t?.stack??n?.stack}],n))}getByRole(e,t){return this.locator(kr(e,t))}getByAltText(e,t){return this.locator(Tr(e,t))}getByLabelText(e,t){return this.locator(wr(e,t))}getByPlaceholder(e,t){return this.locator(Dr(e,t))}getByTestId(t){return this.locator(Cr(e.config.browser.locators.testIdAttribute,t))}getByText(e,t){return this.locator(Or(e,t))}getByTitle(e,t){return this.locator(Er(e,t))}filter(e){let t=[];if(e?.hasText&&t.push(`internal:has-text=${ei(e.hasText)}`),e?.hasNotText&&t.push(`internal:has-not-text=${ei(e.hasNotText)}`),e?.has){let n=e.has;t.push(`internal:has=${JSON.stringify(n._pwSelector||n.selector)}`)}if(e?.hasNot){let n=e.hasNot;t.push(`internal:has-not=${JSON.stringify(n._pwSelector||n.selector)}`)}if(!t.length)throw Error(`Locator.filter expects at least one filter. None provided.`);return this.locator(t.join(` >> `))}and(e){return this.locator(`internal:and=${JSON.stringify(e._pwSelector||e.selector)}`)}or(e){return this.locator(`internal:or=${JSON.stringify(e._pwSelector||e.selector)}`)}query(){let e=this._parsedSelector||=$.parseSelector(this._pwSelector||this.selector);return $.querySelector(e,document.documentElement,!0)}element(){let e=this.query();if(!e)throw n.getElementError(this._pwSelector||this.selector,this._container||document.body);return e}elements(){let e=this._parsedSelector||=$.parseSelector(this._pwSelector||this.selector);return $.querySelectorAll(e,document.documentElement)}get length(){return this.elements().length}all(){return this.elements().map(e=>this.elementLocator(e))}nth(e){return this.locator(`nth=${e}`)}first(){return this.nth(0)}last(){return this.nth(-1)}toString(){return this.selector}toJSON(){return this.selector}async findElement(e={}){let t=Zr(e),r=t?.timeout,i=t?.strict??!0,a=si(),o=0;for(;;){let e=this.elements();if(e.length===1)return e[0];if(e.length>1){if(i)throw pi(this._pwSelector||this.selector,e);return e[0]}let t=si()-a;if(r!=null&&t>=r)throw n.getElementError(this._pwSelector||this.selector,this._container||document.body);let s=ci[Math.min(o++,ci.length-1)];await li(r==null?s:Math.min(s,r-t))}}triggerCommand(e,...t){return this._errorSource?fi({name:e,arguments:t,errorSource:this._errorSource}):Wr(n=>fi({name:e,arguments:t,errorSource:n}))}}function fi(e){return Q().commands.triggerCommand(e.name,e.arguments,e.errorSource)}function pi(e,t){let n=t.slice(0,10).map(e=>({preview:$.previewNode(e),selector:$.generateSelectorSimple(e)})),r=n.map((e,t)=>`\n ${t+1}) ${e.preview} aka ${H(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
7
+ ...`),Error(`strict mode violation: ${H(`javascript`,e)} resolved to ${t.length} elements:${r.join(``)}\n`)}export{fi as A,di as L,N as a,Vt as b,en as c,Ct as d,tn as e,Dt as f,Mt as g,St as h,Hr as i,l as j,jt as k,ri as l,Q as m,Gr as n,Kr as o,Zr as p,Wr as q,Tr as r,wr as s,Dr as t,kr as u,Cr as v,Or as w,Er as x,Qr as y,$ as z};
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ManualMockedModule, RedirectedModule, AutomockedModule, AutospiedModule, MockerRegistry } from '@vitest/mocker';
2
2
  import { dynamicImportPlugin, ServerMockResolver, interceptorPlugin } from '@vitest/mocker/node';
3
3
  import c from 'tinyrainbow';
4
- import { isValidApiRequest, isFileServingAllowed, distDir, resolveApiServerConfig, resolveFsAllow, rolldownVersion, isFileLoadingAllowed, createDebugger, createViteLogger, createViteServer } from 'vitest/node';
4
+ import { isValidApiRequest, isFileServingAllowed, distDir, rolldownVersion, resolveApiServerConfig, resolveFsAllow, isFileLoadingAllowed, createDebugger, createViteLogger, createViteServer } from 'vitest/node';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import fs, { readFileSync, createReadStream, promises, existsSync } from 'node:fs';
7
7
  import { createRequire } from 'node:module';
@@ -18,7 +18,7 @@ import { PNG } from 'pngjs';
18
18
  import { diff } from '@blazediff/core';
19
19
  import { WebSocketServer } from 'ws';
20
20
 
21
- var version = "4.1.0-beta.6";
21
+ var version = "4.1.0";
22
22
 
23
23
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
24
24
  function normalizeWindowsPath(input = "") {
@@ -236,8 +236,7 @@ const Primitives = (_, value) => (
236
236
  typeof value === primitive ? new Primitive(value) : value
237
237
  );
238
238
 
239
- const revive = (input, parsed, output, $) => {
240
- const lazy = [];
239
+ const resolver = (input, lazy, parsed, $) => output => {
241
240
  for (let ke = keys(output), {length} = ke, y = 0; y < length; y++) {
242
241
  const k = ke[y];
243
242
  const value = output[k];
@@ -246,7 +245,7 @@ const revive = (input, parsed, output, $) => {
246
245
  if (typeof tmp === object && !parsed.has(tmp)) {
247
246
  parsed.add(tmp);
248
247
  output[k] = ignore;
249
- lazy.push({k, a: [input, parsed, tmp, $]});
248
+ lazy.push({ o: output, k, r: tmp });
250
249
  }
251
250
  else
252
251
  output[k] = $.call(output, k, tmp);
@@ -254,10 +253,6 @@ const revive = (input, parsed, output, $) => {
254
253
  else if (output[k] !== ignore)
255
254
  output[k] = $.call(output, k, value);
256
255
  }
257
- for (let {length} = lazy, i = 0; i < length; i++) {
258
- const {k, a} = lazy[i];
259
- output[k] = $.call(output, k, revive.apply(null, a));
260
- }
261
256
  return output;
262
257
  };
263
258
 
@@ -275,12 +270,24 @@ const set = (known, input, value) => {
275
270
  */
276
271
  const parse = (text, reviver) => {
277
272
  const input = $parse(text, Primitives).map(primitives);
278
- const value = input[0];
279
273
  const $ = reviver || noop;
280
- const tmp = typeof value === object && value ?
281
- revive(input, new Set, value, $) :
282
- value;
283
- return $.call({'': tmp}, '', tmp);
274
+
275
+ let value = input[0];
276
+
277
+ if (typeof value === object && value) {
278
+ const lazy = [];
279
+ const revive = resolver(input, lazy, new Set, $);
280
+ value = revive(value);
281
+
282
+ let i = 0;
283
+ while (i < lazy.length) {
284
+ // it could be a lazy.shift() but that's costly
285
+ const {o, k, r} = lazy[i++];
286
+ o[k] = $.call(o, k, revive(r));
287
+ }
288
+ }
289
+
290
+ return $.call({'': value}, '', value);
284
291
  };
285
292
 
286
293
  /**
@@ -1175,7 +1182,9 @@ var BrowserPlugin = (parentServer, base = "/") => {
1175
1182
  enforce: "post",
1176
1183
  async config(viteConfig) {
1177
1184
  // Enables using ignore hint for coverage providers with @preserve keyword
1178
- if (viteConfig.esbuild !== false) {
1185
+ // Only set esbuild options when not using rolldown-vite (Vite 8+),
1186
+ // which uses oxc for transformation instead of esbuild
1187
+ if (!rolldownVersion && viteConfig.esbuild !== false) {
1179
1188
  viteConfig.esbuild ||= {};
1180
1189
  viteConfig.esbuild.legalComments = "inline";
1181
1190
  }
package/dist/locators.js CHANGED
@@ -1 +1 @@
1
- export{L as Locator,o as convertElementToCssSelector,q as ensureAwaited,r as getByAltTextSelector,s as getByLabelSelector,t as getByPlaceholderSelector,u as getByRoleSelector,v as getByTestIdSelector,w as getByTextSelector,x as getByTitleSelector,y as getIframeScale,p as processTimeoutOptions,z as selectorEngine,A as triggerCommandWithTrace}from"./index-CDbEr3te.js";import"vitest/browser";import"vitest/internal/browser";
1
+ export{L as Locator,o as convertElementToCssSelector,q as ensureAwaited,r as getByAltTextSelector,s as getByLabelSelector,t as getByPlaceholderSelector,u as getByRoleSelector,v as getByTestIdSelector,w as getByTextSelector,x as getByTitleSelector,y as getIframeScale,p as processTimeoutOptions,z as selectorEngine,A as triggerCommandWithTrace}from"./index-5Pe7X7sp.js";import"vitest/browser";import"vitest/internal/browser";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser",
3
3
  "type": "module",
4
- "version": "4.1.0-beta.6",
4
+ "version": "4.1.0",
5
5
  "description": "Browser running for Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -57,7 +57,7 @@
57
57
  "providers"
58
58
  ],
59
59
  "peerDependencies": {
60
- "vitest": "4.1.0-beta.6"
60
+ "vitest": "4.1.0"
61
61
  },
62
62
  "dependencies": {
63
63
  "@blazediff/core": "1.9.1",
@@ -66,8 +66,8 @@
66
66
  "sirv": "^3.0.2",
67
67
  "tinyrainbow": "^3.0.3",
68
68
  "ws": "^8.19.0",
69
- "@vitest/utils": "4.1.0-beta.6",
70
- "@vitest/mocker": "4.1.0-beta.6"
69
+ "@vitest/mocker": "4.1.0",
70
+ "@vitest/utils": "4.1.0"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@opentelemetry/api": "^1.9.0",
@@ -75,12 +75,12 @@
75
75
  "@types/pngjs": "^6.0.5",
76
76
  "@types/ws": "^8.18.1",
77
77
  "birpc": "^4.0.0",
78
- "flatted": "3.3.4",
78
+ "flatted": "3.4.0",
79
79
  "ivya": "^1.7.1",
80
80
  "mime": "^4.1.0",
81
81
  "pathe": "^2.0.3",
82
- "vitest": "4.1.0-beta.6",
83
- "@vitest/runner": "4.1.0-beta.6"
82
+ "vitest": "4.1.0",
83
+ "@vitest/runner": "4.1.0"
84
84
  },
85
85
  "scripts": {
86
86
  "typecheck": "tsc -p ./src/client/tsconfig.json --noEmit",
@@ -1,7 +0,0 @@
1
- import{server,page,utils}from"vitest/browser";import{__INTERNAL,getSafeTimers}from"vitest/internal/browser";var __defProp=Object.defineProperty,__defNormalProp=(e,T,E)=>T in e?__defProp(e,T,{enumerable:!0,configurable:!0,writable:!0,value:E}):e[T]=E,__publicField=(e,T,E)=>__defNormalProp(e,typeof T==`symbol`?T:T+``,E);function escapeWithQuotes(e,T=`'`){let E=JSON.stringify(e),D=E.substring(1,E.length-1).replace(/\\"/g,`"`);if(T===`'`)return T+D.replace(/'/g,`\\'`)+T;if(T===`"`)return T+D.replace(/"/g,`\\"`)+T;if(T==="`")return T+D.replace(/`/g,"`")+T;throw Error(`Invalid escape char`)}function cssEscape(e){let T=``;for(let E=0;E<e.length;E++)T+=cssEscapeOne(e,E);return T}function quoteCSSAttributeValue(e){return`"${cssEscape(e).replace(/\\ /g,` `)}"`}function cssEscapeOne(e,T){let E=e.charCodeAt(T);return E===0?`�`:E>=1&&E<=31||E>=48&&E<=57&&(T===0||T===1&&e.charCodeAt(0)===45)?`\\${E.toString(16)} `:T===0&&E===45&&e.length===1?`\\${e.charAt(T)}`:E>=128||E===45||E===95||E>=48&&E<=57||E>=65&&E<=90||E>=97&&E<=122?e.charAt(T):`\\${e.charAt(T)}`}function normalizeWhiteSpace(e){return e.replace(/[\u200b\u00ad]/g,``).trim().replace(/\s+/g,` `)}function normalizeEscapedRegexQuotes(e){return e.replace(/(^|[^\\])(\\\\)*\\(['"`])/g,`$1$2$3`)}function escapeRegexForSelector$1(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function escapeForTextSelector$1(e,T){return typeof e==`string`?`${JSON.stringify(e)}${T?`s`:`i`}`:escapeRegexForSelector$1(e)}function escapeForAttributeSelector(e,T){return typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"${T?`s`:`i`}`:escapeRegexForSelector$1(e)}function trimString(e,T,E=``){if(e.length<=T)return e;let D=[...e];return D.length>T?D.slice(0,T-E.length).join(``)+E:D.join(``)}function trimStringWithEllipsis(e,T){return trimString(e,T,`…`)}function escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var between=function(e,T,E){return e>=T&&e<=E};function digit(e){return between(e,48,57)}function hexdigit(e){return digit(e)||between(e,65,70)||between(e,97,102)}function uppercaseletter(e){return between(e,65,90)}function lowercaseletter(e){return between(e,97,122)}function letter(e){return uppercaseletter(e)||lowercaseletter(e)}function nonascii(e){return e>=128}function namestartchar(e){return letter(e)||nonascii(e)||e===95}function namechar(e){return namestartchar(e)||digit(e)||e===45}function nonprintable(e){return between(e,0,8)||e===11||between(e,14,31)||e===127}function newline(e){return e===10}function whitespace(e){return newline(e)||e===9||e===32}var maximumallowedcodepoint=1114111,InvalidCharacterError=class extends Error{constructor(e){super(e),this.name=`InvalidCharacterError`}};function preprocess(e){let T=[];for(let E=0;E<e.length;E++){let D=e.charCodeAt(E);if(D===13&&e.charCodeAt(E+1)===10&&(D=10,E++),(D===13||D===12)&&(D=10),D===0&&(D=65533),between(D,55296,56319)&&between(e.charCodeAt(E+1),56320,57343)){let T=D-55296,O=e.charCodeAt(E+1)-56320;D=2**16+T*2**10+O,E++}T.push(D)}return T}function stringFromCode(e){if(e<=65535)return String.fromCharCode(e);e-=2**16;let T=Math.floor(e/2**10)+55296,E=e%2**10+56320;return String.fromCharCode(T)+String.fromCharCode(E)}function tokenize(e){let T=preprocess(e),E=-1,D=[],O,k=function(e){return e>=T.length?-1:T[e]},A=function(e){if(e===void 0&&(e=1),e>3)throw`Spec Error: no more than three codepoints of lookahead.`;return k(E+e)},j=function(e){return e===void 0&&(e=1),E+=e,O=k(E),!0},M=function(){return--E,!0},N=function(e){return e===void 0&&(e=O),e===-1},P=function(){if(F(),j(),whitespace(O)){for(;whitespace(A());)j();return new WhitespaceToken}else if(O===34)return R();else if(O===35)if(namechar(A())||V(A(1),A(2))){let e=new HashToken(``);return U(A(1),A(2),A(3))&&(e.type=`id`),e.value=Y(),e}else return new DelimToken(O);else if(O===36)return A()===61?(j(),new SuffixMatchToken):new DelimToken(O);else if(O===39)return R();else if(O===40)return new OpenParenToken;else if(O===41)return new CloseParenToken;else if(O===42)return A()===61?(j(),new SubstringMatchToken):new DelimToken(O);else if(O===43)return J()?(M(),I()):new DelimToken(O);else if(O===44)return new CommaToken;else if(O===45)return J()?(M(),I()):A(1)===45&&A(2)===62?(j(2),new CDCToken):W()?(M(),L()):new DelimToken(O);else if(O===46)return J()?(M(),I()):new DelimToken(O);else if(O===58)return new ColonToken;else if(O===59)return new SemicolonToken;else if(O===60)return A(1)===33&&A(2)===45&&A(3)===45?(j(3),new CDOToken):new DelimToken(O);else if(O===64)return U(A(1),A(2),A(3))?new AtKeywordToken(Y()):new DelimToken(O);else if(O===91)return new OpenSquareToken;else if(O===92)return H()?(M(),L()):new DelimToken(O);else if(O===93)return new CloseSquareToken;else if(O===94)return A()===61?(j(),new PrefixMatchToken):new DelimToken(O);else if(O===123)return new OpenCurlyToken;else if(O===124)return A()===61?(j(),new DashMatchToken):A()===124?(j(),new ColumnToken):new DelimToken(O);else if(O===125)return new CloseCurlyToken;else if(O===126)return A()===61?(j(),new IncludeMatchToken):new DelimToken(O);else if(digit(O))return M(),I();else if(namestartchar(O))return M(),L();else if(N())return new EOFToken;else return new DelimToken(O)},F=function(){for(;A(1)===47&&A(2)===42;)for(j(2);;)if(j(),O===42&&A()===47){j();break}else if(N())return},I=function(){let e=X();if(U(A(1),A(2),A(3))){let T=new DimensionToken;return T.value=e.value,T.repr=e.repr,T.type=e.type,T.unit=Y(),T}else if(A()===37){j();let T=new PercentageToken;return T.value=e.value,T.repr=e.repr,T}else{let T=new NumberToken;return T.value=e.value,T.repr=e.repr,T.type=e.type,T}},L=function(){let e=Y();if(e.toLowerCase()===`url`&&A()===40){for(j();whitespace(A(1))&&whitespace(A(2));)j();return A()===34||A()===39||whitespace(A())&&(A(2)===34||A(2)===39)?new FunctionToken(e):z()}else if(A()===40)return j(),new FunctionToken(e);else return new IdentToken(e)},R=function(e){e===void 0&&(e=O);let T=``;for(;j();){if(O===e||N())return new StringToken(T);if(newline(O))return M(),new BadStringToken;O===92?N(A())||(newline(A())?j():T+=stringFromCode(B())):T+=stringFromCode(O)}throw Error(`Internal error`)},z=function(){let e=new URLToken(``);for(;whitespace(A());)j();if(N(A()))return e;for(;j();){if(O===41||N())return e;if(whitespace(O)){for(;whitespace(A());)j();return A()===41||N(A())?(j(),e):(Q(),new BadURLToken)}else if(O===34||O===39||O===40||nonprintable(O))return Q(),new BadURLToken;else if(O===92)if(H())e.value+=stringFromCode(B());else return Q(),new BadURLToken;else e.value+=stringFromCode(O)}throw Error(`Internal error`)},B=function(){if(j(),hexdigit(O)){let e=[O];for(let T=0;T<5&&hexdigit(A());T++)j(),e.push(O);whitespace(A())&&j();let T=Number.parseInt(e.map(e=>String.fromCharCode(e)).join(``),16);return T>maximumallowedcodepoint&&(T=65533),T}else if(N())return 65533;else return O},V=function(e,T){return!(e!==92||newline(T))},H=function(){return V(O,A())},U=function(e,T,E){return e===45?namestartchar(T)||T===45||V(T,E):namestartchar(e)?!0:e===92?V(e,T):!1},W=function(){return U(O,A(1),A(2))},q=function(e,T,E){return e===43||e===45?!!(digit(T)||T===46&&digit(E)):e===46?!!digit(T):!!digit(e)},J=function(){return q(O,A(1),A(2))},Y=function(){let e=``;for(;j();)if(namechar(O))e+=stringFromCode(O);else if(H())e+=stringFromCode(B());else return M(),e;throw Error(`Internal parse error`)},X=function(){let e=``,T=`integer`;for((A()===43||A()===45)&&(j(),e+=stringFromCode(O));digit(A());)j(),e+=stringFromCode(O);if(A(1)===46&&digit(A(2)))for(j(),e+=stringFromCode(O),j(),e+=stringFromCode(O),T=`number`;digit(A());)j(),e+=stringFromCode(O);let E=A(1),D=A(2),k=A(3);if((E===69||E===101)&&digit(D))for(j(),e+=stringFromCode(O),j(),e+=stringFromCode(O),T=`number`;digit(A());)j(),e+=stringFromCode(O);else if((E===69||E===101)&&(D===43||D===45)&&digit(k))for(j(),e+=stringFromCode(O),j(),e+=stringFromCode(O),j(),e+=stringFromCode(O),T=`number`;digit(A());)j(),e+=stringFromCode(O);let M=Z(e);return{type:T,value:M,repr:e}},Z=function(e){return+e},Q=function(){for(;j();){if(O===41||N())return;H()&&B()}},$=0;for(;!N(A());)if(D.push(P()),$++,$>T.length*2)throw Error(`I'm infinite-looping!`);return D}var CSSParserToken=class{constructor(){__publicField(this,`tokenType`,``),__publicField(this,`value`)}toJSON(){return{token:this.tokenType}}toString(){return this.tokenType}toSource(){return`${this}`}},BadStringToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`BADSTRING`)}},BadURLToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`BADURL`)}},WhitespaceToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`WHITESPACE`)}toString(){return`WS`}toSource(){return` `}},CDOToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`CDO`)}toSource(){return`<!--`}},CDCToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`CDC`)}toSource(){return`-->`}},ColonToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`:`)}},SemicolonToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`;`)}},CommaToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`,`)}},GroupingToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`value`,``),__publicField(this,`mirror`,``)}},OpenCurlyToken=class extends GroupingToken{constructor(){super(),__publicField(this,`tokenType`,`{`),this.value=`{`,this.mirror=`}`}},CloseCurlyToken=class extends GroupingToken{constructor(){super(),__publicField(this,`tokenType`,`}`),this.value=`}`,this.mirror=`{`}},OpenSquareToken=class extends GroupingToken{constructor(){super(),__publicField(this,`tokenType`,`[`),this.value=`[`,this.mirror=`]`}},CloseSquareToken=class extends GroupingToken{constructor(){super(),__publicField(this,`tokenType`,`]`),this.value=`]`,this.mirror=`[`}},OpenParenToken=class extends GroupingToken{constructor(){super(),__publicField(this,`tokenType`,`(`),this.value=`(`,this.mirror=`)`}},CloseParenToken=class extends GroupingToken{constructor(){super(),__publicField(this,`tokenType`,`)`),this.value=`)`,this.mirror=`(`}},IncludeMatchToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`~=`)}},DashMatchToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`|=`)}},PrefixMatchToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`^=`)}},SuffixMatchToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`$=`)}},SubstringMatchToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`*=`)}},ColumnToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`||`)}},EOFToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`tokenType`,`EOF`)}toSource(){return``}},DelimToken=class extends CSSParserToken{constructor(e){super(),__publicField(this,`tokenType`,`DELIM`),__publicField(this,`value`,``),this.value=stringFromCode(e)}toString(){return`DELIM(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e}toSource(){return this.value===`\\`?`\\
2
- `:this.value}},StringValuedToken=class extends CSSParserToken{constructor(){super(...arguments),__publicField(this,`value`,``)}ASCIIMatch(e){return this.value.toLowerCase()===e.toLowerCase()}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e}},IdentToken=class extends StringValuedToken{constructor(e){super(),__publicField(this,`tokenType`,`IDENT`),this.value=e}toString(){return`IDENT(${this.value})`}toSource(){return escapeIdent(this.value)}},FunctionToken=class extends StringValuedToken{constructor(e){super(),__publicField(this,`tokenType`,`FUNCTION`),__publicField(this,`mirror`),this.value=e,this.mirror=`)`}toString(){return`FUNCTION(${this.value})`}toSource(){return`${escapeIdent(this.value)}(`}},AtKeywordToken=class extends StringValuedToken{constructor(e){super(),__publicField(this,`tokenType`,`AT-KEYWORD`),this.value=e}toString(){return`AT(${this.value})`}toSource(){return`@${escapeIdent(this.value)}`}},HashToken=class extends StringValuedToken{constructor(e){super(),__publicField(this,`tokenType`,`HASH`),__publicField(this,`type`),this.value=e,this.type=`unrestricted`}toString(){return`HASH(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.type=this.type,e}toSource(){return this.type===`id`?`#${escapeIdent(this.value)}`:`#${escapeHash(this.value)}`}},StringToken=class extends StringValuedToken{constructor(e){super(),__publicField(this,`tokenType`,`STRING`),this.value=e}toString(){return`"${escapeString(this.value)}"`}},URLToken=class extends StringValuedToken{constructor(e){super(),__publicField(this,`tokenType`,`URL`),this.value=e}toString(){return`URL(${this.value})`}toSource(){return`url("${escapeString(this.value)}")`}},NumberToken=class extends CSSParserToken{constructor(){super(),__publicField(this,`tokenType`,`NUMBER`),__publicField(this,`type`),__publicField(this,`repr`),this.type=`integer`,this.repr=``}toString(){return this.type===`integer`?`INT(${this.value})`:`NUMBER(${this.value})`}toJSON(){let e=super.toJSON();return e.value=this.value,e.type=this.type,e.repr=this.repr,e}toSource(){return this.repr}},PercentageToken=class extends CSSParserToken{constructor(){super(),__publicField(this,`tokenType`,`PERCENTAGE`),__publicField(this,`repr`),this.repr=``}toString(){return`PERCENTAGE(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.repr=this.repr,e}toSource(){return`${this.repr}%`}},DimensionToken=class extends CSSParserToken{constructor(){super(),__publicField(this,`tokenType`,`DIMENSION`),__publicField(this,`type`),__publicField(this,`repr`),__publicField(this,`unit`),this.type=`integer`,this.repr=``,this.unit=``}toString(){return`DIM(${this.value},${this.unit})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.type=this.type,e.repr=this.repr,e.unit=this.unit,e}toSource(){let e=this.repr,T=escapeIdent(this.unit);return T[0].toLowerCase()===`e`&&(T[1]===`-`||between(T.charCodeAt(1),48,57))&&(T=`\\65 ${T.slice(1,T.length)}`),e+T}};function escapeIdent(e){e=`${e}`;let T=``,E=e.charCodeAt(0);for(let D=0;D<e.length;D++){let O=e.charCodeAt(D);if(O===0)throw new InvalidCharacterError(`Invalid character: the input contains U+0000.`);between(O,1,31)||O===127||D===0&&between(O,48,57)||D===1&&between(O,48,57)&&E===45?T+=`\\${O.toString(16)} `:O>=128||O===45||O===95||between(O,48,57)||between(O,65,90)||between(O,97,122)?T+=e[D]:T+=`\\${e[D]}`}return T}function escapeHash(e){e=`${e}`;let T=``;for(let E=0;E<e.length;E++){let D=e.charCodeAt(E);if(D===0)throw new InvalidCharacterError(`Invalid character: the input contains U+0000.`);D>=128||D===45||D===95||between(D,48,57)||between(D,65,90)||between(D,97,122)?T+=e[E]:T+=`\\${D.toString(16)} `}return T}function escapeString(e){e=`${e}`;let T=``;for(let E=0;E<e.length;E++){let D=e.charCodeAt(E);if(D===0)throw new InvalidCharacterError(`Invalid character: the input contains U+0000.`);between(D,1,31)||D===127?T+=`\\${D.toString(16)} `:D===34||D===92?T+=`\\${e[E]}`:T+=e[E]}return T}var InvalidSelectorError=class extends Error{};function parseCSS(e,T){let E;try{E=tokenize(e),E[E.length-1]instanceof EOFToken||E.push(new EOFToken)}catch(T){let E=`${T.message} while parsing selector "${e}"`,D=(T.stack||``).indexOf(T.message);throw D!==-1&&(T.stack=T.stack.substring(0,D)+E+T.stack.substring(D+T.message.length)),T.message=E,T}let D=E.find(e=>e instanceof AtKeywordToken||e instanceof BadStringToken||e instanceof BadURLToken||e instanceof ColumnToken||e instanceof CDOToken||e instanceof CDCToken||e instanceof SemicolonToken||e instanceof OpenCurlyToken||e instanceof CloseCurlyToken||e instanceof URLToken||e instanceof PercentageToken);if(D)throw new InvalidSelectorError(`Unsupported token "${D.toSource()}" while parsing selector "${e}"`);let O=0,k=new Set;function A(){return new InvalidSelectorError(`Unexpected token "${E[O].toSource()}" while parsing selector "${e}"`)}function j(){for(;E[O]instanceof WhitespaceToken;)O++}function M(e=O){return E[e]instanceof IdentToken}function N(e=O){return E[e]instanceof StringToken}function P(e=O){return E[e]instanceof NumberToken}function F(e=O){return E[e]instanceof CommaToken}function I(e=O){return E[e]instanceof OpenParenToken}function L(e=O){return E[e]instanceof CloseParenToken}function R(e=O){return E[e]instanceof FunctionToken}function z(e=O){return E[e]instanceof DelimToken&&E[e].value===`*`}function B(e=O){return E[e]instanceof EOFToken}function V(e=O){return E[e]instanceof DelimToken&&[`>`,`+`,`~`].includes(E[e].value)}function H(e=O){return F(e)||L(e)||B(e)||V(e)||E[e]instanceof WhitespaceToken}function U(){let e=[W()];for(;j(),F();)O++,e.push(W());return e}function W(){return j(),P()||N()?E[O++].value:G()}function G(){let e={simples:[]};for(j(),V()?e.simples.push({selector:{functions:[{name:`scope`,args:[]}]},combinator:``}):e.simples.push({selector:K(),combinator:``});;){if(j(),V())e.simples[e.simples.length-1].combinator=E[O++].value,j();else if(H())break;e.simples.push({combinator:``,selector:K()})}return e}function K(){let e=``,D=[];for(;!H();)if(M()||z())e+=E[O++].toSource();else if(E[O]instanceof HashToken)e+=E[O++].toSource();else if(E[O]instanceof DelimToken&&E[O].value===`.`)if(O++,M())e+=`.${E[O++].toSource()}`;else throw A();else if(E[O]instanceof ColonToken)if(O++,M())if(!T.has(E[O].value.toLowerCase()))e+=`:${E[O++].toSource()}`;else{let e=E[O++].value.toLowerCase();D.push({name:e,args:[]}),k.add(e)}else if(R()){let M=E[O++].value.toLowerCase();if(T.has(M)?(D.push({name:M,args:U()}),k.add(M)):e+=`:${M}(${q()})`,j(),!L())throw A();O++}else throw A();else if(E[O]instanceof OpenSquareToken){for(e+=`[`,O++;!(E[O]instanceof CloseSquareToken)&&!B();)e+=E[O++].toSource();if(!(E[O]instanceof CloseSquareToken))throw A();e+=`]`,O++}else throw A();if(!e&&!D.length)throw A();return{css:e||void 0,functions:D}}function q(){let e=``,T=1;for(;!B()&&((I()||R())&&T++,L()&&T--,T);)e+=E[O++].toSource();return e}let J=U();if(!B())throw A();if(J.some(e=>typeof e!=`object`||!(`simples`in e)))throw new InvalidSelectorError(`Error while parsing selector "${e}"`);return{selector:J,names:Array.from(k)}}var kNestedSelectorNames=new Set([`internal:has`,`internal:has-not`,`internal:and`,`internal:or`,`internal:chain`,`left-of`,`right-of`,`above`,`below`,`near`]),kNestedSelectorNamesWithDistance=new Set([`left-of`,`right-of`,`above`,`below`,`near`]),customCSSNames=new Set([`not`,`is`,`where`,`has`,`scope`,`light`,`visible`,`text`,`text-matches`,`text-is`,`has-text`,`above`,`below`,`right-of`,`left-of`,`near`,`nth-match`]);function parseSelector(e){let T=parseSelectorString(e),E=[];for(let e of T.parts){if(e.name===`css`||e.name===`css:light`){e.name===`css:light`&&(e.body=`:light(${e.body})`);let T=parseCSS(e.body,customCSSNames);E.push({name:`css`,body:T.selector,source:e.body});continue}if(kNestedSelectorNames.has(e.name)){let T,D;try{let E=JSON.parse(`[${e.body}]`);if(!Array.isArray(E)||E.length<1||E.length>2||typeof E[0]!=`string`)throw new InvalidSelectorError(`Malformed selector: ${e.name}=${e.body}`);if(T=E[0],E.length===2){if(typeof E[1]!=`number`||!kNestedSelectorNamesWithDistance.has(e.name))throw new InvalidSelectorError(`Malformed selector: ${e.name}=${e.body}`);D=E[1]}}catch{throw new InvalidSelectorError(`Malformed selector: ${e.name}=${e.body}`)}let O={name:e.name,source:e.body,body:{parsed:parseSelector(T),distance:D}},k=[...O.body.parsed.parts].reverse().find(e=>e.name===`internal:control`&&e.body===`enter-frame`),A=k?O.body.parsed.parts.indexOf(k):-1;A!==-1&&selectorPartsEqual(O.body.parsed.parts.slice(0,A+1),E.slice(0,A+1))&&O.body.parsed.parts.splice(0,A+1),E.push(O);continue}E.push({...e,source:e.body})}if(kNestedSelectorNames.has(E[0].name))throw new InvalidSelectorError(`"${E[0].name}" selector cannot be first`);return{capture:T.capture,parts:E}}function selectorPartsEqual(e,T){return stringifySelector({parts:e})===stringifySelector({parts:T})}function stringifySelector(e,T){return typeof e==`string`?e:e.parts.map((E,D)=>{let O=!0;!T&&D!==e.capture&&(E.name===`css`||E.name===`xpath`&&E.source.startsWith(`//`)||E.source.startsWith(`..`))&&(O=!1);let k=O?`${E.name}=`:``;return`${D===e.capture?`*`:``}${k}${E.source}`}).join(` >> `)}function visitAllSelectorParts(e,T){let E=(e,D)=>{for(let O of e.parts)T(O,D),kNestedSelectorNames.has(O.name)&&E(O.body.parsed,!0)};E(e,!1)}function parseSelectorString(e){let T=0,E,D=0,O={parts:[]},k=()=>{let E=e.substring(D,T).trim(),k=E.indexOf(`=`),A,j;k!==-1&&E.substring(0,k).trim().match(/^[\w\-+:*]+$/)?(A=E.substring(0,k).trim(),j=E.substring(k+1)):E.length>1&&E[0]===`"`&&E[E.length-1]===`"`||E.length>1&&E[0]===`'`&&E[E.length-1]===`'`?(A=`text`,j=E):/^\(*\/\//.test(E)||E.startsWith(`..`)?(A=`xpath`,j=E):(A=`css`,j=E);let M=!1;if(A[0]===`*`&&(M=!0,A=A.substring(1)),O.parts.push({name:A,body:j}),M){if(O.capture!==void 0)throw new InvalidSelectorError(`Only one of the selectors can capture using * modifier`);O.capture=O.parts.length-1}};if(!e.includes(`>>`))return T=e.length,k(),O;let A=()=>{let E=e.substring(D,T).match(/^\s*text\s*=(.*)$/);return!!E&&!!E[1]};for(;T<e.length;){let O=e[T];O===`\\`&&T+1<e.length?T+=2:O===E?(E=void 0,T++):!E&&(O===`"`||O===`'`||O==="`")&&!A()?(E=O,T++):!E&&O===`>`&&e[T+1]===`>`?(k(),T+=2,D=T):T++}return k(),O}function parseAttributeSelector(e,T){let E=0,D=e.length===0,O=()=>e[E]||``,k=()=>{let T=O();return++E,D=E>=e.length,T},A=T=>{throw D?new InvalidSelectorError(`Unexpected end of selector while parsing selector \`${e}\``):new InvalidSelectorError(`Error while parsing selector \`${e}\` - unexpected symbol "${O()}" at position ${E}${T?` during ${T}`:``}`)};function j(){for(;!D&&/\s/.test(O());)k()}function M(e){return e>=`€`||e>=`0`&&e<=`9`||e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e>=`0`&&e<=`9`||e===`_`||e===`-`}function N(){let e=``;for(j();!D&&M(O());)e+=k();return e}function P(e){let T=k();for(T!==e&&A(`parsing quoted string`);!D&&O()!==e;)O()===`\\`&&k(),T+=k();return O()!==e&&A(`parsing quoted string`),T+=k(),T}function F(){k()!==`/`&&A(`parsing regular expression`);let T=``,E=!1;for(;!D;){if(O()===`\\`)T+=k(),D&&A(`parsing regular expression`);else if(E&&O()===`]`)E=!1;else if(!E&&O()===`[`)E=!0;else if(!E&&O()===`/`)break;T+=k()}k()!==`/`&&A(`parsing regular expression`);let j=``;for(;!D&&O().match(/[dgimsuy]/);)j+=k();try{return new RegExp(T,j)}catch(T){throw new InvalidSelectorError(`Error while parsing selector \`${e}\`: ${T.message}`)}}function I(){let e=``;return j(),e=O()===`'`||O()===`"`?P(O()).slice(1,-1):N(),e||A(`parsing property path`),e}function L(){j();let e=``;return D||(e+=k()),!D&&e!==`=`&&(e+=k()),[`=`,`*=`,`^=`,`$=`,`|=`,`~=`].includes(e)||A(`parsing operator`),e}function R(){k();let T=[];for(T.push(I()),j();O()===`.`;)k(),T.push(I()),j();if(O()===`]`)return k(),{name:T.join(`.`),jsonPath:T,op:`<truthy>`,value:null,caseSensitive:!1};let E=L(),N,R=!0;if(j(),O()===`/`){if(E!==`=`)throw new InvalidSelectorError(`Error while parsing selector \`${e}\` - cannot use ${E} in attribute with regular expression`);N=F()}else if(O()===`'`||O()===`"`)N=P(O()).slice(1,-1),j(),O()===`i`||O()===`I`?(R=!1,k()):(O()===`s`||O()===`S`)&&(R=!0,k());else{for(N=``;!D&&(M(O())||O()===`+`||O()===`.`);)N+=k();N===`true`?N=!0:N===`false`&&(N=!1)}if(j(),O()!==`]`&&A(`parsing attribute value`),k(),E!==`=`&&typeof N!=`string`)throw new InvalidSelectorError(`Error while parsing selector \`${e}\` - cannot use ${E} in attribute with non-string matching value - ${N}`);return{name:T.join(`.`),jsonPath:T,op:E,value:N,caseSensitive:R}}let z={name:``,attributes:[]};for(z.name=N(),j();O()===`[`;)z.attributes.push(R()),j();if(D||A(void 0),!z.name&&!z.attributes.length)throw new InvalidSelectorError(`Error while parsing selector \`${e}\` - selector cannot be empty`);return z}function hasExplicitAccessibleName(e){return e.hasAttribute(`aria-label`)||e.hasAttribute(`aria-labelledby`)}var kAncestorPreventingLandmark=`article:not([role]), aside:not([role]), main:not([role]), nav:not([role]), section:not([role]), [role=article], [role=complementary], [role=main], [role=navigation], [role=region]`,kGlobalAriaAttributes=new Map([[`aria-atomic`,void 0],[`aria-busy`,void 0],[`aria-controls`,void 0],[`aria-current`,void 0],[`aria-describedby`,void 0],[`aria-details`,void 0],[`aria-dropeffect`,void 0],[`aria-flowto`,void 0],[`aria-grabbed`,void 0],[`aria-hidden`,void 0],[`aria-keyshortcuts`,void 0],[`aria-label`,new Set([`caption`,`code`,`deletion`,`emphasis`,`generic`,`insertion`,`paragraph`,`presentation`,`strong`,`subscript`,`superscript`])],[`aria-labelledby`,new Set([`caption`,`code`,`deletion`,`emphasis`,`generic`,`insertion`,`paragraph`,`presentation`,`strong`,`subscript`,`superscript`])],[`aria-live`,void 0],[`aria-owns`,void 0],[`aria-relevant`,void 0],[`aria-roledescription`,new Set([`generic`])]]);function hasGlobalAriaAttribute(e,T){return[...kGlobalAriaAttributes].some(([E,D])=>!D?.has(T||``)&&e.hasAttribute(E))}function hasTabIndex(e){return!Number.isNaN(Number(String(e.getAttribute(`tabindex`))))}function isFocusable(e){return!isNativelyDisabled(e)&&(isNativelyFocusable(e)||hasTabIndex(e))}function isNativelyFocusable(e){let T=elementSafeTagName(e);return[`BUTTON`,`DETAILS`,`SELECT`,`TEXTAREA`].includes(T)?!0:T===`A`||T===`AREA`?e.hasAttribute(`href`):T===`INPUT`?!e.hidden:!1}var kImplicitRoleByTagName={A:e=>e.hasAttribute(`href`)?`link`:null,AREA:e=>e.hasAttribute(`href`)?`link`:null,ARTICLE:()=>`article`,ASIDE:()=>`complementary`,BLOCKQUOTE:()=>`blockquote`,BUTTON:()=>`button`,CAPTION:()=>`caption`,CODE:()=>`code`,DATALIST:()=>`listbox`,DD:()=>`definition`,DEL:()=>`deletion`,DETAILS:()=>`group`,DFN:()=>`term`,DIALOG:()=>`dialog`,DT:()=>`term`,EM:()=>`emphasis`,FIELDSET:()=>`group`,FIGURE:()=>`figure`,FOOTER:e=>closestCrossShadow(e,kAncestorPreventingLandmark)?null:`contentinfo`,FORM:e=>hasExplicitAccessibleName(e)?`form`:null,H1:()=>`heading`,H2:()=>`heading`,H3:()=>`heading`,H4:()=>`heading`,H5:()=>`heading`,H6:()=>`heading`,HEADER:e=>closestCrossShadow(e,kAncestorPreventingLandmark)?null:`banner`,HR:()=>`separator`,HTML:()=>`document`,IMG:e=>e.getAttribute(`alt`)===``&&!e.getAttribute(`title`)&&!hasGlobalAriaAttribute(e)&&!hasTabIndex(e)?`presentation`:`img`,INPUT:e=>{let T=e.type.toLowerCase();if(T===`search`)return e.hasAttribute(`list`)?`combobox`:`searchbox`;if([`email`,`tel`,`text`,`url`,``].includes(T)){let T=getIdRefs(e,e.getAttribute(`list`))[0];return T&&elementSafeTagName(T)===`DATALIST`?`combobox`:`textbox`}return T===`hidden`?``:T===`file`?`button`:{button:`button`,checkbox:`checkbox`,image:`button`,number:`spinbutton`,radio:`radio`,range:`slider`,reset:`button`,submit:`button`}[T]||`textbox`},INS:()=>`insertion`,LI:()=>`listitem`,MAIN:()=>`main`,MARK:()=>`mark`,MATH:()=>`math`,MENU:()=>`list`,METER:()=>`meter`,NAV:()=>`navigation`,OL:()=>`list`,OPTGROUP:()=>`group`,OPTION:()=>`option`,OUTPUT:()=>`status`,P:()=>`paragraph`,PROGRESS:()=>`progressbar`,SECTION:e=>hasExplicitAccessibleName(e)?`region`:null,SELECT:e=>e.hasAttribute(`multiple`)||e.size>1?`listbox`:`combobox`,STRONG:()=>`strong`,SUB:()=>`subscript`,SUP:()=>`superscript`,SVG:()=>`img`,TABLE:()=>`table`,TBODY:()=>`rowgroup`,TD:e=>{let T=closestCrossShadow(e,`table`),E=T?getExplicitAriaRole(T):``;return E===`grid`||E===`treegrid`?`gridcell`:`cell`},TEXTAREA:()=>`textbox`,TFOOT:()=>`rowgroup`,TH:e=>{if(e.getAttribute(`scope`)===`col`)return`columnheader`;if(e.getAttribute(`scope`)===`row`)return`rowheader`;let T=closestCrossShadow(e,`table`),E=T?getExplicitAriaRole(T):``;return E===`grid`||E===`treegrid`?`gridcell`:`cell`},THEAD:()=>`rowgroup`,TIME:()=>`time`,TR:()=>`row`,UL:()=>`list`},kPresentationInheritanceParents={DD:[`DL`,`DIV`],DIV:[`DL`],DT:[`DL`,`DIV`],LI:[`OL`,`UL`],TBODY:[`TABLE`],TD:[`TR`],TFOOT:[`TABLE`],TH:[`TR`],THEAD:[`TABLE`],TR:[`THEAD`,`TBODY`,`TFOOT`,`TABLE`]};function getImplicitAriaRole(e){let T=kImplicitRoleByTagName[elementSafeTagName(e)]?.call(kImplicitRoleByTagName,e)||``;if(!T)return null;let E=e;for(;E;){let e=parentElementOrShadowHost(E),T=kPresentationInheritanceParents[elementSafeTagName(E)];if(!T||!e||!T.includes(elementSafeTagName(e)))break;let D=getExplicitAriaRole(e);if((D===`none`||D===`presentation`)&&!hasPresentationConflictResolution(e,D))return D;E=e}return T}var allRoles=`alert.alertdialog.application.article.banner.blockquote.button.caption.cell.checkbox.code.columnheader.combobox.command.complementary.composite.contentinfo.definition.deletion.dialog.directory.document.emphasis.feed.figure.form.generic.grid.gridcell.group.heading.img.input.insertion.landmark.link.list.listbox.listitem.log.main.marquee.math.meter.menu.menubar.menuitem.menuitemcheckbox.menuitemradio.navigation.none.note.option.paragraph.presentation.progressbar.radio.radiogroup.range.region.roletype.row.rowgroup.rowheader.scrollbar.search.searchbox.section.sectionhead.select.separator.slider.spinbutton.status.strong.structure.subscript.superscript.switch.tab.table.tablist.tabpanel.term.textbox.time.timer.toolbar.tooltip.tree.treegrid.treeitem.widget.window`.split(`.`),abstractRoles=[`command`,`composite`,`input`,`landmark`,`range`,`roletype`,`section`,`sectionhead`,`select`,`structure`,`widget`,`window`],validRoles=allRoles.filter(e=>!abstractRoles.includes(e));function getExplicitAriaRole(e){return(e.getAttribute(`role`)||``).split(` `).map(e=>e.trim()).find(e=>validRoles.includes(e))||null}function hasPresentationConflictResolution(e,T){return hasGlobalAriaAttribute(e,T)||isFocusable(e)}function getAriaRole(e){let T=getExplicitAriaRole(e);if(!T)return getImplicitAriaRole(e);if(T===`none`||T===`presentation`){let T=getImplicitAriaRole(e);if(hasPresentationConflictResolution(e,T))return T}return T}function getAriaBoolean(e){return e===null?void 0:e.toLowerCase()===`true`}function isElementIgnoredForAria(e){return[`STYLE`,`SCRIPT`,`NOSCRIPT`,`TEMPLATE`].includes(elementSafeTagName(e))}function isElementHiddenForAria(e){if(isElementIgnoredForAria(e))return!0;let T=getElementComputedStyle(e),E=e.nodeName===`SLOT`;if(T?.display===`contents`&&!E){for(let T=e.firstChild;T;T=T.nextSibling)if(T.nodeType===1&&!isElementHiddenForAria(T)||T.nodeType===3&&isVisibleTextNode(T))return!1;return!0}return!(e.nodeName===`OPTION`&&e.closest(`select`))&&!E&&!isElementStyleVisibilityVisible(e,T)?!0:belongsToDisplayNoneOrAriaHiddenOrNonSlotted(e)}function belongsToDisplayNoneOrAriaHiddenOrNonSlotted(e){let T=cacheIsHidden?.get(e);if(T===void 0){if(T=!1,e.parentElement&&e.parentElement.shadowRoot&&!e.assignedSlot&&(T=!0),!T){let E=getElementComputedStyle(e);T=!E||E.display===`none`||getAriaBoolean(e.getAttribute(`aria-hidden`))===!0}if(!T){let E=parentElementOrShadowHost(e);E&&(T=belongsToDisplayNoneOrAriaHiddenOrNonSlotted(E))}cacheIsHidden?.set(e,T)}return T}function getIdRefs(e,T){if(!T)return[];let E=enclosingShadowRootOrDocument(e);if(!E)return[];try{let e=T.split(` `).filter(e=>!!e),D=new Set;for(let T of e){let e=E.querySelector(`#${CSS.escape(T)}`);e&&D.add(e)}return[...D]}catch{return[]}}function trimFlatString(e){return e.trim()}function asFlatString(e){return e.split(`\xA0`).map(e=>e.replace(/\r\n/g,`
3
- `).replace(/[\u200b\u00ad]/g,``).replace(/\s\s*/g,` `)).join(`\xA0`).trim()}function queryInAriaOwned(e,T){let E=[...e.querySelectorAll(T)];for(let D of getIdRefs(e,e.getAttribute(`aria-owns`)))D.matches(T)&&E.push(D),E.push(...D.querySelectorAll(T));return E}function getPseudoContent(e,T){let E=T===`::before`?cachePseudoContentBefore:cachePseudoContentAfter;if(E?.has(e))return E?.get(e)||``;let D=getPseudoContentImpl(getElementComputedStyle(e,T));return E&&E.set(e,D),D}function getPseudoContentImpl(e){if(!e)return``;let T=e.content;if(T[0]===`'`&&T[T.length-1]===`'`||T[0]===`"`&&T[T.length-1]===`"`){let E=T.substring(1,T.length-1);return(e.display||`inline`)===`inline`?E:` ${E} `}return``}function getAriaLabelledByElements(e){let T=e.getAttribute(`aria-labelledby`);return T===null?null:getIdRefs(e,T)}function allowsNameFromContent(e,T){let E=[`button`,`cell`,`checkbox`,`columnheader`,`gridcell`,`heading`,`link`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`option`,`radio`,`row`,`rowheader`,`switch`,`tab`,`tooltip`,`treeitem`].includes(e),D=T&&[``,`caption`,`code`,`contentinfo`,`definition`,`deletion`,`emphasis`,`insertion`,`list`,`listitem`,`mark`,`none`,`paragraph`,`presentation`,`region`,`row`,`rowgroup`,`section`,`strong`,`subscript`,`superscript`,`table`,`term`,`time`].includes(e);return E||D}function getElementAccessibleName(e,T){let E=T?cacheAccessibleNameHidden:cacheAccessibleName,D=E?.get(e);return D===void 0&&(D=``,[`caption`,`code`,`definition`,`deletion`,`emphasis`,`generic`,`insertion`,`mark`,`paragraph`,`presentation`,`strong`,`subscript`,`suggestion`,`superscript`,`term`,`time`].includes(getAriaRole(e)||``)||(D=asFlatString(getTextAlternativeInternal(e,{includeHidden:T,visitedElements:new Set,embeddedInDescribedBy:void 0,embeddedInLabelledBy:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0,embeddedInTargetElement:`self`}))),E?.set(e,D)),D}function getElementAccessibleDescription(e,T){let E=cacheAccessibleDescription,D=E?.get(e);return D===void 0&&(D=``,D=e.hasAttribute(`aria-describedby`)?asFlatString(getIdRefs(e,e.getAttribute(`aria-describedby`)).map(e=>getTextAlternativeInternal(e,{includeHidden:T,visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:isElementHiddenForAria(e)}})).join(` `)):e.hasAttribute(`aria-description`)?asFlatString(e.getAttribute(`aria-description`)||``):asFlatString(e.getAttribute(`title`)||``),E?.set(e,D)),D}var kAriaInvalidRoles=[`application`,`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`slider`,`spinbutton`,`textbox`,`tree`,`columnheader`,`rowheader`,`searchbox`,`switch`,`treegrid`];function getAriaInvalid(e){let T=getAriaRole(e)||``;if(!T||!kAriaInvalidRoles.includes(T))return`false`;let E=e.getAttribute(`aria-invalid`);return!E||E.trim()===``||E.toLocaleLowerCase()===`false`?`false`:E===`true`||E===`grammar`||E===`spelling`?E:`true`}function getValidityInvalid(e){return`validity`in e?e.validity?.valid===!1:!1}function getElementAccessibleErrorMessage(e){let T=cacheAccessibleErrorMessage,E=cacheAccessibleErrorMessage?.get(e);if(E===void 0){E=``;let D=getAriaInvalid(e)!==`false`,O=getValidityInvalid(e);(D||O)&&(E=getIdRefs(e,e.getAttribute(`aria-errormessage`)).map(e=>asFlatString(getTextAlternativeInternal(e,{visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:isElementHiddenForAria(e)}}))).join(` `).trim()),T?.set(e,E)}return E}function getTextAlternativeInternal(e,T){if(T.visitedElements.has(e))return``;let E={...T,embeddedInTargetElement:T.embeddedInTargetElement===`self`?`descendant`:T.embeddedInTargetElement};if(!T.includeHidden){let E=!!T.embeddedInLabelledBy?.hidden||!!T.embeddedInDescribedBy?.hidden||!!T.embeddedInNativeTextAlternative?.hidden||!!T.embeddedInLabel?.hidden;if(isElementIgnoredForAria(e)||!E&&isElementHiddenForAria(e))return T.visitedElements.add(e),``}let D=getAriaLabelledByElements(e);if(!T.embeddedInLabelledBy){let e=(D||[]).map(e=>getTextAlternativeInternal(e,{...T,embeddedInLabelledBy:{element:e,hidden:isElementHiddenForAria(e)},embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0})).join(` `);if(e)return e}let O=getAriaRole(e)||``,k=elementSafeTagName(e);if(T.embeddedInLabel||T.embeddedInLabelledBy||T.embeddedInTargetElement===`descendant`){let A=[...e.labels||[]].includes(e),j=(D||[]).includes(e);if(!A&&!j){if(O===`textbox`)return T.visitedElements.add(e),k===`INPUT`||k===`TEXTAREA`?e.value:e.textContent||``;if([`combobox`,`listbox`].includes(O)){T.visitedElements.add(e);let D;if(k===`SELECT`)D=[...e.selectedOptions],!D.length&&e.options.length&&D.push(e.options[0]);else{let T=O===`combobox`?queryInAriaOwned(e,`*`).find(e=>getAriaRole(e)===`listbox`):e;D=T?queryInAriaOwned(T,`[aria-selected="true"]`).filter(e=>getAriaRole(e)===`option`):[]}return!D.length&&k===`INPUT`?e.value:D.map(e=>getTextAlternativeInternal(e,E)).join(` `)}if([`progressbar`,`scrollbar`,`slider`,`spinbutton`,`meter`].includes(O))return T.visitedElements.add(e),e.hasAttribute(`aria-valuetext`)?e.getAttribute(`aria-valuetext`)||``:e.hasAttribute(`aria-valuenow`)?e.getAttribute(`aria-valuenow`)||``:e.getAttribute(`value`)||``;if([`menu`].includes(O))return T.visitedElements.add(e),``}}let A=e.getAttribute(`aria-label`)||``;if(trimFlatString(A))return T.visitedElements.add(e),A;if(![`presentation`,`none`].includes(O)){if(k===`INPUT`&&[`button`,`submit`,`reset`].includes(e.type)){T.visitedElements.add(e);let E=e.value||``;return trimFlatString(E)?E:e.type===`submit`?`Submit`:e.type===`reset`?`Reset`:e.getAttribute(`title`)||``}if(k===`INPUT`&&e.type===`image`){T.visitedElements.add(e);let E=e.labels||[];if(E.length&&!T.embeddedInLabelledBy)return getAccessibleNameFromAssociatedLabels(E,T);let D=e.getAttribute(`alt`)||``;if(trimFlatString(D))return D;let O=e.getAttribute(`title`)||``;return trimFlatString(O)?O:`Submit`}if(!D&&k===`BUTTON`){T.visitedElements.add(e);let E=e.labels||[];if(E.length)return getAccessibleNameFromAssociatedLabels(E,T)}if(!D&&k===`OUTPUT`){T.visitedElements.add(e);let E=e.labels||[];return E.length?getAccessibleNameFromAssociatedLabels(E,T):e.getAttribute(`title`)||``}if(!D&&(k===`TEXTAREA`||k===`SELECT`||k===`INPUT`)){T.visitedElements.add(e);let E=e.labels||[];if(E.length)return getAccessibleNameFromAssociatedLabels(E,T);let D=k===`INPUT`&&[`text`,`password`,`search`,`tel`,`email`,`url`].includes(e.type)||k===`TEXTAREA`,O=e.getAttribute(`placeholder`)||``,A=e.getAttribute(`title`)||``;return!D||A?A:O}if(!D&&k===`FIELDSET`){T.visitedElements.add(e);for(let T=e.firstElementChild;T;T=T.nextElementSibling)if(elementSafeTagName(T)===`LEGEND`)return getTextAlternativeInternal(T,{...E,embeddedInNativeTextAlternative:{element:T,hidden:isElementHiddenForAria(T)}});return e.getAttribute(`title`)||``}if(!D&&k===`FIGURE`){T.visitedElements.add(e);for(let T=e.firstElementChild;T;T=T.nextElementSibling)if(elementSafeTagName(T)===`FIGCAPTION`)return getTextAlternativeInternal(T,{...E,embeddedInNativeTextAlternative:{element:T,hidden:isElementHiddenForAria(T)}});return e.getAttribute(`title`)||``}if(k===`IMG`){T.visitedElements.add(e);let E=e.getAttribute(`alt`)||``;return trimFlatString(E)?E:e.getAttribute(`title`)||``}if(k===`TABLE`){T.visitedElements.add(e);for(let T=e.firstElementChild;T;T=T.nextElementSibling)if(elementSafeTagName(T)===`CAPTION`)return getTextAlternativeInternal(T,{...E,embeddedInNativeTextAlternative:{element:T,hidden:isElementHiddenForAria(T)}});let D=e.getAttribute(`summary`)||``;if(D)return D}if(k===`AREA`){T.visitedElements.add(e);let E=e.getAttribute(`alt`)||``;return trimFlatString(E)?E:e.getAttribute(`title`)||``}if(k===`SVG`||e.ownerSVGElement){T.visitedElements.add(e);for(let T=e.firstElementChild;T;T=T.nextElementSibling)if(elementSafeTagName(T)===`TITLE`&&T.ownerSVGElement)return getTextAlternativeInternal(T,{...E,embeddedInLabelledBy:{element:T,hidden:isElementHiddenForAria(T)}})}if(e.ownerSVGElement&&k===`A`){let E=e.getAttribute(`xlink:title`)||``;if(trimFlatString(E))return T.visitedElements.add(e),E}}let j=k===`SUMMARY`&&![`presentation`,`none`].includes(O);if(allowsNameFromContent(O,T.embeddedInTargetElement===`descendant`)||j||T.embeddedInLabelledBy||T.embeddedInDescribedBy||T.embeddedInLabel||T.embeddedInNativeTextAlternative){T.visitedElements.add(e);let D=innerAccumulatedElementText(e,E);if(T.embeddedInTargetElement===`self`?trimFlatString(D):D)return D}if(![`presentation`,`none`].includes(O)||k===`IFRAME`){T.visitedElements.add(e);let E=e.getAttribute(`title`)||``;if(trimFlatString(E))return E}return T.visitedElements.add(e),``}function innerAccumulatedElementText(e,T){let E=[],D=(e,D)=>{if(!(D&&e.assignedSlot))if(e.nodeType===1){let D=getElementComputedStyle(e)?.display||`inline`,O=getTextAlternativeInternal(e,T);(D!==`inline`||e.nodeName===`BR`)&&(O=` `+O+` `),E.push(O)}else e.nodeType===3&&E.push(e.textContent||``)};E.push(getPseudoContent(e,`::before`));let O=e.nodeName===`SLOT`?e.assignedNodes():[];if(O.length)for(let e of O)D(e,!1);else{for(let T=e.firstChild;T;T=T.nextSibling)D(T,!0);if(e.shadowRoot)for(let T=e.shadowRoot.firstChild;T;T=T.nextSibling)D(T,!0);for(let T of getIdRefs(e,e.getAttribute(`aria-owns`)))D(T,!0)}return E.push(getPseudoContent(e,`::after`)),E.join(``)}var kAriaSelectedRoles=[`gridcell`,`option`,`row`,`tab`,`rowheader`,`columnheader`,`treeitem`];function getAriaSelected(e){return elementSafeTagName(e)===`OPTION`?e.selected:kAriaSelectedRoles.includes(getAriaRole(e)||``)?getAriaBoolean(e.getAttribute(`aria-selected`))===!0:!1}var kAriaCheckedRoles=[`checkbox`,`menuitemcheckbox`,`option`,`radio`,`switch`,`menuitemradio`,`treeitem`];function getAriaChecked(e){let T=getChecked(e);return T===`error`?!1:T}function getChecked(e,T){let E=elementSafeTagName(e);if(E===`INPUT`&&e.indeterminate)return`mixed`;if(E===`INPUT`&&[`checkbox`,`radio`].includes(e.type))return e.checked;if(kAriaCheckedRoles.includes(getAriaRole(e)||``)){let T=e.getAttribute(`aria-checked`);return T===`true`?!0:T===`mixed`?`mixed`:!1}return`error`}var kAriaPressedRoles=[`button`];function getAriaPressed(e){if(kAriaPressedRoles.includes(getAriaRole(e)||``)){let T=e.getAttribute(`aria-pressed`);if(T===`true`)return!0;if(T===`mixed`)return`mixed`}return!1}var kAriaExpandedRoles=[`application`,`button`,`checkbox`,`combobox`,`gridcell`,`link`,`listbox`,`menuitem`,`row`,`rowheader`,`tab`,`treeitem`,`columnheader`,`menuitemcheckbox`,`menuitemradio`,`rowheader`,`switch`];function getAriaExpanded(e){if(elementSafeTagName(e)===`DETAILS`)return e.open;if(kAriaExpandedRoles.includes(getAriaRole(e)||``)){let T=e.getAttribute(`aria-expanded`);return T===null?`none`:T===`true`}return`none`}var kAriaLevelRoles=[`heading`,`listitem`,`row`,`treeitem`];function getAriaLevel(e){let T={H1:1,H2:2,H3:3,H4:4,H5:5,H6:6}[elementSafeTagName(e)];if(T)return T;if(kAriaLevelRoles.includes(getAriaRole(e)||``)){let T=e.getAttribute(`aria-level`),E=T===null?NaN:Number(T);if(Number.isInteger(E)&&E>=1)return E}return 0}var kAriaDisabledRoles=`application.button.composite.gridcell.group.input.link.menuitem.scrollbar.separator.tab.checkbox.columnheader.combobox.grid.listbox.menu.menubar.menuitemcheckbox.menuitemradio.option.radio.radiogroup.row.rowheader.searchbox.select.slider.spinbutton.switch.tablist.textbox.toolbar.tree.treegrid.treeitem`.split(`.`);function getAriaDisabled(e){return isNativelyDisabled(e)||hasExplicitAriaDisabled(e)}function isNativelyDisabled(e){return[`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`OPTION`,`OPTGROUP`].includes(e.tagName)&&(e.hasAttribute(`disabled`)||belongsToDisabledFieldSet(e))}function belongsToDisabledFieldSet(e){let T=e?.closest(`FIELDSET[DISABLED]`);if(!T)return!1;let E=T.querySelector(`:scope > LEGEND`);return!E||!E.contains(e)}function hasExplicitAriaDisabled(e){if(!e)return!1;if(kAriaDisabledRoles.includes(getAriaRole(e)||``)){let T=(e.getAttribute(`aria-disabled`)||``).toLowerCase();if(T===`true`)return!0;if(T===`false`)return!1}return hasExplicitAriaDisabled(parentElementOrShadowHost(e))}function getAccessibleNameFromAssociatedLabels(e,T){return[...e].map(e=>getTextAlternativeInternal(e,{...T,embeddedInLabel:{element:e,hidden:isElementHiddenForAria(e)},embeddedInNativeTextAlternative:void 0,embeddedInLabelledBy:void 0,embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0})).filter(e=>!!e).join(` `)}var cacheAccessibleName,cacheAccessibleNameHidden,cacheAccessibleErrorMessage,cacheAccessibleDescription,cacheIsHidden,cachePseudoContentBefore,cachePseudoContentAfter,cachesCounter=0;function beginAriaCaches(){++cachesCounter,cacheAccessibleName??=new Map,cacheAccessibleNameHidden??=new Map,cacheAccessibleDescription??=new Map,cacheAccessibleErrorMessage??=new Map,cacheIsHidden??=new Map,cachePseudoContentBefore??=new Map,cachePseudoContentAfter??=new Map}function endAriaCaches(){--cachesCounter||(cacheAccessibleName=void 0,cacheAccessibleNameHidden=void 0,cacheAccessibleDescription=void 0,cacheAccessibleErrorMessage=void 0,cacheIsHidden=void 0,cachePseudoContentBefore=void 0,cachePseudoContentAfter=void 0)}function matchesAttributePart(e,T){let E=typeof e==`string`&&!T.caseSensitive?e.toUpperCase():e,D=typeof T.value==`string`&&!T.caseSensitive?T.value.toUpperCase():T.value;return T.op===`<truthy>`?!!E:T.op===`=`?D instanceof RegExp?typeof E==`string`&&!!E.match(D):E===D:typeof E!=`string`||typeof D!=`string`?!1:T.op===`*=`?E.includes(D):T.op===`^=`?E.startsWith(D):T.op===`$=`?E.endsWith(D):T.op===`|=`?E===D||E.startsWith(`${D}-`):T.op===`~=`?E.split(` `).includes(D):!1}function shouldSkipForTextMatching(e){let T=e.ownerDocument;return e.nodeName===`SCRIPT`||e.nodeName===`NOSCRIPT`||e.nodeName===`STYLE`||T.head&&T.head.contains(e)}function elementText(e,T){let E=e.get(T);if(E===void 0){if(E={full:``,normalized:``,immediate:[]},!shouldSkipForTextMatching(T)){let D=``;if(T instanceof HTMLInputElement&&(T.type===`submit`||T.type===`button`))E={full:T.value,normalized:normalizeWhiteSpace(T.value),immediate:[T.value]};else{for(let O=T.firstChild;O;O=O.nextSibling)O.nodeType===Node.TEXT_NODE?(E.full+=O.nodeValue||``,D+=O.nodeValue||``):(D&&E.immediate.push(D),D=``,O.nodeType===Node.ELEMENT_NODE&&(E.full+=elementText(e,O).full));D&&E.immediate.push(D),T.shadowRoot&&(E.full+=elementText(e,T.shadowRoot).full),E.full&&(E.normalized=normalizeWhiteSpace(E.full))}}e.set(T,E)}return E}function elementMatchesText(e,T,E){if(shouldSkipForTextMatching(T)||!E(elementText(e,T)))return`none`;for(let D=T.firstChild;D;D=D.nextSibling)if(D.nodeType===Node.ELEMENT_NODE&&E(elementText(e,D)))return`selfAndChildren`;return T.shadowRoot&&E(elementText(e,T.shadowRoot))?`selfAndChildren`:`self`}function getElementLabels(e,T){let E=getAriaLabelledByElements(T);if(E)return E.map(T=>elementText(e,T));let D=T.getAttribute(`aria-label`);if(D!==null&&D.trim())return[{full:D,normalized:normalizeWhiteSpace(D),immediate:[D]}];let O=T.nodeName===`INPUT`&&T.type!==`hidden`;if([`BUTTON`,`METER`,`OUTPUT`,`PROGRESS`,`SELECT`,`TEXTAREA`].includes(T.nodeName)||O){let E=T.labels;if(E)return[...E].map(T=>elementText(e,T))}return[]}var kSupportedAttributes=[`selected`,`checked`,`pressed`,`expanded`,`level`,`disabled`,`name`,`include-hidden`];kSupportedAttributes.sort();function validateSupportedRole(e,T,E){if(!T.includes(E))throw Error(`"${e}" attribute is only supported for roles: ${T.slice().sort().map(e=>`"${e}"`).join(`, `)}`)}function validateSupportedValues(e,T){if(e.op!==`<truthy>`&&!T.includes(e.value))throw Error(`"${e.name}" must be one of ${T.map(e=>JSON.stringify(e)).join(`, `)}`)}function validateSupportedOp(e,T){if(!T.includes(e.op))throw Error(`"${e.name}" does not support "${e.op}" matcher`)}function validateAttributes(e,T){let E={role:T};for(let D of e)switch(D.name){case`checked`:validateSupportedRole(D.name,kAriaCheckedRoles,T),validateSupportedValues(D,[!0,!1,`mixed`]),validateSupportedOp(D,[`<truthy>`,`=`]),E.checked=D.op===`<truthy>`?!0:D.value;break;case`pressed`:validateSupportedRole(D.name,kAriaPressedRoles,T),validateSupportedValues(D,[!0,!1,`mixed`]),validateSupportedOp(D,[`<truthy>`,`=`]),E.pressed=D.op===`<truthy>`?!0:D.value;break;case`selected`:validateSupportedRole(D.name,kAriaSelectedRoles,T),validateSupportedValues(D,[!0,!1]),validateSupportedOp(D,[`<truthy>`,`=`]),E.selected=D.op===`<truthy>`?!0:D.value;break;case`expanded`:validateSupportedRole(D.name,kAriaExpandedRoles,T),validateSupportedValues(D,[!0,!1]),validateSupportedOp(D,[`<truthy>`,`=`]),E.expanded=D.op===`<truthy>`?!0:D.value;break;case`level`:if(validateSupportedRole(D.name,kAriaLevelRoles,T),typeof D.value==`string`&&(D.value=+D.value),D.op!==`=`||typeof D.value!=`number`||Number.isNaN(D.value))throw Error(`"level" attribute must be compared to a number`);E.level=D.value;break;case`disabled`:validateSupportedValues(D,[!0,!1]),validateSupportedOp(D,[`<truthy>`,`=`]),E.disabled=D.op===`<truthy>`?!0:D.value;break;case`name`:if(D.op===`<truthy>`)throw Error(`"name" attribute must have a value`);if(typeof D.value!=`string`&&!(D.value instanceof RegExp))throw TypeError(`"name" attribute must be a string or a regular expression`);E.name=D.value,E.nameOp=D.op,E.exact=D.caseSensitive;break;case`include-hidden`:validateSupportedValues(D,[!0,!1]),validateSupportedOp(D,[`<truthy>`,`=`]),E.includeHidden=D.op===`<truthy>`?!0:D.value;break;default:throw Error(`Unknown attribute "${D.name}", must be one of ${kSupportedAttributes.map(e=>`"${e}"`).join(`, `)}.`)}return E}function queryRole(e,T,E){let D=[],O=e=>{if(getAriaRole(e)===T.role&&!(T.selected!==void 0&&getAriaSelected(e)!==T.selected)&&!(T.checked!==void 0&&getAriaChecked(e)!==T.checked)&&!(T.pressed!==void 0&&getAriaPressed(e)!==T.pressed)&&!(T.expanded!==void 0&&getAriaExpanded(e)!==T.expanded)&&!(T.level!==void 0&&getAriaLevel(e)!==T.level)&&!(T.disabled!==void 0&&getAriaDisabled(e)!==T.disabled)&&!(!T.includeHidden&&isElementHiddenForAria(e))){if(T.name!==void 0){let D=normalizeWhiteSpace(getElementAccessibleName(e,!!T.includeHidden));if(typeof T.name==`string`&&(T.name=normalizeWhiteSpace(T.name)),E&&!T.exact&&T.nameOp===`=`&&(T.nameOp=`*=`),!matchesAttributePart(D,{op:T.nameOp||`=`,value:T.name,caseSensitive:!!T.exact}))return}D.push(e)}},k=e=>{let T=[];e.shadowRoot&&T.push(e.shadowRoot);for(let E of e.querySelectorAll(`*`))O(E),E.shadowRoot&&T.push(E.shadowRoot);T.forEach(k)};return k(e),D}function createRoleEngine(e){return{queryAll:(T,E)=>{let D=parseAttributeSelector(E),O=D.name.toLowerCase();if(!O)throw Error(`Role must not be empty`);let k=validateAttributes(D.attributes,O);beginAriaCaches();try{return queryRole(T,k,e)}finally{endAriaCaches()}}}}function asLocator(e,T,E=!1){return asLocators(e,T,E)[0]}function asLocators(e,T,E=!1,D=20,O){try{return innerAsLocators(new generators[e](O),parseSelector(T),E,D)}catch{return[T]}}function innerAsLocators(e,T,E=!1,D=20){let O=[...T.parts];for(let e=0;e<O.length-1;e++)if(O[e].name===`nth`&&O[e+1].name===`internal:control`&&O[e+1].body===`enter-frame`){let[T]=O.splice(e,1);O.splice(e+1,0,T)}let k=[],A=E?`frame-locator`:`page`;for(let T=0;T<O.length;T++){let E=O[T],j=A;if(A=`locator`,E.name===`nth`){E.body===`0`?k.push([e.generateLocator(j,`first`,``),e.generateLocator(j,`nth`,`0`)]):E.body===`-1`?k.push([e.generateLocator(j,`last`,``),e.generateLocator(j,`nth`,`-1`)]):k.push([e.generateLocator(j,`nth`,E.body)]);continue}if(E.name===`internal:text`){let{exact:T,text:D}=detectExact(E.body);k.push([e.generateLocator(j,`text`,D,{exact:T})]);continue}if(E.name===`internal:has-text`){let{exact:T,text:D}=detectExact(E.body);if(!T){k.push([e.generateLocator(j,`has-text`,D,{exact:T})]);continue}}if(E.name===`internal:has-not-text`){let{exact:T,text:D}=detectExact(E.body);if(!T){k.push([e.generateLocator(j,`has-not-text`,D,{exact:T})]);continue}}if(E.name===`internal:has`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`has`,T)));continue}if(E.name===`internal:has-not`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`hasNot`,T)));continue}if(E.name===`internal:and`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`and`,T)));continue}if(E.name===`internal:or`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`or`,T)));continue}if(E.name===`internal:chain`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`chain`,T)));continue}if(E.name===`internal:label`){let{exact:T,text:D}=detectExact(E.body);k.push([e.generateLocator(j,`label`,D,{exact:T})]);continue}if(E.name===`internal:role`){let T=parseAttributeSelector(E.body),D={attrs:[]};for(let e of T.attributes)e.name===`name`?(D.exact=e.caseSensitive,D.name=e.value):(e.name===`level`&&typeof e.value==`string`&&(e.value=+e.value),D.attrs.push({name:e.name===`include-hidden`?`includeHidden`:e.name,value:e.value}));k.push([e.generateLocator(j,`role`,T.name,D)]);continue}if(E.name===`internal:testid`){let{value:T}=parseAttributeSelector(E.body).attributes[0];k.push([e.generateLocator(j,`test-id`,T)]);continue}if(E.name===`internal:attr`){let{name:T,value:D,caseSensitive:O}=parseAttributeSelector(E.body).attributes[0],A=D,M=!!O;if(T===`placeholder`){k.push([e.generateLocator(j,`placeholder`,A,{exact:M})]);continue}if(T===`alt`){k.push([e.generateLocator(j,`alt`,A,{exact:M})]);continue}if(T===`title`){k.push([e.generateLocator(j,`title`,A,{exact:M})]);continue}}let M=`default`,N=O[T+1];N&&N.name===`internal:control`&&N.body===`enter-frame`&&(M=`frame`,A=`frame-locator`,T++);let P=stringifySelector({parts:[E]}),F=e.generateLocator(j,M,P);if(M===`default`&&N&&[`internal:has-text`,`internal:has-not-text`].includes(N.name)){let{exact:E,text:D}=detectExact(N.body);if(!E){let O=e.generateLocator(`locator`,N.name===`internal:has-text`?`has-text`:`has-not-text`,D,{exact:E}),A={};N.name===`internal:has-text`?A.hasText=D:A.hasNotText=D;let M=e.generateLocator(j,`default`,P,A);k.push([e.chainLocators([F,O]),M]),T++;continue}}let I;if([`xpath`,`css`].includes(E.name)){let T=stringifySelector({parts:[E]},!0);I=e.generateLocator(j,M,T)}k.push([F,I].filter(Boolean))}return combineTokens(e,k,D)}function combineTokens(e,T,E){let D=T.map(()=>``),O=[],k=A=>{if(A===T.length)return O.push(e.chainLocators(D)),D.length<E;for(let e of T[A])if(D[A]=e,!k(A+1))return!1;return!0};return k(0),O}function detectExact(e){let T=!1,E=e.match(/^\/(.*)\/([igm]*)$/);return E?{text:new RegExp(E[1],E[2])}:(e.endsWith(`"`)?(e=JSON.parse(e),T=!0):e.endsWith(`"s`)?(e=JSON.parse(e.substring(0,e.length-1)),T=!0):e.endsWith(`"i`)&&(e=JSON.parse(e.substring(0,e.length-1)),T=!1),{exact:T,text:e})}var JavaScriptLocatorFactory=class{constructor(e){this.preferredQuote=e}generateLocator(e,T,E,D={}){switch(T){case`default`:return D.hasText===void 0?D.hasNotText===void 0?`locator(${this.quote(E)})`:`locator(${this.quote(E)}, { hasNotText: ${this.toHasText(D.hasNotText)} })`:`locator(${this.quote(E)}, { hasText: ${this.toHasText(D.hasText)} })`;case`frame`:return`frameLocator(${this.quote(E)})`;case`nth`:return`nth(${E})`;case`first`:return`first()`;case`last`:return`last()`;case`role`:{let e=[];isRegExp(D.name)?e.push(`name: ${this.regexToSourceString(D.name)}`):typeof D.name==`string`&&(e.push(`name: ${this.quote(D.name)}`),D.exact&&e.push(`exact: true`));for(let{name:T,value:E}of D.attrs)e.push(`${T}: ${typeof E==`string`?this.quote(E):E}`);let T=e.length?`, { ${e.join(`, `)} }`:``;return`getByRole(${this.quote(E)}${T})`}case`has-text`:return`filter({ hasText: ${this.toHasText(E)} })`;case`has-not-text`:return`filter({ hasNotText: ${this.toHasText(E)} })`;case`has`:return`filter({ has: ${E} })`;case`hasNot`:return`filter({ hasNot: ${E} })`;case`and`:return`and(${E})`;case`or`:return`or(${E})`;case`chain`:return`locator(${E})`;case`test-id`:{let e=this.toTestIdValue(E);return e.startsWith(`'__vitest_`)&&e.endsWith(`__'`)?`page`:`getByTestId(${e})`}case`text`:return this.toCallWithExact(`getByText`,E,!!D.exact);case`alt`:return this.toCallWithExact(`getByAltText`,E,!!D.exact);case`placeholder`:return this.toCallWithExact(`getByPlaceholder`,E,!!D.exact);case`label`:return this.toCallWithExact(`getByLabel`,E,!!D.exact);case`title`:return this.toCallWithExact(`getByTitle`,E,!!D.exact);default:throw Error(`Unknown selector kind ${T}`)}}chainLocators(e){return e.join(`.`)}regexToSourceString(e){return normalizeEscapedRegexQuotes(String(e))}toCallWithExact(e,T,E){return isRegExp(T)?`${e}(${this.regexToSourceString(T)})`:E?`${e}(${this.quote(T)}, { exact: true })`:`${e}(${this.quote(T)})`}toHasText(e){return isRegExp(e)?this.regexToSourceString(e):this.quote(e)}toTestIdValue(e){return isRegExp(e)?this.regexToSourceString(e):this.quote(e)}quote(e){return escapeWithQuotes(e,this.preferredQuote??`'`)}},generators={javascript:JavaScriptLocatorFactory};function isRegExp(e){return e instanceof RegExp}var cacheAllowText=new Map,cacheDisallowText=new Map,kTextScoreRange=10,kExactPenalty=kTextScoreRange/2,kTestIdScore=1,kOtherTestIdScore=2,kIframeByAttributeScore=10,kBeginPenalizedScore=50,kPlaceholderScore=100,kLabelScore=120,kRoleWithNameScore=140,kAltTextScore=160,kTextScore=180,kTitleScore=200,kTextScoreRegex=250,kPlaceholderScoreExact=kPlaceholderScore+kExactPenalty,kLabelScoreExact=kLabelScore+kExactPenalty,kRoleWithNameScoreExact=kRoleWithNameScore+kExactPenalty,kAltTextScoreExact=kAltTextScore+kExactPenalty,kTextScoreExact=kTextScore+kExactPenalty,kTitleScoreExact=kTitleScore+kExactPenalty,kEndPenalizedScore=300,kCSSIdScore=500,kRoleWithoutNameScore=510,kCSSInputTypeNameScore=520,kCSSTagNameScore=530,kNthScore=1e4,kCSSFallbackScore=1e7;function generateSelector(e,T,E){e._evaluator.begin(),beginAriaCaches();try{return joinTokens(generateSelectorFor(e,T,E)||cssFallback(e,T,E))}finally{cacheAllowText.clear(),cacheDisallowText.clear(),endAriaCaches(),e._evaluator.end()}}function filterRegexTokens(e){return e.filter(e=>e[0].selector[0]!==`/`)}function generateSelectorFor(e,T,E){if(T.ownerDocument.documentElement===T)return[{engine:`css`,selector:`html`,score:1}];let D=(D,k)=>{let A=D===T,j=k?buildTextCandidates(e,D,D===T):[];D!==T&&(j=filterRegexTokens(j));let M=buildNoTextCandidates(e,D,E).map(e=>[e]),N=chooseFirstSelector(e,T.ownerDocument,D,[...j,...M],A);j=filterRegexTokens(j);let P=T=>{let E=k&&!T.length,j=[...T,...M].filter(e=>N?combineScores(e)<combineScores(N):!0),P=j[0];if(P)for(let T=parentElementOrShadowHost(D);T;T=parentElementOrShadowHost(T)){let k=O(T,E);if(!k||N&&combineScores([...k,...P])>=combineScores(N))continue;if(P=chooseFirstSelector(e,T,D,j,A),!P)return;let M=[...k,...P];(!N||combineScores(M)<combineScores(N))&&(N=M)}};return P(j),D===T&&j.length&&P([]),N},O=(e,T)=>{let E=T?cacheAllowText:cacheDisallowText,O=E.get(e);return O===void 0&&(O=D(e,T),E.set(e,O)),O};return D(T,!E.noText)}function buildNoTextCandidates(e,T,E){let D=[];for(let e of[`data-testid`,`data-test-id`,`data-test`])e!==E.testIdAttributeName&&T.getAttribute(e)&&D.push({engine:`css`,selector:`[${e}=${quoteCSSAttributeValue(T.getAttribute(e))}]`,score:kOtherTestIdScore});if(!E.noCSSId){let e=T.getAttribute(`id`);e&&!isGuidLike(e)&&D.push({engine:`css`,selector:makeSelectorForId(e),score:kCSSIdScore})}if(D.push({engine:`css`,selector:cssEscape(T.nodeName.toLowerCase()),score:kCSSTagNameScore}),T.nodeName===`IFRAME`){for(let e of[`name`,`title`])T.getAttribute(e)&&D.push({engine:`css`,selector:`${cssEscape(T.nodeName.toLowerCase())}[${e}=${quoteCSSAttributeValue(T.getAttribute(e))}]`,score:kIframeByAttributeScore});return T.getAttribute(E.testIdAttributeName)&&D.push({engine:`css`,selector:`[${E.testIdAttributeName}=${quoteCSSAttributeValue(T.getAttribute(E.testIdAttributeName))}]`,score:kTestIdScore}),penalizeScoreForLength([D]),D}if(T.getAttribute(E.testIdAttributeName)&&D.push({engine:`internal:testid`,selector:`[${E.testIdAttributeName}=${escapeForAttributeSelector(T.getAttribute(E.testIdAttributeName),!0)}]`,score:kTestIdScore}),T.nodeName===`INPUT`||T.nodeName===`TEXTAREA`){let e=T;if(e.placeholder){D.push({engine:`internal:attr`,selector:`[placeholder=${escapeForAttributeSelector(e.placeholder,!0)}]`,score:kPlaceholderScoreExact});for(let T of suitableTextAlternatives(e.placeholder))D.push({engine:`internal:attr`,selector:`[placeholder=${escapeForAttributeSelector(T.text,!1)}]`,score:kPlaceholderScore-T.scoreBouns})}}let O=getElementLabels(e._evaluator._cacheText,T);for(let e of O){let T=e.normalized;D.push({engine:`internal:label`,selector:escapeForTextSelector$1(T,!0),score:kLabelScoreExact});for(let e of suitableTextAlternatives(T))D.push({engine:`internal:label`,selector:escapeForTextSelector$1(e.text,!1),score:kLabelScore-e.scoreBouns})}let k=getAriaRole(T);return k&&![`none`,`presentation`].includes(k)&&D.push({engine:`internal:role`,selector:k,score:kRoleWithoutNameScore}),T.getAttribute(`name`)&&[`BUTTON`,`FORM`,`FIELDSET`,`FRAME`,`IFRAME`,`INPUT`,`KEYGEN`,`OBJECT`,`OUTPUT`,`SELECT`,`TEXTAREA`,`MAP`,`META`,`PARAM`].includes(T.nodeName)&&D.push({engine:`css`,selector:`${cssEscape(T.nodeName.toLowerCase())}[name=${quoteCSSAttributeValue(T.getAttribute(`name`))}]`,score:kCSSInputTypeNameScore}),[`INPUT`,`TEXTAREA`].includes(T.nodeName)&&T.getAttribute(`type`)!==`hidden`&&T.getAttribute(`type`)&&D.push({engine:`css`,selector:`${cssEscape(T.nodeName.toLowerCase())}[type=${quoteCSSAttributeValue(T.getAttribute(`type`))}]`,score:kCSSInputTypeNameScore}),[`INPUT`,`TEXTAREA`,`SELECT`].includes(T.nodeName)&&T.getAttribute(`type`)!==`hidden`&&D.push({engine:`css`,selector:cssEscape(T.nodeName.toLowerCase()),score:kCSSInputTypeNameScore+1}),penalizeScoreForLength([D]),D}function buildTextCandidates(e,T,E){if(T.nodeName===`SELECT`)return[];let D=[],O=T.getAttribute(`title`);if(O){D.push([{engine:`internal:attr`,selector:`[title=${escapeForAttributeSelector(O,!0)}]`,score:kTitleScoreExact}]);for(let e of suitableTextAlternatives(O))D.push([{engine:`internal:attr`,selector:`[title=${escapeForAttributeSelector(e.text,!1)}]`,score:kTitleScore-e.scoreBouns}])}let k=T.getAttribute(`alt`);if(k&&[`APPLET`,`AREA`,`IMG`,`INPUT`].includes(T.nodeName)){D.push([{engine:`internal:attr`,selector:`[alt=${escapeForAttributeSelector(k,!0)}]`,score:kAltTextScoreExact}]);for(let e of suitableTextAlternatives(k))D.push([{engine:`internal:attr`,selector:`[alt=${escapeForAttributeSelector(e.text,!1)}]`,score:kAltTextScore-e.scoreBouns}])}let A=elementText(e._evaluator._cacheText,T).normalized;if(A){let e=suitableTextAlternatives(A);if(E){A.length<=80&&D.push([{engine:`internal:text`,selector:escapeForTextSelector$1(A,!0),score:kTextScoreExact}]);for(let T of e)D.push([{engine:`internal:text`,selector:escapeForTextSelector$1(T.text,!1),score:kTextScore-T.scoreBouns}])}let O={engine:`css`,selector:cssEscape(T.nodeName.toLowerCase()),score:kCSSTagNameScore};for(let T of e)D.push([O,{engine:`internal:has-text`,selector:escapeForTextSelector$1(T.text,!1),score:kTextScore-T.scoreBouns}]);if(A.length<=80){let e=RegExp(`^${escapeRegExp(A)}$`);D.push([O,{engine:`internal:has-text`,selector:escapeForTextSelector$1(e,!1),score:kTextScoreRegex}])}}let j=getAriaRole(T);if(j&&![`none`,`presentation`].includes(j)){let e=getElementAccessibleName(T,!1);if(e){D.push([{engine:`internal:role`,selector:`${j}[name=${escapeForAttributeSelector(e,!0)}]`,score:kRoleWithNameScoreExact}]);for(let T of suitableTextAlternatives(e))D.push([{engine:`internal:role`,selector:`${j}[name=${escapeForAttributeSelector(T.text,!1)}]`,score:kRoleWithNameScore-T.scoreBouns}])}}return penalizeScoreForLength(D),D}function makeSelectorForId(e){return/^[a-z][\w\-]+$/i.test(e)?`#${e}`:`[id="${cssEscape(e)}"]`}function cssFallback(e,T,E){let D=T.ownerDocument,O=[];function k(E){let k=O.slice();E&&k.unshift(E);let A=k.join(` > `),j=e.parseSelector(A);return e.querySelector(j,D,!1)===T?A:void 0}function A(E){let O={engine:`css`,selector:E,score:kCSSFallbackScore},k=e.parseSelector(E),A=e.querySelectorAll(k,D);return A.length===1?[O]:[O,{engine:`nth`,selector:String(A.indexOf(T)),score:kNthScore}]}for(let e=T;e&&e!==D;e=parentElementOrShadowHost(e)){let T=e.nodeName.toLowerCase(),D=``;if(e.id&&!E.noCSSId){let T=makeSelectorForId(e.id),E=k(T);if(E)return A(E);D=T}let j=e.parentNode,M=[...e.classList];for(let e=0;e<M.length;++e){let T=`.${cssEscape(M.slice(0,e+1).join(`.`))}`,E=k(T);if(E)return A(E);!D&&j&&j.querySelectorAll(T).length===1&&(D=T)}if(j){let E=[...j.children],O=E.filter(e=>e.nodeName.toLowerCase()===T).indexOf(e)===0?cssEscape(T):`${cssEscape(T)}:nth-child(${1+E.indexOf(e)})`,M=k(O);if(M)return A(M);D||=O}else D||=cssEscape(T);O.unshift(D)}return A(k())}function penalizeScoreForLength(e){for(let T of e)for(let e of T)e.score>kBeginPenalizedScore&&e.score<kEndPenalizedScore&&(e.score+=Math.min(kTextScoreRange,e.selector.length/10|0))}function joinTokens(e){let T=[],E=``;for(let{engine:D,selector:O}of e)T.length&&(E!==`css`||D!==`css`||O.startsWith(`:nth-match(`))&&T.push(`>>`),E=D,D===`css`?T.push(O):T.push(`${D}=${O}`);return T.join(` `)}function combineScores(e){let T=0;for(let E=0;E<e.length;E++)T+=e[E].score*(e.length-E);return T}function chooseFirstSelector(e,T,E,D,O){let k=D.map(e=>({tokens:e,score:combineScores(e)}));k.sort((e,T)=>e.score-T.score);let A=null;for(let{tokens:D}of k){let k=e.parseSelector(joinTokens(D)),j=e.querySelectorAll(k,T);if(j[0]===E&&j.length===1)return D;let M=j.indexOf(E);if(!O||A||M===-1||j.length>5)continue;let N={engine:`nth`,selector:String(M),score:kNthScore};A=[...D,N]}return A}function isGuidLike(e){let T,E=0;for(let D=0;D<e.length;++D){let O=e[D],k;if(!(O===`-`||O===`_`)){if(k=O>=`a`&&O<=`z`?`lower`:O>=`A`&&O<=`Z`?`upper`:O>=`0`&&O<=`9`?`digit`:`other`,k===`lower`&&T===`upper`){T=k;continue}T&&T!==k&&++E,T=k}}return E>=e.length/4}function trimWordBoundary(e,T){if(e.length<=T)return e;e=e.substring(0,T);let E=e.match(/^(.*)\b(.+)$/);return E?E[1].trimEnd():``}function suitableTextAlternatives(e){let T=[];{let E=e.match(/^([\d.,]+)[^.,\w]/),D=E?E[1].length:0;if(D){let E=trimWordBoundary(e.substring(D).trimStart(),80);T.push({text:E,scoreBouns:E.length<=30?2:1})}}{let E=e.match(/[^.,\w]([\d.,]+)$/),D=E?E[1].length:0;if(D){let E=trimWordBoundary(e.substring(0,e.length-D).trimEnd(),80);T.push({text:E,scoreBouns:E.length<=30?2:1})}}return e.length<=30?T.push({text:e,scoreBouns:0}):(T.push({text:trimWordBoundary(e,80),scoreBouns:0}),T.push({text:trimWordBoundary(e,30),scoreBouns:1})),T=T.filter(e=>e.text),T.length||T.push({text:e.substring(0,80),scoreBouns:0}),T}function boxRightOf(e,T,E){let D=e.left-T.right;if(!(D<0||E!==void 0&&D>E))return D+Math.max(T.bottom-e.bottom,0)+Math.max(e.top-T.top,0)}function boxLeftOf(e,T,E){let D=T.left-e.right;if(!(D<0||E!==void 0&&D>E))return D+Math.max(T.bottom-e.bottom,0)+Math.max(e.top-T.top,0)}function boxAbove(e,T,E){let D=T.top-e.bottom;if(!(D<0||E!==void 0&&D>E))return D+Math.max(e.left-T.left,0)+Math.max(T.right-e.right,0)}function boxBelow(e,T,E){let D=e.top-T.bottom;if(!(D<0||E!==void 0&&D>E))return D+Math.max(e.left-T.left,0)+Math.max(T.right-e.right,0)}function boxNear(e,T,E){let D=E===void 0?50:E,O=0;return e.left-T.right>=0&&(O+=e.left-T.right),T.left-e.right>=0&&(O+=T.left-e.right),T.top-e.bottom>=0&&(O+=T.top-e.bottom),e.top-T.bottom>=0&&(O+=e.top-T.bottom),O>D?void 0:O}var kLayoutSelectorNames=[`left-of`,`right-of`,`above`,`below`,`near`];function layoutSelectorScore(e,T,E,D){let O=T.getBoundingClientRect(),k={"left-of":boxLeftOf,"right-of":boxRightOf,above:boxAbove,below:boxBelow,near:boxNear}[e],A;for(let e of E){if(e===T)continue;let E=k(O,e.getBoundingClientRect(),D);E!==void 0&&(A===void 0||E<A)&&(A=E)}return A}var SelectorEvaluatorImpl=class{constructor(e){__publicField(this,`_engines`,new Map),__publicField(this,`_cacheQueryCSS`,new Map),__publicField(this,`_cacheMatches`,new Map),__publicField(this,`_cacheQuery`,new Map),__publicField(this,`_cacheMatchesSimple`,new Map),__publicField(this,`_cacheMatchesParents`,new Map),__publicField(this,`_cacheCallMatches`,new Map),__publicField(this,`_cacheCallQuery`,new Map),__publicField(this,`_cacheQuerySimple`,new Map),__publicField(this,`_cacheText`,new Map),__publicField(this,`_scoreMap`),__publicField(this,`_retainCacheCounter`,0);for(let[T,E]of e)this._engines.set(T,E);this._engines.set(`not`,notEngine),this._engines.set(`is`,isEngine),this._engines.set(`where`,isEngine),this._engines.set(`has`,hasEngine),this._engines.set(`scope`,scopeEngine),this._engines.set(`light`,lightEngine),this._engines.set(`visible`,visibleEngine),this._engines.set(`text`,textEngine),this._engines.set(`text-is`,textIsEngine),this._engines.set(`text-matches`,textMatchesEngine),this._engines.set(`has-text`,hasTextEngine),this._engines.set(`right-of`,createLayoutEngine(`right-of`)),this._engines.set(`left-of`,createLayoutEngine(`left-of`)),this._engines.set(`above`,createLayoutEngine(`above`)),this._engines.set(`below`,createLayoutEngine(`below`)),this._engines.set(`near`,createLayoutEngine(`near`)),this._engines.set(`nth-match`,nthMatchEngine);let T=[...this._engines.keys()];T.sort();let E=[...customCSSNames];if(E.sort(),T.join(`|`)!==E.join(`|`))throw Error(`Please keep customCSSNames in sync with evaluator engines: ${T.join(`|`)} vs ${E.join(`|`)}`)}begin(){++this._retainCacheCounter}end(){--this._retainCacheCounter,this._retainCacheCounter||(this._cacheQueryCSS.clear(),this._cacheMatches.clear(),this._cacheQuery.clear(),this._cacheMatchesSimple.clear(),this._cacheMatchesParents.clear(),this._cacheCallMatches.clear(),this._cacheCallQuery.clear(),this._cacheQuerySimple.clear(),this._cacheText.clear())}_cached(e,T,E,D){e.has(T)||e.set(T,[]);let O=e.get(T),k=O.find(e=>E.every((T,E)=>e.rest[E]===T));if(k)return k.result;let A=D();return O.push({rest:E,result:A}),A}_checkSelector(e){if(!(typeof e==`object`&&e&&(Array.isArray(e)||`simples`in e&&e.simples.length)))throw Error(`Malformed selector "${e}"`);return e}matches(e,T,E){let D=this._checkSelector(T);this.begin();try{return this._cached(this._cacheMatches,e,[D,E.scope,E.pierceShadow,E.originalScope],()=>Array.isArray(D)?this._matchesEngine(isEngine,e,D,E):(this._hasScopeClause(D)&&(E=this._expandContextForScopeMatching(E)),this._matchesSimple(e,D.simples[D.simples.length-1].selector,E)?this._matchesParents(e,D,D.simples.length-2,E):!1))}finally{this.end()}}query(e,T){let E=this._checkSelector(T);this.begin();try{return this._cached(this._cacheQuery,E,[e.scope,e.pierceShadow,e.originalScope],()=>{if(Array.isArray(E))return this._queryEngine(isEngine,e,E);this._hasScopeClause(E)&&(e=this._expandContextForScopeMatching(e));let T=this._scoreMap;this._scoreMap=new Map;let D=this._querySimple(e,E.simples[E.simples.length-1].selector);return D=D.filter(T=>this._matchesParents(T,E,E.simples.length-2,e)),this._scoreMap.size&&D.sort((e,T)=>{let E=this._scoreMap.get(e),D=this._scoreMap.get(T);return E===D?0:E===void 0?1:D===void 0?-1:E-D}),this._scoreMap=T,D})}finally{this.end()}}_markScore(e,T){this._scoreMap&&this._scoreMap.set(e,T)}_hasScopeClause(e){return e.simples.some(e=>e.selector.functions.some(e=>e.name===`scope`))}_expandContextForScopeMatching(e){if(e.scope.nodeType!==1)return e;let T=parentElementOrShadowHost(e.scope);return T?{...e,scope:T,originalScope:e.originalScope||e.scope}:e}_matchesSimple(e,T,E){return this._cached(this._cacheMatchesSimple,e,[T,E.scope,E.pierceShadow,E.originalScope],()=>{if(e===E.scope||T.css&&!this._matchesCSS(e,T.css))return!1;for(let D of T.functions)if(!this._matchesEngine(this._getEngine(D.name),e,D.args,E))return!1;return!0})}_querySimple(e,T){return T.functions.length?this._cached(this._cacheQuerySimple,T,[e.scope,e.pierceShadow,e.originalScope],()=>{let E=T.css,D=T.functions;E===`*`&&D.length&&(E=void 0);let O,k=-1;E===void 0?(k=D.findIndex(e=>this._getEngine(e.name).query!==void 0),k===-1&&(k=0),O=this._queryEngine(this._getEngine(D[k].name),e,D[k].args)):O=this._queryCSS(e,E);for(let T=0;T<D.length;T++){if(T===k)continue;let E=this._getEngine(D[T].name);E.matches!==void 0&&(O=O.filter(O=>this._matchesEngine(E,O,D[T].args,e)))}for(let T=0;T<D.length;T++){if(T===k)continue;let E=this._getEngine(D[T].name);E.matches===void 0&&(O=O.filter(O=>this._matchesEngine(E,O,D[T].args,e)))}return O}):this._queryCSS(e,T.css||`*`)}_matchesParents(e,T,E,D){return E<0?!0:this._cached(this._cacheMatchesParents,e,[T,E,D.scope,D.pierceShadow,D.originalScope],()=>{let{selector:O,combinator:k}=T.simples[E];if(k===`>`){let k=parentElementOrShadowHostInContext(e,D);return!k||!this._matchesSimple(k,O,D)?!1:this._matchesParents(k,T,E-1,D)}if(k===`+`){let k=previousSiblingInContext(e,D);return!k||!this._matchesSimple(k,O,D)?!1:this._matchesParents(k,T,E-1,D)}if(k===``){let k=parentElementOrShadowHostInContext(e,D);for(;k;){if(this._matchesSimple(k,O,D)){if(this._matchesParents(k,T,E-1,D))return!0;if(T.simples[E-1].combinator===``)break}k=parentElementOrShadowHostInContext(k,D)}return!1}if(k===`~`){let k=previousSiblingInContext(e,D);for(;k;){if(this._matchesSimple(k,O,D)){if(this._matchesParents(k,T,E-1,D))return!0;if(T.simples[E-1].combinator===`~`)break}k=previousSiblingInContext(k,D)}return!1}if(k===`>=`){let k=e;for(;k;){if(this._matchesSimple(k,O,D)){if(this._matchesParents(k,T,E-1,D))return!0;if(T.simples[E-1].combinator===``)break}k=parentElementOrShadowHostInContext(k,D)}return!1}throw Error(`Unsupported combinator "${k}"`)})}_matchesEngine(e,T,E,D){if(e.matches)return this._callMatches(e,T,E,D);if(e.query)return this._callQuery(e,E,D).includes(T);throw Error(`Selector engine should implement "matches" or "query"`)}_queryEngine(e,T,E){if(e.query)return this._callQuery(e,E,T);if(e.matches)return this._queryCSS(T,`*`).filter(D=>this._callMatches(e,D,E,T));throw Error(`Selector engine should implement "matches" or "query"`)}_callMatches(e,T,E,D){return this._cached(this._cacheCallMatches,T,[e,D.scope,D.pierceShadow,D.originalScope,...E],()=>e.matches(T,E,D,this))}_callQuery(e,T,E){return this._cached(this._cacheCallQuery,e,[E.scope,E.pierceShadow,E.originalScope,...T],()=>e.query(E,T,this))}_matchesCSS(e,T){return e.matches(T)}_queryCSS(e,T){return this._cached(this._cacheQueryCSS,T,[e.scope,e.pierceShadow,e.originalScope],()=>{let E=[];function D(O){if(E=E.concat([...O.querySelectorAll(T)]),e.pierceShadow){O.shadowRoot&&D(O.shadowRoot);for(let e of O.querySelectorAll(`*`))e.shadowRoot&&D(e.shadowRoot)}}return D(e.scope),E})}_getEngine(e){let T=this._engines.get(e);if(!T)throw Error(`Unknown selector engine "${e}"`);return T}},isEngine={matches(e,T,E,D){if(T.length===0)throw Error(`"is" engine expects non-empty selector list`);return T.some(T=>D.matches(e,T,E))},query(e,T,E){if(T.length===0)throw Error(`"is" engine expects non-empty selector list`);let D=[];for(let O of T)D=D.concat(E.query(e,O));return T.length===1?D:sortInDOMOrder(D)}},hasEngine={matches(e,T,E,D){if(T.length===0)throw Error(`"has" engine expects non-empty selector list`);return D.query({...E,scope:e},T).length>0}},scopeEngine={matches(e,T,E,D){if(T.length!==0)throw Error(`"scope" engine expects no arguments`);let O=E.originalScope||E.scope;return O.nodeType===9?e===O.documentElement:e===O},query(e,T,E){if(T.length!==0)throw Error(`"scope" engine expects no arguments`);let D=e.originalScope||e.scope;if(D.nodeType===9){let e=D.documentElement;return e?[e]:[]}return D.nodeType===1?[D]:[]}},notEngine={matches(e,T,E,D){if(T.length===0)throw Error(`"not" engine expects non-empty selector list`);return!D.matches(e,T,E)}},lightEngine={query(e,T,E){return E.query({...e,pierceShadow:!1},T)},matches(e,T,E,D){return D.matches(e,T,{...E,pierceShadow:!1})}},visibleEngine={matches(e,T,E,D){if(T.length)throw Error(`"visible" engine expects no arguments`);return isElementVisible(e)}},textEngine={matches(e,T,E,D){if(T.length!==1||typeof T[0]!=`string`)throw Error(`"text" engine expects a single string`);let O=normalizeWhiteSpace(T[0]).toLowerCase();return elementMatchesText(D._cacheText,e,e=>e.normalized.toLowerCase().includes(O))===`self`}},textIsEngine={matches(e,T,E,D){if(T.length!==1||typeof T[0]!=`string`)throw Error(`"text-is" engine expects a single string`);let O=normalizeWhiteSpace(T[0]);return elementMatchesText(D._cacheText,e,e=>!O&&!e.immediate.length?!0:e.immediate.some(e=>normalizeWhiteSpace(e)===O))!==`none`}},textMatchesEngine={matches(e,T,E,D){if(T.length===0||typeof T[0]!=`string`||T.length>2||T.length===2&&typeof T[1]!=`string`)throw Error(`"text-matches" engine expects a regexp body and optional regexp flags`);let O=new RegExp(T[0],T.length===2?T[1]:void 0);return elementMatchesText(D._cacheText,e,e=>O.test(e.full))===`self`}},hasTextEngine={matches(e,T,E,D){if(T.length!==1||typeof T[0]!=`string`)throw Error(`"has-text" engine expects a single string`);if(shouldSkipForTextMatching(e))return!1;let O=normalizeWhiteSpace(T[0]).toLowerCase();return(e=>e.normalized.toLowerCase().includes(O))(elementText(D._cacheText,e))}};function createLayoutEngine(e){return{matches(T,E,D,O){let k=E.length&&typeof E[E.length-1]==`number`?E[E.length-1]:void 0,A=k===void 0?E:E.slice(0,E.length-1);if(E.length<1+(k===void 0?0:1))throw Error(`"${e}" engine expects a selector list and optional maximum distance in pixels`);let j=layoutSelectorScore(e,T,O.query(D,A),k);return j===void 0?!1:(O._markScore(T,j),!0)}}}var nthMatchEngine={query(e,T,E){let D=T[T.length-1];if(T.length<2)throw Error(`"nth-match" engine expects non-empty selector list and an index argument`);if(typeof D!=`number`||D<1)throw Error(`"nth-match" engine expects a one-based index as the last argument`);let O=isEngine.query(e,T.slice(0,T.length-1),E);return D--,D<O.length?[O[D]]:[]}};function parentElementOrShadowHostInContext(e,T){if(e!==T.scope)return T.pierceShadow?parentElementOrShadowHost(e):e.parentElement||void 0}function previousSiblingInContext(e,T){if(e!==T.scope)return e.previousElementSibling||void 0}function sortInDOMOrder(e){let T=new Map,E=[],D=[];function O(e){let D=T.get(e);if(D)return D;let k=parentElementOrShadowHost(e);return k?O(k).children.push(e):E.push(e),D={children:[],taken:!1},T.set(e,D),D}for(let T of e)O(T).taken=!0;function k(e){let E=T.get(e);if(E.taken&&D.push(e),E.children.length>1){let T=new Set(E.children);E.children=[];let D=e.firstElementChild;for(;D&&E.children.length<T.size;)T.has(D)&&E.children.push(D),D=D.nextElementSibling;for(D=e.shadowRoot?e.shadowRoot.firstElementChild:null;D&&E.children.length<T.size;)T.has(D)&&E.children.push(D),D=D.nextElementSibling}E.children.forEach(k)}return E.forEach(k),D}function getByAttributeTextSelector(e,T,E){return`internal:attr=[${e}=${escapeForAttributeSelector(T,E?.exact||!1)}]`}function getByTestIdSelector(e,T){return`internal:testid=[${e}=${escapeForAttributeSelector(T,!0)}]`}function getByLabelSelector(e,T){return`internal:label=${escapeForTextSelector$1(e,!!T?.exact)}`}function getByAltTextSelector(e,T){return getByAttributeTextSelector(`alt`,e,T)}function getByTitleSelector(e,T){return getByAttributeTextSelector(`title`,e,T)}function getByPlaceholderSelector(e,T){return getByAttributeTextSelector(`placeholder`,e,T)}function getByTextSelector(e,T){return`internal:text=${escapeForTextSelector$1(e,!!T?.exact)}`}function getByRoleSelector(e,T={}){let E=[];return T.checked!==void 0&&E.push([`checked`,String(T.checked)]),T.disabled!==void 0&&E.push([`disabled`,String(T.disabled)]),T.selected!==void 0&&E.push([`selected`,String(T.selected)]),T.expanded!==void 0&&E.push([`expanded`,String(T.expanded)]),T.includeHidden!==void 0&&E.push([`include-hidden`,String(T.includeHidden)]),T.level!==void 0&&E.push([`level`,String(T.level)]),T.name!==void 0&&E.push([`name`,escapeForAttributeSelector(T.name,!!T.exact)]),T.pressed!==void 0&&E.push([`pressed`,String(T.pressed)]),`internal:role=${e}${E.map(([e,T])=>`[${e}=${T}]`).join(``)}`}var _Ivya=class e{constructor(){__publicField(this,`_engines`),__publicField(this,`_evaluator`),this._evaluator=new SelectorEvaluatorImpl(new Map),this._engines=new Map,this._engines.set(`xpath`,XPathEngine),this._engines.set(`xpath:light`,XPathEngine),this._engines.set(`role`,createRoleEngine(!1)),this._engines.set(`text`,this._createTextEngine(!0,!1)),this._engines.set(`text:light`,this._createTextEngine(!1,!1)),this._engines.set(`id`,this._createAttributeEngine(`id`,!0)),this._engines.set(`id:light`,this._createAttributeEngine(`id`,!1)),this._engines.set(`data-testid`,this._createAttributeEngine(`data-testid`,!0)),this._engines.set(`data-testid:light`,this._createAttributeEngine(`data-testid`,!1)),this._engines.set(`data-test-id`,this._createAttributeEngine(`data-test-id`,!0)),this._engines.set(`data-test-id:light`,this._createAttributeEngine(`data-test-id`,!1)),this._engines.set(`data-test`,this._createAttributeEngine(`data-test`,!0)),this._engines.set(`data-test:light`,this._createAttributeEngine(`data-test`,!1)),this._engines.set(`css`,this._createCSSEngine()),this._engines.set(`nth`,{queryAll:()=>[]}),this._engines.set(`visible`,this._createVisibleEngine()),this._engines.set(`internal:control`,this._createControlEngine()),this._engines.set(`internal:has`,this._createHasEngine()),this._engines.set(`internal:has-not`,this._createHasNotEngine()),this._engines.set(`internal:and`,{queryAll:()=>[]}),this._engines.set(`internal:or`,{queryAll:()=>[]}),this._engines.set(`internal:chain`,this._createInternalChainEngine()),this._engines.set(`internal:label`,this._createInternalLabelEngine()),this._engines.set(`internal:text`,this._createTextEngine(!0,!0)),this._engines.set(`internal:has-text`,this._createInternalHasTextEngine()),this._engines.set(`internal:has-not-text`,this._createInternalHasNotTextEngine()),this._engines.set(`internal:attr`,this._createNamedAttributeEngine()),this._engines.set(`internal:testid`,this._createNamedAttributeEngine()),this._engines.set(`internal:role`,createRoleEngine(!0))}static create(T){return Object.assign(e.options,T),e.singleton||=new e}queryLocatorSelector(e,T=document.documentElement,E=!0){return this.querySelector(this.parseSelector(e),T,E)}queryLocatorSelectorAll(e,T=document.documentElement){return this.querySelectorAll(this.parseSelector(e),T)}querySelector(e,T,E=!0){let D=this.querySelectorAll(e,T);if(E&&D.length>1)throw this.strictModeViolationError(e,D);return D[0]||null}queryAllByRole(e,T,E=document.documentElement){let D=this.parseSelector(getByRoleSelector(e,T));return this.querySelectorAll(D,E)}queryAllByLabelText(e,T,E=document.documentElement){let D=this.parseSelector(getByLabelSelector(e,T));return this.querySelectorAll(D,E)}queryAllByTestId(T,E=document.documentElement){let D=this.parseSelector(getByTestIdSelector(e.options.testIdAttribute,T));return this.querySelectorAll(D,E)}queryAllByText(e,T,E=document.documentElement){let D=this.parseSelector(getByTextSelector(e,T));return this.querySelectorAll(D,E)}queryAllByTitle(e,T,E=document.documentElement){let D=this.parseSelector(getByTitleSelector(e,T));return this.querySelectorAll(D,E)}queryAllByPlaceholder(e,T,E=document.documentElement){let D=this.parseSelector(getByPlaceholderSelector(e,T));return this.querySelectorAll(D,E)}queryAllByAltText(e,T,E=document.documentElement){let D=this.parseSelector(getByAltTextSelector(e,T));return this.querySelectorAll(D,E)}queryByRole(e,T,E=document.documentElement){let D=this.parseSelector(getByRoleSelector(e,T));return this.querySelector(D,E,!1)}queryByLabelText(e,T,E=document.documentElement){let D=this.parseSelector(getByLabelSelector(e,T));return this.querySelector(D,E,!1)}queryByTestId(T,E=document.documentElement){let D=this.parseSelector(getByTestIdSelector(e.options.testIdAttribute,T));return this.querySelector(D,E,!1)}queryByText(e,T,E=document.documentElement){let D=this.parseSelector(getByTextSelector(e,T));return this.querySelector(D,E,!1)}queryByTitle(e,T,E=document.documentElement){let D=this.parseSelector(getByTitleSelector(e,T));return this.querySelector(D,E,!1)}queryByPlaceholder(e,T,E=document.documentElement){let D=this.parseSelector(getByPlaceholderSelector(e,T));return this.querySelector(D,E,!1)}queryByAltText(e,T,E=document.documentElement){let D=this.parseSelector(getByAltTextSelector(e,T));return this.querySelector(D,E,!1)}strictModeViolationError(e,T){let E=T.slice(0,10).map(e=>({preview:this.previewNode(e),selector:this.generateSelectorSimple(e)})),D=E.map((e,T)=>`
4
- ${T+1}) ${e.preview} aka ${asLocator(`javascript`,e.selector)}`);return E.length<T.length&&D.push(`
5
- ...`),this.createStacklessError(`strict mode violation: ${asLocator(`javascript`,stringifySelector(e))} resolved to ${T.length} elements:${D.join(``)}
6
- `)}generateSelectorSimple(T,E){return generateSelector(this,T,{...E,testIdAttributeName:e.options.testIdAttribute})}parseSelector(e){let T=parseSelector(e);return visitAllSelectorParts(T,T=>{if(!this._engines.has(T.name))throw this.createStacklessError(`Unknown engine "${T.name}" while parsing selector ${e}`)}),T}previewNode(e){if(e.nodeType===Node.TEXT_NODE)return oneLine(`#text=${e.nodeValue||``}`);if(e.nodeType!==Node.ELEMENT_NODE)return oneLine(`<${e.nodeName.toLowerCase()} />`);let T=e,E=[];for(let e=0;e<T.attributes.length;e++){let{name:D,value:O}=T.attributes[e];D!==`style`&&(!O&&booleanAttributes.has(D)?E.push(` ${D}`):E.push(` ${D}="${O}"`))}E.sort((e,T)=>e.length-T.length);let D=trimStringWithEllipsis(E.join(``),500);if(autoClosingTags.has(T.nodeName))return oneLine(`<${T.nodeName.toLowerCase()}${D}/>`);let O=T.childNodes,k=!1;if(O.length<=5){k=!0;for(let e=0;e<O.length;e++)k&&=O[e].nodeType===Node.TEXT_NODE}let A=k?T.textContent||``:O.length?`…`:``;return oneLine(`<${T.nodeName.toLowerCase()}${D}>${trimStringWithEllipsis(A,50)}</${T.nodeName.toLowerCase()}>`)}querySelectorAll(e,T){if(e.capture!==void 0){if(e.parts.some(e=>e.name===`nth`))throw this.createStacklessError(`Can't query n-th element in a request with the capture.`);let E={parts:e.parts.slice(0,e.capture+1)};if(e.capture<e.parts.length-1){let T={parts:e.parts.slice(e.capture+1)},D={name:`internal:has`,body:{parsed:T},source:stringifySelector(T)};E.parts.push(D)}return this.querySelectorAll(E,T)}if(!T.querySelectorAll)throw this.createStacklessError(`Node is not queryable.`);if(e.capture!==void 0)throw this.createStacklessError(`Internal error: there should not be a capture in the selector.`);if(T.nodeType===11&&e.parts.length===1&&e.parts[0].name===`css`&&e.parts[0].source===`:scope`)return[T];this._evaluator.begin();try{let E=new Set([T]);for(let D of e.parts)if(D.name===`nth`)E=this._queryNth(E,D);else if(D.name===`internal:and`){let e=this.querySelectorAll(D.body.parsed,T);E=new Set(e.filter(e=>E.has(e)))}else if(D.name===`internal:or`){let e=this.querySelectorAll(D.body.parsed,T);E=new Set(sortInDOMOrder(new Set([...E,...e])))}else if(kLayoutSelectorNames.includes(D.name))E=this._queryLayoutSelector(E,D,T);else{let e=new Set;for(let T of E){let E=this._queryEngineAll(D,T);for(let T of E)e.add(T)}E=e}return[...E]}finally{this._evaluator.end()}}_queryEngineAll(e,T){let E=this._engines.get(e.name).queryAll(T,e.body);for(let e of E)if(!(`nodeName`in e))throw this.createStacklessError(`Expected a Node but got ${Object.prototype.toString.call(e)}`);return E}_queryNth(e,T){let E=[...e],D=+T.body;return D===-1&&(D=E.length-1),new Set(E.slice(D,D+1))}_queryLayoutSelector(e,T,E){let D=T.name,O=T.body,k=[],A=this.querySelectorAll(O.parsed,E);for(let T of e){let e=layoutSelectorScore(D,T,A,O.distance);e!==void 0&&k.push({element:T,score:e})}return k.sort((e,T)=>e.score-T.score),new Set(k.map(e=>e.element))}createStacklessError(T){if(e.options.browser===`firefox`){let e=Error(`Error: ${T}`);return e.stack=``,e}let E=Error(T);return delete E.stack,E}_createTextEngine(e,T){return{queryAll:(E,D)=>{let{matcher:O,kind:k}=createTextMatcher(D,T),A=[],j=null,M=e=>{if(k===`lax`&&j&&j.contains(e))return!1;let E=elementMatchesText(this._evaluator._cacheText,e,O);E===`none`&&(j=e),(E===`self`||E===`selfAndChildren`&&k===`strict`&&!T)&&A.push(e)};E.nodeType===Node.ELEMENT_NODE&&M(E);let N=this._evaluator._queryCSS({scope:E,pierceShadow:e},`*`);for(let e of N)M(e);return A}}}_createAttributeEngine(e,T){let E=T=>[{simples:[{selector:{css:`[${e}=${JSON.stringify(T)}]`,functions:[]},combinator:``}]}];return{queryAll:(e,D)=>this._evaluator.query({scope:e,pierceShadow:T},E(D))}}_createCSSEngine(){return{queryAll:(e,T)=>this._evaluator.query({scope:e,pierceShadow:!0},T)}}_createNamedAttributeEngine(){return{queryAll:(e,T)=>{let E=parseAttributeSelector(T);if(E.name||E.attributes.length!==1)throw Error(`Malformed attribute selector: ${T}`);let{name:D,value:O,caseSensitive:k}=E.attributes[0],A=k?null:O.toLowerCase(),j;return j=O instanceof RegExp?e=>!!e.match(O):k?e=>e===O:e=>e.toLowerCase().includes(A),this._evaluator._queryCSS({scope:e,pierceShadow:!0},`[${D}]`).filter(e=>j(e.getAttribute(D)))}}}_createVisibleEngine(){return{queryAll:(e,T)=>e.nodeType===1&&isElementVisible(e)===!!T?[e]:[]}}_createControlEngine(){return{queryAll:(e,T)=>{if(T===`enter-frame`&&e instanceof HTMLIFrameElement){let T=e.contentDocument?.documentElement;return T?[T]:[]}return[]}}}_createHasEngine(){return{queryAll:(e,T)=>e.nodeType===1&&this.querySelector(T.parsed,e,!1)?[e]:[]}}_createHasNotEngine(){return{queryAll:(e,T)=>e.nodeType===1?this.querySelector(T.parsed,e,!1)?[]:[e]:[]}}_createInternalChainEngine(){return{queryAll:(e,T)=>this.querySelectorAll(T.parsed,e)}}_createInternalLabelEngine(){return{queryAll:(e,T)=>{let{matcher:E}=createTextMatcher(T,!0);return this._evaluator._queryCSS({scope:e,pierceShadow:!0},`*`).filter(e=>getElementLabels(this._evaluator._cacheText,e).some(e=>E(e)))}}}_createInternalHasTextEngine(){return{queryAll:(e,T)=>{if(e.nodeType!==1)return[];let E=e,D=elementText(this._evaluator._cacheText,E),{matcher:O}=createTextMatcher(T,!0);return O(D)?[E]:[]}}}_createInternalHasNotTextEngine(){return{queryAll:(e,T)=>{if(e.nodeType!==1)return[];let E=e,D=elementText(this._evaluator._cacheText,E),{matcher:O}=createTextMatcher(T,!0);return O(D)?[]:[E]}}}};__publicField(_Ivya,`options`,{testIdAttribute:`data-testid`,browser:`chromium`}),__publicField(_Ivya,`singleton`,null);var Ivya=_Ivya;function oneLine(e){return e.replace(/\n/g,`↵`).replace(/\t/g,`⇆`)}var booleanAttributes=new Set([`checked`,`selected`,`disabled`,`readonly`,`multiple`]),autoClosingTags=new Set([`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`MENUITEM`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`]);function cssUnquote(e){if(e=e.substring(1,e.length-1),!e.includes(`\\`))return e;let T=[],E=0;for(;E<e.length;)e[E]===`\\`&&E+1<e.length&&E++,T.push(e[E++]);return T.join(``)}function createTextMatcher(e,T){if(e[0]===`/`&&e.lastIndexOf(`/`)>0){let T=e.lastIndexOf(`/`),E=new RegExp(e.substring(1,T),e.substring(T+1));return{matcher:e=>E.test(e.full),kind:`regex`}}let E=T?JSON.parse.bind(JSON):cssUnquote,D=!1;return e.length>1&&e[0]===`"`&&e[e.length-1]===`"`?(e=E(e),D=!0):T&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`i`?(e=E(e.substring(0,e.length-1)),D=!1):T&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`s`?(e=E(e.substring(0,e.length-1)),D=!0):e.length>1&&e[0]===`'`&&e[e.length-1]===`'`&&(e=E(e),D=!0),e=normalizeWhiteSpace(e),D?T?{kind:`strict`,matcher:T=>T.normalized===e}:{matcher:T=>!e&&!T.immediate.length?!0:T.immediate.some(T=>normalizeWhiteSpace(T)===e),kind:`strict`}:(e=e.toLowerCase(),{kind:`lax`,matcher:T=>T.normalized.toLowerCase().includes(e)})}var XPathEngine={queryAll(e,T){T.startsWith(`/`)&&e.nodeType!==Node.DOCUMENT_NODE&&(T=`.${T}`);let E=[],D=e.ownerDocument||e;if(!D)return E;let O=D.evaluate(T,e,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE);for(let e=O.iterateNext();e;e=O.iterateNext())e.nodeType===Node.ELEMENT_NODE&&E.push(e);return E}};function parentElementOrShadowHost(e){if(e.parentElement)return e.parentElement;if(e.parentNode&&e.parentNode.nodeType===11&&e.parentNode.host)return e.parentNode.host}function enclosingShadowRootOrDocument(e){let T=e;for(;T.parentNode;)T=T.parentNode;if(T.nodeType===11||T.nodeType===9)return T}function enclosingShadowHost(e){for(;e.parentElement;)e=e.parentElement;return parentElementOrShadowHost(e)}function closestCrossShadow(e,T){for(;e;){let E=e.closest(T);if(E)return E;e=enclosingShadowHost(e)}}function getElementComputedStyle(e,T){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,T):void 0}function isElementStyleVisibilityVisible(e,T){if(T??=getElementComputedStyle(e),!T)return!0;if(Element.prototype.checkVisibility&&Ivya.options.browser!==`webkit`){if(!e.checkVisibility())return!1}else{let T=e.closest(`details,summary`);if(T!==e&&T?.nodeName===`DETAILS`&&!T.open)return!1}return T.visibility===`visible`}function isElementVisible(e){let T=getElementComputedStyle(e);if(!T)return!0;if(T.display===`contents`){for(let T=e.firstChild;T;T=T.nextSibling)if(T.nodeType===1&&isElementVisible(T)||T.nodeType===3&&isVisibleTextNode(T))return!0;return!1}if(!isElementStyleVisibilityVisible(e,T))return!1;let E=e.getBoundingClientRect();return E.width>0&&E.height>0}function isVisibleTextNode(e){let T=e.ownerDocument.createRange();T.selectNode(e);let E=T.getBoundingClientRect();return E.width>0&&E.height>0}function elementSafeTagName(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function ensureAwaited(e){let T=getWorkerState().current;if(!T||T.type!==`test`)return e();let E=!1,D=Error(`STACK_TRACE_ERROR`);T.onFinished??=[],T.onFinished.push(()=>{if(!E){let e=Error(`The call was not awaited. This method is asynchronous and must be awaited; otherwise, the call will not start to avoid unhandled rejections.`);throw e.stack=D.stack?.replace(D.message,e.message),e}});let O;return{then(T,k){return E=!0,(O||=e(D)).then(T,k)},catch(T){return(O||=e(D)).catch(T)},finally(T){return(O||=e(D)).finally(T)},[Symbol.toStringTag]:`Promise`}}function getBrowserState(){return window.__vitest_browser_runner__}function getWorkerState(){let e=window.__vitest_worker__;if(!e)throw Error(`Worker state is not found. This is an issue with Vitest. Please, open an issue.`);return e}function convertElementToCssSelector(e){if(!e||!(e instanceof Element))throw Error(`Expected DOM element to be an instance of Element, received ${typeof e}`);return getUniqueCssSelector(e)}function escapeIdForCSSSelector(e){return e.split(``).map(e=>{let T=e.charCodeAt(0);return e===` `||e===`#`||e===`.`||e===`:`||e===`[`||e===`]`||e===`>`||e===`+`||e===`~`||e===`\\`?`\\${e}`:T>=65536?`\\${T.toString(16).toUpperCase().padStart(6,`0`)} `:T<32||T===127||T>=128?`\\${T.toString(16).toUpperCase().padStart(2,`0`)} `:e}).join(``)}function getUniqueCssSelector(e){let T=[],E,D=!1;for(;E=getParent(e);){E.shadowRoot&&(D=!0);let O=e.tagName;if(e.id)T.push(`#${escapeIdForCSSSelector(e.id)}`);else if(!e.nextElementSibling&&!e.previousElementSibling)T.push(O.toLowerCase());else{let D=0,k=0,A=0;for(let T of E.children)D++,T.tagName===O&&k++,T===e&&(A=D);k>1?T.push(`${O.toLowerCase()}:nth-child(${A})`):T.push(O.toLowerCase())}e=E}return`${getBrowserState().provider===`webdriverio`&&D?`>>>`:``}${T.reverse().join(` > `)}`}function getParent(e){let T=e.parentNode;return T instanceof ShadowRoot?T.host:T}const now$1=Date.now;function processTimeoutOptions(e){if(e&&e.timeout!=null||getWorkerState().config.browser.providerOptions.actionTimeout!=null)return e;let T=getBrowserState().runner,E=T._currentTaskStartTime;if(!E)return e;let D=T._currentTaskTimeout;if(D===0||D==null||D===1/0)return e;e||={};let O=now$1(),k=E+D-O;return k<=0||(e.timeout=k-100),e}function getIframeScale(){let e=window.parent.document.querySelector(`iframe[data-vitest]`)?.parentElement;if(!e)throw Error(`Cannot find Tester element. This is a bug in Vitest. Please, open a new issue with reproduction.`);let T=e.getAttribute(`data-scale`),E=Number(T);if(Number.isNaN(E))throw TypeError(`Cannot parse scale value from Tester element (${T}). This is a bug in Vitest. Please, open a new issue with reproduction.`);return E}function escapeRegexForSelector(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function escapeForTextSelector(e,T){return typeof e==`string`?`${JSON.stringify(e)}i`:escapeRegexForSelector(e)}const provider=getBrowserState().provider,kElementLocator=Symbol.for(`$$vitest:locator-resolved`);async function convertToSelector(e,T){if(!e)throw Error(`Expected element or locator to be defined.`);if(e instanceof Element)return convertElementToCssSelector(e);if(isLocator(e))return provider===`playwright`||kElementLocator in e?e.selector:convertElementToCssSelector(await e.findElement(T));throw Error(`Expected element or locator to be an instance of Element or Locator.`)}const kLocator$1=Symbol.for(`$$vitest:locator`);function isLocator(e){return!!e&&typeof e==`object`&&kLocator$1 in e}const DEFAULT_WHEEL_DELTA=100;function resolveUserEventWheelOptions(e){let T;if(e.delta)T=e.delta;else switch(e.direction){case`up`:T={y:-100};break;case`down`:T={y:100};break;case`left`:T={x:-100};break;case`right`:T={x:100};break}return{delta:T,times:e.times}}__INTERNAL._asLocator=asLocator;const now=Date.now,waitForIntervals=[0,20,50,100,100,500];function sleep(e){let{setTimeout:T}=getSafeTimers();return new Promise(E=>T(E,e))}const selectorEngine=Ivya.create({browser:(e=>{switch(e){case`edge`:case`chrome`:return`chromium`;case`safari`:return`webkit`;default:return e}})(server.config.browser.name),testIdAttribute:server.config.browser.locators.testIdAttribute}),kLocator=Symbol.for(`$$vitest:locator`);class Locator{_parsedSelector;_container;_pwSelector;_errorSource;constructor(){Object.defineProperty(this,kLocator,{enumerable:!1,writable:!1,configurable:!1,value:kLocator})}click(e){return this.triggerCommand(`__vitest_click`,this.selector,e)}dblClick(e){return this.triggerCommand(`__vitest_dblClick`,this.selector,e)}tripleClick(e){return this.triggerCommand(`__vitest_tripleClick`,this.selector,e)}wheel(e){return ensureAwaited(async T=>{await getBrowserState().commands.triggerCommand(`__vitest_wheel`,[this.selector,resolveUserEventWheelOptions(e)],T);let E=getBrowserState().config.browser.name;if(E===`chromium`||E===`chrome`)return new Promise(e=>{requestAnimationFrame(()=>{e()})})})}clear(e){return this.triggerCommand(`__vitest_clear`,this.selector,e)}hover(e){return this.triggerCommand(`__vitest_hover`,this.selector,e)}unhover(e){return this.triggerCommand(`__vitest_hover`,`html > body`,e)}fill(e,T){return this.triggerCommand(`__vitest_fill`,this.selector,e,T)}upload(e,T){return ensureAwaited(async E=>{let D=(Array.isArray(e)?e:[e]).map(async e=>{if(typeof e==`string`)return e;let T=await new Promise((T,E)=>{let D=new FileReader;D.onload=()=>T(D.result),D.onerror=()=>E(Error(`Failed to read file: ${e.name}`)),D.readAsDataURL(e)});return{name:e.name,mimeType:e.type,base64:T.slice(T.indexOf(`,`)+1)}});return getBrowserState().commands.triggerCommand(`__vitest_upload`,[this.selector,await Promise.all(D),T],E)})}dropTo(e,T={}){return this.triggerCommand(`__vitest_dragAndDrop`,this.selector,e.selector,T)}selectOptions(e,T){let E=(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?e:{element:isLocator(e)?e.selector:selectorEngine.generateSelectorSimple(e)});return this.triggerCommand(`__vitest_selectOptions`,this.selector,E,T)}screenshot(e){return page.screenshot({...e,element:this})}mark(e,T){let E=getWorkerState().current;return!E||!getBrowserState().activeTraceTaskIds.has(E.id)?Promise.resolve():ensureAwaited(E=>getBrowserState().commands.triggerCommand(`__vitest_markTrace`,[{name:e,selector:this.selector,stack:T?.stack??E?.stack}],E))}getByRole(e,T){return this.locator(getByRoleSelector(e,T))}getByAltText(e,T){return this.locator(getByAltTextSelector(e,T))}getByLabelText(e,T){return this.locator(getByLabelSelector(e,T))}getByPlaceholder(e,T){return this.locator(getByPlaceholderSelector(e,T))}getByTestId(T){return this.locator(getByTestIdSelector(server.config.browser.locators.testIdAttribute,T))}getByText(e,T){return this.locator(getByTextSelector(e,T))}getByTitle(e,T){return this.locator(getByTitleSelector(e,T))}filter(e){let T=[];if(e?.hasText&&T.push(`internal:has-text=${escapeForTextSelector(e.hasText)}`),e?.hasNotText&&T.push(`internal:has-not-text=${escapeForTextSelector(e.hasNotText)}`),e?.has){let E=e.has;T.push(`internal:has=${JSON.stringify(E._pwSelector||E.selector)}`)}if(e?.hasNot){let E=e.hasNot;T.push(`internal:has-not=${JSON.stringify(E._pwSelector||E.selector)}`)}if(!T.length)throw Error(`Locator.filter expects at least one filter. None provided.`);return this.locator(T.join(` >> `))}and(e){return this.locator(`internal:and=${JSON.stringify(e._pwSelector||e.selector)}`)}or(e){return this.locator(`internal:or=${JSON.stringify(e._pwSelector||e.selector)}`)}query(){let e=this._parsedSelector||=selectorEngine.parseSelector(this._pwSelector||this.selector);return selectorEngine.querySelector(e,document.documentElement,!0)}element(){let e=this.query();if(!e)throw utils.getElementError(this._pwSelector||this.selector,this._container||document.body);return e}elements(){let e=this._parsedSelector||=selectorEngine.parseSelector(this._pwSelector||this.selector);return selectorEngine.querySelectorAll(e,document.documentElement)}get length(){return this.elements().length}all(){return this.elements().map(e=>this.elementLocator(e))}nth(e){return this.locator(`nth=${e}`)}first(){return this.nth(0)}last(){return this.nth(-1)}toString(){return this.selector}toJSON(){return this.selector}async findElement(e={}){let T=processTimeoutOptions(e),D=T?.timeout,O=T?.strict??!0,k=now(),A=0;for(;;){let e=this.elements();if(e.length===1)return e[0];if(e.length>1){if(O)throw createStrictModeViolationError(this._pwSelector||this.selector,e);return e[0]}let T=now()-k;if(D!=null&&T>=D)throw utils.getElementError(this._pwSelector||this.selector,this._container||document.body);let j=waitForIntervals[Math.min(A++,waitForIntervals.length-1)];await sleep(D==null?j:Math.min(j,D-T))}}triggerCommand(e,...T){return this._errorSource?triggerCommandWithTrace({name:e,arguments:T,errorSource:this._errorSource}):ensureAwaited(E=>triggerCommandWithTrace({name:e,arguments:T,errorSource:E}))}}function triggerCommandWithTrace(e){return getBrowserState().commands.triggerCommand(e.name,e.arguments,e.errorSource)}function createStrictModeViolationError(e,T){let E=T.slice(0,10).map(e=>({preview:selectorEngine.previewNode(e),selector:selectorEngine.generateSelectorSimple(e)})),D=E.map((e,T)=>`\n ${T+1}) ${e.preview} aka ${asLocator(`javascript`,e.selector)}`);return E.length<T.length&&D.push(`
7
- ...`),Error(`strict mode violation: ${asLocator(`javascript`,e)} resolved to ${T.length} elements:${D.join(``)}\n`)}export{triggerCommandWithTrace as A,Locator as L,getAriaRole as a,getAriaDisabled as b,beginAriaCaches as c,getElementAccessibleDescription as d,endAriaCaches as e,getElementAccessibleErrorMessage as f,getAriaChecked as g,getElementAccessibleName as h,isElementVisible as i,cssEscape as j,kAriaCheckedRoles as k,convertToSelector as l,getBrowserState as m,getWorkerState as n,convertElementToCssSelector as o,processTimeoutOptions as p,ensureAwaited as q,getByAltTextSelector as r,getByLabelSelector as s,getByPlaceholderSelector as t,getByRoleSelector as u,getByTestIdSelector as v,getByTextSelector as w,getByTitleSelector as x,getIframeScale as y,selectorEngine as z};