@dev-blinq/cucumber_client 1.0.1670-dev → 1.0.1672-dev
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.
|
@@ -15,7 +15,7 @@ ${e.stack}`,{e:{n:e.name,m:e.message,s:l}}}if(Ql(e))return{d:e.toJSON()};if(Xl(e
|
|
|
15
15
|
})()`);return new n(this,t)}async viewportRatio(e){return await new Promise(t=>{let n=new IntersectionObserver(r=>{t(r[0].intersectionRatio),n.disconnect()});n.observe(e),this.utils.builtins.requestAnimationFrame(()=>{})})}getElementBorderWidth(e){if(e.nodeType!==Node.ELEMENT_NODE||!e.ownerDocument||!e.ownerDocument.defaultView)return{left:0,top:0};let t=e.ownerDocument.defaultView.getComputedStyle(e);return{left:parseInt(t.borderLeftWidth||"",10),top:parseInt(t.borderTopWidth||"",10)}}describeIFrameStyle(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return"error:notconnected";let t=e.ownerDocument.defaultView;for(let r=e;r;r=me(r))if(t.getComputedStyle(r).transform!=="none")return"transformed";let n=t.getComputedStyle(e);return{left:parseInt(n.borderLeftWidth||"",10)+parseInt(n.paddingLeft||"",10),top:parseInt(n.borderTopWidth||"",10)+parseInt(n.paddingTop||"",10)}}retarget(e,t){let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;if(!n)return null;if(t==="none")return n;if(!n.matches("input, textarea, select")&&!n.isContentEditable&&(t==="button-link"?n=n.closest("button, [role=button], a, [role=link]")||n:n=n.closest("button, [role=button], [role=checkbox], [role=radio]")||n),t==="follow-label"&&!n.matches("a, input, textarea, button, select, [role=link], [role=button], [role=checkbox], [role=radio]")&&!n.isContentEditable){let r=n.closest("label");r&&r.control&&(n=r.control)}return n}async checkElementStates(e,t){if(t.includes("stable")){let n=await this._checkElementIsStable(e);if(n===!1)return{missingState:"stable"};if(n==="error:notconnected")return"error:notconnected"}for(let n of t)if(n!=="stable"){let r=this.elementState(e,n);if(r.received==="error:notconnected")return"error:notconnected";if(!r.matches)return{missingState:n}}}async _checkElementIsStable(e){let t=Symbol("continuePolling"),n,r=0,o=0,u=()=>{let v=this.retarget(e,"no-follow-label");if(!v)return"error:notconnected";let m=this.utils.builtins.performance.now();if(this._stableRafCount>1&&m-o<15)return t;o=m;let y=v.getBoundingClientRect(),w={x:y.top,y:y.left,width:y.width,height:y.height};if(n){if(!(w.x===n.x&&w.y===n.y&&w.width===n.width&&w.height===n.height))return!1;if(++r>=this._stableRafCount)return!0}return n=w,t},l,h,p=new Promise((v,m)=>{l=v,h=m}),b=()=>{try{let v=u();v!==t?l(v):this.utils.builtins.requestAnimationFrame(b)}catch(v){h(v)}};return this.utils.builtins.requestAnimationFrame(b),p}_createAriaRefEngine(){return{queryAll:(t,n)=>{var r,o;let u=(o=(r=this._lastAriaSnapshot)==null?void 0:r.elements)==null?void 0:o.get(n);return u&&u.isConnected?[u]:[]}}}elementState(e,t){let n=this.retarget(e,["visible","hidden"].includes(t)?"none":"follow-label");if(!n||!n.isConnected)return t==="hidden"?{matches:!0,received:"hidden"}:{matches:!1,received:"error:notconnected"};if(t==="visible"||t==="hidden"){let r=Ge(n);return{matches:t==="visible"?r:!r,received:r?"visible":"hidden"}}if(t==="disabled"||t==="enabled"){let r=tn(n);return{matches:t==="disabled"?r:!r,received:r?"disabled":"enabled"}}if(t==="editable"){let r=tn(n),o=Oo(n);if(o==="error")throw this.createStacklessError("Element is not an <input>, <textarea>, <select> or [contenteditable] and does not have a role allowing [aria-readonly]");return{matches:!r&&!o,received:r?"disabled":o?"readOnly":"editable"}}if(t==="checked"||t==="unchecked"){let r=t==="checked",o=Lo(n);if(o==="error")throw this.createStacklessError("Not a checkbox or radio button");return{matches:r===o,received:o?"checked":"unchecked"}}if(t==="indeterminate"){let r=Io(n);if(r==="error")throw this.createStacklessError("Not a checkbox or radio button");return{matches:r==="mixed",received:r===!0?"checked":r===!1?"unchecked":"mixed"}}throw this.createStacklessError(`Unexpected element state "${t}"`)}selectOptions(e,t){let n=this.retarget(e,"follow-label");if(!n)return"error:notconnected";if(n.nodeName.toLowerCase()!=="select")throw this.createStacklessError("Element is not a <select> element");let r=n,o=[...r.options],u=[],l=t.slice();for(let h=0;h<o.length;h++){let p=o[h],b=v=>{if(v instanceof Node)return p===v;let m=!0;return v.valueOrLabel!==void 0&&(m=m&&(v.valueOrLabel===p.value||v.valueOrLabel===p.label)),v.value!==void 0&&(m=m&&v.value===p.value),v.label!==void 0&&(m=m&&v.label===p.label),v.index!==void 0&&(m=m&&v.index===h),m};if(l.some(b))if(u.push(p),r.multiple)l=l.filter(v=>!b(v));else{l=[];break}}return l.length?"error:optionsnotfound":(r.value=void 0,u.forEach(h=>h.selected=!0),r.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})),u.map(h=>h.value))}fill(e,t){let n=this.retarget(e,"follow-label");if(!n)return"error:notconnected";if(n.nodeName.toLowerCase()==="input"){let r=n,o=r.type.toLowerCase(),u=new Set(["color","date","time","datetime-local","month","range","week"]);if(!new Set(["","email","number","password","search","tel","text","url"]).has(o)&&!u.has(o))throw this.createStacklessError(`Input of type "${o}" cannot be filled`);if(o==="number"&&(t=t.trim(),isNaN(Number(t))))throw this.createStacklessError("Cannot type text into input[type=number]");if(u.has(o)){if(t=t.trim(),r.focus(),r.value=t,r.value!==t)throw this.createStacklessError("Malformed value");return n.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),n.dispatchEvent(new Event("change",{bubbles:!0})),"done"}}else if(n.nodeName.toLowerCase()!=="textarea"){if(!n.isContentEditable)throw this.createStacklessError("Element is not an <input>, <textarea> or [contenteditable] element")}return this.selectText(n),"needsinput"}selectText(e){let t=this.retarget(e,"follow-label");if(!t)return"error:notconnected";if(t.nodeName.toLowerCase()==="input"){let o=t;return o.select(),o.focus(),"done"}if(t.nodeName.toLowerCase()==="textarea"){let o=t;return o.selectionStart=0,o.selectionEnd=o.value.length,o.focus(),"done"}let n=t.ownerDocument.createRange();n.selectNodeContents(t);let r=t.ownerDocument.defaultView.getSelection();return r&&(r.removeAllRanges(),r.addRange(n)),t.focus(),"done"}_activelyFocused(e){let t=e.getRootNode().activeElement,n=t===e&&!!e.ownerDocument&&e.ownerDocument.hasFocus();return{activeElement:t,isFocused:n}}focusNode(e,t){if(!e.isConnected)return"error:notconnected";if(e.nodeType!==Node.ELEMENT_NODE)throw this.createStacklessError("Node is not an element");let{activeElement:n,isFocused:r}=this._activelyFocused(e);if(e.isContentEditable&&!r&&n&&n.blur&&n.blur(),e.focus(),e.focus(),t&&!r&&e.nodeName.toLowerCase()==="input")try{e.setSelectionRange(0,0)}catch{}return"done"}blurNode(e){if(!e.isConnected)return"error:notconnected";if(e.nodeType!==Node.ELEMENT_NODE)throw this.createStacklessError("Node is not an element");return e.blur(),"done"}setInputFiles(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"Node is not of type HTMLElement";let n=e;if(n.nodeName!=="INPUT")return"Not an <input> element";let r=n;if((r.getAttribute("type")||"").toLowerCase()!=="file")return"Not an input[type=file] element";let u=t.map(h=>{let p=Uint8Array.from(atob(h.buffer),b=>b.charCodeAt(0));return new File([p],h.name,{type:h.mimeType,lastModified:h.lastModifiedMs})}),l=new DataTransfer;for(let h of u)l.items.add(h);r.files=l.files,r.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),r.dispatchEvent(new Event("change",{bubbles:!0}))}expectHitTarget(e,t){let n=[],r=t;for(;r;){let m=Yr(r);if(!m||(n.push(m),m.nodeType===9))break;r=m.host}let o;for(let m=n.length-1;m>=0;m--){let y=n[m],w=y.elementsFromPoint(e.x,e.y),A=y.elementFromPoint(e.x,e.y);if(A&&w[0]&&me(A)===w[0]){let P=this.window.getComputedStyle(A);P?.display==="contents"&&w.unshift(A)}w[0]&&w[0].shadowRoot===y&&w[1]===A&&w.shift();let I=w[0];if(!I||(o=I,m&&I!==n[m-1].host))break}let u=[],l=[];for(;o&&o!==t;)u.push(o),l.push(["sticky","fixed"].includes(this.window.getComputedStyle(o).position)),o=me(o);if(o===t)return"done";let h=this.previewNode(u[0]||this.document.documentElement),p=l.some(m=>m),b,v=t;for(;v;){let m=u.indexOf(v);if(m!==-1){m>1&&(b=this.previewNode(u[m-1])),p=l.slice(0,m).some(y=>y);break}v=me(v)}return b?{hitTargetDescription:`${h} from ${b} subtree`,hasPositionStickyOrFixed:p}:{hitTargetDescription:h,hasPositionStickyOrFixed:p}}setupHitTargetInterceptor(e,t,n,r){let o=this.retarget(e,"button-link");if(!o||!o.isConnected)return"error:notconnected";if(n){let b=this.expectHitTarget(n,o);if(b!=="done")return JSON.stringify(b)}if(t==="drag")return{stop:()=>"done"};let u={hover:this._hoverHitTargetInterceptorEvents,tap:this._tapHitTargetInterceptorEvents,mouse:this._mouseHitTargetInterceptorEvents}[t],l,h=b=>{if(!u.has(b.type)||!b.isTrusted)return;let v=this.window.TouchEvent&&b instanceof this.window.TouchEvent?b.touches[0]:b;l===void 0&&v&&(l=this.expectHitTarget({x:v.clientX,y:v.clientY},o)),(r||l!=="done"&&l!==void 0)&&(b.preventDefault(),b.stopPropagation(),b.stopImmediatePropagation())},p=()=>(this._hitTargetInterceptor===h&&(this._hitTargetInterceptor=void 0),l||"done");return this._hitTargetInterceptor=h,{stop:p}}dispatchEvent(e,t,n){var r,o,u;let l,h={bubbles:!0,cancelable:!0,composed:!0,...n};switch(this._eventTypes.get(t)){case"mouse":l=new MouseEvent(t,h);break;case"keyboard":l=new KeyboardEvent(t,h);break;case"touch":{if(this._browserName==="webkit"){let p=v=>{var m,y;if(v instanceof Touch)return v;let w=v.pageX;w===void 0&&v.clientX!==void 0&&(w=v.clientX+(((m=this.document.scrollingElement)==null?void 0:m.scrollLeft)||0));let A=v.pageY;return A===void 0&&v.clientY!==void 0&&(A=v.clientY+(((y=this.document.scrollingElement)==null?void 0:y.scrollTop)||0)),this.document.createTouch(this.window,v.target??e,v.identifier,w,A,v.screenX,v.screenY,v.radiusX,v.radiusY,v.rotationAngle,v.force)},b=v=>v instanceof TouchList||!v?v:this.document.createTouchList(...v.map(p));h.target??=e,h.touches=b(h.touches),h.targetTouches=b(h.targetTouches),h.changedTouches=b(h.changedTouches),l=new TouchEvent(t,h)}else h.target??=e,h.touches=(r=h.touches)==null?void 0:r.map(p=>p instanceof Touch?p:new Touch({...p,target:p.target??e})),h.targetTouches=(o=h.targetTouches)==null?void 0:o.map(p=>p instanceof Touch?p:new Touch({...p,target:p.target??e})),h.changedTouches=(u=h.changedTouches)==null?void 0:u.map(p=>p instanceof Touch?p:new Touch({...p,target:p.target??e})),l=new TouchEvent(t,h);break}case"pointer":l=new PointerEvent(t,h);break;case"focus":l=new FocusEvent(t,h);break;case"drag":l=new DragEvent(t,h);break;case"wheel":l=new WheelEvent(t,h);break;case"deviceorientation":try{l=new DeviceOrientationEvent(t,h)}catch{let{bubbles:p,cancelable:b,alpha:v,beta:m,gamma:y,absolute:w}=h;l=this.document.createEvent("DeviceOrientationEvent"),l.initDeviceOrientationEvent(t,p,b,v,m,y,w)}break;case"devicemotion":try{l=new DeviceMotionEvent(t,h)}catch{let{bubbles:p,cancelable:b,acceleration:v,accelerationIncludingGravity:m,rotationRate:y,interval:w}=h;l=this.document.createEvent("DeviceMotionEvent"),l.initDeviceMotionEvent(t,p,b,v,m,y,w)}break;default:l=new Event(t,h);break}e.dispatchEvent(l)}previewNode(e){if(e.nodeType===Node.TEXT_NODE)return Rn(`#text=${e.nodeValue||""}`);if(e.nodeType!==Node.ELEMENT_NODE)return Rn(`<${e.nodeName.toLowerCase()} />`);let t=e,n=[];for(let h=0;h<t.attributes.length;h++){let{name:p,value:b}=t.attributes[h];p!=="style"&&(!b&&this._booleanAttributes.has(p)?n.push(` ${p}`):n.push(` ${p}="${b}"`))}n.sort((h,p)=>h.length-p.length);let r=Mr(n.join(""),500);if(this._autoClosingTags.has(t.nodeName))return Rn(`<${t.nodeName.toLowerCase()}${r}/>`);let o=t.childNodes,u=!1;if(o.length<=5){u=!0;for(let h=0;h<o.length;h++)u=u&&o[h].nodeType===Node.TEXT_NODE}let l=u?t.textContent||"":o.length?"\u2026":"";return Rn(`<${t.nodeName.toLowerCase()}${r}>${Mr(l,50)}</${t.nodeName.toLowerCase()}>`)}strictModeViolationError(e,t){let n=t.slice(0,10).map(o=>({preview:this.previewNode(o),selector:this.generateSelectorSimple(o)})),r=n.map((o,u)=>`
|
|
16
16
|
${u+1}) ${o.preview} aka ${Qt(this._sdkLanguage,o.selector)}`);return n.length<t.length&&r.push(`
|
|
17
17
|
...`),this.createStacklessError(`strict mode violation: ${Qt(this._sdkLanguage,je(e))} resolved to ${t.length} elements:${r.join("")}
|
|
18
|
-
`)}createStacklessError(e){if(this._browserName==="firefox"){let n=new Error("Error: "+e);return n.stack="",n}let t=new Error(e);return delete t.stack,t}createHighlight(){return new Or(this)}maskSelectors(e,t){this._highlight&&this.hideHighlight(),this._highlight=new Or(this),this._highlight.install();let n=[];for(let r of e)n.push(this.querySelectorAll(r,this.document.documentElement));this._highlight.maskElements(n.flat(),t)}highlight(e){this._highlight||(this._highlight=new Or(this),this._highlight.install()),this._highlight.runHighlightOnRaf(e)}hideHighlight(){this._highlight&&(this._highlight.uninstall(),delete this._highlight)}markTargetElements(e,t){var n,r;((n=this._markedElements)==null?void 0:n.callId)!==t&&(this._markedElements=void 0);let o=((r=this._markedElements)==null?void 0:r.elements)||new Set,u=new CustomEvent("__playwright_unmark_target__",{bubbles:!0,cancelable:!0,detail:t,composed:!0});for(let h of o)e.has(h)||h.dispatchEvent(u);let l=new CustomEvent("__playwright_mark_target__",{bubbles:!0,cancelable:!0,detail:t,composed:!0});for(let h of e)o.has(h)||h.dispatchEvent(l);this._markedElements={callId:t,elements:e}}_setupGlobalListenersRemovalDetection(){let e="__playwright_global_listeners_check__",t=!1,n=()=>t=!0;this.window.addEventListener(e,n),new MutationObserver(r=>{if(r.some(u=>Array.from(u.addedNodes).includes(this.document.documentElement))&&(t=!1,this.window.dispatchEvent(new CustomEvent(e)),!t)){this.window.addEventListener(e,n);for(let u of this.onGlobalListenersRemoved)u()}}).observe(this.document,{childList:!0})}_setupHitTargetInterceptors(){let e=n=>{var r;return(r=this._hitTargetInterceptor)==null?void 0:r.call(this,n)},t=()=>{for(let n of this._allHitTargetInterceptorEvents)this.window.addEventListener(n,e,{capture:!0,passive:!1})};t(),this.onGlobalListenersRemoved.add(t)}async expect(e,t,n){return t.expression==="to.have.count"||t.expression.endsWith(".array")?this.expectArray(n,t):e?await this.expectSingleElement(e,t):!t.isNot&&t.expression==="to.be.hidden"?{matches:!0}:t.isNot&&t.expression==="to.be.visible"?{matches:!1}:!t.isNot&&t.expression==="to.be.detached"?{matches:!0}:t.isNot&&t.expression==="to.be.attached"?{matches:!1}:t.isNot&&t.expression==="to.be.in.viewport"?{matches:!1}:{matches:t.isNot,missingReceived:!0}}async expectSingleElement(e,t){var n;let r=t.expression;{let o;if(r==="to.have.attribute"){let u=e.hasAttribute(t.expressionArg);o={matches:u,received:u?"attribute present":"attribute not present"}}else if(r==="to.be.checked"){let{checked:u,indeterminate:l}=t.expectedValue;if(l){if(u!==void 0)throw this.createStacklessError("Can't assert indeterminate and checked at the same time");o=this.elementState(e,"indeterminate")}else o=this.elementState(e,u===!1?"unchecked":"checked")}else if(r==="to.be.disabled")o=this.elementState(e,"disabled");else if(r==="to.be.editable")o=this.elementState(e,"editable");else if(r==="to.be.readonly")o=this.elementState(e,"editable"),o.matches=!o.matches;else if(r==="to.be.empty")if(e.nodeName==="INPUT"||e.nodeName==="TEXTAREA"){let u=e.value;o={matches:!u,received:u?"notEmpty":"empty"}}else{let u=(n=e.textContent)==null?void 0:n.trim();o={matches:!u,received:u?"notEmpty":"empty"}}else if(r==="to.be.enabled")o=this.elementState(e,"enabled");else if(r==="to.be.focused"){let u=this._activelyFocused(e).isFocused;o={matches:u,received:u?"focused":"inactive"}}else r==="to.be.hidden"?o=this.elementState(e,"hidden"):r==="to.be.visible"?o=this.elementState(e,"visible"):r==="to.be.attached"?o={matches:!0,received:"attached"}:r==="to.be.detached"&&(o={matches:!1,received:"attached"});if(o){if(o.received==="error:notconnected")throw this.createStacklessError("Element is not connected");return o}}if(r==="to.have.property"){let o=e,u=t.expressionArg.split(".");for(let p=0;p<u.length-1;p++){if(typeof o!="object"||!(u[p]in o))return{received:void 0,matches:!1};o=o[u[p]]}let l=o[u[u.length-1]],h=Hr(l,t.expectedValue);return{received:l,matches:h}}if(r==="to.be.in.viewport"){let o=await this.viewportRatio(e);return{received:`viewport ratio ${o}`,matches:o>0&&o>(t.expectedNumber??0)-1e-9}}if(r==="to.have.values"){if(e=this.retarget(e,"follow-label"),e.nodeName!=="SELECT"||!e.multiple)throw this.createStacklessError("Not a select element with a multiple attribute");let o=[...e.selectedOptions].map(u=>u.value);return o.length!==t.expectedText.length?{received:o,matches:!1}:{received:o,matches:o.map((u,l)=>new Dn(t.expectedText[l]).matches(u)).every(Boolean)}}if(r==="to.match.aria"){let o=al(e,t.expectedValue);return{received:o.received,matches:!!o.matches.length}}{let o;if(r==="to.have.attribute.value"){let u=e.getAttribute(t.expressionArg);if(u===null)return{received:null,matches:!1};o=u}else if(["to.have.class","to.contain.class"].includes(r)){if(!t.expectedText)throw this.createStacklessError("Expected text is not provided for "+r);return{received:e.classList.toString(),matches:new Dn(t.expectedText[0]).matchesClassList(this,e.classList,r==="to.contain.class")}}else if(r==="to.have.css")o=this.window.getComputedStyle(e).getPropertyValue(t.expressionArg);else if(r==="to.have.id")o=e.id;else if(r==="to.have.text")o=t.useInnerText?e.innerText:Se(new Map,e).full;else if(r==="to.have.accessible.name")o=At(e,!1);else if(r==="to.have.accessible.description")o=Rr(e,!1);else if(r==="to.have.accessible.error.message")o=Co(e);else if(r==="to.have.role")o=he(e)||"";else if(r==="to.have.title")o=this.document.title;else if(r==="to.have.url")o=this.document.location.href;else if(r==="to.have.value"){if(e=this.retarget(e,"follow-label"),e.nodeName!=="INPUT"&&e.nodeName!=="TEXTAREA"&&e.nodeName!=="SELECT")throw this.createStacklessError("Not an input element");o=e.value}if(o!==void 0&&t.expectedText){let u=new Dn(t.expectedText[0]);return{received:o,matches:u.matches(o)}}}throw this.createStacklessError("Unknown expect matcher: "+r)}expectArray(e,t){let n=t.expression;if(n==="to.have.count"){let h=e.length,p=h===t.expectedNumber;return{received:h,matches:p}}if(!t.expectedText)throw this.createStacklessError("Expected text is not provided for "+n);if(["to.have.class.array","to.contain.class.array"].includes(n)){let h=e.map(v=>v.classList),p=h.map(String);if(h.length!==t.expectedText.length)return{received:p,matches:!1};let b=this._matchSequentially(t.expectedText,h,(v,m)=>v.matchesClassList(this,m,n==="to.contain.class.array"));return{received:p,matches:b}}if(!["to.contain.text.array","to.have.text.array"].includes(n))throw this.createStacklessError("Unknown expect matcher: "+n);let r=e.map(h=>t.useInnerText?h.innerText:Se(new Map,h).full),o=n!=="to.contain.text.array";if(!(r.length===t.expectedText.length||!o))return{received:r,matches:!1};let l=this._matchSequentially(t.expectedText,r,(h,p)=>h.matches(p));return{received:r,matches:l}}_matchSequentially(e,t,n){let r=e.map(l=>new Dn(l)),o=0,u=0;for(;o<r.length&&u<t.length;)n(r[o],t[u])&&++o,++u;return o===r.length}};function Rn(e){return e.replace(/\n/g,"\u21B5").replace(/\t/g,"\u21C6")}function ou(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 qn(e,t){if(e[0]==="/"&&e.lastIndexOf("/")>0){let o=e.lastIndexOf("/"),u=new RegExp(e.substring(1,o),e.substring(o+1));return{matcher:l=>u.test(l.full),kind:"regex"}}let n=t?JSON.parse.bind(JSON):ou,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=we(e),r?t?{kind:"strict",matcher:u=>u.normalized===e}:{matcher:u=>!e&&!u.immediate.length?!0:u.immediate.some(l=>we(l)===e),kind:"strict"}:(e=e.toLowerCase(),{kind:"lax",matcher:o=>o.normalized.toLowerCase().includes(e)})}var Dn=class{_string;_substring;_regex;_normalizeWhiteSpace;_ignoreCase;constructor(e){if(this._normalizeWhiteSpace=e.normalizeWhiteSpace,this._ignoreCase=e.ignoreCase,this._string=e.matchSubstring?void 0:this.normalize(e.string),this._substring=e.matchSubstring?this.normalize(e.string):void 0,e.regexSource){let t=new Set((e.regexFlags||"").split(""));e.ignoreCase===!1&&t.delete("i"),e.ignoreCase===!0&&t.add("i"),this._regex=new RegExp(e.regexSource,[...t].join(""))}}matches(e){return this._regex||(e=this.normalize(e)),this._string!==void 0?e===this._string:this._substring!==void 0?e.includes(this._substring):this._regex?!!this._regex.test(e):!1}matchesClassList(e,t,n){if(n){if(this._regex)throw e.createStacklessError("Partial matching does not support regular expressions. Please provide a string value.");return this._string.split(/\s+/g).filter(Boolean).every(r=>t.contains(r))}return this.matches(t.toString())}normalize(e){return e&&(this._normalizeWhiteSpace&&(e=we(e)),this._ignoreCase&&(e=e.toLocaleLowerCase()),e)}};function Hr(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!Hr(e[r],t[r]))return!1;return!0}if(e instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;++r)if(!t.hasOwnProperty(n[r]))return!1;for(let r of n)if(!Hr(e[r],t[r]))return!1;return!0}return typeof e=="number"&&typeof t=="number"?isNaN(e)&&isNaN(t):!1}var Me={selectorUtils:zi,roleUtils:to,domUtils:Eo,selectorGenerator:qo,stringUtils:Ji,InjectedScript:iu},pa=function(){if(!Me.InjectedScript)throw new Error("InjectedScript is not available yet.");let e=Me.InjectedScript,t=this.options||{sdkLanguage:"javascript",testIdAttributeName:"blinq-test-id",stableRafCount:0,browserName:"chromium",inputFileRoleTextbox:!1,customEngines:[],isUnderTest:!0};return new e(window,t)};var au=["slot","alt","name","placeholder","title","aria-label","aria-placeholder","role","data-testid","data-cy"];function cu(e){return`"${e.replace(/["\\]/g,t=>"\\"+t)}"`}function lu(e){return/^[a-zA-Z][a-zA-Z0-9\-\_]+$/.test(e)?"#"+e:`[id=${cu(e)}]`}function uu(e){let t="";for(let n=0;n<e.length;n++)t+=hu(e,n);return t}function hu(e,t){let n=e.charCodeAt(t);return n===0?"\uFFFD":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 fu(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,"$1$2\\$3").replace(/>>/g,"\\>\\>")}var Ts=class{constructor(t,n={}){this.locatorStrategies={text:"basic",no_text:"no_text",custom:"custom",context:"context",digitIgnore:"ignore_digit",text_with_index:"text_with_index"},this.options=n,this.dom_Parent=new Ai,this.PW=Me,this.injectedScript=t,this.cache=new Map}generateUniqueCSSSelector(t,n){let r=n?.root||window.document,o=n?.separator||" > ",u=n?.isunique||(y=>this.getMatchingElements(y,n).length===1),l=n?.noCSSId||!1;if(!(t instanceof Element)||!r.contains(t))return"";let h="",p=t.getAttribute("id");if(p&&!/\d/.test(p)&&!l&&(h=lu(p),u(h))||t.tagName&&(h=t.tagName.toLowerCase()+h,u(h)))return h;let b=Array.from(t.classList).filter(y=>!/\d/.test(y));if(b.length&&(h+=b.map(y=>"."+uu(y)).join(""),u(h)))return h;for(let y of au)if(t.hasAttribute(y)){let w=t.getAttribute(y);if(w===""||/\d/.test(w))continue;w=w.replace(/[!"#$%&'()*+,./:;<=>?@[\]^`{|}~]/g,"\\$&"),h+=`[${y}=${this.PW.stringUtils.escapeForAttributeSelector(w)}]`}if(u(h)||t===r)return h;let v=t.parentElement;if(v){if(v!==r&&(t.assignedSlot&&(v=t.assignedSlot.parentElement??t.assignedSlot.parentNode.host),v&&v!==r&&(h=this.generateUniqueCSSSelector(v,n)+o+h,u(h))))return h}else if(t.parentNode instanceof ShadowRoot){let y=t.parentNode.host;if(y&&y!==r&&(h=this.generateUniqueCSSSelector(y,n)+" >>> "+h,u(h)))return h}let m=t.parentElement?.children;if(m){for(let y=0;y<m.length;y++)if(m[y]===t)return h+`:nth-child(${y+1})`}return""}getMatchingElements(t,n={}){let{root:r=window.document,prefix:o,visible:u=!0}=n;return u&&(t=`${t} >> visible=true`),o&&(t=`${o} >> ${t}`),this.injectedScript.querySelectorAll(this.injectedScript.parseSelector(t),r)}getLocatorStrategies(){return this.locatorStrategies}getTextLocators(t,n){let r=this.injectedScript,{textToIgnore:o=null}=n,u=this.PW.selectorGenerator.buildTextCandidates(r,t,n),l=[];for(let h of u){let p=0,b=[];for(let y of h){let{engine:w,selector:A}=y;o&&A.includes(o)||(w==="css"?b.push(A):b.push(`${w}=${A}`),p+=y.score)}let v=b.join(" >> "),m=p/h.length;l.push({css:v,score:m})}return l}getNoTextLocators(t,n){let r=this.injectedScript,o=this.PW.selectorGenerator.buildNoTextCandidates(r,t,n);for(let u of o)u.engine==="css"?u.css=u.selector:u.css=`${u.engine}=${u.selector}`,delete u.engine,delete u.selector;return o}getCustomLocators(t,n){let{customAttributes:r=[]}=this.options;if(!r||!Array.isArray(r))return console.error("Custom attributes must be an array"),[];let o=[],u=[];for(let l of r){if(!l||typeof l!="string"){console.error("Custom attribute must be a string");continue}let h=t.getAttribute(l);h!==null&&(u.push(l),o.push({css:`[${l}=${this.PW.stringUtils.escapeForAttributeSelector(h)}]`,score:1,priority:1}))}return o}toContextLocators(t,n,r={}){let o=this.dom_Parent.findLowestCommonAncestor([n,t]),u=this.dom_Parent.getClimbCountToParent(n,o),l=n.innerText.trim(),h=`internal:text="${l}" >> ${this.getXPathSelector(u)}`,p=this.getElementLocators(t,{root:o,strategies:{[this.locatorStrategies.custom]:!0,[this.locatorStrategies.text]:!0,[this.locatorStrategies.no_text]:!0},prefix:h,...r}),b=y=>{y.forEach(w=>{w.climb=u,w.text=l})},v=p.allStrategyLocators,m=p.locators;if(v){let y=[];for(let w in v){if(w==="strategy")continue;let A=v[w];A.length!==0&&(y.push(...A),v[w]=[])}return b(y),v[this.locatorStrategies.context]=y,v.strategy=this.locatorStrategies.context,p.locators=y,p}return m&&b(m),p}getContextLocators(t,n){if(!n||!Array.isArray(n))return console.error("Locators must be an array"),[];let r=[];try{let o=new Set;for(let u of n){let l=u.css;if(!l||typeof l!="string"){console.error("Locator must have a valid css selector");continue}let p=this.injectedScript.parseSelector(l).parts;if(!p||!Array.isArray(p)||p.length===0){console.error("Locator must have a valid css selector");continue}if(p.length<3)continue;let b=p[0];if(b.name!=="internal:text")continue;let v=b.body;if(!v||typeof v!="string"||v.length===0){console.error("Locator must have a valid text in the first part to be a context locator");continue}let m=p[1];if(m.name!=="xpath")continue;let y=m.body;if(!y||typeof y!="string"||y.length===0)continue;let w=m.body;if(!w||typeof w!="string"||w.length===0)continue;let A=/(\.\.)(\/\.\.)*/;try{if(A.test(w)){let P=w.split("..").length-1,B=l.indexOf(w),q=l.substring(B+w.length+3).trim();if(q.length===0)continue;let H=`internal:text=${v}`,ee=this.getMatchingElements(H,{});if(ee.length!==1){console.error("Context locator must have exactly one element matching the text part");continue}let te=ee[0],Z=this.injectedScript.utils.elementText(new Map,te).full.trim(),se=`${H} >> xpath=${y} >> ${q}`,le=this.getMatchingElements(se,{});if(le.length!==1){console.error("Context locator must have exactly one element matching the full selector");continue}if(le[0]!==t){console.error("Context locator must have the text element as the full element");continue}if(!o.has(Z)){o.add(Z);let re={css:q,climb:P,text:Z,priority:1};u.index!==void 0&&(re.index=u.index),r.push(re)}}}catch(I){console.error("Error parsing climb string:",I);continue}}}catch(o){console.error("Error generating context locators:",o)}return r.sort((o,u)=>o.text.length-u.text.length),r}getDigitIgnoreLocators(t,n){let r=[];try{if(!n||!Array.isArray(n))return console.error("Locators must be an array"),[];for(let o of n){let u=o.css;if(!u||typeof u!="string"){console.error("Locator must have a valid css selector");continue}let h=this.injectedScript.parseSelector(u).parts;if(!h||!Array.isArray(h)||h.length===0){console.error("Locator must have a valid css selector");continue}let p="",b=!1;for(let v of h){if(v.name!=="internal:text"){p+=`${v.name==="css"?"":v.name+"="}${v.source} >> `;continue}if(typeof v.body!="string"||v.body.length===0){p+=`${v.name==="css"?"":v.name+"="}${v.source} >> `;continue}let m=v.body,y=/\d+/g;b=y.test(m);let w=this.PW.stringUtils.escapeRegExp(m.substring(1,m.length-2)),A=new RegExp(w);p+=`internal:text=${fu(A).replace(y,"\\d+")} >> `}if(b&&(p.endsWith(" >> ")&&(p=p.slice(0,-4)),p)){let v=this.getMatchingElements(p,{});if(v.length!==1){console.error("Digit ignore locator must have exactly one element matching the final selector");continue}if(v[0]!==t){console.error("Digit ignore locator must match the original element");continue}r.push({css:p,priority:o.priority||1})}}}catch(o){console.error("Error generating digit ignore locators:",o)}return r}getTextwithIndexLocators(t){if(!t||!Array.isArray(t))return console.error("Locators must be an array"),[];let n=[];try{for(let r of t){if(!r||!r.css||typeof r.css!="string"){console.error("Locator must have a valid css selector");continue}let o=r.index;typeof o!="number"||o<0||n.push(r)}}catch(r){console.error("Error getting text with index locators:",r)}return n}getXPathSelector(t){if(typeof t!="number"||t<0)return console.error("Climb must be a non-negative integer"),"";if(t===0)return"";let n="xpath=..";if(t===1)return n;for(let r=1;r<t;r++)n+="/..";return n}categorizeLocators(t,n,r){let o=[],u=[],l=r?.visible??!0;try{for(let h of n){if(!h||!h.css||typeof h.css!="string"){console.error("Locator must have a valid css selector found: ",h);continue}l===!1&&(h.visible=!1);let p=this.getMatchingElements(h.css,r);if(p.length===0){console.warn(`No elements found for locator: ${h.css}`);continue}else if(p.length===1){if(t===p[0])h.priority=1,o.push(h);else if(t.contains(p[0])){h.priority=1;let b=this.dom_Parent.getClimbCountToParent(p[0],t),v=this.getXPathSelector(b),m=`${h.css} >> ${v}`;h.css=m,o.push(h)}}else h.priority=2,h.elements=p,u.push(h)}}catch(h){console.error("Error categorizing locators:",h)}return{unique:o,nonUnique:u}}getUniqueLocators(t,n=this.getNoTextLocators,r={}){return this.getUniqueLocators2(t,n,r)}getUniqueLocators1(t,n=this.getNoTextLocators,r={}){try{let{maxLocators:o=5,root:u=window.document.body,next:l="LCA",minLocators:h=3}=r;if(!t)return[];if(t===u)return t===window.document.documentElement?[{css:"html",score:1,priority:1},{css:":root",score:1,priority:1}]:[{css:":root",score:1,priority:1}];console.log("Generating locators for element:",t);let p=n(t,r);if(console.log("Generated locators:",p),!p||!Array.isArray(p))return console.error("Locator generator did not return an array of locators"),[];console.log("Categorizing locators for element:",t);let b=this.categorizeLocators(t,p,r);console.log("Categorized locators:",b);let{unique:v,nonUnique:m}=b,y=[];if(v.length>0&&y.push(...v),y.length>=o)return y.slice(0,o);let w=null;for(let A of m){let I=A.css??A.selector,P=A.elements||this.getMatchingElements(I,r);if(l==="parent"?w=this.dom_Parent.getActualParent(t):w=this.dom_Parent.findBranchingParent(P,t),w&&w!==t)if(u.contains(w)){let B=this.getUniqueLocators(w,n,{...r,root:u});for(let q of B){if(y.length>=o)return y.slice(0,o);let ee=`${q.css??q.selector} >> ${I}`,te=this.getMatchingElements(ee,r),Z=(q.score+A.score)/2+100;if(te.length===1&&te[0]===t)q.css=ee,q.score=Z,q.priority=1,y.push(q);else{let se=te.indexOf(t);se!==-1&&se<5&&(q.css=ee,q.index=se,q.priority=2,q.score=Z,y.push(q))}}}else{let B=P.indexOf(t);B!==-1&&B<5&&(A.index=B,A.priority=2,y.push(A))}else{let B=P.indexOf(t);B!==-1&&B<5&&(A.index=B,A.priority=2,y.push(A))}delete A.elements,delete A.strategy,delete A.engine,delete A.selector}if(y.length<h&&u&&u.contains(t)){let A=this.dom_Parent.getActualParent(t),I=this.getUniqueLocators(A,n,{...r,root:u});y.push(...I)}return y.sort((A,I)=>A.score-I.score),console.log("Final locators:",y,t),console.groupEnd(),y.slice(0,o)}catch(o){return console.error("Error in getUniqueLocators:",o),[]}}getUniqueLocators2(t,n=this.getNoTextLocators,r={}){try{let{maxLocators:o=5,root:u=window.document.body,prefix:l}=r;if(!t)return[];if(t===u)return t===window.document.documentElement?[{css:"html",score:1,priority:1},{css:":root",score:1,priority:1}]:[];console.log("Generating locators for element:",t);let h=n(t,r);if(console.log("Generated locators:",h),!h||!Array.isArray(h))return console.error("Locator generator did not return an array of locators"),[];console.log("Categorizing locators for element:",t);let p=this.categorizeLocators(t,h,r);console.log("Categorized locators:",p);let{unique:b,nonUnique:v}=p,m=[];if(b.length>0&&m.push(...b),m.length>=o)return m.slice(0,o);let y=new Map,w=l?[t]:this.dom_Parent.getFullAncestorChainToRoot(t,u);w.shift();let A=new Map,I=this.PW.selectorUtils.elementText(A,t).full.trim(),P=[],B=null;for(let q of w){let H=n(q,{...r,textToIgnore:I});if(!H||!Array.isArray(H)||H.length===0)continue;let ee=this.categorizeLocators(q,H,r);if(P.push({element:q,locators:ee}),y.set(q,ee),ee.unique.length>0){B={element:q,locators:ee};break}}for(let q of v){let H=q.css??q.selector;if((q.elements||this.getMatchingElements(H,r)).length===0){console.warn(`No elements found for locator: ${H}`);continue}if(!B){let te=this.getMatchingElements(H,r);if(te.length===1&&te[0]===t)m.push({css:H,score:q.score,priority:1});else{let Z=te.indexOf(t);Z!==-1&&m.push({css:H,index:Z,score:q.score+200,priority:2})}continue}for(let te of B.locators.unique){let Z=`${te.css} >> ${H}`,se=this.getMatchingElements(Z,r);if(se.length===1&&se[0]===t){let le=(te.score+q.score)/2+100,D={...te,css:Z,score:le,priority:1};m.push(D)}else{let le=se.indexOf(t);if(le!==-1&&le<5){let D=(te.score+q.score)/2,re={...te,css:Z,index:le,score:D+200,priority:2};m.push(re)}}}}return m.sort((q,H)=>q.score-H.score),console.log("Final locators:",m,t),console.groupEnd(),m.slice(0,o)}catch(o){return console.error("Error in getUniqueLocators:",o),[]}}isElementVisible(t){if(!(t instanceof Element))return!1;let n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden"||n.opacity==="0")return!1;let r=t.getBoundingClientRect();return!(r.width===0||r.height===0)}getElementLocators(t,n={}){let r=this.isElementVisible(t);r===!1&&(console.warn("Element is not visible: ",t),n.visible=r);try{let{excludeText:o=!1,strategies:u={[this.locatorStrategies.custom]:!0,[this.locatorStrategies.context]:!0,[this.locatorStrategies.text]:!0,[this.locatorStrategies.text_with_index]:!0,[this.locatorStrategies.digitIgnore]:!0,[this.locatorStrategies.no_text]:!0}}=n,l={[this.locatorStrategies.custom]:[],[this.locatorStrategies.context]:[],[this.locatorStrategies.text]:[],[this.locatorStrategies.text_with_index]:[],[this.locatorStrategies.digitIgnore]:[],[this.locatorStrategies.no_text]:[]};if(u[this.locatorStrategies.custom]&&this.options?.customAttributes&&Array.isArray(this.options.customAttributes)&&this.options.customAttributes.length>0){console.groupCollapsed("Generating Custom locators for element:",t);let v=this.getUniqueLocators(t,this.getCustomLocators.bind(this),n);v.length>0&&(l[this.locatorStrategies.custom]=v)}if(console.groupEnd(),!o&&u[this.locatorStrategies.text]){console.groupCollapsed("Generating Text locators for element:",t);let v=this.getUniqueLocators(t,this.getTextLocators.bind(this),n);if(console.groupEnd(),v.length>0&&(l[this.locatorStrategies.text]=v),u[this.locatorStrategies.text_with_index]){let m=this.getTextwithIndexLocators(v);m.length>0&&(l[this.locatorStrategies.text_with_index]=m)}if(u[this.locatorStrategies.digitIgnore]){let m=this.getDigitIgnoreLocators(t,v);m.length>0&&(l[this.locatorStrategies.digitIgnore]=m)}if(u[this.locatorStrategies.context]){let m=this.getContextLocators(t,v);m.length>0&&(l[this.locatorStrategies.context]=m)}}if(u[this.locatorStrategies.no_text]){console.groupCollapsed("Generating No Text locators for element:",t);let v=this.getUniqueLocators(t,this.getNoTextLocators.bind(this),n);if(v.length>0)l[this.locatorStrategies.no_text]=v;else{let m=[];m.push({css:this.generateUniqueCSSSelector(t,n),score:500,priority:3}),m.length>0&&(l[this.locatorStrategies.no_text]=m)}console.groupEnd()}let h=this.getBestStrategy(l);if(!h)throw new Error("No locators found for element: "+t);l.strategy=h;let b={locators:l[l.strategy]??[],element_name:""};return Object.keys(l).length>1&&(b.allStrategyLocators=l),console.log("Generated locators:",b),b}catch(o){return console.error("Error in getElementLocators:",o),{locators:[],element_name:""}}}getBestStrategy(t){let n=[this.locatorStrategies.custom,this.locatorStrategies.context,this.locatorStrategies.text,this.locatorStrategies.text_with_index,this.locatorStrategies.digitIgnore,this.locatorStrategies.no_text];for(let r of n)if(t[r]&&t[r].length>0)return r;return null}},ga=Ts;var ks=class{constructor(t={}){let{inlineImages:n=!0,inlineStyles:r=!0,excludeSelectors:o=[]}=t;this.inlineImages=n,this.inlineStyles=r,this.excludeSelectors=o}imageToDataURL(t,n){try{let r=n.createElement("canvas");return r.width=t.naturalWidth||t.width,r.height=t.naturalHeight||t.height,r.getContext("2d").drawImage(t,0,0),r.toDataURL("image/png")}catch(r){return console.warn(`Failed to inline image: ${t.src}`,r),t.src}}processStyles(t){if(!this.inlineStyles)return;let n=Array.from(window.document.styleSheets);for(let r of n)try{let o=r.ownerNode.cloneNode(!0);if(!o.href)t.head.appendChild(o);else{let u=Array.from(r.cssRules).map(h=>h.cssText).join(`
|
|
18
|
+
`)}createStacklessError(e){if(this._browserName==="firefox"){let n=new Error("Error: "+e);return n.stack="",n}let t=new Error(e);return delete t.stack,t}createHighlight(){return new Or(this)}maskSelectors(e,t){this._highlight&&this.hideHighlight(),this._highlight=new Or(this),this._highlight.install();let n=[];for(let r of e)n.push(this.querySelectorAll(r,this.document.documentElement));this._highlight.maskElements(n.flat(),t)}highlight(e){this._highlight||(this._highlight=new Or(this),this._highlight.install()),this._highlight.runHighlightOnRaf(e)}hideHighlight(){this._highlight&&(this._highlight.uninstall(),delete this._highlight)}markTargetElements(e,t){var n,r;((n=this._markedElements)==null?void 0:n.callId)!==t&&(this._markedElements=void 0);let o=((r=this._markedElements)==null?void 0:r.elements)||new Set,u=new CustomEvent("__playwright_unmark_target__",{bubbles:!0,cancelable:!0,detail:t,composed:!0});for(let h of o)e.has(h)||h.dispatchEvent(u);let l=new CustomEvent("__playwright_mark_target__",{bubbles:!0,cancelable:!0,detail:t,composed:!0});for(let h of e)o.has(h)||h.dispatchEvent(l);this._markedElements={callId:t,elements:e}}_setupGlobalListenersRemovalDetection(){let e="__playwright_global_listeners_check__",t=!1,n=()=>t=!0;this.window.addEventListener(e,n),new MutationObserver(r=>{if(r.some(u=>Array.from(u.addedNodes).includes(this.document.documentElement))&&(t=!1,this.window.dispatchEvent(new CustomEvent(e)),!t)){this.window.addEventListener(e,n);for(let u of this.onGlobalListenersRemoved)u()}}).observe(this.document,{childList:!0})}_setupHitTargetInterceptors(){let e=n=>{var r;return(r=this._hitTargetInterceptor)==null?void 0:r.call(this,n)},t=()=>{for(let n of this._allHitTargetInterceptorEvents)this.window.addEventListener(n,e,{capture:!0,passive:!1})};t(),this.onGlobalListenersRemoved.add(t)}async expect(e,t,n){return t.expression==="to.have.count"||t.expression.endsWith(".array")?this.expectArray(n,t):e?await this.expectSingleElement(e,t):!t.isNot&&t.expression==="to.be.hidden"?{matches:!0}:t.isNot&&t.expression==="to.be.visible"?{matches:!1}:!t.isNot&&t.expression==="to.be.detached"?{matches:!0}:t.isNot&&t.expression==="to.be.attached"?{matches:!1}:t.isNot&&t.expression==="to.be.in.viewport"?{matches:!1}:{matches:t.isNot,missingReceived:!0}}async expectSingleElement(e,t){var n;let r=t.expression;{let o;if(r==="to.have.attribute"){let u=e.hasAttribute(t.expressionArg);o={matches:u,received:u?"attribute present":"attribute not present"}}else if(r==="to.be.checked"){let{checked:u,indeterminate:l}=t.expectedValue;if(l){if(u!==void 0)throw this.createStacklessError("Can't assert indeterminate and checked at the same time");o=this.elementState(e,"indeterminate")}else o=this.elementState(e,u===!1?"unchecked":"checked")}else if(r==="to.be.disabled")o=this.elementState(e,"disabled");else if(r==="to.be.editable")o=this.elementState(e,"editable");else if(r==="to.be.readonly")o=this.elementState(e,"editable"),o.matches=!o.matches;else if(r==="to.be.empty")if(e.nodeName==="INPUT"||e.nodeName==="TEXTAREA"){let u=e.value;o={matches:!u,received:u?"notEmpty":"empty"}}else{let u=(n=e.textContent)==null?void 0:n.trim();o={matches:!u,received:u?"notEmpty":"empty"}}else if(r==="to.be.enabled")o=this.elementState(e,"enabled");else if(r==="to.be.focused"){let u=this._activelyFocused(e).isFocused;o={matches:u,received:u?"focused":"inactive"}}else r==="to.be.hidden"?o=this.elementState(e,"hidden"):r==="to.be.visible"?o=this.elementState(e,"visible"):r==="to.be.attached"?o={matches:!0,received:"attached"}:r==="to.be.detached"&&(o={matches:!1,received:"attached"});if(o){if(o.received==="error:notconnected")throw this.createStacklessError("Element is not connected");return o}}if(r==="to.have.property"){let o=e,u=t.expressionArg.split(".");for(let p=0;p<u.length-1;p++){if(typeof o!="object"||!(u[p]in o))return{received:void 0,matches:!1};o=o[u[p]]}let l=o[u[u.length-1]],h=Hr(l,t.expectedValue);return{received:l,matches:h}}if(r==="to.be.in.viewport"){let o=await this.viewportRatio(e);return{received:`viewport ratio ${o}`,matches:o>0&&o>(t.expectedNumber??0)-1e-9}}if(r==="to.have.values"){if(e=this.retarget(e,"follow-label"),e.nodeName!=="SELECT"||!e.multiple)throw this.createStacklessError("Not a select element with a multiple attribute");let o=[...e.selectedOptions].map(u=>u.value);return o.length!==t.expectedText.length?{received:o,matches:!1}:{received:o,matches:o.map((u,l)=>new Dn(t.expectedText[l]).matches(u)).every(Boolean)}}if(r==="to.match.aria"){let o=al(e,t.expectedValue);return{received:o.received,matches:!!o.matches.length}}{let o;if(r==="to.have.attribute.value"){let u=e.getAttribute(t.expressionArg);if(u===null)return{received:null,matches:!1};o=u}else if(["to.have.class","to.contain.class"].includes(r)){if(!t.expectedText)throw this.createStacklessError("Expected text is not provided for "+r);return{received:e.classList.toString(),matches:new Dn(t.expectedText[0]).matchesClassList(this,e.classList,r==="to.contain.class")}}else if(r==="to.have.css")o=this.window.getComputedStyle(e).getPropertyValue(t.expressionArg);else if(r==="to.have.id")o=e.id;else if(r==="to.have.text")o=t.useInnerText?e.innerText:Se(new Map,e).full;else if(r==="to.have.accessible.name")o=At(e,!1);else if(r==="to.have.accessible.description")o=Rr(e,!1);else if(r==="to.have.accessible.error.message")o=Co(e);else if(r==="to.have.role")o=he(e)||"";else if(r==="to.have.title")o=this.document.title;else if(r==="to.have.url")o=this.document.location.href;else if(r==="to.have.value"){if(e=this.retarget(e,"follow-label"),e.nodeName!=="INPUT"&&e.nodeName!=="TEXTAREA"&&e.nodeName!=="SELECT")throw this.createStacklessError("Not an input element");o=e.value}if(o!==void 0&&t.expectedText){let u=new Dn(t.expectedText[0]);return{received:o,matches:u.matches(o)}}}throw this.createStacklessError("Unknown expect matcher: "+r)}expectArray(e,t){let n=t.expression;if(n==="to.have.count"){let h=e.length,p=h===t.expectedNumber;return{received:h,matches:p}}if(!t.expectedText)throw this.createStacklessError("Expected text is not provided for "+n);if(["to.have.class.array","to.contain.class.array"].includes(n)){let h=e.map(v=>v.classList),p=h.map(String);if(h.length!==t.expectedText.length)return{received:p,matches:!1};let b=this._matchSequentially(t.expectedText,h,(v,m)=>v.matchesClassList(this,m,n==="to.contain.class.array"));return{received:p,matches:b}}if(!["to.contain.text.array","to.have.text.array"].includes(n))throw this.createStacklessError("Unknown expect matcher: "+n);let r=e.map(h=>t.useInnerText?h.innerText:Se(new Map,h).full),o=n!=="to.contain.text.array";if(!(r.length===t.expectedText.length||!o))return{received:r,matches:!1};let l=this._matchSequentially(t.expectedText,r,(h,p)=>h.matches(p));return{received:r,matches:l}}_matchSequentially(e,t,n){let r=e.map(l=>new Dn(l)),o=0,u=0;for(;o<r.length&&u<t.length;)n(r[o],t[u])&&++o,++u;return o===r.length}};function Rn(e){return e.replace(/\n/g,"\u21B5").replace(/\t/g,"\u21C6")}function ou(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 qn(e,t){if(e[0]==="/"&&e.lastIndexOf("/")>0){let o=e.lastIndexOf("/"),u=new RegExp(e.substring(1,o),e.substring(o+1));return{matcher:l=>u.test(l.full),kind:"regex"}}let n=t?JSON.parse.bind(JSON):ou,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=we(e),r?t?{kind:"strict",matcher:u=>u.normalized===e}:{matcher:u=>!e&&!u.immediate.length?!0:u.immediate.some(l=>we(l)===e),kind:"strict"}:(e=e.toLowerCase(),{kind:"lax",matcher:o=>o.normalized.toLowerCase().includes(e)})}var Dn=class{_string;_substring;_regex;_normalizeWhiteSpace;_ignoreCase;constructor(e){if(this._normalizeWhiteSpace=e.normalizeWhiteSpace,this._ignoreCase=e.ignoreCase,this._string=e.matchSubstring?void 0:this.normalize(e.string),this._substring=e.matchSubstring?this.normalize(e.string):void 0,e.regexSource){let t=new Set((e.regexFlags||"").split(""));e.ignoreCase===!1&&t.delete("i"),e.ignoreCase===!0&&t.add("i"),this._regex=new RegExp(e.regexSource,[...t].join(""))}}matches(e){return this._regex||(e=this.normalize(e)),this._string!==void 0?e===this._string:this._substring!==void 0?e.includes(this._substring):this._regex?!!this._regex.test(e):!1}matchesClassList(e,t,n){if(n){if(this._regex)throw e.createStacklessError("Partial matching does not support regular expressions. Please provide a string value.");return this._string.split(/\s+/g).filter(Boolean).every(r=>t.contains(r))}return this.matches(t.toString())}normalize(e){return e&&(this._normalizeWhiteSpace&&(e=we(e)),this._ignoreCase&&(e=e.toLocaleLowerCase()),e)}};function Hr(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!Hr(e[r],t[r]))return!1;return!0}if(e instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;++r)if(!t.hasOwnProperty(n[r]))return!1;for(let r of n)if(!Hr(e[r],t[r]))return!1;return!0}return typeof e=="number"&&typeof t=="number"?isNaN(e)&&isNaN(t):!1}var Me={selectorUtils:zi,roleUtils:to,domUtils:Eo,selectorGenerator:qo,stringUtils:Ji,InjectedScript:iu},pa=function(){if(!Me.InjectedScript)throw new Error("InjectedScript is not available yet.");let e=Me.InjectedScript,t=this.options||{sdkLanguage:"javascript",testIdAttributeName:"blinq-test-id",stableRafCount:0,browserName:"chromium",inputFileRoleTextbox:!1,customEngines:[],isUnderTest:!0};return new e(window,t)};var au=["slot","alt","name","placeholder","title","aria-label","aria-placeholder","role","data-testid","data-cy"];function cu(e){return`"${e.replace(/["\\]/g,t=>"\\"+t)}"`}function lu(e){return/^[a-zA-Z][a-zA-Z0-9\-\_]+$/.test(e)?"#"+e:`[id=${cu(e)}]`}function uu(e){let t="";for(let n=0;n<e.length;n++)t+=hu(e,n);return t}function hu(e,t){let n=e.charCodeAt(t);return n===0?"\uFFFD":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 fu(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,"$1$2\\$3").replace(/>>/g,"\\>\\>")}var Ts=class{constructor(t,n={}){this.locatorStrategies={text:"basic",no_text:"no_text",custom:"custom",context:"context",digitIgnore:"ignore_digit",text_with_index:"text_with_index"},this.options=n,this.dom_Parent=new Ai,this.PW=Me,this.injectedScript=t,this.cache=new Map}generateUniqueCSSSelector(t,n){let r=n?.root||window.document,o=n?.separator||" > ",u=n?.isunique||(y=>this.getMatchingElements(y,n).length===1),l=n?.noCSSId||!1;if(!(t instanceof Element)||!r.contains(t))return"";let h="",p=t.getAttribute("id");if(p&&!/\d/.test(p)&&!l&&(h=lu(p),u(h))||t.tagName&&(h=t.tagName.toLowerCase()+h,u(h)))return h;let b=Array.from(t.classList).filter(y=>!/\d/.test(y));if(b.length&&(h+=b.map(y=>"."+uu(y)).join(""),u(h)))return h;for(let y of au)if(t.hasAttribute(y)){let w=t.getAttribute(y);if(w===""||/\d/.test(w))continue;w=w.replace(/[!"#$%&'()*+,./:;<=>?@[\]^`{|}~]/g,"\\$&"),h+=`[${y}=${this.PW.stringUtils.escapeForAttributeSelector(w)}]`}if(u(h)||t===r)return h;let v=t.parentElement;if(v){if(v!==r&&(t.assignedSlot&&(v=t.assignedSlot.parentElement??t.assignedSlot.parentNode.host),v&&v!==r&&(h=this.generateUniqueCSSSelector(v,n)+o+h,u(h))))return h}else if(t.parentNode instanceof ShadowRoot){let y=t.parentNode.host;if(y&&y!==r&&(h=this.generateUniqueCSSSelector(y,n)+" >>> "+h,u(h)))return h}let m=t.parentElement?.children;if(m){for(let y=0;y<m.length;y++)if(m[y]===t)return h+`:nth-child(${y+1})`}return""}getMatchingElements(t,n={}){let{root:r=window.document,prefix:o,visible:u=!0}=n;return u&&(t=`${t} >> visible=true`),o&&(t=`${o} >> ${t}`),this.injectedScript.querySelectorAll(this.injectedScript.parseSelector(t),r)}getLocatorStrategies(){return this.locatorStrategies}getTextLocators(t,n){let r=this.injectedScript,{textToIgnore:o=null}=n,u=this.PW.selectorGenerator.buildTextCandidates(r,t,n),l=[];for(let h of u){let p=0,b=[];for(let y of h){let{engine:w,selector:A}=y;o&&A.includes(o)||(w==="css"?b.push(A):b.push(`${w}=${A}`),p+=y.score)}let v=b.join(" >> "),m=p/h.length;l.push({css:v,score:m})}return l}getNoTextLocators(t,n){let r=this.injectedScript,o=this.PW.selectorGenerator.buildNoTextCandidates(r,t,n);for(let u of o)u.engine==="css"?u.css=u.selector:u.css=`${u.engine}=${u.selector}`,delete u.engine,delete u.selector;return o}getCustomLocators(t,n){let{customAttributes:r=[]}=this.options;if(!r||!Array.isArray(r))return console.error("Custom attributes must be an array"),[];let o=[],u=[];for(let l of r){if(!l||typeof l!="string"){console.error("Custom attribute must be a string");continue}let h=t.getAttribute(l);h!==null&&(u.push(l),o.push({css:`[${l}=${this.PW.stringUtils.escapeForAttributeSelector(h)}]`,score:1,priority:1}))}return o}toContextLocators(t,n,r={}){let o=this.dom_Parent.findLowestCommonAncestor([n,t]),u=this.dom_Parent.getClimbCountToParent(n,o),l=n.innerText.trim(),h=`internal:text="${l}" >> ${this.getXPathSelector(u)}`,p=this.getElementLocators(t,{root:o,strategies:{[this.locatorStrategies.custom]:!0,[this.locatorStrategies.text]:!0,[this.locatorStrategies.no_text]:!0},prefix:h,...r}),b=y=>{y.forEach(w=>{w.climb=u,w.text=l})},v=p.allStrategyLocators,m=p.locators;if(v){let y=[];for(let w in v){if(w==="strategy")continue;let A=v[w];A.length!==0&&(y.push(...A),v[w]=[])}return b(y),v[this.locatorStrategies.context]=y,v.strategy=this.locatorStrategies.context,p.locators=y,p}return m&&b(m),p}getContextLocators(t,n){if(!n||!Array.isArray(n))return console.error("Locators must be an array"),[];let r=[];try{let o=new Set;for(let u of n){let l=u.css;if(!l||typeof l!="string"){console.error("Locator must have a valid css selector");continue}let p=this.injectedScript.parseSelector(l).parts;if(!p||!Array.isArray(p)||p.length===0){console.error("Locator must have a valid css selector");continue}if(p.length<3)continue;let b=p[0];if(b.name!=="internal:text")continue;let v=b.body;if(!v||typeof v!="string"||v.length===0){console.error("Locator must have a valid text in the first part to be a context locator");continue}let m=p[1];if(m.name!=="xpath")continue;let y=m.body;if(!y||typeof y!="string"||y.length===0)continue;let w=m.body;if(!w||typeof w!="string"||w.length===0)continue;let A=/(\.\.)(\/\.\.)*/;try{if(A.test(w)){let P=w.split("..").length-1,B=l.indexOf(w),q=l.substring(B+w.length+3).trim();if(q.length===0)continue;let H=`internal:text=${v}`,ee=this.getMatchingElements(H,{});if(ee.length!==1){console.error("Context locator must have exactly one element matching the text part");continue}let te=ee[0],Z=this.injectedScript.utils.elementText(new Map,te).full.trim(),se=`${H} >> xpath=${y} >> ${q}`,le=this.getMatchingElements(se,{});if(le.length!==1){console.error("Context locator must have exactly one element matching the full selector");continue}if(le[0]!==t){console.error("Context locator must have the text element as the full element");continue}if(!o.has(Z)){o.add(Z);let re={css:q,climb:P,text:Z,priority:1};u.index!==void 0&&(re.index=u.index),r.push(re)}}}catch(I){console.error("Error parsing climb string:",I);continue}}}catch(o){console.error("Error generating context locators:",o)}return r.sort((o,u)=>o.text.length-u.text.length),r}getDigitIgnoreLocators(t,n){let r=[];try{if(!n||!Array.isArray(n))return console.error("Locators must be an array"),[];for(let o of n){let u=o.css;if(!u||typeof u!="string"){console.error("Locator must have a valid css selector");continue}let h=this.injectedScript.parseSelector(u).parts;if(!h||!Array.isArray(h)||h.length===0){console.error("Locator must have a valid css selector");continue}let p="",b=!1;for(let v of h){if(v.name!=="internal:text"){p+=`${v.name==="css"?"":v.name+"="}${v.source} >> `;continue}if(typeof v.body!="string"||v.body.length===0){p+=`${v.name==="css"?"":v.name+"="}${v.source} >> `;continue}let m=v.body,y=/\d+/g;b=y.test(m);let w=this.PW.stringUtils.escapeRegExp(m.substring(1,m.length-2)),A=new RegExp(w);p+=`internal:text=${fu(A).replace(y,"\\d+")} >> `}if(b&&(p.endsWith(" >> ")&&(p=p.slice(0,-4)),p)){let v=this.getMatchingElements(p,{});if(v.length!==1){console.error("Digit ignore locator must have exactly one element matching the final selector");continue}if(v[0]!==t){console.error("Digit ignore locator must match the original element");continue}r.push({css:p,priority:o.priority||1})}}}catch(o){console.error("Error generating digit ignore locators:",o)}return r}getTextwithIndexLocators(t){if(!t||!Array.isArray(t))return console.error("Locators must be an array"),[];let n=[];try{for(let r of t){if(!r||!r.css||typeof r.css!="string"){console.error("Locator must have a valid css selector");continue}let o=r.index;typeof o!="number"||o<0||n.push(r)}}catch(r){console.error("Error getting text with index locators:",r)}return n}getXPathSelector(t){if(typeof t!="number"||t<0)return console.error("Climb must be a non-negative integer"),"";if(t===0)return"";let n="xpath=..";if(t===1)return n;for(let r=1;r<t;r++)n+="/..";return n}categorizeLocators(t,n,r){let o=[],u=[],l=r?.visible??!0;try{for(let h of n){if(!h||!h.css||typeof h.css!="string"){console.error("Locator must have a valid css selector found: ",h);continue}l===!1&&(h.visible=!1);let p=this.getMatchingElements(h.css,r);if(p.length===0){console.warn(`No elements found for locator: ${h.css}`);continue}else if(p.length===1){if(t===p[0])h.priority=1,o.push(h);else if(t.contains(p[0])){h.priority=1;let b=this.dom_Parent.getClimbCountToParent(p[0],t),v=this.getXPathSelector(b),m=`${h.css} >> ${v}`;h.css=m,o.push(h)}}else h.priority=2,h.elements=p,u.push(h)}}catch(h){console.error("Error categorizing locators:",h)}return{unique:o,nonUnique:u}}getUniqueLocators(t,n=this.getNoTextLocators,r={}){return this.getUniqueLocators2(t,n,r)}getUniqueLocators1(t,n=this.getNoTextLocators,r={}){try{let{maxLocators:o=5,root:u=window.document.body,next:l="LCA",minLocators:h=3}=r;if(!t)return[];if(t===u)return t===window.document.documentElement?[{css:"html",score:1,priority:1},{css:":root",score:1,priority:1}]:[{css:":root",score:1,priority:1}];console.log("Generating locators for element:",t);let p=n(t,r);if(console.log("Generated locators:",p),!p||!Array.isArray(p))return console.error("Locator generator did not return an array of locators"),[];console.log("Categorizing locators for element:",t);let b=this.categorizeLocators(t,p,r);console.log("Categorized locators:",b);let{unique:v,nonUnique:m}=b,y=[];if(v.length>0&&y.push(...v),y.length>=o)return y.slice(0,o);let w=null;for(let A of m){let I=A.css??A.selector,P=A.elements||this.getMatchingElements(I,r);if(l==="parent"?w=this.dom_Parent.getActualParent(t):w=this.dom_Parent.findBranchingParent(P,t),w&&w!==t)if(u.contains(w)){let B=this.getUniqueLocators(w,n,{...r,root:u});for(let q of B){if(y.length>=o)return y.slice(0,o);let ee=`${q.css??q.selector} >> ${I}`,te=this.getMatchingElements(ee,r),Z=(q.score+A.score)/2+100;if(te.length===1&&te[0]===t)q.css=ee,q.score=Z,q.priority=1,y.push(q);else{let se=te.indexOf(t);se!==-1&&se<10&&(q.css=ee,q.index=se,q.priority=2,q.score=Z,y.push(q))}}}else{let B=P.indexOf(t);B!==-1&&B<10&&(A.index=B,A.priority=2,y.push(A))}else{let B=P.indexOf(t);B!==-1&&B<10&&(A.index=B,A.priority=2,y.push(A))}delete A.elements,delete A.strategy,delete A.engine,delete A.selector}if(y.length<h&&u&&u.contains(t)){let A=this.dom_Parent.getActualParent(t),I=this.getUniqueLocators(A,n,{...r,root:u});y.push(...I)}return y.sort((A,I)=>A.score-I.score),console.log("Final locators:",y,t),console.groupEnd(),y.slice(0,o)}catch(o){return console.error("Error in getUniqueLocators:",o),[]}}getUniqueLocators2(t,n=this.getNoTextLocators,r={}){try{let{maxLocators:o=5,root:u=window.document.body,prefix:l}=r;if(!t)return[];if(t===u)return t===window.document.documentElement?[{css:"html",score:1,priority:1},{css:":root",score:1,priority:1}]:[];console.log("Generating locators for element:",t);let h=n(t,r);if(console.log("Generated locators:",h),!h||!Array.isArray(h))return console.error("Locator generator did not return an array of locators"),[];console.log("Categorizing locators for element:",t);let p=this.categorizeLocators(t,h,r);console.log("Categorized locators:",p);let{unique:b,nonUnique:v}=p,m=[];if(b.length>0&&m.push(...b),m.length>=o)return m.slice(0,o);let y=new Map,w=l?[t]:this.dom_Parent.getFullAncestorChainToRoot(t,u);w.shift();let A=new Map,I=this.PW.selectorUtils.elementText(A,t).full.trim(),P=[],B=null;for(let q of w){let H=n(q,{...r,textToIgnore:I});if(!H||!Array.isArray(H)||H.length===0)continue;let ee=this.categorizeLocators(q,H,r);if(P.push({element:q,locators:ee}),y.set(q,ee),ee.unique.length>0){B={element:q,locators:ee};break}}for(let q of v){let H=q.css??q.selector;if((q.elements||this.getMatchingElements(H,r)).length===0){console.warn(`No elements found for locator: ${H}`);continue}if(!B){let te=this.getMatchingElements(H,r);if(te.length===1&&te[0]===t)m.push({css:H,score:q.score,priority:1});else{let Z=te.indexOf(t);Z!==-1&&m.push({css:H,index:Z,score:q.score+200,priority:2})}continue}for(let te of B.locators.unique){let Z=`${te.css} >> ${H}`,se=this.getMatchingElements(Z,r);if(se.length===1&&se[0]===t){let le=(te.score+q.score)/2+100,D={...te,css:Z,score:le,priority:1};m.push(D)}else{let le=se.indexOf(t);if(le!==-1&&le<10){let D=(te.score+q.score)/2,re={...te,css:Z,index:le,score:D+200,priority:2};m.push(re)}}}}return m.sort((q,H)=>q.score-H.score),console.log("Final locators:",m,t),console.groupEnd(),m.slice(0,o)}catch(o){return console.error("Error in getUniqueLocators:",o),[]}}isElementVisible(t){if(!(t instanceof Element))return!1;let n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden"||n.opacity==="0")return!1;let r=t.getBoundingClientRect();return!(r.width===0||r.height===0)}getElementLocators(t,n={}){let r=this.isElementVisible(t);r===!1&&(console.warn("Element is not visible: ",t),n.visible=r);try{let{excludeText:o=!1,strategies:u={[this.locatorStrategies.custom]:!0,[this.locatorStrategies.context]:!0,[this.locatorStrategies.text]:!0,[this.locatorStrategies.text_with_index]:!0,[this.locatorStrategies.digitIgnore]:!0,[this.locatorStrategies.no_text]:!0}}=n,l={[this.locatorStrategies.custom]:[],[this.locatorStrategies.context]:[],[this.locatorStrategies.text]:[],[this.locatorStrategies.text_with_index]:[],[this.locatorStrategies.digitIgnore]:[],[this.locatorStrategies.no_text]:[]};if(u[this.locatorStrategies.custom]&&this.options?.customAttributes&&Array.isArray(this.options.customAttributes)&&this.options.customAttributes.length>0){console.groupCollapsed("Generating Custom locators for element:",t);let v=this.getUniqueLocators(t,this.getCustomLocators.bind(this),n);v.length>0&&(l[this.locatorStrategies.custom]=v)}if(console.groupEnd(),!o&&u[this.locatorStrategies.text]){console.groupCollapsed("Generating Text locators for element:",t);let v=this.getUniqueLocators(t,this.getTextLocators.bind(this),n);if(console.groupEnd(),v.length>0&&(l[this.locatorStrategies.text]=v),u[this.locatorStrategies.text_with_index]){let m=this.getTextwithIndexLocators(v);m.length>0&&(l[this.locatorStrategies.text_with_index]=m)}if(u[this.locatorStrategies.digitIgnore]){let m=this.getDigitIgnoreLocators(t,v);m.length>0&&(l[this.locatorStrategies.digitIgnore]=m)}if(u[this.locatorStrategies.context]){let m=this.getContextLocators(t,v);m.length>0&&(l[this.locatorStrategies.context]=m)}}if(u[this.locatorStrategies.no_text]){console.groupCollapsed("Generating No Text locators for element:",t);let v=this.getUniqueLocators(t,this.getNoTextLocators.bind(this),n);if(v.length>0)l[this.locatorStrategies.no_text]=v;else{let m=[];m.push({css:this.generateUniqueCSSSelector(t,n),score:500,priority:3}),m.length>0&&(l[this.locatorStrategies.no_text]=m)}console.groupEnd()}let h=this.getBestStrategy(l);if(!h)throw new Error("No locators found for element: "+t);l.strategy=h;let b={locators:l[l.strategy]??[],element_name:""};return Object.keys(l).length>1&&(b.allStrategyLocators=l),console.log("Generated locators:",b),b}catch(o){return console.error("Error in getElementLocators:",o),{locators:[],element_name:""}}}getBestStrategy(t){let n=[this.locatorStrategies.custom,this.locatorStrategies.context,this.locatorStrategies.text,this.locatorStrategies.text_with_index,this.locatorStrategies.digitIgnore,this.locatorStrategies.no_text];for(let r of n)if(t[r]&&t[r].length>0)return r;return null}},ga=Ts;var ks=class{constructor(t={}){let{inlineImages:n=!0,inlineStyles:r=!0,excludeSelectors:o=[]}=t;this.inlineImages=n,this.inlineStyles=r,this.excludeSelectors=o}imageToDataURL(t,n){try{let r=n.createElement("canvas");return r.width=t.naturalWidth||t.width,r.height=t.naturalHeight||t.height,r.getContext("2d").drawImage(t,0,0),r.toDataURL("image/png")}catch(r){return console.warn(`Failed to inline image: ${t.src}`,r),t.src}}processStyles(t){if(!this.inlineStyles)return;let n=Array.from(window.document.styleSheets);for(let r of n)try{let o=r.ownerNode.cloneNode(!0);if(!o.href)t.head.appendChild(o);else{let u=Array.from(r.cssRules).map(h=>h.cssText).join(`
|
|
19
19
|
`),l=t.createElement("style");l.textContent=u,t.head.appendChild(l)}}catch(o){console.warn(`Error processing stylesheet: ${r.href}`,o)}}processImages(t){if(!this.inlineImages)return;t.querySelectorAll("img").forEach(r=>{if(!(r.src.startsWith("data:")||r.src.endsWith(".svg"))&&!this.excludeSelectors.some(o=>r.matches(o))&&r.complete&&r.naturalWidth!==0)try{r.setAttribute("src",this.imageToDataURL(r,t))}catch(o){console.warn(`Failed to process image: ${r.src}`,o)}})}removeExcludedElements(t){this.excludeSelectors.forEach(n=>{t.querySelectorAll(n).forEach(o=>{o.parentNode?.removeChild(o)})})}processComputedStyles(t){t.querySelectorAll("*").forEach(r=>{if(this.excludeSelectors.some(h=>r.matches(h)))return;let o=window.getComputedStyle(r),u=["display","position","width","height","margin","padding","color","background-color","font-family","font-size","text-align","line-height","border","box-shadow","opacity"],l=[];if(u.forEach(h=>{let p=o.getPropertyValue(h);p&&l.push(`${h}: ${p}`)}),l.length>0){let h=r.getAttribute("style")||"";r.setAttribute("style",h+l.join("; ")+";")}})}createSnapshot(){let t=window.document.cloneNode(!0),n=window.document,r=t;this.processStyles(r),this.processImages(r),this.removeExcludedElements(r),this.processComputedStyles(r);let o=n.doctype?new XMLSerializer().serializeToString(n.doctype):"<!DOCTYPE html>",u=r.documentElement.outerHTML;return`${o}${u}`}},ma=ks;var _s=class{isLeafNode(t){return t.kind==="text"?!0:!t.children||t.children.length===0}deepClone(t){if(t.kind==="text")return t.text;{let n={kind:"role",role:t.role};return"checked"in t&&(n.checked=t.checked),"disabled"in t&&(n.disabled=t.disabled),"expanded"in t&&(n.expanded=t.expanded),"level"in t&&(n.level=t.level),"pressed"in t&&(n.pressed=t.pressed),"selected"in t&&(n.selected=t.selected),t.name!==void 0&&(n.name=t.name),t.props&&(n.props=Object.assign({},t.props)),t.containerMode&&(n.containerMode=t.containerMode),t.children&&(n.children=t.children.map(r=>this.deepClone(r))),n}}yamlEscapeKeyIfNeeded(t){return this.yamlStringNeedsQuotes(t)?"'"+t.replace(/'/g,"''")+"'":t}yamlEscapeValueIfNeeded(t){return this.yamlStringNeedsQuotes(t)?'"'+t.replace(/[\\"\x00-\x1f\x7f-\x9f]/g,n=>{switch(n){case"\\":return"\\\\";case'"':return'\\"';case"\b":return"\\b";case"\f":return"\\f";case`
|
|
20
20
|
`:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return"\\x"+n.charCodeAt(0).toString(16).padStart(2,"0")}})+'"':t}yamlStringNeedsQuotes(t){return t?!!(t.length===0||/^\s|\s$/.test(t)||/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/.test(t)||/^-/.test(t)||/[\n:](\s|$)/.test(t)||/\s#/.test(t)||/[\n\r]/.test(t)||/^[&*\],?!>|@"'#%]/.test(t)||/[{}`]/.test(t)||/^\[/.test(t)||!isNaN(Number(t))||["y","n","yes","no","true","false","on","off","null"].includes(t.toLowerCase())):!1}filterParentToChildren(t,n){let r=n.some(o=>JSON.stringify(o)===JSON.stringify(t));if(r||this.isLeafNode(t))return r?this.deepClone(t):null;if(t.kind==="role"&&t.children&&t.children.length>0){let o=t.children.map(u=>this.filterParentToChildren(u,n)).filter(u=>u!==null);if(o.length>0){let u=this.deepClone(t);return u.children=o,u}}return null}serializeAriaSnapshot(t,n=0){let r=[],o=(l,h,p)=>{if(typeof l=="string"){let y=this.yamlEscapeValueIfNeeded(l);y&&r.push(p+"- text: "+y);return}let b=l.role;if(l.name&&l.name.length<=900){let y=l.name;if(y){let w=y.startsWith("/")&&y.endsWith("/")?y:JSON.stringify(y);b+=" "+w}}l.checked==="mixed"&&(b+=" [checked=mixed]"),l.checked===!0&&(b+=" [checked]"),l.disabled&&(b+=" [disabled]"),l.expanded&&(b+=" [expanded]"),l.level&&(b+=` [level=${l.level}]`),l.pressed==="mixed"&&(b+=" [pressed=mixed]"),l.pressed===!0&&(b+=" [pressed]"),l.selected===!0&&(b+=" [selected]");let v=p+"- "+this.yamlEscapeKeyIfNeeded(b);l.props===void 0&&(l.props={}),l.children===void 0&&(l.children=[]);let m=!!Object.keys(l.props).length;if(!l.children.length&&!m)r.push(v);else if(l.children.length===1&&typeof l.children[0]=="string"&&!m){let y=l.children[0];y?r.push(v+": "+this.yamlEscapeValueIfNeeded(y)):r.push(v)}else{r.push(v+":");for(let[y,w]of Object.entries(l.props)||[])r.push(p+" - /"+y+": "+this.yamlEscapeValueIfNeeded(w));for(let y of l.children||[])o(y,l,p+" ")}},u=t;if(u.role==="fragment")for(let l of u.children||[])o(l,u,"");else o(u,null,"");return r.join(`
|
|
21
21
|
`)}isSnapshotAvailable(t,n){if(n.has(t))return t}findMatchingElements(t,n){let r=new Map,o=t.trim().split(`
|
|
@@ -621,7 +621,7 @@ class LocatorGenerator {
|
|
|
621
621
|
result.push(_locator);
|
|
622
622
|
} else {
|
|
623
623
|
const index = _elements.indexOf(element);
|
|
624
|
-
if (index !== -1 && index <
|
|
624
|
+
if (index !== -1 && index < 10) {
|
|
625
625
|
// _locator.selector = fullSelector;
|
|
626
626
|
_locator.css = fullSelector;
|
|
627
627
|
_locator.index = index;
|
|
@@ -633,7 +633,7 @@ class LocatorGenerator {
|
|
|
633
633
|
}
|
|
634
634
|
} else {
|
|
635
635
|
const index = elements.indexOf(element);
|
|
636
|
-
if (index !== -1 && index <
|
|
636
|
+
if (index !== -1 && index < 10) {
|
|
637
637
|
locator.index = index;
|
|
638
638
|
locator.priority = 2; // non-unique locators have lower priority
|
|
639
639
|
result.push(locator);
|
|
@@ -641,7 +641,7 @@ class LocatorGenerator {
|
|
|
641
641
|
}
|
|
642
642
|
} else {
|
|
643
643
|
const index = elements.indexOf(element);
|
|
644
|
-
if (index !== -1 && index <
|
|
644
|
+
if (index !== -1 && index < 10) {
|
|
645
645
|
locator.index = index;
|
|
646
646
|
locator.priority = 2; // non-unique locators have lower priority
|
|
647
647
|
result.push(locator);
|
|
@@ -794,7 +794,7 @@ class LocatorGenerator {
|
|
|
794
794
|
result.push(newLocator);
|
|
795
795
|
} else {
|
|
796
796
|
const index = elements.indexOf(element);
|
|
797
|
-
if (index !== -1 && index <
|
|
797
|
+
if (index !== -1 && index < 10) {
|
|
798
798
|
const effectiveScore = (unique_locator.score + locator.score) / 2;
|
|
799
799
|
const newLocator = {
|
|
800
800
|
...unique_locator,
|