@checksum-ai/runtime 2.0.24 → 3.0.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.
- package/.env +1 -1
- package/cli.js +1 -1
- package/index.js +4 -4
- package/package.json +2 -2
- package/pw-report-template.html +1 -1
- package/scripts/playwright_patches/1.59.0.js +502 -0
- package/test-run-monitor.js +98 -98
- package/vtg-pw-bridge-runner.js +5 -5
package/vtg-pw-bridge-runner.js
CHANGED
|
@@ -130,7 +130,7 @@ ${r.format(i)}`.trim())}};e(Lvr,"MockAgent");var Rvr=Lvr;Rrn.exports=Rvr});var j
|
|
|
130
130
|
${p}`;break;case"retry":Msn(p)&&(i[c]=p);break;case"id":jsn(p)&&(i[c]=p);break;case"event":p.length>0&&(i[c]=p);break}}processEvent(r){r.retry&&Msn(r.retry)&&(this.state.reconnectionTime=parseInt(r.retry,10)),r.id!==void 0&&jsn(r.id)&&(this.state.lastEventId=r.id),r.data!==void 0&&this.push({type:r.event||"message",options:{data:r.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};e(Axr,"EventSourceStream");var vxr=Axr;Usn.exports={EventSourceStream:vxr}});var Gsn=$r((Ova,Wsn)=>{"use strict";var{pipeline:Kbi}=require("stream"),{fetching:Ybi}=wit(),{makeRequest:Xbi}=CLe(),{webidl:c$}=NL(),{EventSourceStream:Zbi}=Qsn(),{parseMIMEType:eEi}=Ote(),{createFastMessageEvent:tEi}=fTt(),{isNetworkError:qsn}=Cit(),{kEnumerableProperty:zwe}=CA(),{environmentSettingsObject:$sn}=aY(),Vsn=!1,Jsn=3e3,Rit=0,zsn=1,Lit=2,rEi="anonymous",nEi="use-credentials",XB,VLe,Mit,Gte,Hwe,jit,Uit,Zfe,hCe,xxr,bxr,wTt=class wTt extends EventTarget{constructor(i,s={}){super();wl(this,hCe);wl(this,XB,{open:null,error:null,message:null});wl(this,VLe);wl(this,Mit,!1);wl(this,Gte,Rit);wl(this,Hwe,null);wl(this,jit,null);wl(this,Uit);wl(this,Zfe);c$.util.markAsUncloneable(this);let c="EventSource constructor";c$.argumentLengthCheck(arguments,1,c),Vsn||(Vsn=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),i=c$.converters.USVString(i),s=c$.converters.EventSourceInitDict(s,c,"eventSourceInitDict"),du(this,Uit,s.node.dispatcher||s.dispatcher),du(this,Zfe,{lastEventId:"",reconnectionTime:s.node.reconnectionTime});let p=$sn,_;try{_=new URL(i,p.settingsObject.baseUrl),hr(this,Zfe).origin=_.origin}catch(D){throw new DOMException(D,"SyntaxError")}du(this,VLe,_.href);let v=rEi;s.withCredentials===!0&&(v=nEi,du(this,Mit,!0));let E={redirect:"follow",keepalive:!0,mode:"cors",credentials:v==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};E.client=$sn.settingsObject,E.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],E.cache="no-store",E.initiator="other",E.urlList=[new URL(hr(this,VLe))],du(this,Hwe,Xbi(E)),gm(this,hCe,xxr).call(this)}get readyState(){return hr(this,Gte)}get url(){return hr(this,VLe)}get withCredentials(){return hr(this,Mit)}close(){c$.brandCheck(this,wTt),hr(this,Gte)!==Lit&&(du(this,Gte,Lit),hr(this,jit).abort(),du(this,Hwe,null))}get onopen(){return hr(this,XB).open}set onopen(i){hr(this,XB).open&&this.removeEventListener("open",hr(this,XB).open);let s=c$.converters.EventHandlerNonNull(i);s!==null?(this.addEventListener("open",s),hr(this,XB).open=i):hr(this,XB).open=null}get onmessage(){return hr(this,XB).message}set onmessage(i){hr(this,XB).message&&this.removeEventListener("message",hr(this,XB).message);let s=c$.converters.EventHandlerNonNull(i);s!==null?(this.addEventListener("message",s),hr(this,XB).message=i):hr(this,XB).message=null}get onerror(){return hr(this,XB).error}set onerror(i){hr(this,XB).error&&this.removeEventListener("error",hr(this,XB).error);let s=c$.converters.EventHandlerNonNull(i);s!==null?(this.addEventListener("error",s),hr(this,XB).error=i):hr(this,XB).error=null}};XB=new WeakMap,VLe=new WeakMap,Mit=new WeakMap,Gte=new WeakMap,Hwe=new WeakMap,jit=new WeakMap,Uit=new WeakMap,Zfe=new WeakMap,hCe=new WeakSet,xxr=e(function(){if(hr(this,Gte)===Lit)return;du(this,Gte,Rit);let i={request:hr(this,Hwe),dispatcher:hr(this,Uit)},s=e(c=>{if(!qsn(c))return gm(this,hCe,bxr).call(this)},"processEventSourceEndOfBody");i.processResponseEndOfBody=s,i.processResponse=c=>{if(qsn(c))if(c.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{gm(this,hCe,bxr).call(this);return}let p=c.headersList.get("content-type",!0),_=p!==null?eEi(p):"failure",v=_!=="failure"&&_.essence==="text/event-stream";if(c.status!==200||v===!1){this.close(),this.dispatchEvent(new Event("error"));return}du(this,Gte,zsn),this.dispatchEvent(new Event("open")),hr(this,Zfe).origin=c.urlList[c.urlList.length-1].origin;let E=new Zbi({eventSourceSettings:hr(this,Zfe),push:e(D=>{this.dispatchEvent(tEi(D.type,D.options))},"push")});Kbi(c.body.stream,E,D=>{(D==null?void 0:D.aborted)===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},du(this,jit,Ybi(i))},"#connect"),bxr=e(function(){var i;hr(this,Gte)!==Lit&&(du(this,Gte,Rit),this.dispatchEvent(new Event("error")),(i=setTimeout(()=>{hr(this,Gte)===Rit&&(hr(this,Zfe).lastEventId.length&&hr(this,Hwe).headersList.set("last-event-id",hr(this,Zfe).lastEventId,!0),gm(this,hCe,xxr).call(this))},hr(this,Zfe).reconnectionTime))==null||i.unref())},"#reconnect"),e(wTt,"EventSource");var JLe=wTt,Hsn={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:Rit,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:zsn,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:Lit,writable:!1}};Object.defineProperties(JLe,Hsn);Object.defineProperties(JLe.prototype,Hsn);Object.defineProperties(JLe.prototype,{close:zwe,onerror:zwe,onmessage:zwe,onopen:zwe,readyState:zwe,url:zwe,withCredentials:zwe});c$.converters.EventSourceInitDict=c$.dictionaryConverter([{key:"withCredentials",converter:c$.converters.boolean,defaultValue:e(()=>!1,"defaultValue")},{key:"dispatcher",converter:c$.converters.any},{key:"node",converter:c$.dictionaryConverter([{key:"reconnectionTime",converter:c$.converters["unsigned long"],defaultValue:e(()=>Jsn,"defaultValue")},{key:"dispatcher",converter:c$.converters.any}]),defaultValue:e(()=>({}),"defaultValue")}]);Wsn.exports={EventSource:JLe,defaultReconnectionTime:Jsn}});var ton=$r((Lva,K1)=>{"use strict";var iEi=MEe(),Ysn=wRe(),aEi=uwe(),sEi=gen(),oEi=xen(),cEi=fwe(),uEi=s2r(),lEi=A2r(),pEi=d2r(),fEi=ltn(),dEi=htn(),_Ei=vtn(),Xsn=rA(),kTt=CA(),{InvalidArgumentError:TTt}=Xsn,zLe=Xtn(),mEi=twe(),hEi=bvr(),{MockCallHistory:gEi,MockCallHistoryLog:yEi}=wvr(),vEi=Mvr(),AEi=Nvr(),xEi=nnn(),bEi=rvr(),EEi=fwt(),{getGlobalDispatcher:Zsn,setGlobalDispatcher:CEi}=Twt(),DEi=nLe(),SEi=Yvr();Object.assign(Ysn.prototype,zLe);K1.exports.Dispatcher=Ysn;K1.exports.Client=iEi;K1.exports.Pool=aEi;K1.exports.BalancedPool=sEi;K1.exports.RoundRobinPool=oEi;K1.exports.Agent=cEi;K1.exports.Dispatcher1Wrapper=uEi;K1.exports.ProxyAgent=lEi;K1.exports.Socks5ProxyAgent=pEi;K1.exports.EnvHttpProxyAgent=fEi;K1.exports.RetryAgent=dEi;K1.exports.H2CClient=_Ei;K1.exports.RetryHandler=EEi;K1.exports.DecoratorHandler=DEi;K1.exports.RedirectHandler=SEi;K1.exports.interceptors={redirect:mnn(),responseError:gnn(),retry:vnn(),dump:bnn(),dns:Tnn(),cache:Hnn(),decompress:rin(),deduplicate:uin()};K1.exports.cacheStores={MemoryCacheStore:_Ar()};var wEi=din();K1.exports.cacheStores.SqliteCacheStore=wEi;K1.exports.buildConnector=mEi;K1.exports.errors=Xsn;K1.exports.util={parseHeaders:kTt.parseHeaders,headerNameToString:kTt.headerNameToString};function Qit(n){return(r,i,s)=>{if(typeof i=="function"&&(s=i,i=null),!r||typeof r!="string"&&typeof r!="object"&&!(r instanceof URL))throw new TTt("invalid url");if(i!=null&&typeof i!="object")throw new TTt("invalid opts");if(i&&i.path!=null){if(typeof i.path!="string")throw new TTt("invalid opts.path");let _=i.path;i.path.startsWith("/")||(_=`/${_}`),r=new URL(kTt.parseOrigin(r).origin+_)}else i||(i=typeof r=="object"?r:{}),r=kTt.parseURL(r);let{agent:c,dispatcher:p=Zsn()}=i;if(c)throw new TTt("unsupported opts.agent. Did you mean opts.client?");return n.call(p,{...i,origin:r.origin,path:r.search?`${r.pathname}${r.search}`:r.pathname,method:i.method||(i.body?"PUT":"GET")},s)}}e(Qit,"makeDispatcher");K1.exports.setGlobalDispatcher=CEi;K1.exports.getGlobalDispatcher=Zsn;var TEi=wit().fetch,Ksn=typeof __filename<"u"?__filename:void 0;function eon(n,r){if(!n||typeof n!="object")return;let i=typeof n.stack=="string"?n.stack:"",s=r.replace(/\\/g,"/");if(i&&(i.includes(r)||i.includes(s)))return;let c={};if(Error.captureStackTrace(c,eon),!c.stack)return;let p=c.stack.split(`
|
|
131
131
|
`).slice(1).join(`
|
|
132
132
|
`);n.stack=i?`${i}
|
|
133
|
-
${p}`:c.stack}e(eon,"appendFetchStackTrace");K1.exports.fetch=e(function(r,i=void 0){return TEi(r,i).catch(s=>{throw Ksn?eon(s,Ksn):s&&typeof s=="object"&&Error.captureStackTrace(s,K1.exports.fetch),s})},"fetch");K1.exports.Headers=Fwe().Headers;K1.exports.Response=Cit().Response;K1.exports.Request=CLe().Request;K1.exports.FormData=L8t().FormData;var{setGlobalOrigin:kEi,getGlobalOrigin:IEi}=Rgr();K1.exports.setGlobalOrigin=kEi;K1.exports.getGlobalOrigin=IEi;var{CacheStorage:FEi}=Can(),{kConstruct:NEi}=B4();K1.exports.caches=new FEi(NEi);var{deleteCookie:PEi,getCookies:BEi,getSetCookies:OEi,setCookie:REi,parseCookie:LEi}=Lan();K1.exports.deleteCookie=PEi;K1.exports.getCookies=BEi;K1.exports.getSetCookies=OEi;K1.exports.setCookie=REi;K1.exports.parseCookie=LEi;var{parseMIMEType:MEi,serializeAMimeType:jEi}=Ote();K1.exports.parseMIMEType=MEi;K1.exports.serializeAMimeType=jEi;var{CloseEvent:UEi,ErrorEvent:QEi,MessageEvent:qEi}=fTt(),{WebSocket:$Ei,ping:VEi}=bsn();K1.exports.WebSocket=$Ei;K1.exports.CloseEvent=UEi;K1.exports.ErrorEvent=QEi;K1.exports.MessageEvent=qEi;K1.exports.ping=VEi;K1.exports.WebSocketStream=Osn().WebSocketStream;K1.exports.WebSocketError=fxr().WebSocketError;K1.exports.request=Qit(zLe.request);K1.exports.stream=Qit(zLe.stream);K1.exports.pipeline=Qit(zLe.pipeline);K1.exports.connect=Qit(zLe.connect);K1.exports.upgrade=Qit(zLe.upgrade);K1.exports.MockClient=hEi;K1.exports.MockCallHistory=gEi;K1.exports.MockCallHistoryLog=yEi;K1.exports.MockPool=AEi;K1.exports.MockAgent=vEi;K1.exports.SnapshotAgent=xEi;K1.exports.mockErrors=bEi;var{EventSource:JEi}=Gsn();K1.exports.EventSource=JEi;function zEi(){globalThis.fetch=K1.exports.fetch,globalThis.Headers=K1.exports.Headers,globalThis.Response=K1.exports.Response,globalThis.Request=K1.exports.Request,globalThis.FormData=K1.exports.FormData,globalThis.WebSocket=K1.exports.WebSocket,globalThis.CloseEvent=K1.exports.CloseEvent,globalThis.ErrorEvent=K1.exports.ErrorEvent,globalThis.MessageEvent=K1.exports.MessageEvent,globalThis.EventSource=K1.exports.EventSource}e(zEi,"install");K1.exports.install=zEi});var qit,Exr,$it,ron=Ws(()=>{"use strict";_6();qit=require("perf_hooks"),Exr=class Exr{constructor(r={}){this.options=r;this.priorityQueue=[];this.nonPriorityQueue=[];this.isRunning=!1;this.taskIndex=0;this.timeRunningTasks=0;this.timeGoingBack=0;this.tasksExecuted=0}enqueue(r){let i=this.taskIndex++,s={...r,index:i,queuedAt:qit.performance.now()};if(r.priority)this.priorityQueue.push(s);else if(this.options.sortByTimestamp){let c=this.nonPriorityQueue.findIndex(p=>p.timestamp>r.timestamp);c===-1?this.nonPriorityQueue.push(s):this.nonPriorityQueue.splice(c,0,s)}else this.nonPriorityQueue.push(s);return i}popTask(){return this.priorityQueue.length>0?this.priorityQueue.shift():this.nonPriorityQueue.shift()}async runTasks(r){if(!this.isRunning){this.isRunning=!0;try{for(;this.getQueueLength()>0;){let i=this.popTask();if(!i)break;let s=qit.performance.now();try{if(this.options.logPerformance){let p=qit.performance.now()-i.queuedAt;af.info(`Running task, timestamp: ${i.timestamp} \x1B[36m${i.name}\x1B[0m, index: ${i.index}, was pending for ${p}ms`)}await r(i);let c=qit.performance.now()-s;this.timeRunningTasks+=c,this.options.logPerformance&&af.info("Finished running task, took",c,"ms.","Queue lengths:",`priority=${this.priorityQueue.length}`,`non-priority=${this.nonPriorityQueue.length}`),this.tasksExecuted++}catch(c){af.error("Task execution error:",c)}}}finally{this.isRunning=!1,this.getQueueLength()>0&&this.options.logPerformance&&af.info("Accumulated time running tasks:",this.timeRunningTasks,"ms, from which time spent going back:",this.timeGoingBack)}}}getTasksAtTimestamp(r){return[...this.priorityQueue.filter(i=>i.timestamp===r),...this.nonPriorityQueue.filter(i=>i.timestamp===r)]}removeTasksAtTimestamp(r){this.priorityQueue=this.priorityQueue.filter(i=>i.timestamp!==r),this.nonPriorityQueue=this.nonPriorityQueue.filter(i=>i.timestamp!==r)}getQueueLength(){return this.priorityQueue.length+this.nonPriorityQueue.length}setTimeGoingBack(r){this.timeGoingBack=r}};e(Exr,"TaskTimeMachineQueue");$it=Exr});var non,Jit,Vit,Cxr,oge,ITt=Ws(()=>{"use strict";non=require("@playwright/test");tYr();WS();_6();bRe();Jit=nd(ton());ron();Vit=require("perf_hooks"),Cxr=class Cxr{constructor(r,i,s={headless:!0,logPerformance:!1,timestampBatchingEnabled:!1,sortByTimestamp:!1,taskTimeout:24e4,debugPort:void 0,frameMsgBrokerRegisterName:void 0}){this.frameMsgBroker=r;this.injectedScriptManager=i;this.options=s;this.currentTimestamp=0;this.currentBeforeTimestamp=!1;this.currentChecksumId="0";this.timeGoingBack=0;this.pagesWithCorsInterception=new Set;this.reducedHTMLCache={};this.getReducedHTMLWithRetries=e(async(r,{retriesLeft:i=3,retryWaitMS:s=1e3}={})=>{try{let{reducedHTML:c,currentChecksumId:p}=await r.evaluate(async _=>{var v,E;return(E=(v=window==null?void 0:window.checksum)==null?void 0:v.testGenerator)==null?void 0:E.reduceHTML({},_)},{stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:this.currentChecksumId,fromTimeMachine:!0,invalidateCache:!0});return this.currentChecksumId=p,{reducedHTML:c}}catch(c){if(i>0)return await Mb(s),this.getReducedHTMLWithRetries(r,{retriesLeft:i-1,retryWaitMS:s});throw c}},"getReducedHTMLWithRetries");if(this.taskQueue=new $it({sortByTimestamp:s.sortByTimestamp,logPerformance:s.logPerformance}),s.webProxy){let{username:c,password:p,server:_}=s.webProxy;c&&p?this.webProxyAgent=new Jit.ProxyAgent({uri:`http://${c}:${p}@${_.replace("http://","")}`}):this.webProxyAgent=new Jit.ProxyAgent({uri:_})}}getPage(){return this.timeMachineFrame.page()}getFrame(){return this.timeMachineFrame}async prepare(r,i,s){this.recordingFrame=r,await this.frameMsgBroker.register("live",r),i?this.timeMachineFrame=i:this.timeMachineFrame=await this.prepareBrowserContextAndFrame(),await this.preventCrossOriginErrors(this.timeMachineFrame),this.options.frameMsgBrokerRegisterName&&await this.frameMsgBroker.register(this.options.frameMsgBrokerRegisterName,this.timeMachineFrame),s&&s(this.timeMachineFrame),await this.injectedScriptManager.addTrackedFrame(this.timeMachineFrame),this.timeMachineFrame.page().on("framenavigated",async c=>{await this.injectedScriptManager.onFrameNavigated(c)}),this.subscribeToRrwebEvents(),this.taskQueue=new $it({sortByTimestamp:this.options.sortByTimestamp,logPerformance:this.options.logPerformance}),await this.start()}async preventCrossOriginErrors(r){try{let i=r.page(),s=nw(i);if(this.pagesWithCorsInterception.has(s))return;this.pagesWithCorsInterception.add(s),await i.route(/^https?:\/\/(?!(?:localhost|127\.0\.0\.1|::1)).*/,async(c,p)=>{var E;let v=c.request().url();try{let D=this.webProxyAgent?{dispatcher:this.webProxyAgent}:{},w=await(0,Jit.fetch)(v,D),B=w.status,P={};w.headers.forEach((le,de)=>P[de]=le),P["access-control-allow-origin"]="*";let L=parseInt(w.headers.get("content-length")||"0",10),j=25*1024*1024;if(L>j)return c.continue();if(!w.body){await c.fulfill({status:B,headers:P});return}let ee=await w.arrayBuffer(),ue=Buffer.from(ee);await c.fulfill({status:B,headers:P,body:ue})}catch(D){return(E=D.cause)==null||E.code,c.continue()}})}catch{}}async start(){await this.timeMachineFrame.evaluate(async()=>{window.checksum.timeMachine.start({firstEventTimestamp:Date.now()})})}setBrowserContext(r){this.timeMachineBrowserContext=r}async executeTask(r,i=void 0,{name:s,beforeTimestamp:c=!1,priority:p=!1}={}){return new Promise((_,v)=>{let E=e(async({shouldGoBack:D,shouldBatch:w}={shouldGoBack:!0,shouldBatch:this.options.timestampBatchingEnabled})=>{if(this.timeMachineFrame.isDetached()&&v(),D){let L=Vit.performance.now();await this.goBack(i,c),this.timeGoingBack+=Vit.performance.now()-L,this.taskQueue.setTimeGoingBack(this.timeGoingBack)}let B=e(L=>async()=>{try{let j=Vit.performance.now(),V=await HS(L(this.timeMachineFrame),this.options.taskTimeout,()=>`Task execution timeout - ${s}, took ${Vit.performance.now()-j}ms with timeout of ${this.options.taskTimeout}ms`);_(V)}catch(j){af.error("Task execution error:",j.message),v(j)}},"makeSafeRunTask"),P=[B(r)];if(this.taskQueue.getQueueLength()>0&&w){let L=this.taskQueue.getTasksAtTimestamp(i);P.push(...L.map(({task:j})=>B(()=>j({shouldGoBack:!1,shouldBatch:!1})))),this.taskQueue.removeTasksAtTimestamp(i),P.length&&console.log(`Batching to task "${s}" ${P.length-1} more tasks`)}for(let L of P)await L()},"taskWrapper");this.taskQueue.enqueue({name:s,task:E,timestamp:c?i-1:i,priority:p}),this.runTasks()})}executeReducedHTMLTask(r,{priority:i=!1}={}){if(this.reducedHTMLCache[r]){let s=new tnt(this.reducedHTMLCache[r]);return Promise.resolve(s.getRrwebIdsReducedDomString())}return this.executeTask(async s=>{let c="",p=await this.getReducedHTMLWithRetries(s);return c=p==null?void 0:p.reducedHTML,c&&(this.reducedHTMLCache[r]=c),new tnt(c).getRrwebIdsReducedDomString()},r,{name:"getReducedHTMLForTimestamp",priority:i})}goBack(r,i=!1){return this.currentBeforeTimestamp===i&&this.currentTimestamp===r?Promise.resolve():(this.currentTimestamp=r,this.currentBeforeTimestamp=i,this.timeMachineFrame.evaluate(({timestamp:s,beforeTimestamp:c})=>s===void 0?window.checksum.timeMachine.goLive():window.checksum.timeMachine.goBack(s,{beforeTimestamp:c}),{timestamp:r,beforeTimestamp:i}))}goLive(){return this.timeMachineFrame.evaluate(()=>window.checksum.timeMachine.goLive())}async runTasks(){await this.taskQueue.runTasks(async r=>{await r.task()})}async rrwebEventHandler(r){let i=JSON.stringify(r);try{await this.timeMachineFrame.evaluate(function(s){let c=JSON.parse(s);return window.checksum.timeMachine.handleEvents(c)},i)}catch{}return r=null,i}async makeBrowserContext(){let r=[];this.options.debugPort&&r.push(`--remote-debugging-port=${this.options.debugPort}`);let i=await non.chromium.launch({devtools:!1,headless:this.options.headless,args:r});return this.timeMachineBrowserContext=await i.newContext({bypassCSP:!0}),this.timeMachineBrowserContext}async makeFrame(){return(await this.timeMachineBrowserContext.newPage()).mainFrame()}async prepareBrowserContextAndFrame(){return this.timeMachineBrowserContext||await this.makeBrowserContext(),this.makeFrame()}subscribeToRrwebEvents(){let r="rrweb";this.frameMsgBroker.subscribeToChannel(r,this.timeMachineFrame,{originFrame:this.recordingFrame,handler:this.rrwebEventHandler.bind(this)}),this.timeMachineFrame.page().on("close",()=>this.frameMsgBroker.unsubscribeFromChannel(r,this.timeMachineFrame))}async toggleTimeMachineHandleEvents(r){try{await this.timeMachineFrame.evaluate(i=>window.checksum.timeMachine.setShouldHandleEvents(i),r)}catch{}}};e(Cxr,"ChecksumTimeMachine");oge=Cxr});var Dxr=Ws(()=>{"use strict"});var FTt=$r((HLe,zit)=>{(function(){var n,r="4.18.1",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",c="Expected a function",p="Invalid `variable` option passed into `_.template`",_="Invalid `imports` option passed into `_.template`",v="__lodash_hash_undefined__",E=500,D="__lodash_placeholder__",w=1,B=2,P=4,L=1,j=2,V=1,ee=2,ue=4,le=8,de=16,xe=32,Re=64,$e=128,Ke=256,Ce=512,We=30,mt="...",Ve=800,Ue=16,Qe=1,qe=2,Ge=3,Ze=1/0,je=9007199254740991,qt=17976931348623157e292,Nt=NaN,It=4294967295,Zt=It-1,lr=It>>>1,Jt=[["ary",$e],["bind",V],["bindKey",ee],["curry",le],["curryRight",de],["flip",Ce],["partial",xe],["partialRight",Re],["rearg",Ke]],ti="[object Arguments]",xn="[object Array]",rt="[object AsyncFunction]",pt="[object Boolean]",Qr="[object Date]",Pr="[object DOMException]",ai="[object Error]",In="[object Function]",Ri="[object GeneratorFunction]",kr="[object Map]",Ss="[object Number]",Vs="[object Null]",Fa="[object Object]",va="[object Promise]",as="[object Proxy]",Bs="[object RegExp]",rs="[object Set]",Oa="[object String]",sa="[object Symbol]",ga="[object Undefined]",qo="[object WeakMap]",Na="[object WeakSet]",so="[object ArrayBuffer]",ec="[object DataView]",Lr="[object Float32Array]",ri="[object Float64Array]",ma="[object Int8Array]",Vn="[object Int16Array]",qa="[object Int32Array]",Go="[object Uint8Array]",li="[object Uint8ClampedArray]",or="[object Uint16Array]",lt="[object Uint32Array]",ht=/\b__p \+= '';/g,Xe=/\b(__p \+=) '' \+/g,tt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,At=/&(?:amp|lt|gt|quot|#39);/g,st=/[&<>"']/g,Yt=RegExp(At.source),un=RegExp(st.source),Er=/<%-([\s\S]+?)%>/g,jn=/<%([\s\S]+?)%>/g,Li=/<%=([\s\S]+?)%>/g,fa=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,si=/^\w*$/,an=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Un=/[\\^$.*+?()[\]{}|]/g,Xn=RegExp(Un.source),_n=/^\s+/,Xt=/\s/,Me=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Pt=/\{\n\/\* \[wrapped with (.+)\] \*/,Gt=/,? & /,Tt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,qr=/[()=,{}\[\]\/\s]/,br=/\\(\\)?/g,dt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Mt=/\w*$/,rr=/^[-+]0x[0-9a-f]+$/i,Or=/^0b[01]+$/i,en=/^\[object .+?Constructor\]$/,$n=/^0o[0-7]+$/i,na=/^(?:0|[1-9]\d*)$/,Wi=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Fi=/($^)/,mn=/['\n\r\u2028\u2029\\]/g,Ba="\\ud800-\\udfff",vi="\\u0300-\\u036f",uo="\\ufe20-\\ufe2f",Ru="\\u20d0-\\u20ff",of=vi+uo+Ru,Uc="\\u2700-\\u27bf",Fl="a-z\\xdf-\\xf6\\xf8-\\xff",Df="\\xac\\xb1\\xd7\\xf7",Rl="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Qp="\\u2000-\\u206f",Bu=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",cf="A-Z\\xc0-\\xd6\\xd8-\\xde",fd="\\ufe0e\\ufe0f",Im=Df+Rl+Qp+Bu,Yh="['\u2019]",Lg="["+Ba+"]",D_="["+Im+"]",R2="["+of+"]",L2="\\d+",d0="["+Uc+"]",_c="["+Fl+"]",qf="[^"+Ba+Im+L2+Uc+Fl+cf+"]",Tl="\\ud83c[\\udffb-\\udfff]",rf="(?:"+R2+"|"+Tl+")",ip="[^"+Ba+"]",kf="(?:\\ud83c[\\udde6-\\uddff]){2}",_u="[\\ud800-\\udbff][\\udc00-\\udfff]",mc="["+cf+"]",Ra="\\u200d",Ci="(?:"+_c+"|"+qf+")",Fc="(?:"+mc+"|"+qf+")",_0="(?:"+Yh+"(?:d|ll|m|re|s|t|ve))?",If="(?:"+Yh+"(?:D|LL|M|RE|S|T|VE))?",K_=rf+"?",zr="["+fd+"]?",tr="(?:"+Ra+"(?:"+[ip,kf,_u].join("|")+")"+zr+K_+")*",Yn="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ta="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",xs=zr+K_+tr,Ca="(?:"+[d0,kf,_u].join("|")+")"+xs,To="(?:"+[ip+R2+"?",R2,kf,_u,Lg].join("|")+")",hu=RegExp(Yh,"g"),Ao=RegExp(R2,"g"),fo=RegExp(Tl+"(?="+Tl+")|"+To+xs,"g"),cc=RegExp([mc+"?"+_c+"+"+_0+"(?="+[D_,mc,"$"].join("|")+")",Fc+"+"+If+"(?="+[D_,mc+Ci,"$"].join("|")+")",mc+"?"+Ci+"+"+_0,mc+"+"+If,Ta,Yn,L2,Ca].join("|"),"g"),Nc=RegExp("["+Ra+Ba+of+fd+"]"),fu=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fu=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ln=-1,Qu={};Qu[Lr]=Qu[ri]=Qu[ma]=Qu[Vn]=Qu[qa]=Qu[Go]=Qu[li]=Qu[or]=Qu[lt]=!0,Qu[ti]=Qu[xn]=Qu[so]=Qu[pt]=Qu[ec]=Qu[Qr]=Qu[ai]=Qu[In]=Qu[kr]=Qu[Ss]=Qu[Fa]=Qu[Bs]=Qu[rs]=Qu[Oa]=Qu[qo]=!1;var Au={};Au[ti]=Au[xn]=Au[so]=Au[ec]=Au[pt]=Au[Qr]=Au[Lr]=Au[ri]=Au[ma]=Au[Vn]=Au[qa]=Au[kr]=Au[Ss]=Au[Fa]=Au[Bs]=Au[rs]=Au[Oa]=Au[sa]=Au[Go]=Au[li]=Au[or]=Au[lt]=!0,Au[ai]=Au[In]=Au[qo]=!1;var Vp={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Y0={"&":"&","<":"<",">":">",'"':""","'":"'"},kd={"&":"&","<":"<",">":">",""":'"',"'":"'"},Hd={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},X0=parseFloat,Of=parseInt,ji=typeof global=="object"&&global&&global.Object===Object&&global,eo=typeof self=="object"&&self&&self.Object===Object&&self,Ea=ji||eo||Function("return this")(),Ec=typeof HLe=="object"&&HLe&&!HLe.nodeType&&HLe,Ja=Ec&&typeof zit=="object"&&zit&&!zit.nodeType&&zit,Hi=Ja&&Ja.exports===Ec,Ni=Hi&&ji.process,ta=function(){try{var Gc=Ja&&Ja.require&&Ja.require("util").types;return Gc||Ni&&Ni.binding&&Ni.binding("util")}catch{}}(),jt=ta&&ta.isArrayBuffer,Br=ta&&ta.isDate,kn=ta&&ta.isMap,hi=ta&&ta.isRegExp,ea=ta&&ta.isSet,Fo=ta&&ta.isTypedArray;function Wa(Gc,fp,ja){switch(ja.length){case 0:return Gc.call(fp);case 1:return Gc.call(fp,ja[0]);case 2:return Gc.call(fp,ja[0],ja[1]);case 3:return Gc.call(fp,ja[0],ja[1],ja[2])}return Gc.apply(fp,ja)}e(Wa,"apply");function Ka(Gc,fp,ja,Qd){for(var _h=-1,ay=Gc==null?0:Gc.length;++_h<ay;){var K2=Gc[_h];fp(Qd,K2,ja(K2),Gc)}return Qd}e(Ka,"arrayAggregator");function nc(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length;++ja<Qd&&fp(Gc[ja],ja,Gc)!==!1;);return Gc}e(nc,"arrayEach");function ju(Gc,fp){for(var ja=Gc==null?0:Gc.length;ja--&&fp(Gc[ja],ja,Gc)!==!1;);return Gc}e(ju,"arrayEachRight");function se(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length;++ja<Qd;)if(!fp(Gc[ja],ja,Gc))return!1;return!0}e(se,"arrayEvery");function Lo(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length,_h=0,ay=[];++ja<Qd;){var K2=Gc[ja];fp(K2,ja,Gc)&&(ay[_h++]=K2)}return ay}e(Lo,"arrayFilter");function Ip(Gc,fp){var ja=Gc==null?0:Gc.length;return!!ja&&gu(Gc,fp,0)>-1}e(Ip,"arrayIncludes");function jl(Gc,fp,ja){for(var Qd=-1,_h=Gc==null?0:Gc.length;++Qd<_h;)if(ja(fp,Gc[Qd]))return!0;return!1}e(jl,"arrayIncludesWith");function Ul(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length,_h=Array(Qd);++ja<Qd;)_h[ja]=fp(Gc[ja],ja,Gc);return _h}e(Ul,"arrayMap");function Ff(Gc,fp){for(var ja=-1,Qd=fp.length,_h=Gc.length;++ja<Qd;)Gc[_h+ja]=fp[ja];return Gc}e(Ff,"arrayPush");function I0(Gc,fp,ja,Qd){var _h=-1,ay=Gc==null?0:Gc.length;for(Qd&&ay&&(ja=Gc[++_h]);++_h<ay;)ja=fp(ja,Gc[_h],_h,Gc);return ja}e(I0,"arrayReduce");function H0(Gc,fp,ja,Qd){var _h=Gc==null?0:Gc.length;for(Qd&&_h&&(ja=Gc[--_h]);_h--;)ja=fp(ja,Gc[_h],_h,Gc);return ja}e(H0,"arrayReduceRight");function mp(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length;++ja<Qd;)if(fp(Gc[ja],ja,Gc))return!0;return!1}e(mp,"arraySome");var C0=hs("length");function Jn(Gc){return Gc.split("")}e(Jn,"asciiToArray");function ws(Gc){return Gc.match(Tt)||[]}e(ws,"asciiWords");function Eo(Gc,fp,ja){var Qd;return ja(Gc,function(_h,ay,K2){if(fp(_h,ay,K2))return Qd=ay,!1}),Qd}e(Eo,"baseFindKey");function Ko(Gc,fp,ja,Qd){for(var _h=Gc.length,ay=ja+(Qd?1:-1);Qd?ay--:++ay<_h;)if(fp(Gc[ay],ay,Gc))return ay;return-1}e(Ko,"baseFindIndex");function gu(Gc,fp,ja){return fp===fp?r1(Gc,fp,ja):Ko(Gc,zu,ja)}e(gu,"baseIndexOf");function Qo(Gc,fp,ja,Qd){for(var _h=ja-1,ay=Gc.length;++_h<ay;)if(Qd(Gc[_h],fp))return _h;return-1}e(Qo,"baseIndexOfWith");function zu(Gc){return Gc!==Gc}e(zu,"baseIsNaN");function kl(Gc,fp){var ja=Gc==null?0:Gc.length;return ja?sn(Gc,fp)/ja:Nt}e(kl,"baseMean");function hs(Gc){return function(fp){return fp==null?n:fp[Gc]}}e(hs,"baseProperty");function v0(Gc){return function(fp){return Gc==null?n:Gc[fp]}}e(v0,"basePropertyOf");function M0(Gc,fp,ja,Qd,_h){return _h(Gc,function(ay,K2,ly){ja=Qd?(Qd=!1,ay):fp(ja,ay,K2,ly)}),ja}e(M0,"baseReduce");function u0(Gc,fp){var ja=Gc.length;for(Gc.sort(fp);ja--;)Gc[ja]=Gc[ja].value;return Gc}e(u0,"baseSortBy");function sn(Gc,fp){for(var ja,Qd=-1,_h=Gc.length;++Qd<_h;){var ay=fp(Gc[Qd]);ay!==n&&(ja=ja===n?ay:ja+ay)}return ja}e(sn,"baseSum");function ts(Gc,fp){for(var ja=-1,Qd=Array(Gc);++ja<Gc;)Qd[ja]=fp(ja);return Qd}e(ts,"baseTimes");function nu(Gc,fp){return Ul(fp,function(ja){return[ja,Gc[ja]]})}e(nu,"baseToPairs");function Po(Gc){return Gc&&Gc.slice(0,Mp(Gc)+1).replace(_n,"")}e(Po,"baseTrim");function Ku(Gc){return function(fp){return Gc(fp)}}e(Ku,"baseUnary");function lp(Gc,fp){return Ul(fp,function(ja){return Gc[ja]})}e(lp,"baseValues");function xl(Gc,fp){return Gc.has(fp)}e(xl,"cacheHas");function Co(Gc,fp){for(var ja=-1,Qd=Gc.length;++ja<Qd&&gu(fp,Gc[ja],0)>-1;);return ja}e(Co,"charsStartIndex");function Pi(Gc,fp){for(var ja=Gc.length;ja--&&gu(fp,Gc[ja],0)>-1;);return ja}e(Pi,"charsEndIndex");function Gs(Gc,fp){for(var ja=Gc.length,Qd=0;ja--;)Gc[ja]===fp&&++Qd;return Qd}e(Gs,"countHolders");var gs=v0(Vp),No=v0(Y0);function za(Gc){return"\\"+Hd[Gc]}e(za,"escapeStringChar");function yc(Gc,fp){return Gc==null?n:Gc[fp]}e(yc,"getValue");function Tu(Gc){return Nc.test(Gc)}e(Tu,"hasUnicode");function hp(Gc){return fu.test(Gc)}e(hp,"hasUnicodeWord");function uf(Gc){for(var fp,ja=[];!(fp=Gc.next()).done;)ja.push(fp.value);return ja}e(uf,"iteratorToArray");function gf(Gc){var fp=-1,ja=Array(Gc.size);return Gc.forEach(function(Qd,_h){ja[++fp]=[_h,Qd]}),ja}e(gf,"mapToArray");function Np(Gc,fp){return function(ja){return Gc(fp(ja))}}e(Np,"overArg");function $f(Gc,fp){for(var ja=-1,Qd=Gc.length,_h=0,ay=[];++ja<Qd;){var K2=Gc[ja];(K2===fp||K2===D)&&(Gc[ja]=D,ay[_h++]=ja)}return ay}e($f,"replaceHolders");function S_(Gc){var fp=-1,ja=Array(Gc.size);return Gc.forEach(function(Qd){ja[++fp]=Qd}),ja}e(S_,"setToArray");function od(Gc){var fp=-1,ja=Array(Gc.size);return Gc.forEach(function(Qd){ja[++fp]=[Qd,Qd]}),ja}e(od,"setToPairs");function r1(Gc,fp,ja){for(var Qd=ja-1,_h=Gc.length;++Qd<_h;)if(Gc[Qd]===fp)return Qd;return-1}e(r1,"strictIndexOf");function Wp(Gc,fp,ja){for(var Qd=ja+1;Qd--;)if(Gc[Qd]===fp)return Qd;return Qd}e(Wp,"strictLastIndexOf");function pc(Gc){return Tu(Gc)?b_(Gc):C0(Gc)}e(pc,"stringSize");function Ll(Gc){return Tu(Gc)?Hs(Gc):Jn(Gc)}e(Ll,"stringToArray");function Mp(Gc){for(var fp=Gc.length;fp--&&Xt.test(Gc.charAt(fp)););return fp}e(Mp,"trimmedEndIndex");var zf=v0(kd);function b_(Gc){for(var fp=fo.lastIndex=0;fo.test(Gc);)++fp;return fp}e(b_,"unicodeSize");function Hs(Gc){return Gc.match(fo)||[]}e(Hs,"unicodeToArray");function n_(Gc){return Gc.match(cc)||[]}e(n_,"unicodeWords");var ym=e(function Gc(fp){fp=fp==null?Ea:E_.defaults(Ea.Object(),fp,E_.pick(Ea,Fu));var ja=fp.Array,Qd=fp.Date,_h=fp.Error,ay=fp.Function,K2=fp.Math,ly=fp.Object,Px=fp.RegExp,Db=fp.String,nA=fp.TypeError,A6=ja.prototype,uC=ay.prototype,lC=ly.prototype,ME=fp["__core-js_shared__"],pC=uC.toString,Mg=lC.hasOwnProperty,$1=0,fD=function(){var te=/[^.]+$/.exec(ME&&ME.keys&&ME.keys.IE_PROTO||"");return te?"Symbol(src)_1."+te:""}(),Wx=lC.toString,py=pC.call(ly),Sb=Ea._,ZA=Px("^"+pC.call(Mg).replace(Un,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),n2=Hi?fp.Buffer:n,Bx=fp.Symbol,he=fp.Uint8Array,yr=n2?n2.allocUnsafe:n,Qi=Np(ly.getPrototypeOf,ly),Za=ly.create,Qc=lC.propertyIsEnumerable,Op=A6.splice,Ha=Bx?Bx.isConcatSpreadable:n,La=Bx?Bx.iterator:n,$i=Bx?Bx.toStringTag:n,Pa=function(){try{var te=x9(ly,"defineProperty");return te({},"",{}),te}catch{}}(),Aa=fp.clearTimeout!==Ea.clearTimeout&&fp.clearTimeout,ba=Qd&&Qd.now!==Ea.Date.now&&Qd.now,ss=fp.setTimeout!==Ea.setTimeout&&fp.setTimeout,Os=K2.ceil,ka=K2.floor,to=ly.getOwnPropertySymbols,ls=n2?n2.isBuffer:n,go=fp.isFinite,Yo=A6.join,Oo=Np(ly.keys,ly),Dc=K2.max,yu=K2.min,vu=Qd.now,ep=fp.parseInt,Ms=K2.random,dl=A6.reverse,qc=x9(fp,"DataView"),Rc=x9(fp,"Map"),fe=x9(fp,"Promise"),Te=x9(fp,"Set"),Hr=x9(fp,"WeakMap"),dr=x9(ly,"create"),Zn=Hr&&new Hr,hn={},Fr=Eg(qc),ir=Eg(Rc),En=Eg(fe),Ct=Eg(Te),Cn=Eg(Hr),Ti=Bx?Bx.prototype:n,Gi=Ti?Ti.valueOf:n,ua=Ti?Ti.toString:n;function _e(te){if(AC(te)&&!k1(te)&&!(te instanceof Sc)){if(te instanceof no)return te;if(Mg.call(te,"__wrapped__"))return AT(te)}return new no(te)}e(_e,"lodash");var $a=function(){function te(){}return e(te,"object"),function(me){if(!KC(me))return{};if(Za)return Za(me);te.prototype=me;var xt=new te;return te.prototype=n,xt}}();function Ya(){}e(Ya,"baseLodash");function no(te,me){this.__wrapped__=te,this.__actions__=[],this.__chain__=!!me,this.__index__=0,this.__values__=n}e(no,"LodashWrapper"),_e.templateSettings={escape:Er,evaluate:jn,interpolate:Li,variable:"",imports:{_:_e}},_e.prototype=Ya.prototype,_e.prototype.constructor=_e,no.prototype=$a(Ya.prototype),no.prototype.constructor=no;function Sc(te){this.__wrapped__=te,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=It,this.__views__=[]}e(Sc,"LazyWrapper");function oo(){var te=new Sc(this.__wrapped__);return te.__actions__=Ts(this.__actions__),te.__dir__=this.__dir__,te.__filtered__=this.__filtered__,te.__iteratees__=Ts(this.__iteratees__),te.__takeCount__=this.__takeCount__,te.__views__=Ts(this.__views__),te}e(oo,"lazyClone");function _o(){if(this.__filtered__){var te=new Sc(this);te.__dir__=-1,te.__filtered__=!0}else te=this.clone(),te.__dir__*=-1;return te}e(_o,"lazyReverse");function zo(){var te=this.__wrapped__.value(),me=this.__dir__,xt=k1(te),An=me<0,ya=xt?te.length:0,co=zoe(0,ya,this.__views__),Xc=co.start,rl=co.end,dp=rl-Xc,td=An?rl:Xc-1,j0=this.__iteratees__,z0=j0.length,V_=0,n1=yu(dp,this.__takeCount__);if(!xt||!An&&ya==dp&&n1==dp)return hE(te,this.__actions__);var J1=[];e:for(;dp--&&V_<n1;){td+=me;for(var z1=-1,dg=te[td];++z1<z0;){var Ay=j0[z1],Nv=Ay.iteratee,c3=Ay.type,AE=Nv(dg);if(c3==qe)dg=AE;else if(!AE){if(c3==Qe)continue e;break e}}J1[V_++]=dg}return J1}e(zo,"lazyValue"),Sc.prototype=$a(Ya.prototype),Sc.prototype.constructor=Sc;function Zc(te){var me=-1,xt=te==null?0:te.length;for(this.clear();++me<xt;){var An=te[me];this.set(An[0],An[1])}}e(Zc,"Hash");function _l(){this.__data__=dr?dr(null):{},this.size=0}e(_l,"hashClear");function $o(te){var me=this.has(te)&&delete this.__data__[te];return this.size-=me?1:0,me}e($o,"hashDelete");function xp(te){var me=this.__data__;if(dr){var xt=me[te];return xt===v?n:xt}return Mg.call(me,te)?me[te]:n}e(xp,"hashGet");function $s(te){var me=this.__data__;return dr?me[te]!==n:Mg.call(me,te)}e($s,"hashHas");function Pc(te,me){var xt=this.__data__;return this.size+=this.has(te)?0:1,xt[te]=dr&&me===n?v:me,this}e(Pc,"hashSet"),Zc.prototype.clear=_l,Zc.prototype.delete=$o,Zc.prototype.get=xp,Zc.prototype.has=$s,Zc.prototype.set=Pc;function tp(te){var me=-1,xt=te==null?0:te.length;for(this.clear();++me<xt;){var An=te[me];this.set(An[0],An[1])}}e(tp,"ListCache");function Xp(){this.__data__=[],this.size=0}e(Xp,"listCacheClear");function Dp(te){var me=this.__data__,xt=jE(me,te);if(xt<0)return!1;var An=me.length-1;return xt==An?me.pop():Op.call(me,xt,1),--this.size,!0}e(Dp,"listCacheDelete");function lf(te){var me=this.__data__,xt=jE(me,te);return xt<0?n:me[xt][1]}e(lf,"listCacheGet");function yf(te){return jE(this.__data__,te)>-1}e(yf,"listCacheHas");function Uf(te,me){var xt=this.__data__,An=jE(xt,te);return An<0?(++this.size,xt.push([te,me])):xt[An][1]=me,this}e(Uf,"listCacheSet"),tp.prototype.clear=Xp,tp.prototype.delete=Dp,tp.prototype.get=lf,tp.prototype.has=yf,tp.prototype.set=Uf;function A0(te){var me=-1,xt=te==null?0:te.length;for(this.clear();++me<xt;){var An=te[me];this.set(An[0],An[1])}}e(A0,"MapCache");function $d(){this.size=0,this.__data__={hash:new Zc,map:new(Rc||tp),string:new Zc}}e($d,"mapCacheClear");function ku(te){var me=pF(this,te).delete(te);return this.size-=me?1:0,me}e(ku,"mapCacheDelete");function gp(te){return pF(this,te).get(te)}e(gp,"mapCacheGet");function Hf(te){return pF(this,te).has(te)}e(Hf,"mapCacheHas");function c_(te,me){var xt=pF(this,te),An=xt.size;return xt.set(te,me),this.size+=xt.size==An?0:1,this}e(c_,"mapCacheSet"),A0.prototype.clear=$d,A0.prototype.delete=ku,A0.prototype.get=gp,A0.prototype.has=Hf,A0.prototype.set=c_;function v_(te){var me=-1,xt=te==null?0:te.length;for(this.__data__=new A0;++me<xt;)this.add(te[me])}e(v_,"SetCache");function Hm(te){return this.__data__.set(te,v),this}e(Hm,"setCacheAdd");function Iv(te){return this.__data__.has(te)}e(Iv,"setCacheHas"),v_.prototype.add=v_.prototype.push=Hm,v_.prototype.has=Iv;function Ky(te){var me=this.__data__=new tp(te);this.size=me.size}e(Ky,"Stack");function iA(){this.__data__=new tp,this.size=0}e(iA,"stackClear");function Vb(te){var me=this.__data__,xt=me.delete(te);return this.size=me.size,xt}e(Vb,"stackDelete");function fC(te){return this.__data__.get(te)}e(fC,"stackGet");function x6(te){return this.__data__.has(te)}e(x6,"stackHas");function iv(te,me){var xt=this.__data__;if(xt instanceof tp){var An=xt.__data__;if(!Rc||An.length<i-1)return An.push([te,me]),this.size=++xt.size,this;xt=this.__data__=new A0(An)}return xt.set(te,me),this.size=xt.size,this}e(iv,"stackSet"),Ky.prototype.clear=iA,Ky.prototype.delete=Vb,Ky.prototype.get=fC,Ky.prototype.has=x6,Ky.prototype.set=iv;function ql(te,me){var xt=k1(te),An=!xt&&Ox(te),ya=!xt&&!An&&D6(te),co=!xt&&!An&&!ya&&AF(te),Xc=xt||An||ya||co,rl=Xc?ts(te.length,Db):[],dp=rl.length;for(var td in te)(me||Mg.call(te,td))&&!(Xc&&(td=="length"||ya&&(td=="offset"||td=="parent")||co&&(td=="buffer"||td=="byteLength"||td=="byteOffset")||yy(td,dp)))&&rl.push(td);return rl}e(ql,"arrayLikeKeys");function pm(te){var me=te.length;return me?te[Gg(0,me-1)]:n}e(pm,"arraySample");function Om(te,me){return cd(Ts(te),ei(me,0,te.length))}e(Om,"arraySampleSize");function jg(te){return cd(Ts(te))}e(jg,"arrayShuffle");function By(te,me,xt){(xt!==n&&!c7(te[me],xt)||xt===n&&!(me in te))&&De(te,me,xt)}e(By,"assignMergeValue");function ex(te,me,xt){var An=te[me];(!(Mg.call(te,me)&&c7(An,xt))||xt===n&&!(me in te))&&De(te,me,xt)}e(ex,"assignValue");function jE(te,me){for(var xt=te.length;xt--;)if(c7(te[xt][0],me))return xt;return-1}e(jE,"assocIndexOf");function av(te,me,xt,An){return vn(te,function(ya,co,Xc){me(An,ya,xt(ya),Xc)}),An}e(av,"baseAggregator");function Jb(te,me){return te&&J4(me,YC(me),te)}e(Jb,"baseAssign");function M(te,me){return te&&J4(me,wy(me),te)}e(M,"baseAssignIn");function De(te,me,xt){me=="__proto__"&&Pa?Pa(te,me,{configurable:!0,enumerable:!0,value:xt,writable:!0}):te[me]=xt}e(De,"baseAssignValue");function Vr(te,me){for(var xt=-1,An=me.length,ya=ja(An),co=te==null;++xt<An;)ya[xt]=co?n:WU(te,me[xt]);return ya}e(Vr,"baseAt");function ei(te,me,xt){return te===te&&(xt!==n&&(te=te<=xt?te:xt),me!==n&&(te=te>=me?te:me)),te}e(ei,"baseClamp");function Ne(te,me,xt,An,ya,co){var Xc,rl=me&w,dp=me&B,td=me&P;if(xt&&(Xc=ya?xt(te,An,ya,co):xt(te)),Xc!==n)return Xc;if(!KC(te))return te;var j0=k1(te);if(j0){if(Xc=O$(te),!rl)return Ts(te,Xc)}else{var z0=hC(te),V_=z0==In||z0==Ri;if(D6(te))return s8(te,rl);if(z0==Fa||z0==ti||V_&&!ya){if(Xc=dp||V_?{}:HH(te),!rl)return dp?ZS(te,M(Xc,te)):v9(te,Jb(Xc,te))}else{if(!Au[z0])return ya?te:{};Xc=Ro(te,z0,rl)}}co||(co=new Ky);var n1=co.get(te);if(n1)return n1;co.set(te,Xc),lW(te)?te.forEach(function(dg){Xc.add(Ne(dg,me,xt,dg,te,co))}):AD(te)&&te.forEach(function(dg,Ay){Xc.set(Ay,Ne(dg,me,xt,Ay,te,co))});var J1=td?dp?lF:Fv:dp?wy:YC,z1=j0?n:J1(te);return nc(z1||te,function(dg,Ay){z1&&(Ay=dg,dg=te[Ay]),ex(Xc,Ay,Ne(dg,me,xt,Ay,te,co))}),Xc}e(Ne,"baseClone");function wt(te){var me=YC(te);return function(xt){return Ot(xt,te,me)}}e(wt,"baseConforms");function Ot(te,me,xt){var An=xt.length;if(te==null)return!An;for(te=ly(te);An--;){var ya=xt[An],co=me[ya],Xc=te[ya];if(Xc===n&&!(ya in te)||!co(Xc))return!1}return!0}e(Ot,"baseConformsTo");function zt(te,me,xt){if(typeof te!="function")throw new nA(c);return Cu(function(){te.apply(n,xt)},me)}e(zt,"baseDelay");function Nr(te,me,xt,An){var ya=-1,co=Ip,Xc=!0,rl=te.length,dp=[],td=me.length;if(!rl)return dp;xt&&(me=Ul(me,Ku(xt))),An?(co=jl,Xc=!1):me.length>=i&&(co=xl,Xc=!1,me=new v_(me));e:for(;++ya<rl;){var j0=te[ya],z0=xt==null?j0:xt(j0);if(j0=An||j0!==0?j0:0,Xc&&z0===z0){for(var V_=td;V_--;)if(me[V_]===z0)continue e;dp.push(j0)}else co(me,z0,An)||dp.push(j0)}return dp}e(Nr,"baseDifference");var vn=xh(Da),cn=xh(Cs,!0);function ln(te,me){var xt=!0;return vn(te,function(An,ya,co){return xt=!!me(An,ya,co),xt}),xt}e(ln,"baseEvery");function Rr(te,me,xt){for(var An=-1,ya=te.length;++An<ya;){var co=te[An],Xc=me(co);if(Xc!=null&&(rl===n?Xc===Xc&&!p8(Xc):xt(Xc,rl)))var rl=Xc,dp=co}return dp}e(Rr,"baseExtremum");function oi(te,me,xt,An){var ya=te.length;for(xt=oy(xt),xt<0&&(xt=-xt>ya?0:ya+xt),An=An===n||An>ya?ya:oy(An),An<0&&(An+=ya),An=xt>An?0:xF(An);xt<An;)te[xt++]=me;return te}e(oi,"baseFill");function Dr(te,me){var xt=[];return vn(te,function(An,ya,co){me(An,ya,co)&&xt.push(An)}),xt}e(Dr,"baseFilter");function Vt(te,me,xt,An,ya){var co=-1,Xc=te.length;for(xt||(xt=Gx),ya||(ya=[]);++co<Xc;){var rl=te[co];me>0&&xt(rl)?me>1?Vt(rl,me-1,xt,An,ya):Ff(ya,rl):An||(ya[ya.length]=rl)}return ya}e(Vt,"baseFlatten");var qn=V5(),Fn=V5(!0);function Da(te,me){return te&&qn(te,me,YC)}e(Da,"baseForOwn");function Cs(te,me){return te&&Fn(te,me,YC)}e(Cs,"baseForOwnRight");function _s(te,me){return Lo(me,function(xt){return u7(te[xt])})}e(_s,"baseFunctions");function ys(te,me){me=gE(me,te);for(var xt=0,An=me.length;te!=null&&xt<An;)te=te[i7(me[xt++])];return xt&&xt==An?te:n}e(ys,"baseGet");function Bi(te,me,xt){var An=me(te);return k1(te)?An:Ff(An,xt(te))}e(Bi,"baseGetAllKeys");function ha(te){return te==null?te===n?ga:Vs:$i&&$i in ly(te)?Xu(te):RU(te)}e(ha,"baseGetTag");function lo(te,me){return te>me}e(lo,"baseGt");function mu(te,me){return te!=null&&Mg.call(te,me)}e(mu,"baseHas");function Jp(te,me){return te!=null&&me in ly(te)}e(Jp,"baseHasIn");function yd(te,me,xt){return te>=yu(me,xt)&&te<Dc(me,xt)}e(yd,"baseInRange");function u_(te,me,xt){for(var An=xt?jl:Ip,ya=te[0].length,co=te.length,Xc=co,rl=ja(co),dp=1/0,td=[];Xc--;){var j0=te[Xc];Xc&&me&&(j0=Ul(j0,Ku(me))),dp=yu(j0.length,dp),rl[Xc]=!xt&&(me||ya>=120&&j0.length>=120)?new v_(Xc&&j0):n}j0=te[0];var z0=-1,V_=rl[0];e:for(;++z0<ya&&td.length<dp;){var n1=j0[z0],J1=me?me(n1):n1;if(n1=xt||n1!==0?n1:0,!(V_?xl(V_,J1):An(td,J1,xt))){for(Xc=co;--Xc;){var z1=rl[Xc];if(!(z1?xl(z1,J1):An(te[Xc],J1,xt)))continue e}V_&&V_.push(J1),td.push(n1)}}return td}e(u_,"baseIntersection");function Vd(te,me,xt,An){return Da(te,function(ya,co,Xc){me(An,xt(ya),co,Xc)}),An}e(Vd,"baseInverter");function _m(te,me,xt){me=gE(me,te),te=WH(te,me);var An=te==null?te:te[i7(a7(me))];return An==null?n:Wa(An,te,xt)}e(_m,"baseInvoke");function __(te){return AC(te)&&ha(te)==ti}e(__,"baseIsArguments");function q_(te){return AC(te)&&ha(te)==so}e(q_,"baseIsArrayBuffer");function Al(te){return AC(te)&&ha(te)==Qr}e(Al,"baseIsDate");function P0(te,me,xt,An,ya){return te===me?!0:te==null||me==null||!AC(te)&&!AC(me)?te!==te&&me!==me:Kl(te,me,xt,An,P0,ya)}e(P0,"baseIsEqual");function Kl(te,me,xt,An,ya,co){var Xc=k1(te),rl=k1(me),dp=Xc?xn:hC(te),td=rl?xn:hC(me);dp=dp==ti?Fa:dp,td=td==ti?Fa:td;var j0=dp==Fa,z0=td==Fa,V_=dp==td;if(V_&&D6(te)){if(!D6(me))return!1;Xc=!0,j0=!1}if(V_&&!j0)return co||(co=new Ky),Xc||AF(te)?Hre(te,me,xt,An,ya,co):J5(te,me,dp,xt,An,ya,co);if(!(xt&L)){var n1=j0&&Mg.call(te,"__wrapped__"),J1=z0&&Mg.call(me,"__wrapped__");if(n1||J1){var z1=n1?te.value():te,dg=J1?me.value():me;return co||(co=new Ky),ya(z1,dg,xt,An,co)}}return V_?(co||(co=new Ky),nP(te,me,xt,An,ya,co)):!1}e(Kl,"baseIsEqualDeep");function mo(te){return AC(te)&&hC(te)==kr}e(mo,"baseIsMap");function Do(te,me,xt,An){var ya=xt.length,co=ya,Xc=!An;if(te==null)return!co;for(te=ly(te);ya--;){var rl=xt[ya];if(Xc&&rl[2]?rl[1]!==te[rl[0]]:!(rl[0]in te))return!1}for(;++ya<co;){rl=xt[ya];var dp=rl[0],td=te[dp],j0=rl[1];if(Xc&&rl[2]){if(td===n&&!(dp in te))return!1}else{var z0=new Ky;if(An)var V_=An(td,j0,dp,te,me,z0);if(!(V_===n?P0(j0,td,L|j,An,z0):V_))return!1}}return!0}e(Do,"baseIsMatch");function id(te){if(!KC(te)||OU(te))return!1;var me=u7(te)?ZA:en;return me.test(Eg(te))}e(id,"baseIsNative");function X_(te){return AC(te)&&ha(te)==Bs}e(X_,"baseIsRegExp");function Ih(te){return AC(te)&&hC(te)==rs}e(Ih,"baseIsSet");function x0(te){return AC(te)&&hx(te.length)&&!!Qu[ha(te)]}e(x0,"baseIsTypedArray");function Nf(te){return typeof te=="function"?te:te==null?d8:typeof te=="object"?k1(te)?Ir(te[0],te[1]):qu(te):gP(te)}e(Nf,"baseIteratee");function Wf(te){if(!Hb(te))return Oo(te);var me=[];for(var xt in ly(te))Mg.call(te,xt)&&xt!="constructor"&&me.push(xt);return me}e(Wf,"baseKeys");function Cm(te){if(!KC(te))return mw(te);var me=Hb(te),xt=[];for(var An in te)An=="constructor"&&(me||!Mg.call(te,An))||xt.push(An);return xt}e(Cm,"baseKeysIn");function $_(te,me){return te<me}e($_,"baseLt");function Fm(te,me){var xt=-1,An=i3(te)?ja(te.length):[];return vn(te,function(ya,co,Xc){An[++xt]=me(ya,co,Xc)}),An}e(Fm,"baseMap");function qu(te){var me=fw(te);return me.length==1&&me[0][2]?zY(me[0][0],me[0][1]):function(xt){return xt===te||Do(xt,te,me)}}e(qu,"baseMatches");function Ir(te,me){return mO(te)&&_D(me)?zY(i7(te),me):function(xt){var An=WU(xt,te);return An===n&&An===me?lM(xt,te):P0(me,An,L|j)}}e(Ir,"baseMatchesProperty");function la(te,me,xt,An,ya){te!==me&&qn(me,function(co,Xc){if(ya||(ya=new Ky),KC(co))vc(te,me,Xc,xt,la,An,ya);else{var rl=An?An(n7(te,Xc),co,Xc+"",te,me,ya):n;rl===n&&(rl=co),By(te,Xc,rl)}},wy)}e(la,"baseMerge");function vc(te,me,xt,An,ya,co,Xc){var rl=n7(te,xt),dp=n7(me,xt),td=Xc.get(dp);if(td){By(te,xt,td);return}var j0=co?co(rl,dp,xt+"",te,me,Xc):n,z0=j0===n;if(z0){var V_=k1(dp),n1=!V_&&D6(dp),J1=!V_&&!n1&&AF(dp);j0=dp,V_||n1||J1?k1(rl)?j0=rl:vC(rl)?j0=Ts(rl):n1?(z0=!1,j0=s8(dp,!0)):J1?(z0=!1,j0=E6(dp,!0)):j0=[]:wT(dp)||Ox(dp)?(j0=rl,Ox(rl)?j0=pW(rl):(!KC(rl)||u7(rl))&&(j0=HH(dp))):z0=!1}z0&&(Xc.set(dp,j0),ya(j0,dp,An,co,Xc),Xc.delete(dp)),By(te,xt,j0)}e(vc,"baseMergeDeep");function Ds(te,me){var xt=te.length;if(xt)return me+=me<0?xt:0,yy(me,xt)?te[me]:n}e(Ds,"baseNth");function ol(te,me,xt){me.length?me=Ul(me,function(co){return k1(co)?function(Xc){return ys(Xc,co.length===1?co[0]:co)}:co}):me=[d8];var An=-1;me=Ul(me,Ku(Kg()));var ya=Fm(te,function(co,Xc,rl){var dp=Ul(me,function(td){return td(co)});return{criteria:dp,index:++An,value:co}});return u0(ya,function(co,Xc){return mC(co,Xc,xt)})}e(ol,"baseOrderBy");function Nl(te,me){return k_(te,me,function(xt,An){return lM(te,An)})}e(Nl,"basePick");function k_(te,me,xt){for(var An=-1,ya=me.length,co={};++An<ya;){var Xc=me[An],rl=ys(te,Xc);xt(rl,Xc)&&pb(co,gE(Xc,te),rl)}return co}e(k_,"basePickBy");function L_(te){return function(me){return ys(me,te)}}e(L_,"basePropertyDeep");function rh(te,me,xt,An){var ya=An?Qo:gu,co=-1,Xc=me.length,rl=te;for(te===me&&(me=Ts(me)),xt&&(rl=Ul(te,Ku(xt)));++co<Xc;)for(var dp=0,td=me[co],j0=xt?xt(td):td;(dp=ya(rl,j0,dp,An))>-1;)rl!==te&&Op.call(rl,dp,1),Op.call(te,dp,1);return te}e(rh,"basePullAll");function kg(te,me){for(var xt=te?me.length:0,An=xt-1;xt--;){var ya=me[xt];if(xt==An||ya!==co){var co=ya;yy(ya)?Op.call(te,ya,1):a8(te,ya)}}return te}e(kg,"basePullAt");function Gg(te,me){return te+ka(Ms()*(me-te+1))}e(Gg,"baseRandom");function Dh(te,me,xt,An){for(var ya=-1,co=Dc(Os((me-te)/(xt||1)),0),Xc=ja(co);co--;)Xc[An?co:++ya]=te,te+=xt;return Xc}e(Dh,"baseRange");function fy(te,me){var xt="";if(!te||me<1||me>je)return xt;do me%2&&(xt+=te),me=ka(me/2),me&&(te+=te);while(me);return xt}e(fy,"baseRepeat");function H(te,me){return fS(mD(te,me,d8),te+"")}e(H,"baseRest");function O(te){return pm(cl(te))}e(O,"baseSample");function y1(te,me){var xt=cl(te);return cd(xt,ei(me,0,xt.length))}e(y1,"baseSampleSize");function pb(te,me,xt,An){if(!KC(te))return te;me=gE(me,te);for(var ya=-1,co=me.length,Xc=co-1,rl=te;rl!=null&&++ya<co;){var dp=i7(me[ya]),td=xt;if(dp==="__proto__"||dp==="constructor"||dp==="prototype")return te;if(ya!=Xc){var j0=rl[dp];td=An?An(j0,dp,rl):n,td===n&&(td=KC(j0)?j0:yy(me[ya+1])?[]:{})}ex(rl,dp,td),rl=rl[dp]}return te}e(pb,"baseSet");var dC=Zn?function(te,me){return Zn.set(te,me),te}:d8,TA=Pa?function(te,me){return Pa(te,"toString",{configurable:!0,enumerable:!1,value:P9(me),writable:!0})}:d8;function g9(te){return cd(cl(te))}e(g9,"baseShuffle");function zC(te,me,xt){var An=-1,ya=te.length;me<0&&(me=-me>ya?0:ya+me),xt=xt>ya?ya:xt,xt<0&&(xt+=ya),ya=me>xt?0:xt-me>>>0,me>>>=0;for(var co=ja(ya);++An<ya;)co[An]=te[An+me];return co}e(zC,"baseSlice");function y9(te,me){var xt;return vn(te,function(An,ya,co){return xt=me(An,ya,co),!xt}),!!xt}e(y9,"baseSome");function cF(te,me,xt){var An=0,ya=te==null?An:te.length;if(typeof me=="number"&&me===me&&ya<=lr){for(;An<ya;){var co=An+ya>>>1,Xc=te[co];Xc!==null&&!p8(Xc)&&(xt?Xc<=me:Xc<me)?An=co+1:ya=co}return ya}return uS(te,me,d8,xt)}e(cF,"baseSortedIndex");function uS(te,me,xt,An){var ya=0,co=te==null?0:te.length;if(co===0)return 0;me=xt(me);for(var Xc=me!==me,rl=me===null,dp=p8(me),td=me===n;ya<co;){var j0=ka((ya+co)/2),z0=xt(te[j0]),V_=z0!==n,n1=z0===null,J1=z0===z0,z1=p8(z0);if(Xc)var dg=An||J1;else td?dg=J1&&(An||V_):rl?dg=J1&&V_&&(An||!n1):dp?dg=J1&&V_&&!n1&&(An||!z1):n1||z1?dg=!1:dg=An?z0<=me:z0<me;dg?ya=j0+1:co=j0}return yu(co,Zt)}e(uS,"baseSortedIndexBy");function N$(te,me){for(var xt=-1,An=te.length,ya=0,co=[];++xt<An;){var Xc=te[xt],rl=me?me(Xc):Xc;if(!xt||!c7(rl,dp)){var dp=rl;co[ya++]=Xc===0?0:Xc}}return co}e(N$,"baseSortedUniq");function zH(te){return typeof te=="number"?te:p8(te)?Nt:+te}e(zH,"baseToNumber");function lS(te){if(typeof te=="string")return te;if(k1(te))return Ul(te,lS)+"";if(p8(te))return ua?ua.call(te):"";var me=te+"";return me=="0"&&1/te==-Ze?"-0":me}e(lS,"baseToString");function UE(te,me,xt){var An=-1,ya=Ip,co=te.length,Xc=!0,rl=[],dp=rl;if(xt)Xc=!1,ya=jl;else if(co>=i){var td=me?null:Jv(te);if(td)return S_(td);Xc=!1,ya=xl,dp=new v_}else dp=me?[]:rl;e:for(;++An<co;){var j0=te[An],z0=me?me(j0):j0;if(j0=xt||j0!==0?j0:0,Xc&&z0===z0){for(var V_=dp.length;V_--;)if(dp[V_]===z0)continue e;me&&dp.push(z0),rl.push(j0)}else ya(dp,z0,xt)||(dp!==rl&&dp.push(z0),rl.push(j0))}return rl}e(UE,"baseUniq");function a8(te,me){me=gE(me,te);var xt=-1,An=me.length;if(!An)return!0;for(;++xt<An;){var ya=i7(me[xt]);if(ya==="__proto__"&&!Mg.call(te,"__proto__")||(ya==="constructor"||ya==="prototype")&&xt<An-1)return!1}var co=WH(te,me);return co==null||delete co[i7(a7(me))]}e(a8,"baseUnset");function yT(te,me,xt,An){return pb(te,me,xt(ys(te,me)),An)}e(yT,"baseUpdate");function U5(te,me,xt,An){for(var ya=te.length,co=An?ya:-1;(An?co--:++co<ya)&&me(te[co],co,te););return xt?zC(te,An?0:co,An?co+1:ya):zC(te,An?co+1:0,An?ya:co)}e(U5,"baseWhile");function hE(te,me){var xt=te;return xt instanceof Sc&&(xt=xt.value()),I0(me,function(An,ya){return ya.func.apply(ya.thisArg,Ff([An],ya.args))},xt)}e(hE,"baseWrapperValue");function Q5(te,me,xt){var An=te.length;if(An<2)return An?UE(te[0]):[];for(var ya=-1,co=ja(An);++ya<An;)for(var Xc=te[ya],rl=-1;++rl<An;)rl!=ya&&(co[ya]=Nr(co[ya]||Xc,te[rl],me,xt));return UE(Vt(co,1),me,xt)}e(Q5,"baseXor");function uF(te,me,xt){for(var An=-1,ya=te.length,co=me.length,Xc={};++An<ya;){var rl=An<co?me[An]:n;xt(Xc,te[An],rl)}return Xc}e(uF,"baseZipObject");function Nm(te){return vC(te)?te:[]}e(Nm,"castArrayLikeObject");function q4(te){return typeof te=="function"?te:d8}e(q4,"castFunction");function gE(te,me){return k1(te)?te:mO(te,me)?[te]:Gf(vy(te))}e(gE,"castPath");var q5=H;function $4(te,me,xt){var An=te.length;return xt=xt===n?An:xt,!me&&xt>=An?te:zC(te,me,xt)}e($4,"castSlice");var V4=Aa||function(te){return Ea.clearTimeout(te)};function s8(te,me){if(me)return te.slice();var xt=te.length,An=yr?yr(xt):new te.constructor(xt);return te.copy(An),An}e(s8,"cloneBuffer");function pS(te){var me=new te.constructor(te.byteLength);return new he(me).set(new he(te)),me}e(pS,"cloneArrayBuffer");function QE(te,me){var xt=me?pS(te.buffer):te.buffer;return new te.constructor(xt,te.byteOffset,te.byteLength)}e(QE,"cloneDataView");function _C(te){var me=new te.constructor(te.source,Mt.exec(te));return me.lastIndex=te.lastIndex,me}e(_C,"cloneRegExp");function b6(te){return Gi?ly(Gi.call(te)):{}}e(b6,"cloneSymbol");function E6(te,me){var xt=me?pS(te.buffer):te.buffer;return new te.constructor(xt,te.byteOffset,te.length)}e(E6,"cloneTypedArray");function H_(te,me){if(te!==me){var xt=te!==n,An=te===null,ya=te===te,co=p8(te),Xc=me!==n,rl=me===null,dp=me===me,td=p8(me);if(!rl&&!td&&!co&&te>me||co&&Xc&&dp&&!rl&&!td||An&&Xc&&dp||!xt&&dp||!ya)return 1;if(!An&&!co&&!td&&te<me||td&&xt&&ya&&!An&&!co||rl&&xt&&ya||!Xc&&ya||!dp)return-1}return 0}e(H_,"compareAscending");function mC(te,me,xt){for(var An=-1,ya=te.criteria,co=me.criteria,Xc=ya.length,rl=xt.length;++An<Xc;){var dp=H_(ya[An],co[An]);if(dp){if(An>=rl)return dp;var td=xt[An];return dp*(td=="desc"?-1:1)}}return te.index-me.index}e(mC,"compareMultiple");function M2(te,me,xt,An){for(var ya=-1,co=te.length,Xc=xt.length,rl=-1,dp=me.length,td=Dc(co-Xc,0),j0=ja(dp+td),z0=!An;++rl<dp;)j0[rl]=me[rl];for(;++ya<Xc;)(z0||ya<co)&&(j0[xt[ya]]=te[ya]);for(;td--;)j0[rl++]=te[ya++];return j0}e(M2,"composeArgs");function vv(te,me,xt,An){for(var ya=-1,co=te.length,Xc=-1,rl=xt.length,dp=-1,td=me.length,j0=Dc(co-rl,0),z0=ja(j0+td),V_=!An;++ya<j0;)z0[ya]=te[ya];for(var n1=ya;++dp<td;)z0[n1+dp]=me[dp];for(;++Xc<rl;)(V_||ya<co)&&(z0[n1+xt[Xc]]=te[ya++]);return z0}e(vv,"composeArgsRight");function Ts(te,me){var xt=-1,An=te.length;for(me||(me=ja(An));++xt<An;)me[xt]=te[xt];return me}e(Ts,"copyArray");function J4(te,me,xt,An){var ya=!xt;xt||(xt={});for(var co=-1,Xc=me.length;++co<Xc;){var rl=me[co],dp=An?An(xt[rl],te[rl],rl,xt,te):n;dp===n&&(dp=te[rl]),ya?De(xt,rl,dp):ex(xt,rl,dp)}return xt}e(J4,"copyObject");function v9(te,me){return J4(te,B$(te),me)}e(v9,"copySymbols");function ZS(te,me){return J4(te,Joe(te),me)}e(ZS,"copySymbolsIn");function $5(te,me){return function(xt,An){var ya=k1(xt)?Ka:av,co=me?me():{};return ya(xt,te,Kg(An,2),co)}}e($5,"createAggregator");function dD(te){return H(function(me,xt){var An=-1,ya=xt.length,co=ya>1?xt[ya-1]:n,Xc=ya>2?xt[2]:n;for(co=te.length>3&&typeof co=="function"?(ya--,co):n,Xc&&r7(xt[0],xt[1],Xc)&&(co=ya<3?n:co,ya=1),me=ly(me);++An<ya;){var rl=xt[An];rl&&te(me,rl,An,co)}return me})}e(dD,"createAssigner");function xh(te,me){return function(xt,An){if(xt==null)return xt;if(!i3(xt))return te(xt,An);for(var ya=xt.length,co=me?ya:-1,Xc=ly(xt);(me?co--:++co<ya)&&An(Xc[co],co,Xc)!==!1;);return xt}}e(xh,"createBaseEach");function V5(te){return function(me,xt,An){for(var ya=-1,co=ly(me),Xc=An(me),rl=Xc.length;rl--;){var dp=Xc[te?rl:++ya];if(xt(co[dp],dp,co)===!1)break}return me}}e(V5,"createBaseFor");function uw(te,me,xt){var An=me&V,ya=R(te);function co(){var Xc=this&&this!==Ea&&this instanceof co?ya:te;return Xc.apply(An?xt:this,arguments)}return e(co,"wrapper"),co}e(uw,"createBind");function zb(te){return function(me){me=vy(me);var xt=Tu(me)?Ll(me):n,An=xt?xt[0]:me.charAt(0),ya=xt?$4(xt,1).join(""):me.slice(1);return An[te]()+ya}}e(zb,"createCaseFirst");function fi(te){return function(me){return I0(CD(GU(me).replace(hu,"")),te,"")}}e(fi,"createCompounder");function R(te){return function(){var me=arguments;switch(me.length){case 0:return new te;case 1:return new te(me[0]);case 2:return new te(me[0],me[1]);case 3:return new te(me[0],me[1],me[2]);case 4:return new te(me[0],me[1],me[2],me[3]);case 5:return new te(me[0],me[1],me[2],me[3],me[4]);case 6:return new te(me[0],me[1],me[2],me[3],me[4],me[5]);case 7:return new te(me[0],me[1],me[2],me[3],me[4],me[5],me[6])}var xt=$a(te.prototype),An=te.apply(xt,me);return KC(An)?An:xt}}e(R,"createCtor");function ie(te,me,xt){var An=R(te);function ya(){for(var co=arguments.length,Xc=ja(co),rl=co,dp=bg(ya);rl--;)Xc[rl]=arguments[rl];var td=co<3&&Xc[0]!==dp&&Xc[co-1]!==dp?[]:$f(Xc,dp);if(co-=td.length,co<xt)return sh(te,me,Zr,ya.placeholder,n,Xc,td,n,n,xt-co);var j0=this&&this!==Ea&&this instanceof ya?An:te;return Wa(j0,this,Xc)}return e(ya,"wrapper"),ya}e(ie,"createCurry");function Ie(te){return function(me,xt,An){var ya=ly(me);if(!i3(me)){var co=Kg(xt,3);me=YC(me),xt=e(function(rl){return co(ya[rl],rl,ya)},"predicate")}var Xc=te(me,xt,An);return Xc>-1?ya[co?me[Xc]:Xc]:n}}e(Ie,"createFind");function yt(te){return pw(function(me){var xt=me.length,An=xt,ya=no.prototype.thru;for(te&&me.reverse();An--;){var co=me[An];if(typeof co!="function")throw new nA(c);if(ya&&!Xc&&A9(co)=="wrapper")var Xc=new no([],!0)}for(An=Xc?An:xt;++An<xt;){co=me[An];var rl=A9(co),dp=rl=="wrapper"?P$(co):n;dp&&nM(dp[0])&&dp[1]==($e|le|xe|Ke)&&!dp[4].length&&dp[9]==1?Xc=Xc[A9(dp[0])].apply(Xc,dp[3]):Xc=co.length==1&&nM(co)?Xc[rl]():Xc.thru(co)}return function(){var td=arguments,j0=td[0];if(Xc&&td.length==1&&k1(j0))return Xc.plant(j0).value();for(var z0=0,V_=xt?me[z0].apply(this,td):j0;++z0<xt;)V_=me[z0].call(this,V_);return V_}})}e(yt,"createFlow");function Zr(te,me,xt,An,ya,co,Xc,rl,dp,td){var j0=me&$e,z0=me&V,V_=me&ee,n1=me&(le|de),J1=me&Ce,z1=V_?n:R(te);function dg(){for(var Ay=arguments.length,Nv=ja(Ay),c3=Ay;c3--;)Nv[c3]=arguments[c3];if(n1)var AE=bg(dg),Xy=Gs(Nv,AE);if(An&&(Nv=M2(Nv,An,ya,n1)),co&&(Nv=vv(Nv,co,Xc,n1)),Ay-=Xy,n1&&Ay<td){var Yb=$f(Nv,AE);return sh(te,me,Zr,dg.placeholder,xt,Nv,Yb,rl,dp,td-Ay)}var Xb=z0?xt:this,oA=V_?Xb[te]:te;return Ay=Nv.length,rl?Nv=GH(Nv,rl):J1&&Ay>1&&Nv.reverse(),j0&&dp<Ay&&(Nv.length=dp),this&&this!==Ea&&this instanceof dg&&(oA=z1||R(oA)),oA.apply(Xb,Nv)}return e(dg,"wrapper"),dg}e(Zr,"createHybrid");function Xi(te,me){return function(xt,An){return Vd(xt,te,me(An),{})}}e(Xi,"createInverter");function Js(te,me){return function(xt,An){var ya;if(xt===n&&An===n)return me;if(xt!==n&&(ya=xt),An!==n){if(ya===n)return An;typeof xt=="string"||typeof An=="string"?(xt=lS(xt),An=lS(An)):(xt=zH(xt),An=zH(An)),ya=te(xt,An)}return ya}}e(Js,"createMathOperation");function Tc(te){return pw(function(me){return me=Ul(me,Ku(Kg())),H(function(xt){var An=this;return te(me,function(ya){return Wa(ya,An,xt)})})})}e(Tc,"createOver");function xu(te,me){me=me===n?" ":lS(me);var xt=me.length;if(xt<2)return xt?fy(me,te):me;var An=fy(me,Os(te/pc(me)));return Tu(me)?$4(Ll(An),0,te).join(""):An.slice(0,te)}e(xu,"createPadding");function Yu(te,me,xt,An){var ya=me&V,co=R(te);function Xc(){for(var rl=-1,dp=arguments.length,td=-1,j0=An.length,z0=ja(j0+dp),V_=this&&this!==Ea&&this instanceof Xc?co:te;++td<j0;)z0[td]=An[td];for(;dp--;)z0[td++]=arguments[++rl];return Wa(V_,ya?xt:this,z0)}return e(Xc,"wrapper"),Xc}e(Yu,"createPartial");function Id(te){return function(me,xt,An){return An&&typeof An!="number"&&r7(me,xt,An)&&(xt=An=n),me=qE(me),xt===n?(xt=me,me=0):xt=qE(xt),An=An===n?me<xt?1:-1:qE(An),Dh(me,xt,An,te)}}e(Id,"createRange");function am(te){return function(me,xt){return typeof me=="string"&&typeof xt=="string"||(me=p7(me),xt=p7(xt)),te(me,xt)}}e(am,"createRelationalOperation");function sh(te,me,xt,An,ya,co,Xc,rl,dp,td){var j0=me&le,z0=j0?Xc:n,V_=j0?n:Xc,n1=j0?co:n,J1=j0?n:co;me|=j0?xe:Re,me&=~(j0?Re:xe),me&ue||(me&=~(V|ee));var z1=[te,me,ya,n1,z0,J1,V_,rl,dp,td],dg=xt.apply(n,z1);return nM(te)&&ig(dg,z1),dg.placeholder=An,vm(dg,te,me)}e(sh,"createRecurry");function sm(te){var me=K2[te];return function(xt,An){if(xt=p7(xt),An=An==null?0:yu(oy(An),292),An&&go(xt)){var ya=(vy(xt)+"e").split("e"),co=me(ya[0]+"e"+(+ya[1]+An));return ya=(vy(co)+"e").split("e"),+(ya[0]+"e"+(+ya[1]-An))}return me(xt)}}e(sm,"createRound");var Jv=Te&&1/S_(new Te([,-0]))[1]==Ze?function(te){return new Te(te)}:B9;function sv(te){return function(me){var xt=hC(me);return xt==kr?gf(me):xt==rs?od(me):nu(me,te(me))}}e(sv,"createToPairs");function om(te,me,xt,An,ya,co,Xc,rl){var dp=meⅇif(!dp&&typeof te!="function")throw new nA(c);var td=An?An.length:0;if(td||(me&=~(xe|Re),An=ya=n),Xc=Xc===n?Xc:Dc(oy(Xc),0),rl=rl===n?rl:oy(rl),td-=ya?ya.length:0,me&Re){var j0=An,z0=ya;An=ya=n}var V_=dp?n:P$(te),n1=[te,me,xt,An,ya,j0,z0,co,Xc,rl];if(V_&&hO(n1,V_),te=n1[0],me=n1[1],xt=n1[2],An=n1[3],ya=n1[4],rl=n1[9]=n1[9]===n?dp?0:te.length:Dc(n1[9]-td,0),!rl&&me&(le|de)&&(me&=~(le|de)),!me||me==V)var J1=uw(te,me,xt);else me==le||me==de?J1=ie(te,me,rl):(me==xe||me==(V|xe))&&!ya.length?J1=Yu(te,me,xt,An):J1=Zr.apply(n,n1);var z1=V_?dC:ig;return vm(z1(J1,n1),te,me)}e(om,"createWrap");function aA(te,me,xt,An){return te===n||c7(te,lC[xt])&&!Mg.call(An,xt)?me:te}e(aA,"customDefaultsAssignIn");function rM(te,me,xt,An,ya,co){return KC(te)&&KC(me)&&(co.set(me,te),la(te,me,n,rM,co),co.delete(me)),te}e(rM,"customDefaultsMerge");function lw(te){return wT(te)?n:te}e(lw,"customOmitClone");function Hre(te,me,xt,An,ya,co){var Xc=xt&L,rl=te.length,dp=me.length;if(rl!=dp&&!(Xc&&dp>rl))return!1;var td=co.get(te),j0=co.get(me);if(td&&j0)return td==me&&j0==te;var z0=-1,V_=!0,n1=xt&j?new v_:n;for(co.set(te,me),co.set(me,te);++z0<rl;){var J1=te[z0],z1=me[z0];if(An)var dg=Xc?An(z1,J1,z0,me,te,co):An(J1,z1,z0,te,me,co);if(dg!==n){if(dg)continue;V_=!1;break}if(n1){if(!mp(me,function(Ay,Nv){if(!xl(n1,Nv)&&(J1===Ay||ya(J1,Ay,xt,An,co)))return n1.push(Nv)})){V_=!1;break}}else if(!(J1===z1||ya(J1,z1,xt,An,co))){V_=!1;break}}return co.delete(te),co.delete(me),V_}e(Hre,"equalArrays");function J5(te,me,xt,An,ya,co,Xc){switch(xt){case ec:if(te.byteLength!=me.byteLength||te.byteOffset!=me.byteOffset)return!1;te=te.buffer,me=me.buffer;case so:return!(te.byteLength!=me.byteLength||!co(new he(te),new he(me)));case pt:case Qr:case Ss:return c7(+te,+me);case ai:return te.name==me.name&&te.message==me.message;case Bs:case Oa:return te==me+"";case kr:var rl=gf;case rs:var dp=An&L;if(rl||(rl=S_),te.size!=me.size&&!dp)return!1;var td=Xc.get(te);if(td)return td==me;An|=j,Xc.set(te,me);var j0=Hre(rl(te),rl(me),An,ya,co,Xc);return Xc.delete(te),j0;case sa:if(Gi)return Gi.call(te)==Gi.call(me)}return!1}e(J5,"equalByTag");function nP(te,me,xt,An,ya,co){var Xc=xt&L,rl=Fv(te),dp=rl.length,td=Fv(me),j0=td.length;if(dp!=j0&&!Xc)return!1;for(var z0=dp;z0--;){var V_=rl[z0];if(!(Xc?V_ in me:Mg.call(me,V_)))return!1}var n1=co.get(te),J1=co.get(me);if(n1&&J1)return n1==me&&J1==te;var z1=!0;co.set(te,me),co.set(me,te);for(var dg=Xc;++z0<dp;){V_=rl[z0];var Ay=te[V_],Nv=me[V_];if(An)var c3=Xc?An(Nv,Ay,V_,me,te,co):An(Ay,Nv,V_,te,me,co);if(!(c3===n?Ay===Nv||ya(Ay,Nv,xt,An,co):c3)){z1=!1;break}dg||(dg=V_=="constructor")}if(z1&&!dg){var AE=te.constructor,Xy=me.constructor;AE!=Xy&&"constructor"in te&&"constructor"in me&&!(typeof AE=="function"&&AE instanceof AE&&typeof Xy=="function"&&Xy instanceof Xy)&&(z1=!1)}return co.delete(te),co.delete(me),z1}e(nP,"equalObjects");function pw(te){return fS(mD(te,n,R$),te+"")}e(pw,"flatRest");function Fv(te){return Bi(te,YC,B$)}e(Fv,"getAllKeys");function lF(te){return Bi(te,wy,Joe)}e(lF,"getAllKeysIn");var P$=Zn?function(te){return Zn.get(te)}:B9;function A9(te){for(var me=te.name+"",xt=hn[me],An=Mg.call(hn,me)?xt.length:0;An--;){var ya=xt[An],co=ya.func;if(co==null||co==te)return ya.name}return me}e(A9,"getFuncName");function bg(te){var me=Mg.call(_e,"placeholder")?_e:te;return me.placeholder}e(bg,"getHolder");function Kg(){var te=_e.iteratee||X5;return te=te===X5?Nf:te,arguments.length?te(arguments[0],arguments[1]):te}e(Kg,"getIteratee");function pF(te,me){var xt=te.__data__;return _w(me)?xt[typeof me=="string"?"string":"hash"]:xt.map}e(pF,"getMapData");function fw(te){for(var me=YC(te),xt=me.length;xt--;){var An=me[xt],ya=te[An];me[xt]=[An,ya,_D(ya)]}return me}e(fw,"getMatchData");function x9(te,me){var xt=yc(te,me);return id(xt)?xt:n}e(x9,"getNative");function Xu(te){var me=Mg.call(te,$i),xt=te[$i];try{te[$i]=n;var An=!0}catch{}var ya=Wx.call(te);return An&&(me?te[$i]=xt:delete te[$i]),ya}e(Xu,"getRawTag");var B$=to?function(te){return te==null?[]:(te=ly(te),Lo(to(te),function(me){return Qc.call(te,me)}))}:X$,Joe=to?function(te){for(var me=[];te;)Ff(me,B$(te)),te=Qi(te);return me}:X$,hC=ha;(qc&&hC(new qc(new ArrayBuffer(1)))!=ec||Rc&&hC(new Rc)!=kr||fe&&hC(fe.resolve())!=va||Te&&hC(new Te)!=rs||Hr&&hC(new Hr)!=qo)&&(hC=e(function(te){var me=ha(te),xt=me==Fa?te.constructor:n,An=xt?Eg(xt):"";if(An)switch(An){case Fr:return ec;case ir:return kr;case En:return va;case Ct:return rs;case Cn:return qo}return me},"getTag"));function zoe(te,me,xt){for(var An=-1,ya=xt.length;++An<ya;){var co=xt[An],Xc=co.size;switch(co.type){case"drop":te+=Xc;break;case"dropRight":me-=Xc;break;case"take":me=yu(me,te+Xc);break;case"takeRight":te=Dc(te,me-Xc);break}}return{start:te,end:me}}e(zoe,"getView");function dw(te){var me=te.match(Pt);return me?me[1].split(Gt):[]}e(dw,"getWrapDetails");function BU(te,me,xt){me=gE(me,te);for(var An=-1,ya=me.length,co=!1;++An<ya;){var Xc=i7(me[An]);if(!(co=te!=null&&xt(te,Xc)))break;te=te[Xc]}return co||++An!=ya?co:(ya=te==null?0:te.length,!!ya&&hx(ya)&&yy(Xc,ya)&&(k1(te)||Ox(te)))}e(BU,"hasPath");function O$(te){var me=te.length,xt=new te.constructor(me);return me&&typeof te[0]=="string"&&Mg.call(te,"index")&&(xt.index=te.index,xt.input=te.input),xt}e(O$,"initCloneArray");function HH(te){return typeof te.constructor=="function"&&!Hb(te)?$a(Qi(te)):{}}e(HH,"initCloneObject");function Ro(te,me,xt){var An=te.constructor;switch(me){case so:return pS(te);case pt:case Qr:return new An(+te);case ec:return QE(te,xt);case Lr:case ri:case ma:case Vn:case qa:case Go:case li:case or:case lt:return E6(te,xt);case kr:return new An;case Ss:case Oa:return new An(te);case Bs:return _C(te);case rs:return new An;case sa:return b6(te)}}e(Ro,"initCloneByTag");function vT(te,me){var xt=me.length;if(!xt)return te;var An=xt-1;return me[An]=(xt>1?"& ":"")+me[An],me=me.join(xt>2?", ":" "),te.replace(Me,`{
|
|
133
|
+
${p}`:c.stack}e(eon,"appendFetchStackTrace");K1.exports.fetch=e(function(r,i=void 0){return TEi(r,i).catch(s=>{throw Ksn?eon(s,Ksn):s&&typeof s=="object"&&Error.captureStackTrace(s,K1.exports.fetch),s})},"fetch");K1.exports.Headers=Fwe().Headers;K1.exports.Response=Cit().Response;K1.exports.Request=CLe().Request;K1.exports.FormData=L8t().FormData;var{setGlobalOrigin:kEi,getGlobalOrigin:IEi}=Rgr();K1.exports.setGlobalOrigin=kEi;K1.exports.getGlobalOrigin=IEi;var{CacheStorage:FEi}=Can(),{kConstruct:NEi}=B4();K1.exports.caches=new FEi(NEi);var{deleteCookie:PEi,getCookies:BEi,getSetCookies:OEi,setCookie:REi,parseCookie:LEi}=Lan();K1.exports.deleteCookie=PEi;K1.exports.getCookies=BEi;K1.exports.getSetCookies=OEi;K1.exports.setCookie=REi;K1.exports.parseCookie=LEi;var{parseMIMEType:MEi,serializeAMimeType:jEi}=Ote();K1.exports.parseMIMEType=MEi;K1.exports.serializeAMimeType=jEi;var{CloseEvent:UEi,ErrorEvent:QEi,MessageEvent:qEi}=fTt(),{WebSocket:$Ei,ping:VEi}=bsn();K1.exports.WebSocket=$Ei;K1.exports.CloseEvent=UEi;K1.exports.ErrorEvent=QEi;K1.exports.MessageEvent=qEi;K1.exports.ping=VEi;K1.exports.WebSocketStream=Osn().WebSocketStream;K1.exports.WebSocketError=fxr().WebSocketError;K1.exports.request=Qit(zLe.request);K1.exports.stream=Qit(zLe.stream);K1.exports.pipeline=Qit(zLe.pipeline);K1.exports.connect=Qit(zLe.connect);K1.exports.upgrade=Qit(zLe.upgrade);K1.exports.MockClient=hEi;K1.exports.MockCallHistory=gEi;K1.exports.MockCallHistoryLog=yEi;K1.exports.MockPool=AEi;K1.exports.MockAgent=vEi;K1.exports.SnapshotAgent=xEi;K1.exports.mockErrors=bEi;var{EventSource:JEi}=Gsn();K1.exports.EventSource=JEi;function zEi(){globalThis.fetch=K1.exports.fetch,globalThis.Headers=K1.exports.Headers,globalThis.Response=K1.exports.Response,globalThis.Request=K1.exports.Request,globalThis.FormData=K1.exports.FormData,globalThis.WebSocket=K1.exports.WebSocket,globalThis.CloseEvent=K1.exports.CloseEvent,globalThis.ErrorEvent=K1.exports.ErrorEvent,globalThis.MessageEvent=K1.exports.MessageEvent,globalThis.EventSource=K1.exports.EventSource}e(zEi,"install");K1.exports.install=zEi});var qit,Exr,$it,ron=Ws(()=>{"use strict";_6();qit=require("perf_hooks"),Exr=class Exr{constructor(r={}){this.options=r;this.priorityQueue=[];this.nonPriorityQueue=[];this.isRunning=!1;this.taskIndex=0;this.timeRunningTasks=0;this.timeGoingBack=0;this.tasksExecuted=0}enqueue(r){let i=this.taskIndex++,s={...r,index:i,queuedAt:qit.performance.now()};if(r.priority)this.priorityQueue.push(s);else if(this.options.sortByTimestamp){let c=this.nonPriorityQueue.findIndex(p=>p.timestamp>r.timestamp);c===-1?this.nonPriorityQueue.push(s):this.nonPriorityQueue.splice(c,0,s)}else this.nonPriorityQueue.push(s);return i}popTask(){return this.priorityQueue.length>0?this.priorityQueue.shift():this.nonPriorityQueue.shift()}async runTasks(r){if(!this.isRunning){this.isRunning=!0;try{for(;this.getQueueLength()>0;){let i=this.popTask();if(!i)break;let s=qit.performance.now();try{if(this.options.logPerformance){let p=qit.performance.now()-i.queuedAt;af.info(`Running task, timestamp: ${i.timestamp} \x1B[36m${i.name}\x1B[0m, index: ${i.index}, was pending for ${p}ms`)}await r(i);let c=qit.performance.now()-s;this.timeRunningTasks+=c,this.options.logPerformance&&af.info("Finished running task, took",c,"ms.","Queue lengths:",`priority=${this.priorityQueue.length}`,`non-priority=${this.nonPriorityQueue.length}`),this.tasksExecuted++}catch(c){af.error("Task execution error:",c)}}}finally{this.isRunning=!1,this.getQueueLength()>0&&this.options.logPerformance&&af.info("Accumulated time running tasks:",this.timeRunningTasks,"ms, from which time spent going back:",this.timeGoingBack)}}}getTasksAtTimestamp(r){return[...this.priorityQueue.filter(i=>i.timestamp===r),...this.nonPriorityQueue.filter(i=>i.timestamp===r)]}removeTasksAtTimestamp(r){this.priorityQueue=this.priorityQueue.filter(i=>i.timestamp!==r),this.nonPriorityQueue=this.nonPriorityQueue.filter(i=>i.timestamp!==r)}getQueueLength(){return this.priorityQueue.length+this.nonPriorityQueue.length}setTimeGoingBack(r){this.timeGoingBack=r}};e(Exr,"TaskTimeMachineQueue");$it=Exr});var non,Jit,Vit,Cxr,oge,ITt=Ws(()=>{"use strict";non=require("@playwright/test");tYr();WS();_6();bRe();Jit=nd(ton());ron();Vit=require("perf_hooks"),Cxr=class Cxr{constructor(r,i,s={headless:!0,logPerformance:!1,timestampBatchingEnabled:!1,sortByTimestamp:!1,taskTimeout:24e4,debugPort:void 0,frameMsgBrokerRegisterName:void 0}){this.frameMsgBroker=r;this.injectedScriptManager=i;this.options=s;this.currentTimestamp=0;this.currentBeforeTimestamp=!1;this.currentChecksumId="0";this.timeGoingBack=0;this.pagesWithCorsInterception=new Set;this.reducedHTMLCache={};this.getReducedHTMLWithRetries=e(async(r,{retriesLeft:i=3,retryWaitMS:s=1e3}={})=>{try{let{reducedHTML:c,currentChecksumId:p}=await r.evaluate(async _=>{var v,E;return(E=(v=window==null?void 0:window.checksum)==null?void 0:v.testGenerator)==null?void 0:E.reduceHTML({},_)},{stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:this.currentChecksumId,fromTimeMachine:!0,invalidateCache:!0});return this.currentChecksumId=p,{reducedHTML:c}}catch(c){if(i>0)return await Mb(s),this.getReducedHTMLWithRetries(r,{retriesLeft:i-1,retryWaitMS:s});throw c}},"getReducedHTMLWithRetries");if(this.taskQueue=new $it({sortByTimestamp:s.sortByTimestamp,logPerformance:s.logPerformance}),s.webProxy){let{username:c,password:p,server:_}=s.webProxy;c&&p?this.webProxyAgent=new Jit.ProxyAgent({uri:`http://${c}:${p}@${_.replace("http://","")}`}):this.webProxyAgent=new Jit.ProxyAgent({uri:_})}}getPage(){return this.timeMachineFrame.page()}getFrame(){return this.timeMachineFrame}async prepare(r,i,s){this.recordingFrame=r,await this.frameMsgBroker.register("live",r),i?this.timeMachineFrame=i:this.timeMachineFrame=await this.prepareBrowserContextAndFrame(),await this.preventCrossOriginErrors(this.timeMachineFrame),this.options.frameMsgBrokerRegisterName&&await this.frameMsgBroker.register(this.options.frameMsgBrokerRegisterName,this.timeMachineFrame),s&&s(this.timeMachineFrame),await this.injectedScriptManager.addTrackedFrame(this.timeMachineFrame),this.timeMachineFrame.page().on("framenavigated",async c=>{await this.injectedScriptManager.onFrameNavigated(c)}),this.subscribeToRrwebEvents(),this.taskQueue=new $it({sortByTimestamp:this.options.sortByTimestamp,logPerformance:this.options.logPerformance}),await this.start()}async preventCrossOriginErrors(r){try{let i=r.page(),s=nw(i);if(this.pagesWithCorsInterception.has(s))return;this.pagesWithCorsInterception.add(s),await i.route(/^https?:\/\/(?!(?:localhost|127\.0\.0\.1|::1)).*/,async(c,p)=>{var E;let v=c.request().url();try{let D=this.webProxyAgent?{dispatcher:this.webProxyAgent}:{},w=await(0,Jit.fetch)(v,D),B=w.status,P={};w.headers.forEach((le,de)=>P[de]=le),P["access-control-allow-origin"]="*";let L=parseInt(w.headers.get("content-length")||"0",10),j=25*1024*1024;if(L>j)return c.continue();if(!w.body){await c.fulfill({status:B,headers:P});return}let ee=await w.arrayBuffer(),ue=Buffer.from(ee);await c.fulfill({status:B,headers:P,body:ue})}catch(D){return(E=D.cause)==null||E.code,c.continue()}})}catch{}}async start(){await this.timeMachineFrame.evaluate(async()=>{window.checksum.timeMachine.start({firstEventTimestamp:Date.now()})})}setBrowserContext(r){this.timeMachineBrowserContext=r}async executeTask(r,i=void 0,{name:s,beforeTimestamp:c=!1,priority:p=!1}={}){return new Promise((_,v)=>{let E=e(async({shouldGoBack:D,shouldBatch:w}={shouldGoBack:!0,shouldBatch:this.options.timestampBatchingEnabled})=>{if(this.timeMachineFrame.isDetached()&&v(),D){let L=Vit.performance.now();await this.goBack(i,c),this.timeGoingBack+=Vit.performance.now()-L,this.taskQueue.setTimeGoingBack(this.timeGoingBack)}let B=e(L=>async()=>{try{let j=Vit.performance.now(),V=await HS(L(this.timeMachineFrame),this.options.taskTimeout,()=>`Task execution timeout - ${s}, took ${Vit.performance.now()-j}ms with timeout of ${this.options.taskTimeout}ms`);_(V)}catch(j){af.error("Task execution error:",j.message),v(j)}},"makeSafeRunTask"),P=[B(r)];if(this.taskQueue.getQueueLength()>0&&w){let L=this.taskQueue.getTasksAtTimestamp(i);P.push(...L.map(({task:j})=>B(()=>j({shouldGoBack:!1,shouldBatch:!1})))),this.taskQueue.removeTasksAtTimestamp(i),P.length&&console.log(`Batching to task "${s}" ${P.length-1} more tasks`)}for(let L of P)await L()},"taskWrapper");this.taskQueue.enqueue({name:s,task:E,timestamp:c?i-1:i,priority:p}),this.runTasks()})}executeReducedHTMLTask(r,{priority:i=!1}={}){if(this.reducedHTMLCache[r]){let s=new tnt(this.reducedHTMLCache[r]);return Promise.resolve(s.getRrwebIdsReducedDomString())}return this.executeTask(async s=>{let c="",p=await this.getReducedHTMLWithRetries(s);return c=p==null?void 0:p.reducedHTML,c&&(this.reducedHTMLCache[r]=c),new tnt(c).getRrwebIdsReducedDomString()},r,{name:"getReducedHTMLForTimestamp",priority:i})}goBack(r,i=!1){return this.currentBeforeTimestamp===i&&this.currentTimestamp===r?Promise.resolve():(this.currentTimestamp=r,this.currentBeforeTimestamp=i,this.timeMachineFrame.evaluate(({timestamp:s,beforeTimestamp:c})=>s===void 0?window.checksum.timeMachine.goLive():window.checksum.timeMachine.goBack(s,{beforeTimestamp:c}),{timestamp:r,beforeTimestamp:i}))}goLive(){return this.timeMachineFrame.evaluate(()=>window.checksum.timeMachine.goLive())}async runTasks(){await this.taskQueue.runTasks(async r=>{await r.task()})}async rrwebEventHandler(r){let i=JSON.stringify(r);try{await this.timeMachineFrame.evaluate(function(s){let c=JSON.parse(s);return window.checksum.timeMachine.handleEvents(c)},i)}catch{}return r=null,i}async makeBrowserContext(){let r=[];this.options.debugPort&&r.push(`--remote-debugging-port=${this.options.debugPort}`);let i=await non.chromium.launch({headless:this.options.headless,args:r});return this.timeMachineBrowserContext=await i.newContext({bypassCSP:!0}),this.timeMachineBrowserContext}async makeFrame(){return(await this.timeMachineBrowserContext.newPage()).mainFrame()}async prepareBrowserContextAndFrame(){return this.timeMachineBrowserContext||await this.makeBrowserContext(),this.makeFrame()}subscribeToRrwebEvents(){let r="rrweb";this.frameMsgBroker.subscribeToChannel(r,this.timeMachineFrame,{originFrame:this.recordingFrame,handler:this.rrwebEventHandler.bind(this)}),this.timeMachineFrame.page().on("close",()=>this.frameMsgBroker.unsubscribeFromChannel(r,this.timeMachineFrame))}async toggleTimeMachineHandleEvents(r){try{await this.timeMachineFrame.evaluate(i=>window.checksum.timeMachine.setShouldHandleEvents(i),r)}catch{}}};e(Cxr,"ChecksumTimeMachine");oge=Cxr});var Dxr=Ws(()=>{"use strict"});var FTt=$r((HLe,zit)=>{(function(){var n,r="4.18.1",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",c="Expected a function",p="Invalid `variable` option passed into `_.template`",_="Invalid `imports` option passed into `_.template`",v="__lodash_hash_undefined__",E=500,D="__lodash_placeholder__",w=1,B=2,P=4,L=1,j=2,V=1,ee=2,ue=4,le=8,de=16,xe=32,Re=64,$e=128,Ke=256,Ce=512,We=30,mt="...",Ve=800,Ue=16,Qe=1,qe=2,Ge=3,Ze=1/0,je=9007199254740991,qt=17976931348623157e292,Nt=NaN,It=4294967295,Zt=It-1,lr=It>>>1,Jt=[["ary",$e],["bind",V],["bindKey",ee],["curry",le],["curryRight",de],["flip",Ce],["partial",xe],["partialRight",Re],["rearg",Ke]],ti="[object Arguments]",xn="[object Array]",rt="[object AsyncFunction]",pt="[object Boolean]",Qr="[object Date]",Pr="[object DOMException]",ai="[object Error]",In="[object Function]",Ri="[object GeneratorFunction]",kr="[object Map]",Ss="[object Number]",Vs="[object Null]",Fa="[object Object]",va="[object Promise]",as="[object Proxy]",Bs="[object RegExp]",rs="[object Set]",Oa="[object String]",sa="[object Symbol]",ga="[object Undefined]",qo="[object WeakMap]",Na="[object WeakSet]",so="[object ArrayBuffer]",ec="[object DataView]",Lr="[object Float32Array]",ri="[object Float64Array]",ma="[object Int8Array]",Vn="[object Int16Array]",qa="[object Int32Array]",Go="[object Uint8Array]",li="[object Uint8ClampedArray]",or="[object Uint16Array]",lt="[object Uint32Array]",ht=/\b__p \+= '';/g,Xe=/\b(__p \+=) '' \+/g,tt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,At=/&(?:amp|lt|gt|quot|#39);/g,st=/[&<>"']/g,Yt=RegExp(At.source),un=RegExp(st.source),Er=/<%-([\s\S]+?)%>/g,jn=/<%([\s\S]+?)%>/g,Li=/<%=([\s\S]+?)%>/g,fa=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,si=/^\w*$/,an=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Un=/[\\^$.*+?()[\]{}|]/g,Xn=RegExp(Un.source),_n=/^\s+/,Xt=/\s/,Me=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Pt=/\{\n\/\* \[wrapped with (.+)\] \*/,Gt=/,? & /,Tt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,qr=/[()=,{}\[\]\/\s]/,br=/\\(\\)?/g,dt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Mt=/\w*$/,rr=/^[-+]0x[0-9a-f]+$/i,Or=/^0b[01]+$/i,en=/^\[object .+?Constructor\]$/,$n=/^0o[0-7]+$/i,na=/^(?:0|[1-9]\d*)$/,Wi=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Fi=/($^)/,mn=/['\n\r\u2028\u2029\\]/g,Ba="\\ud800-\\udfff",vi="\\u0300-\\u036f",uo="\\ufe20-\\ufe2f",Ru="\\u20d0-\\u20ff",of=vi+uo+Ru,Uc="\\u2700-\\u27bf",Fl="a-z\\xdf-\\xf6\\xf8-\\xff",Df="\\xac\\xb1\\xd7\\xf7",Rl="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Qp="\\u2000-\\u206f",Bu=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",cf="A-Z\\xc0-\\xd6\\xd8-\\xde",fd="\\ufe0e\\ufe0f",Im=Df+Rl+Qp+Bu,Yh="['\u2019]",Lg="["+Ba+"]",D_="["+Im+"]",R2="["+of+"]",L2="\\d+",d0="["+Uc+"]",_c="["+Fl+"]",qf="[^"+Ba+Im+L2+Uc+Fl+cf+"]",Tl="\\ud83c[\\udffb-\\udfff]",rf="(?:"+R2+"|"+Tl+")",ip="[^"+Ba+"]",kf="(?:\\ud83c[\\udde6-\\uddff]){2}",_u="[\\ud800-\\udbff][\\udc00-\\udfff]",mc="["+cf+"]",Ra="\\u200d",Ci="(?:"+_c+"|"+qf+")",Fc="(?:"+mc+"|"+qf+")",_0="(?:"+Yh+"(?:d|ll|m|re|s|t|ve))?",If="(?:"+Yh+"(?:D|LL|M|RE|S|T|VE))?",K_=rf+"?",zr="["+fd+"]?",tr="(?:"+Ra+"(?:"+[ip,kf,_u].join("|")+")"+zr+K_+")*",Yn="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ta="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",xs=zr+K_+tr,Ca="(?:"+[d0,kf,_u].join("|")+")"+xs,To="(?:"+[ip+R2+"?",R2,kf,_u,Lg].join("|")+")",hu=RegExp(Yh,"g"),Ao=RegExp(R2,"g"),fo=RegExp(Tl+"(?="+Tl+")|"+To+xs,"g"),cc=RegExp([mc+"?"+_c+"+"+_0+"(?="+[D_,mc,"$"].join("|")+")",Fc+"+"+If+"(?="+[D_,mc+Ci,"$"].join("|")+")",mc+"?"+Ci+"+"+_0,mc+"+"+If,Ta,Yn,L2,Ca].join("|"),"g"),Nc=RegExp("["+Ra+Ba+of+fd+"]"),fu=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fu=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ln=-1,Qu={};Qu[Lr]=Qu[ri]=Qu[ma]=Qu[Vn]=Qu[qa]=Qu[Go]=Qu[li]=Qu[or]=Qu[lt]=!0,Qu[ti]=Qu[xn]=Qu[so]=Qu[pt]=Qu[ec]=Qu[Qr]=Qu[ai]=Qu[In]=Qu[kr]=Qu[Ss]=Qu[Fa]=Qu[Bs]=Qu[rs]=Qu[Oa]=Qu[qo]=!1;var Au={};Au[ti]=Au[xn]=Au[so]=Au[ec]=Au[pt]=Au[Qr]=Au[Lr]=Au[ri]=Au[ma]=Au[Vn]=Au[qa]=Au[kr]=Au[Ss]=Au[Fa]=Au[Bs]=Au[rs]=Au[Oa]=Au[sa]=Au[Go]=Au[li]=Au[or]=Au[lt]=!0,Au[ai]=Au[In]=Au[qo]=!1;var Vp={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Y0={"&":"&","<":"<",">":">",'"':""","'":"'"},kd={"&":"&","<":"<",">":">",""":'"',"'":"'"},Hd={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},X0=parseFloat,Of=parseInt,ji=typeof global=="object"&&global&&global.Object===Object&&global,eo=typeof self=="object"&&self&&self.Object===Object&&self,Ea=ji||eo||Function("return this")(),Ec=typeof HLe=="object"&&HLe&&!HLe.nodeType&&HLe,Ja=Ec&&typeof zit=="object"&&zit&&!zit.nodeType&&zit,Hi=Ja&&Ja.exports===Ec,Ni=Hi&&ji.process,ta=function(){try{var Gc=Ja&&Ja.require&&Ja.require("util").types;return Gc||Ni&&Ni.binding&&Ni.binding("util")}catch{}}(),jt=ta&&ta.isArrayBuffer,Br=ta&&ta.isDate,kn=ta&&ta.isMap,hi=ta&&ta.isRegExp,ea=ta&&ta.isSet,Fo=ta&&ta.isTypedArray;function Wa(Gc,fp,ja){switch(ja.length){case 0:return Gc.call(fp);case 1:return Gc.call(fp,ja[0]);case 2:return Gc.call(fp,ja[0],ja[1]);case 3:return Gc.call(fp,ja[0],ja[1],ja[2])}return Gc.apply(fp,ja)}e(Wa,"apply");function Ka(Gc,fp,ja,Qd){for(var _h=-1,ay=Gc==null?0:Gc.length;++_h<ay;){var K2=Gc[_h];fp(Qd,K2,ja(K2),Gc)}return Qd}e(Ka,"arrayAggregator");function nc(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length;++ja<Qd&&fp(Gc[ja],ja,Gc)!==!1;);return Gc}e(nc,"arrayEach");function ju(Gc,fp){for(var ja=Gc==null?0:Gc.length;ja--&&fp(Gc[ja],ja,Gc)!==!1;);return Gc}e(ju,"arrayEachRight");function se(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length;++ja<Qd;)if(!fp(Gc[ja],ja,Gc))return!1;return!0}e(se,"arrayEvery");function Lo(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length,_h=0,ay=[];++ja<Qd;){var K2=Gc[ja];fp(K2,ja,Gc)&&(ay[_h++]=K2)}return ay}e(Lo,"arrayFilter");function Ip(Gc,fp){var ja=Gc==null?0:Gc.length;return!!ja&&gu(Gc,fp,0)>-1}e(Ip,"arrayIncludes");function jl(Gc,fp,ja){for(var Qd=-1,_h=Gc==null?0:Gc.length;++Qd<_h;)if(ja(fp,Gc[Qd]))return!0;return!1}e(jl,"arrayIncludesWith");function Ul(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length,_h=Array(Qd);++ja<Qd;)_h[ja]=fp(Gc[ja],ja,Gc);return _h}e(Ul,"arrayMap");function Ff(Gc,fp){for(var ja=-1,Qd=fp.length,_h=Gc.length;++ja<Qd;)Gc[_h+ja]=fp[ja];return Gc}e(Ff,"arrayPush");function I0(Gc,fp,ja,Qd){var _h=-1,ay=Gc==null?0:Gc.length;for(Qd&&ay&&(ja=Gc[++_h]);++_h<ay;)ja=fp(ja,Gc[_h],_h,Gc);return ja}e(I0,"arrayReduce");function H0(Gc,fp,ja,Qd){var _h=Gc==null?0:Gc.length;for(Qd&&_h&&(ja=Gc[--_h]);_h--;)ja=fp(ja,Gc[_h],_h,Gc);return ja}e(H0,"arrayReduceRight");function mp(Gc,fp){for(var ja=-1,Qd=Gc==null?0:Gc.length;++ja<Qd;)if(fp(Gc[ja],ja,Gc))return!0;return!1}e(mp,"arraySome");var C0=hs("length");function Jn(Gc){return Gc.split("")}e(Jn,"asciiToArray");function ws(Gc){return Gc.match(Tt)||[]}e(ws,"asciiWords");function Eo(Gc,fp,ja){var Qd;return ja(Gc,function(_h,ay,K2){if(fp(_h,ay,K2))return Qd=ay,!1}),Qd}e(Eo,"baseFindKey");function Ko(Gc,fp,ja,Qd){for(var _h=Gc.length,ay=ja+(Qd?1:-1);Qd?ay--:++ay<_h;)if(fp(Gc[ay],ay,Gc))return ay;return-1}e(Ko,"baseFindIndex");function gu(Gc,fp,ja){return fp===fp?r1(Gc,fp,ja):Ko(Gc,zu,ja)}e(gu,"baseIndexOf");function Qo(Gc,fp,ja,Qd){for(var _h=ja-1,ay=Gc.length;++_h<ay;)if(Qd(Gc[_h],fp))return _h;return-1}e(Qo,"baseIndexOfWith");function zu(Gc){return Gc!==Gc}e(zu,"baseIsNaN");function kl(Gc,fp){var ja=Gc==null?0:Gc.length;return ja?sn(Gc,fp)/ja:Nt}e(kl,"baseMean");function hs(Gc){return function(fp){return fp==null?n:fp[Gc]}}e(hs,"baseProperty");function v0(Gc){return function(fp){return Gc==null?n:Gc[fp]}}e(v0,"basePropertyOf");function M0(Gc,fp,ja,Qd,_h){return _h(Gc,function(ay,K2,ly){ja=Qd?(Qd=!1,ay):fp(ja,ay,K2,ly)}),ja}e(M0,"baseReduce");function u0(Gc,fp){var ja=Gc.length;for(Gc.sort(fp);ja--;)Gc[ja]=Gc[ja].value;return Gc}e(u0,"baseSortBy");function sn(Gc,fp){for(var ja,Qd=-1,_h=Gc.length;++Qd<_h;){var ay=fp(Gc[Qd]);ay!==n&&(ja=ja===n?ay:ja+ay)}return ja}e(sn,"baseSum");function ts(Gc,fp){for(var ja=-1,Qd=Array(Gc);++ja<Gc;)Qd[ja]=fp(ja);return Qd}e(ts,"baseTimes");function nu(Gc,fp){return Ul(fp,function(ja){return[ja,Gc[ja]]})}e(nu,"baseToPairs");function Po(Gc){return Gc&&Gc.slice(0,Mp(Gc)+1).replace(_n,"")}e(Po,"baseTrim");function Ku(Gc){return function(fp){return Gc(fp)}}e(Ku,"baseUnary");function lp(Gc,fp){return Ul(fp,function(ja){return Gc[ja]})}e(lp,"baseValues");function xl(Gc,fp){return Gc.has(fp)}e(xl,"cacheHas");function Co(Gc,fp){for(var ja=-1,Qd=Gc.length;++ja<Qd&&gu(fp,Gc[ja],0)>-1;);return ja}e(Co,"charsStartIndex");function Pi(Gc,fp){for(var ja=Gc.length;ja--&&gu(fp,Gc[ja],0)>-1;);return ja}e(Pi,"charsEndIndex");function Gs(Gc,fp){for(var ja=Gc.length,Qd=0;ja--;)Gc[ja]===fp&&++Qd;return Qd}e(Gs,"countHolders");var gs=v0(Vp),No=v0(Y0);function za(Gc){return"\\"+Hd[Gc]}e(za,"escapeStringChar");function yc(Gc,fp){return Gc==null?n:Gc[fp]}e(yc,"getValue");function Tu(Gc){return Nc.test(Gc)}e(Tu,"hasUnicode");function hp(Gc){return fu.test(Gc)}e(hp,"hasUnicodeWord");function uf(Gc){for(var fp,ja=[];!(fp=Gc.next()).done;)ja.push(fp.value);return ja}e(uf,"iteratorToArray");function gf(Gc){var fp=-1,ja=Array(Gc.size);return Gc.forEach(function(Qd,_h){ja[++fp]=[_h,Qd]}),ja}e(gf,"mapToArray");function Np(Gc,fp){return function(ja){return Gc(fp(ja))}}e(Np,"overArg");function $f(Gc,fp){for(var ja=-1,Qd=Gc.length,_h=0,ay=[];++ja<Qd;){var K2=Gc[ja];(K2===fp||K2===D)&&(Gc[ja]=D,ay[_h++]=ja)}return ay}e($f,"replaceHolders");function S_(Gc){var fp=-1,ja=Array(Gc.size);return Gc.forEach(function(Qd){ja[++fp]=Qd}),ja}e(S_,"setToArray");function od(Gc){var fp=-1,ja=Array(Gc.size);return Gc.forEach(function(Qd){ja[++fp]=[Qd,Qd]}),ja}e(od,"setToPairs");function r1(Gc,fp,ja){for(var Qd=ja-1,_h=Gc.length;++Qd<_h;)if(Gc[Qd]===fp)return Qd;return-1}e(r1,"strictIndexOf");function Wp(Gc,fp,ja){for(var Qd=ja+1;Qd--;)if(Gc[Qd]===fp)return Qd;return Qd}e(Wp,"strictLastIndexOf");function pc(Gc){return Tu(Gc)?b_(Gc):C0(Gc)}e(pc,"stringSize");function Ll(Gc){return Tu(Gc)?Hs(Gc):Jn(Gc)}e(Ll,"stringToArray");function Mp(Gc){for(var fp=Gc.length;fp--&&Xt.test(Gc.charAt(fp)););return fp}e(Mp,"trimmedEndIndex");var zf=v0(kd);function b_(Gc){for(var fp=fo.lastIndex=0;fo.test(Gc);)++fp;return fp}e(b_,"unicodeSize");function Hs(Gc){return Gc.match(fo)||[]}e(Hs,"unicodeToArray");function n_(Gc){return Gc.match(cc)||[]}e(n_,"unicodeWords");var ym=e(function Gc(fp){fp=fp==null?Ea:E_.defaults(Ea.Object(),fp,E_.pick(Ea,Fu));var ja=fp.Array,Qd=fp.Date,_h=fp.Error,ay=fp.Function,K2=fp.Math,ly=fp.Object,Px=fp.RegExp,Db=fp.String,nA=fp.TypeError,A6=ja.prototype,uC=ay.prototype,lC=ly.prototype,ME=fp["__core-js_shared__"],pC=uC.toString,Mg=lC.hasOwnProperty,$1=0,fD=function(){var te=/[^.]+$/.exec(ME&&ME.keys&&ME.keys.IE_PROTO||"");return te?"Symbol(src)_1."+te:""}(),Wx=lC.toString,py=pC.call(ly),Sb=Ea._,ZA=Px("^"+pC.call(Mg).replace(Un,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),n2=Hi?fp.Buffer:n,Bx=fp.Symbol,he=fp.Uint8Array,yr=n2?n2.allocUnsafe:n,Qi=Np(ly.getPrototypeOf,ly),Za=ly.create,Qc=lC.propertyIsEnumerable,Op=A6.splice,Ha=Bx?Bx.isConcatSpreadable:n,La=Bx?Bx.iterator:n,$i=Bx?Bx.toStringTag:n,Pa=function(){try{var te=x9(ly,"defineProperty");return te({},"",{}),te}catch{}}(),Aa=fp.clearTimeout!==Ea.clearTimeout&&fp.clearTimeout,ba=Qd&&Qd.now!==Ea.Date.now&&Qd.now,ss=fp.setTimeout!==Ea.setTimeout&&fp.setTimeout,Os=K2.ceil,ka=K2.floor,to=ly.getOwnPropertySymbols,ls=n2?n2.isBuffer:n,go=fp.isFinite,Yo=A6.join,Oo=Np(ly.keys,ly),Dc=K2.max,yu=K2.min,vu=Qd.now,ep=fp.parseInt,Ms=K2.random,dl=A6.reverse,qc=x9(fp,"DataView"),Rc=x9(fp,"Map"),fe=x9(fp,"Promise"),Te=x9(fp,"Set"),Hr=x9(fp,"WeakMap"),dr=x9(ly,"create"),Zn=Hr&&new Hr,hn={},Fr=Eg(qc),ir=Eg(Rc),En=Eg(fe),Ct=Eg(Te),Cn=Eg(Hr),Ti=Bx?Bx.prototype:n,Gi=Ti?Ti.valueOf:n,ua=Ti?Ti.toString:n;function _e(te){if(AC(te)&&!k1(te)&&!(te instanceof Sc)){if(te instanceof no)return te;if(Mg.call(te,"__wrapped__"))return AT(te)}return new no(te)}e(_e,"lodash");var $a=function(){function te(){}return e(te,"object"),function(me){if(!KC(me))return{};if(Za)return Za(me);te.prototype=me;var xt=new te;return te.prototype=n,xt}}();function Ya(){}e(Ya,"baseLodash");function no(te,me){this.__wrapped__=te,this.__actions__=[],this.__chain__=!!me,this.__index__=0,this.__values__=n}e(no,"LodashWrapper"),_e.templateSettings={escape:Er,evaluate:jn,interpolate:Li,variable:"",imports:{_:_e}},_e.prototype=Ya.prototype,_e.prototype.constructor=_e,no.prototype=$a(Ya.prototype),no.prototype.constructor=no;function Sc(te){this.__wrapped__=te,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=It,this.__views__=[]}e(Sc,"LazyWrapper");function oo(){var te=new Sc(this.__wrapped__);return te.__actions__=Ts(this.__actions__),te.__dir__=this.__dir__,te.__filtered__=this.__filtered__,te.__iteratees__=Ts(this.__iteratees__),te.__takeCount__=this.__takeCount__,te.__views__=Ts(this.__views__),te}e(oo,"lazyClone");function _o(){if(this.__filtered__){var te=new Sc(this);te.__dir__=-1,te.__filtered__=!0}else te=this.clone(),te.__dir__*=-1;return te}e(_o,"lazyReverse");function zo(){var te=this.__wrapped__.value(),me=this.__dir__,xt=k1(te),An=me<0,ya=xt?te.length:0,co=zoe(0,ya,this.__views__),Xc=co.start,rl=co.end,dp=rl-Xc,td=An?rl:Xc-1,j0=this.__iteratees__,z0=j0.length,V_=0,n1=yu(dp,this.__takeCount__);if(!xt||!An&&ya==dp&&n1==dp)return hE(te,this.__actions__);var J1=[];e:for(;dp--&&V_<n1;){td+=me;for(var z1=-1,dg=te[td];++z1<z0;){var Ay=j0[z1],Nv=Ay.iteratee,c3=Ay.type,AE=Nv(dg);if(c3==qe)dg=AE;else if(!AE){if(c3==Qe)continue e;break e}}J1[V_++]=dg}return J1}e(zo,"lazyValue"),Sc.prototype=$a(Ya.prototype),Sc.prototype.constructor=Sc;function Zc(te){var me=-1,xt=te==null?0:te.length;for(this.clear();++me<xt;){var An=te[me];this.set(An[0],An[1])}}e(Zc,"Hash");function _l(){this.__data__=dr?dr(null):{},this.size=0}e(_l,"hashClear");function $o(te){var me=this.has(te)&&delete this.__data__[te];return this.size-=me?1:0,me}e($o,"hashDelete");function xp(te){var me=this.__data__;if(dr){var xt=me[te];return xt===v?n:xt}return Mg.call(me,te)?me[te]:n}e(xp,"hashGet");function $s(te){var me=this.__data__;return dr?me[te]!==n:Mg.call(me,te)}e($s,"hashHas");function Pc(te,me){var xt=this.__data__;return this.size+=this.has(te)?0:1,xt[te]=dr&&me===n?v:me,this}e(Pc,"hashSet"),Zc.prototype.clear=_l,Zc.prototype.delete=$o,Zc.prototype.get=xp,Zc.prototype.has=$s,Zc.prototype.set=Pc;function tp(te){var me=-1,xt=te==null?0:te.length;for(this.clear();++me<xt;){var An=te[me];this.set(An[0],An[1])}}e(tp,"ListCache");function Xp(){this.__data__=[],this.size=0}e(Xp,"listCacheClear");function Dp(te){var me=this.__data__,xt=jE(me,te);if(xt<0)return!1;var An=me.length-1;return xt==An?me.pop():Op.call(me,xt,1),--this.size,!0}e(Dp,"listCacheDelete");function lf(te){var me=this.__data__,xt=jE(me,te);return xt<0?n:me[xt][1]}e(lf,"listCacheGet");function yf(te){return jE(this.__data__,te)>-1}e(yf,"listCacheHas");function Uf(te,me){var xt=this.__data__,An=jE(xt,te);return An<0?(++this.size,xt.push([te,me])):xt[An][1]=me,this}e(Uf,"listCacheSet"),tp.prototype.clear=Xp,tp.prototype.delete=Dp,tp.prototype.get=lf,tp.prototype.has=yf,tp.prototype.set=Uf;function A0(te){var me=-1,xt=te==null?0:te.length;for(this.clear();++me<xt;){var An=te[me];this.set(An[0],An[1])}}e(A0,"MapCache");function $d(){this.size=0,this.__data__={hash:new Zc,map:new(Rc||tp),string:new Zc}}e($d,"mapCacheClear");function ku(te){var me=pF(this,te).delete(te);return this.size-=me?1:0,me}e(ku,"mapCacheDelete");function gp(te){return pF(this,te).get(te)}e(gp,"mapCacheGet");function Hf(te){return pF(this,te).has(te)}e(Hf,"mapCacheHas");function c_(te,me){var xt=pF(this,te),An=xt.size;return xt.set(te,me),this.size+=xt.size==An?0:1,this}e(c_,"mapCacheSet"),A0.prototype.clear=$d,A0.prototype.delete=ku,A0.prototype.get=gp,A0.prototype.has=Hf,A0.prototype.set=c_;function v_(te){var me=-1,xt=te==null?0:te.length;for(this.__data__=new A0;++me<xt;)this.add(te[me])}e(v_,"SetCache");function Hm(te){return this.__data__.set(te,v),this}e(Hm,"setCacheAdd");function Iv(te){return this.__data__.has(te)}e(Iv,"setCacheHas"),v_.prototype.add=v_.prototype.push=Hm,v_.prototype.has=Iv;function Ky(te){var me=this.__data__=new tp(te);this.size=me.size}e(Ky,"Stack");function iA(){this.__data__=new tp,this.size=0}e(iA,"stackClear");function Vb(te){var me=this.__data__,xt=me.delete(te);return this.size=me.size,xt}e(Vb,"stackDelete");function fC(te){return this.__data__.get(te)}e(fC,"stackGet");function x6(te){return this.__data__.has(te)}e(x6,"stackHas");function iv(te,me){var xt=this.__data__;if(xt instanceof tp){var An=xt.__data__;if(!Rc||An.length<i-1)return An.push([te,me]),this.size=++xt.size,this;xt=this.__data__=new A0(An)}return xt.set(te,me),this.size=xt.size,this}e(iv,"stackSet"),Ky.prototype.clear=iA,Ky.prototype.delete=Vb,Ky.prototype.get=fC,Ky.prototype.has=x6,Ky.prototype.set=iv;function ql(te,me){var xt=k1(te),An=!xt&&Ox(te),ya=!xt&&!An&&D6(te),co=!xt&&!An&&!ya&&AF(te),Xc=xt||An||ya||co,rl=Xc?ts(te.length,Db):[],dp=rl.length;for(var td in te)(me||Mg.call(te,td))&&!(Xc&&(td=="length"||ya&&(td=="offset"||td=="parent")||co&&(td=="buffer"||td=="byteLength"||td=="byteOffset")||yy(td,dp)))&&rl.push(td);return rl}e(ql,"arrayLikeKeys");function pm(te){var me=te.length;return me?te[Gg(0,me-1)]:n}e(pm,"arraySample");function Om(te,me){return cd(Ts(te),ei(me,0,te.length))}e(Om,"arraySampleSize");function jg(te){return cd(Ts(te))}e(jg,"arrayShuffle");function By(te,me,xt){(xt!==n&&!c7(te[me],xt)||xt===n&&!(me in te))&&De(te,me,xt)}e(By,"assignMergeValue");function ex(te,me,xt){var An=te[me];(!(Mg.call(te,me)&&c7(An,xt))||xt===n&&!(me in te))&&De(te,me,xt)}e(ex,"assignValue");function jE(te,me){for(var xt=te.length;xt--;)if(c7(te[xt][0],me))return xt;return-1}e(jE,"assocIndexOf");function av(te,me,xt,An){return vn(te,function(ya,co,Xc){me(An,ya,xt(ya),Xc)}),An}e(av,"baseAggregator");function Jb(te,me){return te&&J4(me,YC(me),te)}e(Jb,"baseAssign");function M(te,me){return te&&J4(me,wy(me),te)}e(M,"baseAssignIn");function De(te,me,xt){me=="__proto__"&&Pa?Pa(te,me,{configurable:!0,enumerable:!0,value:xt,writable:!0}):te[me]=xt}e(De,"baseAssignValue");function Vr(te,me){for(var xt=-1,An=me.length,ya=ja(An),co=te==null;++xt<An;)ya[xt]=co?n:WU(te,me[xt]);return ya}e(Vr,"baseAt");function ei(te,me,xt){return te===te&&(xt!==n&&(te=te<=xt?te:xt),me!==n&&(te=te>=me?te:me)),te}e(ei,"baseClamp");function Ne(te,me,xt,An,ya,co){var Xc,rl=me&w,dp=me&B,td=me&P;if(xt&&(Xc=ya?xt(te,An,ya,co):xt(te)),Xc!==n)return Xc;if(!KC(te))return te;var j0=k1(te);if(j0){if(Xc=O$(te),!rl)return Ts(te,Xc)}else{var z0=hC(te),V_=z0==In||z0==Ri;if(D6(te))return s8(te,rl);if(z0==Fa||z0==ti||V_&&!ya){if(Xc=dp||V_?{}:HH(te),!rl)return dp?ZS(te,M(Xc,te)):v9(te,Jb(Xc,te))}else{if(!Au[z0])return ya?te:{};Xc=Ro(te,z0,rl)}}co||(co=new Ky);var n1=co.get(te);if(n1)return n1;co.set(te,Xc),lW(te)?te.forEach(function(dg){Xc.add(Ne(dg,me,xt,dg,te,co))}):AD(te)&&te.forEach(function(dg,Ay){Xc.set(Ay,Ne(dg,me,xt,Ay,te,co))});var J1=td?dp?lF:Fv:dp?wy:YC,z1=j0?n:J1(te);return nc(z1||te,function(dg,Ay){z1&&(Ay=dg,dg=te[Ay]),ex(Xc,Ay,Ne(dg,me,xt,Ay,te,co))}),Xc}e(Ne,"baseClone");function wt(te){var me=YC(te);return function(xt){return Ot(xt,te,me)}}e(wt,"baseConforms");function Ot(te,me,xt){var An=xt.length;if(te==null)return!An;for(te=ly(te);An--;){var ya=xt[An],co=me[ya],Xc=te[ya];if(Xc===n&&!(ya in te)||!co(Xc))return!1}return!0}e(Ot,"baseConformsTo");function zt(te,me,xt){if(typeof te!="function")throw new nA(c);return Cu(function(){te.apply(n,xt)},me)}e(zt,"baseDelay");function Nr(te,me,xt,An){var ya=-1,co=Ip,Xc=!0,rl=te.length,dp=[],td=me.length;if(!rl)return dp;xt&&(me=Ul(me,Ku(xt))),An?(co=jl,Xc=!1):me.length>=i&&(co=xl,Xc=!1,me=new v_(me));e:for(;++ya<rl;){var j0=te[ya],z0=xt==null?j0:xt(j0);if(j0=An||j0!==0?j0:0,Xc&&z0===z0){for(var V_=td;V_--;)if(me[V_]===z0)continue e;dp.push(j0)}else co(me,z0,An)||dp.push(j0)}return dp}e(Nr,"baseDifference");var vn=xh(Da),cn=xh(Cs,!0);function ln(te,me){var xt=!0;return vn(te,function(An,ya,co){return xt=!!me(An,ya,co),xt}),xt}e(ln,"baseEvery");function Rr(te,me,xt){for(var An=-1,ya=te.length;++An<ya;){var co=te[An],Xc=me(co);if(Xc!=null&&(rl===n?Xc===Xc&&!p8(Xc):xt(Xc,rl)))var rl=Xc,dp=co}return dp}e(Rr,"baseExtremum");function oi(te,me,xt,An){var ya=te.length;for(xt=oy(xt),xt<0&&(xt=-xt>ya?0:ya+xt),An=An===n||An>ya?ya:oy(An),An<0&&(An+=ya),An=xt>An?0:xF(An);xt<An;)te[xt++]=me;return te}e(oi,"baseFill");function Dr(te,me){var xt=[];return vn(te,function(An,ya,co){me(An,ya,co)&&xt.push(An)}),xt}e(Dr,"baseFilter");function Vt(te,me,xt,An,ya){var co=-1,Xc=te.length;for(xt||(xt=Gx),ya||(ya=[]);++co<Xc;){var rl=te[co];me>0&&xt(rl)?me>1?Vt(rl,me-1,xt,An,ya):Ff(ya,rl):An||(ya[ya.length]=rl)}return ya}e(Vt,"baseFlatten");var qn=V5(),Fn=V5(!0);function Da(te,me){return te&&qn(te,me,YC)}e(Da,"baseForOwn");function Cs(te,me){return te&&Fn(te,me,YC)}e(Cs,"baseForOwnRight");function _s(te,me){return Lo(me,function(xt){return u7(te[xt])})}e(_s,"baseFunctions");function ys(te,me){me=gE(me,te);for(var xt=0,An=me.length;te!=null&&xt<An;)te=te[i7(me[xt++])];return xt&&xt==An?te:n}e(ys,"baseGet");function Bi(te,me,xt){var An=me(te);return k1(te)?An:Ff(An,xt(te))}e(Bi,"baseGetAllKeys");function ha(te){return te==null?te===n?ga:Vs:$i&&$i in ly(te)?Xu(te):RU(te)}e(ha,"baseGetTag");function lo(te,me){return te>me}e(lo,"baseGt");function mu(te,me){return te!=null&&Mg.call(te,me)}e(mu,"baseHas");function Jp(te,me){return te!=null&&me in ly(te)}e(Jp,"baseHasIn");function yd(te,me,xt){return te>=yu(me,xt)&&te<Dc(me,xt)}e(yd,"baseInRange");function u_(te,me,xt){for(var An=xt?jl:Ip,ya=te[0].length,co=te.length,Xc=co,rl=ja(co),dp=1/0,td=[];Xc--;){var j0=te[Xc];Xc&&me&&(j0=Ul(j0,Ku(me))),dp=yu(j0.length,dp),rl[Xc]=!xt&&(me||ya>=120&&j0.length>=120)?new v_(Xc&&j0):n}j0=te[0];var z0=-1,V_=rl[0];e:for(;++z0<ya&&td.length<dp;){var n1=j0[z0],J1=me?me(n1):n1;if(n1=xt||n1!==0?n1:0,!(V_?xl(V_,J1):An(td,J1,xt))){for(Xc=co;--Xc;){var z1=rl[Xc];if(!(z1?xl(z1,J1):An(te[Xc],J1,xt)))continue e}V_&&V_.push(J1),td.push(n1)}}return td}e(u_,"baseIntersection");function Vd(te,me,xt,An){return Da(te,function(ya,co,Xc){me(An,xt(ya),co,Xc)}),An}e(Vd,"baseInverter");function _m(te,me,xt){me=gE(me,te),te=WH(te,me);var An=te==null?te:te[i7(a7(me))];return An==null?n:Wa(An,te,xt)}e(_m,"baseInvoke");function __(te){return AC(te)&&ha(te)==ti}e(__,"baseIsArguments");function q_(te){return AC(te)&&ha(te)==so}e(q_,"baseIsArrayBuffer");function Al(te){return AC(te)&&ha(te)==Qr}e(Al,"baseIsDate");function P0(te,me,xt,An,ya){return te===me?!0:te==null||me==null||!AC(te)&&!AC(me)?te!==te&&me!==me:Kl(te,me,xt,An,P0,ya)}e(P0,"baseIsEqual");function Kl(te,me,xt,An,ya,co){var Xc=k1(te),rl=k1(me),dp=Xc?xn:hC(te),td=rl?xn:hC(me);dp=dp==ti?Fa:dp,td=td==ti?Fa:td;var j0=dp==Fa,z0=td==Fa,V_=dp==td;if(V_&&D6(te)){if(!D6(me))return!1;Xc=!0,j0=!1}if(V_&&!j0)return co||(co=new Ky),Xc||AF(te)?Hre(te,me,xt,An,ya,co):J5(te,me,dp,xt,An,ya,co);if(!(xt&L)){var n1=j0&&Mg.call(te,"__wrapped__"),J1=z0&&Mg.call(me,"__wrapped__");if(n1||J1){var z1=n1?te.value():te,dg=J1?me.value():me;return co||(co=new Ky),ya(z1,dg,xt,An,co)}}return V_?(co||(co=new Ky),nP(te,me,xt,An,ya,co)):!1}e(Kl,"baseIsEqualDeep");function mo(te){return AC(te)&&hC(te)==kr}e(mo,"baseIsMap");function Do(te,me,xt,An){var ya=xt.length,co=ya,Xc=!An;if(te==null)return!co;for(te=ly(te);ya--;){var rl=xt[ya];if(Xc&&rl[2]?rl[1]!==te[rl[0]]:!(rl[0]in te))return!1}for(;++ya<co;){rl=xt[ya];var dp=rl[0],td=te[dp],j0=rl[1];if(Xc&&rl[2]){if(td===n&&!(dp in te))return!1}else{var z0=new Ky;if(An)var V_=An(td,j0,dp,te,me,z0);if(!(V_===n?P0(j0,td,L|j,An,z0):V_))return!1}}return!0}e(Do,"baseIsMatch");function id(te){if(!KC(te)||OU(te))return!1;var me=u7(te)?ZA:en;return me.test(Eg(te))}e(id,"baseIsNative");function X_(te){return AC(te)&&ha(te)==Bs}e(X_,"baseIsRegExp");function Ih(te){return AC(te)&&hC(te)==rs}e(Ih,"baseIsSet");function x0(te){return AC(te)&&hx(te.length)&&!!Qu[ha(te)]}e(x0,"baseIsTypedArray");function Nf(te){return typeof te=="function"?te:te==null?d8:typeof te=="object"?k1(te)?Ir(te[0],te[1]):qu(te):gP(te)}e(Nf,"baseIteratee");function Wf(te){if(!Hb(te))return Oo(te);var me=[];for(var xt in ly(te))Mg.call(te,xt)&&xt!="constructor"&&me.push(xt);return me}e(Wf,"baseKeys");function Cm(te){if(!KC(te))return mw(te);var me=Hb(te),xt=[];for(var An in te)An=="constructor"&&(me||!Mg.call(te,An))||xt.push(An);return xt}e(Cm,"baseKeysIn");function $_(te,me){return te<me}e($_,"baseLt");function Fm(te,me){var xt=-1,An=i3(te)?ja(te.length):[];return vn(te,function(ya,co,Xc){An[++xt]=me(ya,co,Xc)}),An}e(Fm,"baseMap");function qu(te){var me=fw(te);return me.length==1&&me[0][2]?zY(me[0][0],me[0][1]):function(xt){return xt===te||Do(xt,te,me)}}e(qu,"baseMatches");function Ir(te,me){return mO(te)&&_D(me)?zY(i7(te),me):function(xt){var An=WU(xt,te);return An===n&&An===me?lM(xt,te):P0(me,An,L|j)}}e(Ir,"baseMatchesProperty");function la(te,me,xt,An,ya){te!==me&&qn(me,function(co,Xc){if(ya||(ya=new Ky),KC(co))vc(te,me,Xc,xt,la,An,ya);else{var rl=An?An(n7(te,Xc),co,Xc+"",te,me,ya):n;rl===n&&(rl=co),By(te,Xc,rl)}},wy)}e(la,"baseMerge");function vc(te,me,xt,An,ya,co,Xc){var rl=n7(te,xt),dp=n7(me,xt),td=Xc.get(dp);if(td){By(te,xt,td);return}var j0=co?co(rl,dp,xt+"",te,me,Xc):n,z0=j0===n;if(z0){var V_=k1(dp),n1=!V_&&D6(dp),J1=!V_&&!n1&&AF(dp);j0=dp,V_||n1||J1?k1(rl)?j0=rl:vC(rl)?j0=Ts(rl):n1?(z0=!1,j0=s8(dp,!0)):J1?(z0=!1,j0=E6(dp,!0)):j0=[]:wT(dp)||Ox(dp)?(j0=rl,Ox(rl)?j0=pW(rl):(!KC(rl)||u7(rl))&&(j0=HH(dp))):z0=!1}z0&&(Xc.set(dp,j0),ya(j0,dp,An,co,Xc),Xc.delete(dp)),By(te,xt,j0)}e(vc,"baseMergeDeep");function Ds(te,me){var xt=te.length;if(xt)return me+=me<0?xt:0,yy(me,xt)?te[me]:n}e(Ds,"baseNth");function ol(te,me,xt){me.length?me=Ul(me,function(co){return k1(co)?function(Xc){return ys(Xc,co.length===1?co[0]:co)}:co}):me=[d8];var An=-1;me=Ul(me,Ku(Kg()));var ya=Fm(te,function(co,Xc,rl){var dp=Ul(me,function(td){return td(co)});return{criteria:dp,index:++An,value:co}});return u0(ya,function(co,Xc){return mC(co,Xc,xt)})}e(ol,"baseOrderBy");function Nl(te,me){return k_(te,me,function(xt,An){return lM(te,An)})}e(Nl,"basePick");function k_(te,me,xt){for(var An=-1,ya=me.length,co={};++An<ya;){var Xc=me[An],rl=ys(te,Xc);xt(rl,Xc)&&pb(co,gE(Xc,te),rl)}return co}e(k_,"basePickBy");function L_(te){return function(me){return ys(me,te)}}e(L_,"basePropertyDeep");function rh(te,me,xt,An){var ya=An?Qo:gu,co=-1,Xc=me.length,rl=te;for(te===me&&(me=Ts(me)),xt&&(rl=Ul(te,Ku(xt)));++co<Xc;)for(var dp=0,td=me[co],j0=xt?xt(td):td;(dp=ya(rl,j0,dp,An))>-1;)rl!==te&&Op.call(rl,dp,1),Op.call(te,dp,1);return te}e(rh,"basePullAll");function kg(te,me){for(var xt=te?me.length:0,An=xt-1;xt--;){var ya=me[xt];if(xt==An||ya!==co){var co=ya;yy(ya)?Op.call(te,ya,1):a8(te,ya)}}return te}e(kg,"basePullAt");function Gg(te,me){return te+ka(Ms()*(me-te+1))}e(Gg,"baseRandom");function Dh(te,me,xt,An){for(var ya=-1,co=Dc(Os((me-te)/(xt||1)),0),Xc=ja(co);co--;)Xc[An?co:++ya]=te,te+=xt;return Xc}e(Dh,"baseRange");function fy(te,me){var xt="";if(!te||me<1||me>je)return xt;do me%2&&(xt+=te),me=ka(me/2),me&&(te+=te);while(me);return xt}e(fy,"baseRepeat");function H(te,me){return fS(mD(te,me,d8),te+"")}e(H,"baseRest");function O(te){return pm(cl(te))}e(O,"baseSample");function y1(te,me){var xt=cl(te);return cd(xt,ei(me,0,xt.length))}e(y1,"baseSampleSize");function pb(te,me,xt,An){if(!KC(te))return te;me=gE(me,te);for(var ya=-1,co=me.length,Xc=co-1,rl=te;rl!=null&&++ya<co;){var dp=i7(me[ya]),td=xt;if(dp==="__proto__"||dp==="constructor"||dp==="prototype")return te;if(ya!=Xc){var j0=rl[dp];td=An?An(j0,dp,rl):n,td===n&&(td=KC(j0)?j0:yy(me[ya+1])?[]:{})}ex(rl,dp,td),rl=rl[dp]}return te}e(pb,"baseSet");var dC=Zn?function(te,me){return Zn.set(te,me),te}:d8,TA=Pa?function(te,me){return Pa(te,"toString",{configurable:!0,enumerable:!1,value:P9(me),writable:!0})}:d8;function g9(te){return cd(cl(te))}e(g9,"baseShuffle");function zC(te,me,xt){var An=-1,ya=te.length;me<0&&(me=-me>ya?0:ya+me),xt=xt>ya?ya:xt,xt<0&&(xt+=ya),ya=me>xt?0:xt-me>>>0,me>>>=0;for(var co=ja(ya);++An<ya;)co[An]=te[An+me];return co}e(zC,"baseSlice");function y9(te,me){var xt;return vn(te,function(An,ya,co){return xt=me(An,ya,co),!xt}),!!xt}e(y9,"baseSome");function cF(te,me,xt){var An=0,ya=te==null?An:te.length;if(typeof me=="number"&&me===me&&ya<=lr){for(;An<ya;){var co=An+ya>>>1,Xc=te[co];Xc!==null&&!p8(Xc)&&(xt?Xc<=me:Xc<me)?An=co+1:ya=co}return ya}return uS(te,me,d8,xt)}e(cF,"baseSortedIndex");function uS(te,me,xt,An){var ya=0,co=te==null?0:te.length;if(co===0)return 0;me=xt(me);for(var Xc=me!==me,rl=me===null,dp=p8(me),td=me===n;ya<co;){var j0=ka((ya+co)/2),z0=xt(te[j0]),V_=z0!==n,n1=z0===null,J1=z0===z0,z1=p8(z0);if(Xc)var dg=An||J1;else td?dg=J1&&(An||V_):rl?dg=J1&&V_&&(An||!n1):dp?dg=J1&&V_&&!n1&&(An||!z1):n1||z1?dg=!1:dg=An?z0<=me:z0<me;dg?ya=j0+1:co=j0}return yu(co,Zt)}e(uS,"baseSortedIndexBy");function N$(te,me){for(var xt=-1,An=te.length,ya=0,co=[];++xt<An;){var Xc=te[xt],rl=me?me(Xc):Xc;if(!xt||!c7(rl,dp)){var dp=rl;co[ya++]=Xc===0?0:Xc}}return co}e(N$,"baseSortedUniq");function zH(te){return typeof te=="number"?te:p8(te)?Nt:+te}e(zH,"baseToNumber");function lS(te){if(typeof te=="string")return te;if(k1(te))return Ul(te,lS)+"";if(p8(te))return ua?ua.call(te):"";var me=te+"";return me=="0"&&1/te==-Ze?"-0":me}e(lS,"baseToString");function UE(te,me,xt){var An=-1,ya=Ip,co=te.length,Xc=!0,rl=[],dp=rl;if(xt)Xc=!1,ya=jl;else if(co>=i){var td=me?null:Jv(te);if(td)return S_(td);Xc=!1,ya=xl,dp=new v_}else dp=me?[]:rl;e:for(;++An<co;){var j0=te[An],z0=me?me(j0):j0;if(j0=xt||j0!==0?j0:0,Xc&&z0===z0){for(var V_=dp.length;V_--;)if(dp[V_]===z0)continue e;me&&dp.push(z0),rl.push(j0)}else ya(dp,z0,xt)||(dp!==rl&&dp.push(z0),rl.push(j0))}return rl}e(UE,"baseUniq");function a8(te,me){me=gE(me,te);var xt=-1,An=me.length;if(!An)return!0;for(;++xt<An;){var ya=i7(me[xt]);if(ya==="__proto__"&&!Mg.call(te,"__proto__")||(ya==="constructor"||ya==="prototype")&&xt<An-1)return!1}var co=WH(te,me);return co==null||delete co[i7(a7(me))]}e(a8,"baseUnset");function yT(te,me,xt,An){return pb(te,me,xt(ys(te,me)),An)}e(yT,"baseUpdate");function U5(te,me,xt,An){for(var ya=te.length,co=An?ya:-1;(An?co--:++co<ya)&&me(te[co],co,te););return xt?zC(te,An?0:co,An?co+1:ya):zC(te,An?co+1:0,An?ya:co)}e(U5,"baseWhile");function hE(te,me){var xt=te;return xt instanceof Sc&&(xt=xt.value()),I0(me,function(An,ya){return ya.func.apply(ya.thisArg,Ff([An],ya.args))},xt)}e(hE,"baseWrapperValue");function Q5(te,me,xt){var An=te.length;if(An<2)return An?UE(te[0]):[];for(var ya=-1,co=ja(An);++ya<An;)for(var Xc=te[ya],rl=-1;++rl<An;)rl!=ya&&(co[ya]=Nr(co[ya]||Xc,te[rl],me,xt));return UE(Vt(co,1),me,xt)}e(Q5,"baseXor");function uF(te,me,xt){for(var An=-1,ya=te.length,co=me.length,Xc={};++An<ya;){var rl=An<co?me[An]:n;xt(Xc,te[An],rl)}return Xc}e(uF,"baseZipObject");function Nm(te){return vC(te)?te:[]}e(Nm,"castArrayLikeObject");function q4(te){return typeof te=="function"?te:d8}e(q4,"castFunction");function gE(te,me){return k1(te)?te:mO(te,me)?[te]:Gf(vy(te))}e(gE,"castPath");var q5=H;function $4(te,me,xt){var An=te.length;return xt=xt===n?An:xt,!me&&xt>=An?te:zC(te,me,xt)}e($4,"castSlice");var V4=Aa||function(te){return Ea.clearTimeout(te)};function s8(te,me){if(me)return te.slice();var xt=te.length,An=yr?yr(xt):new te.constructor(xt);return te.copy(An),An}e(s8,"cloneBuffer");function pS(te){var me=new te.constructor(te.byteLength);return new he(me).set(new he(te)),me}e(pS,"cloneArrayBuffer");function QE(te,me){var xt=me?pS(te.buffer):te.buffer;return new te.constructor(xt,te.byteOffset,te.byteLength)}e(QE,"cloneDataView");function _C(te){var me=new te.constructor(te.source,Mt.exec(te));return me.lastIndex=te.lastIndex,me}e(_C,"cloneRegExp");function b6(te){return Gi?ly(Gi.call(te)):{}}e(b6,"cloneSymbol");function E6(te,me){var xt=me?pS(te.buffer):te.buffer;return new te.constructor(xt,te.byteOffset,te.length)}e(E6,"cloneTypedArray");function H_(te,me){if(te!==me){var xt=te!==n,An=te===null,ya=te===te,co=p8(te),Xc=me!==n,rl=me===null,dp=me===me,td=p8(me);if(!rl&&!td&&!co&&te>me||co&&Xc&&dp&&!rl&&!td||An&&Xc&&dp||!xt&&dp||!ya)return 1;if(!An&&!co&&!td&&te<me||td&&xt&&ya&&!An&&!co||rl&&xt&&ya||!Xc&&ya||!dp)return-1}return 0}e(H_,"compareAscending");function mC(te,me,xt){for(var An=-1,ya=te.criteria,co=me.criteria,Xc=ya.length,rl=xt.length;++An<Xc;){var dp=H_(ya[An],co[An]);if(dp){if(An>=rl)return dp;var td=xt[An];return dp*(td=="desc"?-1:1)}}return te.index-me.index}e(mC,"compareMultiple");function M2(te,me,xt,An){for(var ya=-1,co=te.length,Xc=xt.length,rl=-1,dp=me.length,td=Dc(co-Xc,0),j0=ja(dp+td),z0=!An;++rl<dp;)j0[rl]=me[rl];for(;++ya<Xc;)(z0||ya<co)&&(j0[xt[ya]]=te[ya]);for(;td--;)j0[rl++]=te[ya++];return j0}e(M2,"composeArgs");function vv(te,me,xt,An){for(var ya=-1,co=te.length,Xc=-1,rl=xt.length,dp=-1,td=me.length,j0=Dc(co-rl,0),z0=ja(j0+td),V_=!An;++ya<j0;)z0[ya]=te[ya];for(var n1=ya;++dp<td;)z0[n1+dp]=me[dp];for(;++Xc<rl;)(V_||ya<co)&&(z0[n1+xt[Xc]]=te[ya++]);return z0}e(vv,"composeArgsRight");function Ts(te,me){var xt=-1,An=te.length;for(me||(me=ja(An));++xt<An;)me[xt]=te[xt];return me}e(Ts,"copyArray");function J4(te,me,xt,An){var ya=!xt;xt||(xt={});for(var co=-1,Xc=me.length;++co<Xc;){var rl=me[co],dp=An?An(xt[rl],te[rl],rl,xt,te):n;dp===n&&(dp=te[rl]),ya?De(xt,rl,dp):ex(xt,rl,dp)}return xt}e(J4,"copyObject");function v9(te,me){return J4(te,B$(te),me)}e(v9,"copySymbols");function ZS(te,me){return J4(te,Joe(te),me)}e(ZS,"copySymbolsIn");function $5(te,me){return function(xt,An){var ya=k1(xt)?Ka:av,co=me?me():{};return ya(xt,te,Kg(An,2),co)}}e($5,"createAggregator");function dD(te){return H(function(me,xt){var An=-1,ya=xt.length,co=ya>1?xt[ya-1]:n,Xc=ya>2?xt[2]:n;for(co=te.length>3&&typeof co=="function"?(ya--,co):n,Xc&&r7(xt[0],xt[1],Xc)&&(co=ya<3?n:co,ya=1),me=ly(me);++An<ya;){var rl=xt[An];rl&&te(me,rl,An,co)}return me})}e(dD,"createAssigner");function xh(te,me){return function(xt,An){if(xt==null)return xt;if(!i3(xt))return te(xt,An);for(var ya=xt.length,co=me?ya:-1,Xc=ly(xt);(me?co--:++co<ya)&&An(Xc[co],co,Xc)!==!1;);return xt}}e(xh,"createBaseEach");function V5(te){return function(me,xt,An){for(var ya=-1,co=ly(me),Xc=An(me),rl=Xc.length;rl--;){var dp=Xc[te?rl:++ya];if(xt(co[dp],dp,co)===!1)break}return me}}e(V5,"createBaseFor");function uw(te,me,xt){var An=me&V,ya=R(te);function co(){var Xc=this&&this!==Ea&&this instanceof co?ya:te;return Xc.apply(An?xt:this,arguments)}return e(co,"wrapper"),co}e(uw,"createBind");function zb(te){return function(me){me=vy(me);var xt=Tu(me)?Ll(me):n,An=xt?xt[0]:me.charAt(0),ya=xt?$4(xt,1).join(""):me.slice(1);return An[te]()+ya}}e(zb,"createCaseFirst");function fi(te){return function(me){return I0(CD(GU(me).replace(hu,"")),te,"")}}e(fi,"createCompounder");function R(te){return function(){var me=arguments;switch(me.length){case 0:return new te;case 1:return new te(me[0]);case 2:return new te(me[0],me[1]);case 3:return new te(me[0],me[1],me[2]);case 4:return new te(me[0],me[1],me[2],me[3]);case 5:return new te(me[0],me[1],me[2],me[3],me[4]);case 6:return new te(me[0],me[1],me[2],me[3],me[4],me[5]);case 7:return new te(me[0],me[1],me[2],me[3],me[4],me[5],me[6])}var xt=$a(te.prototype),An=te.apply(xt,me);return KC(An)?An:xt}}e(R,"createCtor");function ie(te,me,xt){var An=R(te);function ya(){for(var co=arguments.length,Xc=ja(co),rl=co,dp=bg(ya);rl--;)Xc[rl]=arguments[rl];var td=co<3&&Xc[0]!==dp&&Xc[co-1]!==dp?[]:$f(Xc,dp);if(co-=td.length,co<xt)return sh(te,me,Zr,ya.placeholder,n,Xc,td,n,n,xt-co);var j0=this&&this!==Ea&&this instanceof ya?An:te;return Wa(j0,this,Xc)}return e(ya,"wrapper"),ya}e(ie,"createCurry");function Ie(te){return function(me,xt,An){var ya=ly(me);if(!i3(me)){var co=Kg(xt,3);me=YC(me),xt=e(function(rl){return co(ya[rl],rl,ya)},"predicate")}var Xc=te(me,xt,An);return Xc>-1?ya[co?me[Xc]:Xc]:n}}e(Ie,"createFind");function yt(te){return pw(function(me){var xt=me.length,An=xt,ya=no.prototype.thru;for(te&&me.reverse();An--;){var co=me[An];if(typeof co!="function")throw new nA(c);if(ya&&!Xc&&A9(co)=="wrapper")var Xc=new no([],!0)}for(An=Xc?An:xt;++An<xt;){co=me[An];var rl=A9(co),dp=rl=="wrapper"?P$(co):n;dp&&nM(dp[0])&&dp[1]==($e|le|xe|Ke)&&!dp[4].length&&dp[9]==1?Xc=Xc[A9(dp[0])].apply(Xc,dp[3]):Xc=co.length==1&&nM(co)?Xc[rl]():Xc.thru(co)}return function(){var td=arguments,j0=td[0];if(Xc&&td.length==1&&k1(j0))return Xc.plant(j0).value();for(var z0=0,V_=xt?me[z0].apply(this,td):j0;++z0<xt;)V_=me[z0].call(this,V_);return V_}})}e(yt,"createFlow");function Zr(te,me,xt,An,ya,co,Xc,rl,dp,td){var j0=me&$e,z0=me&V,V_=me&ee,n1=me&(le|de),J1=me&Ce,z1=V_?n:R(te);function dg(){for(var Ay=arguments.length,Nv=ja(Ay),c3=Ay;c3--;)Nv[c3]=arguments[c3];if(n1)var AE=bg(dg),Xy=Gs(Nv,AE);if(An&&(Nv=M2(Nv,An,ya,n1)),co&&(Nv=vv(Nv,co,Xc,n1)),Ay-=Xy,n1&&Ay<td){var Yb=$f(Nv,AE);return sh(te,me,Zr,dg.placeholder,xt,Nv,Yb,rl,dp,td-Ay)}var Xb=z0?xt:this,oA=V_?Xb[te]:te;return Ay=Nv.length,rl?Nv=GH(Nv,rl):J1&&Ay>1&&Nv.reverse(),j0&&dp<Ay&&(Nv.length=dp),this&&this!==Ea&&this instanceof dg&&(oA=z1||R(oA)),oA.apply(Xb,Nv)}return e(dg,"wrapper"),dg}e(Zr,"createHybrid");function Xi(te,me){return function(xt,An){return Vd(xt,te,me(An),{})}}e(Xi,"createInverter");function Js(te,me){return function(xt,An){var ya;if(xt===n&&An===n)return me;if(xt!==n&&(ya=xt),An!==n){if(ya===n)return An;typeof xt=="string"||typeof An=="string"?(xt=lS(xt),An=lS(An)):(xt=zH(xt),An=zH(An)),ya=te(xt,An)}return ya}}e(Js,"createMathOperation");function Tc(te){return pw(function(me){return me=Ul(me,Ku(Kg())),H(function(xt){var An=this;return te(me,function(ya){return Wa(ya,An,xt)})})})}e(Tc,"createOver");function xu(te,me){me=me===n?" ":lS(me);var xt=me.length;if(xt<2)return xt?fy(me,te):me;var An=fy(me,Os(te/pc(me)));return Tu(me)?$4(Ll(An),0,te).join(""):An.slice(0,te)}e(xu,"createPadding");function Yu(te,me,xt,An){var ya=me&V,co=R(te);function Xc(){for(var rl=-1,dp=arguments.length,td=-1,j0=An.length,z0=ja(j0+dp),V_=this&&this!==Ea&&this instanceof Xc?co:te;++td<j0;)z0[td]=An[td];for(;dp--;)z0[td++]=arguments[++rl];return Wa(V_,ya?xt:this,z0)}return e(Xc,"wrapper"),Xc}e(Yu,"createPartial");function Id(te){return function(me,xt,An){return An&&typeof An!="number"&&r7(me,xt,An)&&(xt=An=n),me=qE(me),xt===n?(xt=me,me=0):xt=qE(xt),An=An===n?me<xt?1:-1:qE(An),Dh(me,xt,An,te)}}e(Id,"createRange");function am(te){return function(me,xt){return typeof me=="string"&&typeof xt=="string"||(me=p7(me),xt=p7(xt)),te(me,xt)}}e(am,"createRelationalOperation");function sh(te,me,xt,An,ya,co,Xc,rl,dp,td){var j0=me&le,z0=j0?Xc:n,V_=j0?n:Xc,n1=j0?co:n,J1=j0?n:co;me|=j0?xe:Re,me&=~(j0?Re:xe),me&ue||(me&=~(V|ee));var z1=[te,me,ya,n1,z0,J1,V_,rl,dp,td],dg=xt.apply(n,z1);return nM(te)&&ig(dg,z1),dg.placeholder=An,vm(dg,te,me)}e(sh,"createRecurry");function sm(te){var me=K2[te];return function(xt,An){if(xt=p7(xt),An=An==null?0:yu(oy(An),292),An&&go(xt)){var ya=(vy(xt)+"e").split("e"),co=me(ya[0]+"e"+(+ya[1]+An));return ya=(vy(co)+"e").split("e"),+(ya[0]+"e"+(+ya[1]-An))}return me(xt)}}e(sm,"createRound");var Jv=Te&&1/S_(new Te([,-0]))[1]==Ze?function(te){return new Te(te)}:B9;function sv(te){return function(me){var xt=hC(me);return xt==kr?gf(me):xt==rs?od(me):nu(me,te(me))}}e(sv,"createToPairs");function om(te,me,xt,An,ya,co,Xc,rl){var dp=meⅇif(!dp&&typeof te!="function")throw new nA(c);var td=An?An.length:0;if(td||(me&=~(xe|Re),An=ya=n),Xc=Xc===n?Xc:Dc(oy(Xc),0),rl=rl===n?rl:oy(rl),td-=ya?ya.length:0,me&Re){var j0=An,z0=ya;An=ya=n}var V_=dp?n:P$(te),n1=[te,me,xt,An,ya,j0,z0,co,Xc,rl];if(V_&&hO(n1,V_),te=n1[0],me=n1[1],xt=n1[2],An=n1[3],ya=n1[4],rl=n1[9]=n1[9]===n?dp?0:te.length:Dc(n1[9]-td,0),!rl&&me&(le|de)&&(me&=~(le|de)),!me||me==V)var J1=uw(te,me,xt);else me==le||me==de?J1=ie(te,me,rl):(me==xe||me==(V|xe))&&!ya.length?J1=Yu(te,me,xt,An):J1=Zr.apply(n,n1);var z1=V_?dC:ig;return vm(z1(J1,n1),te,me)}e(om,"createWrap");function aA(te,me,xt,An){return te===n||c7(te,lC[xt])&&!Mg.call(An,xt)?me:te}e(aA,"customDefaultsAssignIn");function rM(te,me,xt,An,ya,co){return KC(te)&&KC(me)&&(co.set(me,te),la(te,me,n,rM,co),co.delete(me)),te}e(rM,"customDefaultsMerge");function lw(te){return wT(te)?n:te}e(lw,"customOmitClone");function Hre(te,me,xt,An,ya,co){var Xc=xt&L,rl=te.length,dp=me.length;if(rl!=dp&&!(Xc&&dp>rl))return!1;var td=co.get(te),j0=co.get(me);if(td&&j0)return td==me&&j0==te;var z0=-1,V_=!0,n1=xt&j?new v_:n;for(co.set(te,me),co.set(me,te);++z0<rl;){var J1=te[z0],z1=me[z0];if(An)var dg=Xc?An(z1,J1,z0,me,te,co):An(J1,z1,z0,te,me,co);if(dg!==n){if(dg)continue;V_=!1;break}if(n1){if(!mp(me,function(Ay,Nv){if(!xl(n1,Nv)&&(J1===Ay||ya(J1,Ay,xt,An,co)))return n1.push(Nv)})){V_=!1;break}}else if(!(J1===z1||ya(J1,z1,xt,An,co))){V_=!1;break}}return co.delete(te),co.delete(me),V_}e(Hre,"equalArrays");function J5(te,me,xt,An,ya,co,Xc){switch(xt){case ec:if(te.byteLength!=me.byteLength||te.byteOffset!=me.byteOffset)return!1;te=te.buffer,me=me.buffer;case so:return!(te.byteLength!=me.byteLength||!co(new he(te),new he(me)));case pt:case Qr:case Ss:return c7(+te,+me);case ai:return te.name==me.name&&te.message==me.message;case Bs:case Oa:return te==me+"";case kr:var rl=gf;case rs:var dp=An&L;if(rl||(rl=S_),te.size!=me.size&&!dp)return!1;var td=Xc.get(te);if(td)return td==me;An|=j,Xc.set(te,me);var j0=Hre(rl(te),rl(me),An,ya,co,Xc);return Xc.delete(te),j0;case sa:if(Gi)return Gi.call(te)==Gi.call(me)}return!1}e(J5,"equalByTag");function nP(te,me,xt,An,ya,co){var Xc=xt&L,rl=Fv(te),dp=rl.length,td=Fv(me),j0=td.length;if(dp!=j0&&!Xc)return!1;for(var z0=dp;z0--;){var V_=rl[z0];if(!(Xc?V_ in me:Mg.call(me,V_)))return!1}var n1=co.get(te),J1=co.get(me);if(n1&&J1)return n1==me&&J1==te;var z1=!0;co.set(te,me),co.set(me,te);for(var dg=Xc;++z0<dp;){V_=rl[z0];var Ay=te[V_],Nv=me[V_];if(An)var c3=Xc?An(Nv,Ay,V_,me,te,co):An(Ay,Nv,V_,te,me,co);if(!(c3===n?Ay===Nv||ya(Ay,Nv,xt,An,co):c3)){z1=!1;break}dg||(dg=V_=="constructor")}if(z1&&!dg){var AE=te.constructor,Xy=me.constructor;AE!=Xy&&"constructor"in te&&"constructor"in me&&!(typeof AE=="function"&&AE instanceof AE&&typeof Xy=="function"&&Xy instanceof Xy)&&(z1=!1)}return co.delete(te),co.delete(me),z1}e(nP,"equalObjects");function pw(te){return fS(mD(te,n,R$),te+"")}e(pw,"flatRest");function Fv(te){return Bi(te,YC,B$)}e(Fv,"getAllKeys");function lF(te){return Bi(te,wy,Joe)}e(lF,"getAllKeysIn");var P$=Zn?function(te){return Zn.get(te)}:B9;function A9(te){for(var me=te.name+"",xt=hn[me],An=Mg.call(hn,me)?xt.length:0;An--;){var ya=xt[An],co=ya.func;if(co==null||co==te)return ya.name}return me}e(A9,"getFuncName");function bg(te){var me=Mg.call(_e,"placeholder")?_e:te;return me.placeholder}e(bg,"getHolder");function Kg(){var te=_e.iteratee||X5;return te=te===X5?Nf:te,arguments.length?te(arguments[0],arguments[1]):te}e(Kg,"getIteratee");function pF(te,me){var xt=te.__data__;return _w(me)?xt[typeof me=="string"?"string":"hash"]:xt.map}e(pF,"getMapData");function fw(te){for(var me=YC(te),xt=me.length;xt--;){var An=me[xt],ya=te[An];me[xt]=[An,ya,_D(ya)]}return me}e(fw,"getMatchData");function x9(te,me){var xt=yc(te,me);return id(xt)?xt:n}e(x9,"getNative");function Xu(te){var me=Mg.call(te,$i),xt=te[$i];try{te[$i]=n;var An=!0}catch{}var ya=Wx.call(te);return An&&(me?te[$i]=xt:delete te[$i]),ya}e(Xu,"getRawTag");var B$=to?function(te){return te==null?[]:(te=ly(te),Lo(to(te),function(me){return Qc.call(te,me)}))}:X$,Joe=to?function(te){for(var me=[];te;)Ff(me,B$(te)),te=Qi(te);return me}:X$,hC=ha;(qc&&hC(new qc(new ArrayBuffer(1)))!=ec||Rc&&hC(new Rc)!=kr||fe&&hC(fe.resolve())!=va||Te&&hC(new Te)!=rs||Hr&&hC(new Hr)!=qo)&&(hC=e(function(te){var me=ha(te),xt=me==Fa?te.constructor:n,An=xt?Eg(xt):"";if(An)switch(An){case Fr:return ec;case ir:return kr;case En:return va;case Ct:return rs;case Cn:return qo}return me},"getTag"));function zoe(te,me,xt){for(var An=-1,ya=xt.length;++An<ya;){var co=xt[An],Xc=co.size;switch(co.type){case"drop":te+=Xc;break;case"dropRight":me-=Xc;break;case"take":me=yu(me,te+Xc);break;case"takeRight":te=Dc(te,me-Xc);break}}return{start:te,end:me}}e(zoe,"getView");function dw(te){var me=te.match(Pt);return me?me[1].split(Gt):[]}e(dw,"getWrapDetails");function BU(te,me,xt){me=gE(me,te);for(var An=-1,ya=me.length,co=!1;++An<ya;){var Xc=i7(me[An]);if(!(co=te!=null&&xt(te,Xc)))break;te=te[Xc]}return co||++An!=ya?co:(ya=te==null?0:te.length,!!ya&&hx(ya)&&yy(Xc,ya)&&(k1(te)||Ox(te)))}e(BU,"hasPath");function O$(te){var me=te.length,xt=new te.constructor(me);return me&&typeof te[0]=="string"&&Mg.call(te,"index")&&(xt.index=te.index,xt.input=te.input),xt}e(O$,"initCloneArray");function HH(te){return typeof te.constructor=="function"&&!Hb(te)?$a(Qi(te)):{}}e(HH,"initCloneObject");function Ro(te,me,xt){var An=te.constructor;switch(me){case so:return pS(te);case pt:case Qr:return new An(+te);case ec:return QE(te,xt);case Lr:case ri:case ma:case Vn:case qa:case Go:case li:case or:case lt:return E6(te,xt);case kr:return new An;case Ss:case Oa:return new An(te);case Bs:return _C(te);case rs:return new An;case sa:return b6(te)}}e(Ro,"initCloneByTag");function vT(te,me){var xt=me.length;if(!xt)return te;var An=xt-1;return me[An]=(xt>1?"& ":"")+me[An],me=me.join(xt>2?", ":" "),te.replace(Me,`{
|
|
134
134
|
/* [wrapped with `+me+`] */
|
|
135
135
|
`)}e(vT,"insertWrapDetails");function Gx(te){return k1(te)||Ox(te)||!!(Ha&&te&&te[Ha])}e(Gx,"isFlattenable");function yy(te,me){var xt=typeof te;return me=me??je,!!me&&(xt=="number"||xt!="symbol"&&na.test(te))&&te>-1&&te%1==0&&te<me}e(yy,"isIndex");function r7(te,me,xt){if(!KC(xt))return!1;var An=typeof me;return(An=="number"?i3(xt)&&yy(me,xt.length):An=="string"&&me in xt)?c7(xt[me],te):!1}e(r7,"isIterateeCall");function mO(te,me){if(k1(te))return!1;var xt=typeof te;return xt=="number"||xt=="symbol"||xt=="boolean"||te==null||p8(te)?!0:si.test(te)||!fa.test(te)||me!=null&&te in ly(me)}e(mO,"isKey");function _w(te){var me=typeof te;return me=="string"||me=="number"||me=="symbol"||me=="boolean"?te!=="__proto__":te===null}e(_w,"isKeyable");function nM(te){var me=A9(te),xt=_e[me];if(typeof xt!="function"||!(me in Sc.prototype))return!1;if(te===xt)return!0;var An=P$(xt);return!!An&&te===An[0]}e(nM,"isLaziable");function OU(te){return!!fD&&fD in te}e(OU,"isMasked");var Wre=ME?u7:FO;function Hb(te){var me=te&&te.constructor,xt=typeof me=="function"&&me.prototype||lC;return te===xt}e(Hb,"isPrototype");function _D(te){return te===te&&!KC(te)}e(_D,"isStrictComparable");function zY(te,me){return function(xt){return xt==null?!1:xt[te]===me&&(me!==n||te in ly(xt))}}e(zY,"matchesStrictComparable");function z5(te){var me=vf(te,function(An){return xt.size===E&&xt.clear(),An}),xt=me.cache;return me}e(z5,"memoizeCapped");function hO(te,me){var xt=te[1],An=me[1],ya=xt|An,co=ya<(V|ee|$e),Xc=An==$e&&xt==le||An==$e&&xt==Ke&&te[7].length<=me[8]||An==($e|Ke)&&me[7].length<=me[8]&&xt==le;if(!(co||Xc))return te;An&V&&(te[2]=me[2],ya|=xt&V?0:ue);var rl=me[3];if(rl){var dp=te[3];te[3]=dp?M2(dp,rl,me[4]):rl,te[4]=dp?$f(te[3],D):me[4]}return rl=me[5],rl&&(dp=te[5],te[5]=dp?vv(dp,rl,me[6]):rl,te[6]=dp?$f(te[5],D):me[6]),rl=me[7],rl&&(te[7]=rl),An&$e&&(te[8]=te[8]==null?me[8]:yu(te[8],me[8])),te[9]==null&&(te[9]=me[9]),te[0]=me[0],te[1]=ya,te}e(hO,"mergeData");function mw(te){var me=[];if(te!=null)for(var xt in ly(te))me.push(xt);return me}e(mw,"nativeKeysIn");function RU(te){return Wx.call(te)}e(RU,"objectToString");function mD(te,me,xt){return me=Dc(me===n?te.length-1:me,0),function(){for(var An=arguments,ya=-1,co=Dc(An.length-me,0),Xc=ja(co);++ya<co;)Xc[ya]=An[me+ya];ya=-1;for(var rl=ja(me+1);++ya<me;)rl[ya]=An[ya];return rl[me]=xt(Xc),Wa(te,this,rl)}}e(mD,"overRest");function WH(te,me){return me.length<2?te:ys(te,zC(me,0,-1))}e(WH,"parent");function GH(te,me){for(var xt=te.length,An=yu(me.length,xt),ya=Ts(te);An--;){var co=me[An];te[An]=yy(co,xt)?ya[co]:n}return te}e(GH,"reorder");function n7(te,me){if(!(me==="constructor"&&typeof te[me]=="function")&&me!="__proto__")return te[me]}e(n7,"safeGet");var ig=Yy(dC),Cu=ss||function(te,me){return Ea.setTimeout(te,me)},fS=Yy(TA);function vm(te,me,xt){var An=me+"";return fS(te,vT(An,HY(dw(An),xt)))}e(vm,"setWrapToString");function Yy(te){var me=0,xt=0;return function(){var An=vu(),ya=Ue-(An-xt);if(xt=An,ya>0){if(++me>=Ve)return arguments[0]}else me=0;return te.apply(n,arguments)}}e(Yy,"shortOut");function cd(te,me){var xt=-1,An=te.length,ya=An-1;for(me=me===n?An:me;++xt<me;){var co=Gg(xt,ya),Xc=te[co];te[co]=te[xt],te[xt]=Xc}return te.length=me,te}e(cd,"shuffleSelf");var Gf=z5(function(te){var me=[];return te.charCodeAt(0)===46&&me.push(""),te.replace(an,function(xt,An,ya,co){me.push(ya?co.replace(br,"$1"):An||xt)}),me});function i7(te){if(typeof te=="string"||p8(te))return te;var me=te+"";return me=="0"&&1/te==-Ze?"-0":me}e(i7,"toKey");function Eg(te){if(te!=null){try{return pC.call(te)}catch{}try{return te+""}catch{}}return""}e(Eg,"toSource");function HY(te,me){return nc(Jt,function(xt){var An="_."+xt[0];me&xt[1]&&!Ip(te,An)&&te.push(An)}),te.sort()}e(HY,"updateWrapDetails");function AT(te){if(te instanceof Sc)return te.clone();var me=new no(te.__wrapped__,te.__chain__);return me.__actions__=Ts(te.__actions__),me.__index__=te.__index__,me.__values__=te.__values__,me}e(AT,"wrapperClone");function iM(te,me,xt){(xt?r7(te,me,xt):me===n)?me=1:me=Dc(oy(me),0);var An=te==null?0:te.length;if(!An||me<1)return[];for(var ya=0,co=0,Xc=ja(Os(An/me));ya<An;)Xc[co++]=zC(te,ya,ya+=me);return Xc}e(iM,"chunk");function fF(te){for(var me=-1,xt=te==null?0:te.length,An=0,ya=[];++me<xt;){var co=te[me];co&&(ya[An++]=co)}return ya}e(fF,"compact");function C2(){var te=arguments.length;if(!te)return[];for(var me=ja(te-1),xt=arguments[0],An=te;An--;)me[An-1]=arguments[An];return Ff(k1(xt)?Ts(xt):[xt],Vt(me,1))}e(C2,"concat");var LU=H(function(te,me){return vC(te)?Nr(te,Vt(me,1,vC,!0)):[]}),fm=H(function(te,me){var xt=a7(me);return vC(xt)&&(xt=n),vC(te)?Nr(te,Vt(me,1,vC,!0),Kg(xt,2)):[]}),MU=H(function(te,me){var xt=a7(me);return vC(xt)&&(xt=n),vC(te)?Nr(te,Vt(me,1,vC,!0),n,xt):[]});function o8(te,me,xt){var An=te==null?0:te.length;return An?(me=xt||me===n?1:oy(me),zC(te,me<0?0:me,An)):[]}e(o8,"drop");function _x(te,me,xt){var An=te==null?0:te.length;return An?(me=xt||me===n?1:oy(me),me=An-me,zC(te,0,me<0?0:me)):[]}e(_x,"dropRight");function WY(te,me){return te&&te.length?U5(te,Kg(me,3),!0,!0):[]}e(WY,"dropRightWhile");function b9(te,me){return te&&te.length?U5(te,Kg(me,3),!0):[]}e(b9,"dropWhile");function E9(te,me,xt,An){var ya=te==null?0:te.length;return ya?(xt&&typeof xt!="number"&&r7(te,me,xt)&&(xt=0,An=ya),oi(te,me,xt,An)):[]}e(E9,"fill");function H5(te,me,xt){var An=te==null?0:te.length;if(!An)return-1;var ya=xt==null?0:oy(xt);return ya<0&&(ya=Dc(An+ya,0)),Ko(te,Kg(me,3),ya)}e(H5,"findIndex");function jU(te,me,xt){var An=te==null?0:te.length;if(!An)return-1;var ya=An-1;return xt!==n&&(ya=oy(xt),ya=xt<0?Dc(An+ya,0):yu(ya,An-1)),Ko(te,Kg(me,3),ya,!0)}e(jU,"findLastIndex");function R$(te){var me=te==null?0:te.length;return me?Vt(te,1):[]}e(R$,"flatten");function L$(te){var me=te==null?0:te.length;return me?Vt(te,Ze):[]}e(L$,"flattenDeep");function C9(te,me){var xt=te==null?0:te.length;return xt?(me=me===n?1:oy(me),Vt(te,me)):[]}e(C9,"flattenDepth");function GY(te){for(var me=-1,xt=te==null?0:te.length,An={};++me<xt;){var ya=te[me];De(An,ya[0],ya[1])}return An}e(GY,"fromPairs");function xT(te){return te&&te.length?te[0]:n}e(xT,"head");function KH(te,me,xt){var An=te==null?0:te.length;if(!An)return-1;var ya=xt==null?0:oy(xt);return ya<0&&(ya=Dc(An+ya,0)),gu(te,me,ya)}e(KH,"indexOf");function YH(te){var me=te==null?0:te.length;return me?zC(te,0,-1):[]}e(YH,"initial");var dF=H(function(te){var me=Ul(te,Nm);return me.length&&me[0]===te[0]?u_(me):[]}),KY=H(function(te){var me=a7(te),xt=Ul(te,Nm);return me===a7(xt)?me=n:xt.pop(),xt.length&&xt[0]===te[0]?u_(xt,Kg(me,2)):[]}),YY=H(function(te){var me=a7(te),xt=Ul(te,Nm);return me=typeof me=="function"?me:n,me&&xt.pop(),xt.length&&xt[0]===te[0]?u_(xt,n,me):[]});function UU(te,me){return te==null?"":Yo.call(te,me)}e(UU,"join");function a7(te){var me=te==null?0:te.length;return me?te[me-1]:n}e(a7,"last");function XH(te,me,xt){var An=te==null?0:te.length;if(!An)return-1;var ya=An;return xt!==n&&(ya=oy(xt),ya=ya<0?Dc(An+ya,0):yu(ya,An-1)),me===me?Wp(te,me,ya):Ko(te,zu,ya,!0)}e(XH,"lastIndexOf");function ZH(te,me){return te&&te.length?Ds(te,oy(me)):n}e(ZH,"nth");var M$=H(e4);function e4(te,me){return te&&te.length&&me&&me.length?rh(te,me):te}e(e4,"pullAll");function aM(te,me,xt){return te&&te.length&&me&&me.length?rh(te,me,Kg(xt,2)):te}e(aM,"pullAllBy");function QU(te,me,xt){return te&&te.length&&me&&me.length?rh(te,me,n,xt):te}e(QU,"pullAllWith");var eW=pw(function(te,me){var xt=te==null?0:te.length,An=Vr(te,me);return kg(te,Ul(me,function(ya){return yy(ya,xt)?+ya:ya}).sort(H_)),An});function XY(te,me){var xt=[];if(!(te&&te.length))return xt;var An=-1,ya=[],co=te.length;for(me=Kg(me,3);++An<co;){var Xc=te[An];me(Xc,An,te)&&(xt.push(Xc),ya.push(An))}return kg(te,ya),xt}e(XY,"remove");function hw(te){return te==null?te:dl.call(te)}e(hw,"reverse");function c8(te,me,xt){var An=te==null?0:te.length;return An?(xt&&typeof xt!="number"&&r7(te,me,xt)?(me=0,xt=An):(me=me==null?0:oy(me),xt=xt===n?An:oy(xt)),zC(te,me,xt)):[]}e(c8,"slice");function u8(te,me){return cF(te,me)}e(u8,"sortedIndex");function gO(te,me,xt){return uS(te,me,Kg(xt,2))}e(gO,"sortedIndexBy");function j$(te,me){var xt=te==null?0:te.length;if(xt){var An=cF(te,me);if(An<xt&&c7(te[An],me))return An}return-1}e(j$,"sortedIndexOf");function bT(te,me){return cF(te,me,!0)}e(bT,"sortedLastIndex");function C6(te,me,xt){return uS(te,me,Kg(xt,2),!0)}e(C6,"sortedLastIndexBy");function ET(te,me){var xt=te==null?0:te.length;if(xt){var An=cF(te,me,!0)-1;if(c7(te[An],me))return An}return-1}e(ET,"sortedLastIndexOf");function ZY(te){return te&&te.length?N$(te):[]}e(ZY,"sortedUniq");function yO(te,me){return te&&te.length?N$(te,Kg(me,2)):[]}e(yO,"sortedUniqBy");function eX(te){var me=te==null?0:te.length;return me?zC(te,1,me):[]}e(eX,"tail");function gw(te,me,xt){return te&&te.length?(me=xt||me===n?1:oy(me),zC(te,0,me<0?0:me)):[]}e(gw,"take");function vO(te,me,xt){var An=te==null?0:te.length;return An?(me=xt||me===n?1:oy(me),me=An-me,zC(te,me<0?0:me,An)):[]}e(vO,"takeRight");function dS(te,me){return te&&te.length?U5(te,Kg(me,3),!1,!0):[]}e(dS,"takeRightWhile");function sM(te,me){return te&&te.length?U5(te,Kg(me,3)):[]}e(sM,"takeWhile");var CT=H(function(te){return UE(Vt(te,1,vC,!0))}),tW=H(function(te){var me=a7(te);return vC(me)&&(me=n),UE(Vt(te,1,vC,!0),Kg(me,2))}),_F=H(function(te){var me=a7(te);return me=typeof me=="function"?me:n,UE(Vt(te,1,vC,!0),n,me)});function mx(te){return te&&te.length?UE(te):[]}e(mx,"uniq");function iP(te,me){return te&&te.length?UE(te,Kg(me,2)):[]}e(iP,"uniqBy");function qU(te,me){return me=typeof me=="function"?me:n,te&&te.length?UE(te,n,me):[]}e(qU,"uniqWith");function AO(te){if(!(te&&te.length))return[];var me=0;return te=Lo(te,function(xt){if(vC(xt))return me=Dc(xt.length,me),!0}),ts(me,function(xt){return Ul(te,hs(xt))})}e(AO,"unzip");function mF(te,me){if(!(te&&te.length))return[];var xt=AO(te);return me==null?xt:Ul(xt,function(An){return Wa(me,n,An)})}e(mF,"unzipWith");var s7=H(function(te,me){return vC(te)?Nr(te,me):[]}),hD=H(function(te){return Q5(Lo(te,vC))}),hF=H(function(te){var me=a7(te);return vC(me)&&(me=n),Q5(Lo(te,vC),Kg(me,2))}),U$=H(function(te){var me=a7(te);return me=typeof me=="function"?me:n,Q5(Lo(te,vC),n,me)}),gD=H(AO);function DT(te,me){return uF(te||[],me||[],ex)}e(DT,"zipObject");function Q$(te,me){return uF(te||[],me||[],pb)}e(Q$,"zipObjectDeep");var rW=H(function(te){var me=te.length,xt=me>1?te[me-1]:n;return xt=typeof xt=="function"?(te.pop(),xt):n,mF(te,xt)});function _S(te){var me=_e(te);return me.__chain__=!0,me}e(_S,"chain");function z4(te,me){return me(te),te}e(z4,"tap");function D9(te,me){return me(te)}e(D9,"thru");var aP=pw(function(te){var me=te.length,xt=me?te[0]:0,An=this.__wrapped__,ya=e(function(co){return Vr(co,te)},"interceptor");return me>1||this.__actions__.length||!(An instanceof Sc)||!yy(xt)?this.thru(ya):(An=An.slice(xt,+xt+(me?1:0)),An.__actions__.push({func:D9,args:[ya],thisArg:n}),new no(An,this.__chain__).thru(function(co){return me&&!co.length&&co.push(n),co}))});function gF(){return _S(this)}e(gF,"wrapperChain");function e3(){return new no(this.value(),this.__chain__)}e(e3,"wrapperCommit");function H4(){this.__values__===n&&(this.__values__=Gb(this.value()));var te=this.__index__>=this.__values__.length,me=te?n:this.__values__[this.__index__++];return{done:te,value:me}}e(H4,"wrapperNext");function t4(){return this}e(t4,"wrapperToIterator");function t3(te){for(var me,xt=this;xt instanceof Ya;){var An=AT(xt);An.__index__=0,An.__values__=n,me?ya.__wrapped__=An:me=An;var ya=An;xt=xt.__wrapped__}return ya.__wrapped__=te,me}e(t3,"wrapperPlant");function r3(){var te=this.__wrapped__;if(te instanceof Sc){var me=te;return this.__actions__.length&&(me=new Sc(this)),me=me.reverse(),me.__actions__.push({func:D9,args:[hw],thisArg:n}),new no(me,this.__chain__)}return this.thru(hw)}e(r3,"wrapperReverse");function tX(){return hE(this.__wrapped__,this.__actions__)}e(tX,"wrapperValue");var HC=$5(function(te,me,xt){Mg.call(te,xt)?++te[xt]:De(te,xt,1)});function Gre(te,me,xt){var An=k1(te)?se:ln;return xt&&r7(te,me,xt)&&(me=n),An(te,Kg(me,3))}e(Gre,"every");function ST(te,me){var xt=k1(te)?Lo:Dr;return xt(te,Kg(me,3))}e(ST,"filter");var oM=Ie(H5),sy=Ie(jU);function mS(te,me){return Vt(i2(te,me),1)}e(mS,"flatMap");function WC(te,me){return Vt(i2(te,me),Ze)}e(WC,"flatMapDeep");function Kx(te,me,xt){return xt=xt===n?1:oy(xt),Vt(i2(te,me),xt)}e(Kx,"flatMapDepth");function yD(te,me){var xt=k1(te)?nc:vn;return xt(te,Kg(me,3))}e(yD,"forEach");function o7(te,me){var xt=k1(te)?ju:cn;return xt(te,Kg(me,3))}e(o7,"forEachRight");var yE=$5(function(te,me,xt){Mg.call(te,xt)?te[xt].push(me):De(te,xt,[me])});function rX(te,me,xt,An){te=i3(te)?te:cl(te),xt=xt&&!An?oy(xt):0;var ya=te.length;return xt<0&&(xt=Dc(ya+xt,0)),gx(te)?xt<=ya&&te.indexOf(me,xt)>-1:!!ya&&gu(te,me,xt)>-1}e(rX,"includes");var tl=H(function(te,me,xt){var An=-1,ya=typeof me=="function",co=i3(te)?ja(te.length):[];return vn(te,function(Xc){co[++An]=ya?Wa(me,Xc,xt):_m(Xc,me,xt)}),co}),sA=$5(function(te,me,xt){De(te,xt,me)});function i2(te,me){var xt=k1(te)?Ul:Fm;return xt(te,Kg(me,3))}e(i2,"map");function l8(te,me,xt,An){return te==null?[]:(k1(me)||(me=me==null?[]:[me]),xt=An?n:xt,k1(xt)||(xt=xt==null?[]:[xt]),ol(te,me,xt))}e(l8,"orderBy");var Qm=$5(function(te,me,xt){te[xt?0:1].push(me)},function(){return[[],[]]});function xO(te,me,xt){var An=k1(te)?I0:M0,ya=arguments.length<3;return An(te,Kg(me,4),xt,ya,vn)}e(xO,"reduce");function Yg(te,me,xt){var An=k1(te)?H0:M0,ya=arguments.length<3;return An(te,Kg(me,4),xt,ya,cn)}e(Yg,"reduceRight");function $U(te,me){var xt=k1(te)?Lo:Dr;return xt(te,q$(Kg(me,3)))}e($U,"reject");function dde(te){var me=k1(te)?pm:O;return me(te)}e(dde,"sample");function sP(te,me,xt){(xt?r7(te,me,xt):me===n)?me=1:me=oy(me);var An=k1(te)?Om:y1;return An(te,me)}e(sP,"sampleSize");function S9(te){var me=k1(te)?jg:g9;return me(te)}e(S9,"shuffle");function _2(te){if(te==null)return 0;if(i3(te))return gx(te)?pc(te):te.length;var me=hC(te);return me==kr||me==rs?te.size:Wf(te).length}e(_2,"size");function g0(te,me,xt){var An=k1(te)?mp:y9;return xt&&r7(te,me,xt)&&(me=n),An(te,Kg(me,3))}e(g0,"some");var r4=H(function(te,me){if(te==null)return[];var xt=me.length;return xt>1&&r7(te,me[0],me[1])?me=[]:xt>2&&r7(me[0],me[1],me[2])&&(me=[me[0]]),ol(te,Vt(me,1),[])}),Yx=ba||function(){return Ea.Date.now()};function nW(te,me){if(typeof me!="function")throw new nA(c);return te=oy(te),function(){if(--te<1)return me.apply(this,arguments)}}e(nW,"after");function w9(te,me,xt){return me=xt?n:me,me=te&&me==null?te.length:me,om(te,$e,n,n,n,n,me)}e(w9,"ary");function Sy(te,me){var xt;if(typeof me!="function")throw new nA(c);return te=oy(te),function(){return--te>0&&(xt=me.apply(this,arguments)),te<=1&&(me=n),xt}}e(Sy,"before");var T9=H(function(te,me,xt){var An=V;if(xt.length){var ya=$f(xt,bg(T9));An|=xe}return om(te,An,me,xt,ya)}),vD=H(function(te,me,xt){var An=V|ee;if(xt.length){var ya=$f(xt,bg(vD));An|=xe}return om(me,An,te,xt,ya)});function gC(te,me,xt){me=xt?n:me;var An=om(te,le,n,n,n,n,n,me);return An.placeholder=gC.placeholder,An}e(gC,"curry");function dd(te,me,xt){me=xt?n:me;var An=om(te,de,n,n,n,n,n,me);return An.placeholder=dd.placeholder,An}e(dd,"curryRight");function k9(te,me,xt){var An,ya,co,Xc,rl,dp,td=0,j0=!1,z0=!1,V_=!0;if(typeof te!="function")throw new nA(c);me=p7(me)||0,KC(xt)&&(j0=!!xt.leading,z0="maxWait"in xt,co=z0?Dc(p7(xt.maxWait)||0,me):co,V_="trailing"in xt?!!xt.trailing:V_);function n1(Yb){var Xb=An,oA=ya;return An=ya=n,td=Yb,Xc=te.apply(oA,Xb),Xc}e(n1,"invokeFunc");function J1(Yb){return td=Yb,rl=Cu(Ay,me),j0?n1(Yb):Xc}e(J1,"leadingEdge");function z1(Yb){var Xb=Yb-dp,oA=Yb-td,_M=me-Xb;return z0?yu(_M,co-oA):_M}e(z1,"remainingWait");function dg(Yb){var Xb=Yb-dp,oA=Yb-td;return dp===n||Xb>=me||Xb<0||z0&&oA>=co}e(dg,"shouldInvoke");function Ay(){var Yb=Yx();if(dg(Yb))return Nv(Yb);rl=Cu(Ay,z1(Yb))}e(Ay,"timerExpired");function Nv(Yb){return rl=n,V_&&An?n1(Yb):(An=ya=n,Xc)}e(Nv,"trailingEdge");function c3(){rl!==n&&V4(rl),td=0,An=dp=ya=rl=n}e(c3,"cancel");function AE(){return rl===n?Xc:Nv(Yx())}e(AE,"flush");function Xy(){var Yb=Yx(),Xb=dg(Yb);if(An=arguments,ya=this,dp=Yb,Xb){if(rl===n)return J1(dp);if(z0)return V4(rl),rl=Cu(Ay,me),n1(dp)}return rl===n&&(rl=Cu(Ay,me)),Xc}return e(Xy,"debounced"),Xy.cancel=c3,Xy.flush=AE,Xy}e(k9,"debounce");var Wm=H(function(te,me){return zt(te,1,me)}),VU=H(function(te,me,xt){return zt(te,p7(me)||0,xt)});function ne(te){return om(te,Ce)}e(ne,"flip");function vf(te,me){if(typeof te!="function"||me!=null&&typeof me!="function")throw new nA(c);var xt=e(function(){var An=arguments,ya=me?me.apply(this,An):An[0],co=xt.cache;if(co.has(ya))return co.get(ya);var Xc=te.apply(this,An);return xt.cache=co.set(ya,Xc)||co,Xc},"memoized");return xt.cache=new(vf.Cache||A0),xt}e(vf,"memoize"),vf.Cache=A0;function q$(te){if(typeof te!="function")throw new nA(c);return function(){var me=arguments;switch(me.length){case 0:return!te.call(this);case 1:return!te.call(this,me[0]);case 2:return!te.call(this,me[0],me[1]);case 3:return!te.call(this,me[0],me[1],me[2])}return!te.apply(this,me)}}e(q$,"negate");function Xx(te){return Sy(2,te)}e(Xx,"once");var iW=q5(function(te,me){me=me.length==1&&k1(me[0])?Ul(me[0],Ku(Kg())):Ul(Vt(me,1),Ku(Kg()));var xt=me.length;return H(function(An){for(var ya=-1,co=yu(An.length,xt);++ya<co;)An[ya]=me[ya].call(this,An[ya]);return Wa(te,this,An)})}),W5=H(function(te,me){var xt=$f(me,bg(W5));return om(te,xe,n,me,xt)}),JU=H(function(te,me){var xt=$f(me,bg(JU));return om(te,Re,n,me,xt)}),aW=pw(function(te,me){return om(te,Ke,n,n,n,me)});function Av(te,me){if(typeof te!="function")throw new nA(c);return me=me===n?me:oy(me),H(te,me)}e(Av,"rest");function yC(te,me){if(typeof te!="function")throw new nA(c);return me=me==null?0:Dc(oy(me),0),H(function(xt){var An=xt[me],ya=$4(xt,0,me);return An&&Ff(ya,An),Wa(te,this,ya)})}e(yC,"spread");function zU(te,me,xt){var An=!0,ya=!0;if(typeof te!="function")throw new nA(c);return KC(xt)&&(An="leading"in xt?!!xt.leading:An,ya="trailing"in xt?!!xt.trailing:ya),k9(te,me,{leading:An,maxWait:me,trailing:ya})}e(zU,"throttle");function yw(te){return w9(te,1)}e(yw,"unary");function n4(te,me){return W5(q4(me),te)}e(n4,"wrap");function hS(){if(!arguments.length)return[];var te=arguments[0];return k1(te)?te:[te]}e(hS,"castArray");function Oy(te){return Ne(te,P)}e(Oy,"clone");function yF(te,me){return me=typeof me=="function"?me:n,Ne(te,P,me)}e(yF,"cloneWith");function oP(te){return Ne(te,w|P)}e(oP,"cloneDeep");function HU(te,me){return me=typeof me=="function"?me:n,Ne(te,w|P,me)}e(HU,"cloneDeepWith");function cP(te,me){return me==null||Ot(te,me,YC(me))}e(cP,"conformsTo");function c7(te,me){return te===me||te!==te&&me!==me}e(c7,"eq");var vs=am(lo),n3=am(function(te,me){return te>=me}),Ox=__(function(){return arguments}())?__:function(te){return AC(te)&&Mg.call(te,"callee")&&!Qc.call(te,"callee")},k1=ja.isArray,cM=jt?Ku(jt):q_;function i3(te){return te!=null&&hx(te.length)&&!u7(te)}e(i3,"isArrayLike");function vC(te){return AC(te)&&i3(te)}e(vC,"isArrayLikeObject");function vE(te){return te===!0||te===!1||AC(te)&&ha(te)==pt}e(vE,"isBoolean");var D6=ls||FO,vF=Br?Ku(Br):Al;function $$(te){return AC(te)&&te.nodeType===1&&!wT(te)}e($$,"isElement");function GC(te){if(te==null)return!0;if(i3(te)&&(k1(te)||typeof te=="string"||typeof te.splice=="function"||D6(te)||AF(te)||Ox(te)))return!te.length;var me=hC(te);if(me==kr||me==rs)return!te.size;if(Hb(te))return!Wf(te).length;for(var xt in te)if(Mg.call(te,xt))return!1;return!0}e(GC,"isEmpty");function sW(te,me){return P0(te,me)}e(sW,"isEqual");function Kre(te,me,xt){xt=typeof xt=="function"?xt:n;var An=xt?xt(te,me):n;return An===n?P0(te,me,n,xt):!!An}e(Kre,"isEqualWith");function nX(te){if(!AC(te))return!1;var me=ha(te);return me==ai||me==Pr||typeof te.message=="string"&&typeof te.name=="string"&&!wT(te)}e(nX,"isError");function oW(te){return typeof te=="number"&&go(te)}e(oW,"isFinite");function u7(te){if(!KC(te))return!1;var me=ha(te);return me==In||me==Ri||me==rt||me==as}e(u7,"isFunction");function l7(te){return typeof te=="number"&&te==oy(te)}e(l7,"isInteger");function hx(te){return typeof te=="number"&&te>-1&&te%1==0&&te<=je}e(hx,"isLength");function KC(te){var me=typeof te;return te!=null&&(me=="object"||me=="function")}e(KC,"isObject");function AC(te){return te!=null&&typeof te=="object"}e(AC,"isObjectLike");var AD=kn?Ku(kn):mo;function Rf(te,me){return te===me||Do(te,me,fw(me))}e(Rf,"isMatch");function cW(te,me,xt){return xt=typeof xt=="function"?xt:n,Do(te,me,fw(me),xt)}e(cW,"isMatchWith");function gS(te){return bO(te)&&te!=+te}e(gS,"isNaN");function _d(te){if(Wre(te))throw new _h(s);return id(te)}e(_d,"isNative");function Tye(te){return te===null}e(Tye,"isNull");function uW(te){return te==null}e(uW,"isNil");function bO(te){return typeof te=="number"||AC(te)&&ha(te)==Ss}e(bO,"isNumber");function wT(te){if(!AC(te)||ha(te)!=Fa)return!1;var me=Qi(te);if(me===null)return!0;var xt=Mg.call(me,"constructor")&&me.constructor;return typeof xt=="function"&&xt instanceof xt&&pC.call(xt)==py}e(wT,"isPlainObject");var Wb=hi?Ku(hi):X_;function G5(te){return l7(te)&&te>=-je&&te<=je}e(G5,"isSafeInteger");var lW=ea?Ku(ea):Ih;function gx(te){return typeof te=="string"||!k1(te)&&AC(te)&&ha(te)==Oa}e(gx,"isString");function p8(te){return typeof te=="symbol"||AC(te)&&ha(te)==sa}e(p8,"isSymbol");var AF=Fo?Ku(Fo):x0;function vw(te){return te===n}e(vw,"isUndefined");function V$(te){return AC(te)&&hC(te)==qo}e(V$,"isWeakMap");function EO(te){return AC(te)&&ha(te)==Na}e(EO,"isWeakSet");var xD=am($_),W4=am(function(te,me){return te<=me});function Gb(te){if(!te)return[];if(i3(te))return gx(te)?Ll(te):Ts(te);if(La&&te[La])return uf(te[La]());var me=hC(te),xt=me==kr?gf:me==rs?S_:cl;return xt(te)}e(Gb,"toArray");function qE(te){if(!te)return te===0?te:0;if(te=p7(te),te===Ze||te===-Ze){var me=te<0?-1:1;return me*qt}return te===te?te:0}e(qE,"toFinite");function oy(te){var me=qE(te),xt=me%1;return me===me?xt?me-xt:me:0}e(oy,"toInteger");function xF(te){return te?ei(oy(te),0,It):0}e(xF,"toLength");function p7(te){if(typeof te=="number")return te;if(p8(te))return Nt;if(KC(te)){var me=typeof te.valueOf=="function"?te.valueOf():te;te=KC(me)?me+"":me}if(typeof te!="string")return te===0?te:+te;te=Po(te);var xt=Or.test(te);return xt||$n.test(te)?Of(te.slice(2),xt?2:8):rr.test(te)?Nt:+te}e(p7,"toNumber");function pW(te){return J4(te,wy(te))}e(pW,"toPlainObject");function uP(te){return te?ei(oy(te),-je,je):te===0?te:0}e(uP,"toSafeInteger");function vy(te){return te==null?"":lS(te)}e(vy,"toString");var X1=dD(function(te,me){if(Hb(me)||i3(me)){J4(me,YC(me),te);return}for(var xt in me)Mg.call(me,xt)&&ex(te,xt,me[xt])}),CO=dD(function(te,me){J4(me,wy(me),te)}),iX=dD(function(te,me,xt,An){J4(me,wy(me),te,An)}),bD=dD(function(te,me,xt,An){J4(me,YC(me),te,An)}),Hoe=pw(Vr);function aX(te,me){var xt=$a(te);return me==null?xt:Jb(xt,me)}e(aX,"create");var sX=H(function(te,me){te=ly(te);var xt=-1,An=me.length,ya=An>2?me[2]:n;for(ya&&r7(me[0],me[1],ya)&&(An=1);++xt<An;)for(var co=me[xt],Xc=wy(co),rl=-1,dp=Xc.length;++rl<dp;){var td=Xc[rl],j0=te[td];(j0===n||c7(j0,lC[td])&&!Mg.call(te,td))&&(te[td]=co[td])}return te}),I9=H(function(te){return te.push(n,rM),Wa(EF,n,te)});function uM(te,me){return Eo(te,Kg(me,3),Da)}e(uM,"findKey");function oX(te,me){return Eo(te,Kg(me,3),Cs)}e(oX,"findLastKey");function bF(te,me){return te==null?te:qn(te,Kg(me,3),wy)}e(bF,"forIn");function ag(te,me){return te==null?te:Fn(te,Kg(me,3),wy)}e(ag,"forInRight");function K5(te,me){return te&&Da(te,Kg(me,3))}e(K5,"forOwn");function Pm(te,me){return te&&Cs(te,Kg(me,3))}e(Pm,"forOwnRight");function f8(te){return te==null?[]:_s(te,YC(te))}e(f8,"functions");function F9(te){return te==null?[]:_s(te,wy(te))}e(F9,"functionsIn");function WU(te,me,xt){var An=te==null?n:ys(te,me);return An===n?xt:An}e(WU,"get");function Woe(te,me){return te!=null&&BU(te,me,mu)}e(Woe,"has");function lM(te,me){return te!=null&&BU(te,me,Jp)}e(lM,"hasIn");var Yre=Xi(function(te,me,xt){me!=null&&typeof me.toString!="function"&&(me=Wx.call(me)),te[me]=xt},P9(d8)),cX=Xi(function(te,me,xt){me!=null&&typeof me.toString!="function"&&(me=Wx.call(me)),Mg.call(te,me)?te[me].push(xt):te[me]=[xt]},Kg),i4=H(_m);function YC(te){return i3(te)?ql(te):Wf(te)}e(YC,"keys");function wy(te){return i3(te)?ql(te,!0):Cm(te)}e(wy,"keysIn");function Aw(te,me){var xt={};return me=Kg(me,3),Da(te,function(An,ya,co){De(xt,me(An,ya,co),An)}),xt}e(Aw,"mapKeys");function pM(te,me){var xt={};return me=Kg(me,3),Da(te,function(An,ya,co){De(xt,ya,me(An,ya,co))}),xt}e(pM,"mapValues");var fM=dD(function(te,me,xt){la(te,me,xt)}),EF=dD(function(te,me,xt,An){la(te,me,xt,An)}),Y5=pw(function(te,me){var xt={};if(te==null)return xt;var An=!1;me=Ul(me,function(co){return co=gE(co,te),An||(An=co.length>1),co}),J4(te,lF(te),xt),An&&(xt=Ne(xt,w|B|P,lw));for(var ya=me.length;ya--;)a8(xt,me[ya]);return xt});function xw(te,me){return a3(te,q$(Kg(me)))}e(xw,"omitBy");var yx=pw(function(te,me){return te==null?{}:Nl(te,me)});function a3(te,me){if(te==null)return{};var xt=Ul(lF(te),function(An){return[An]});return me=Kg(me),k_(te,xt,function(An,ya){return me(An,ya[0])})}e(a3,"pickBy");function DO(te,me,xt){me=gE(me,te);var An=-1,ya=me.length;for(ya||(ya=1,te=n);++An<ya;){var co=te==null?n:te[i7(me[An])];co===n&&(An=ya,co=xt),te=u7(co)?co.call(te):co}return te}e(DO,"result");function Zx(te,me,xt){return te==null?te:pb(te,me,xt)}e(Zx,"set");function Goe(te,me,xt,An){return An=typeof An=="function"?An:n,te==null?te:pb(te,me,xt,An)}e(Goe,"setWith");var SO=sv(YC),bw=sv(wy);function J$(te,me,xt){var An=k1(te),ya=An||D6(te)||AF(te);if(me=Kg(me,4),xt==null){var co=te&&te.constructor;ya?xt=An?new co:[]:KC(te)?xt=u7(co)?$a(Qi(te)):{}:xt={}}return(ya?nc:Da)(te,function(Xc,rl,dp){return me(xt,Xc,rl,dp)}),xt}e(J$,"transform");function fW(te,me){return te==null?!0:a8(te,me)}e(fW,"unset");function wO(te,me,xt){return te==null?te:yT(te,me,q4(xt))}e(wO,"update");function uX(te,me,xt,An){return An=typeof An=="function"?An:n,te==null?te:yT(te,me,q4(xt),An)}e(uX,"updateWith");function cl(te){return te==null?[]:lp(te,YC(te))}e(cl,"values");function S6(te){return te==null?[]:lp(te,wy(te))}e(S6,"valuesIn");function Ew(te,me,xt){return xt===n&&(xt=me,me=n),xt!==n&&(xt=p7(xt),xt=xt===xt?xt:0),me!==n&&(me=p7(me),me=me===me?me:0),ei(p7(te),me,xt)}e(Ew,"clamp");function lP(te,me,xt){return me=qE(me),xt===n?(xt=me,me=0):xt=qE(xt),te=p7(te),yd(te,me,xt)}e(lP,"inRange");function w6(te,me,xt){if(xt&&typeof xt!="boolean"&&r7(te,me,xt)&&(me=xt=n),xt===n&&(typeof me=="boolean"?(xt=me,me=n):typeof te=="boolean"&&(xt=te,te=n)),te===n&&me===n?(te=0,me=1):(te=qE(te),me===n?(me=te,te=0):me=qE(me)),te>me){var An=te;te=me,me=An}if(xt||te%1||me%1){var ya=Ms();return yu(te+ya*(me-te+X0("1e-"+((ya+"").length-1))),me)}return Gg(te,me)}e(w6,"random");var lX=fi(function(te,me,xt){return me=me.toLowerCase(),te+(xt?pP(me):me)});function pP(te){return Zre(vy(te).toLowerCase())}e(pP,"capitalize");function GU(te){return te=vy(te),te&&te.replace(Wi,gs).replace(Ao,"")}e(GU,"deburr");function D2(te,me,xt){te=vy(te),me=lS(me);var An=te.length;xt=xt===n?An:ei(oy(xt),0,An);var ya=xt;return xt-=me.length,xt>=0&&te.slice(xt,ya)==me}e(D2,"endsWith");function wb(te){return te=vy(te),te&&un.test(te)?te.replace(st,No):te}e(wb,"escape");function KU(te){return te=vy(te),te&&Xn.test(te)?te.replace(Un,"\\$&"):te}e(KU,"escapeRegExp");var z$=fi(function(te,me,xt){return te+(xt?"-":"")+me.toLowerCase()}),Xre=fi(function(te,me,xt){return te+(xt?" ":"")+me.toLowerCase()}),H$=zb("toLowerCase");function TO(te,me,xt){te=vy(te),me=oy(me);var An=me?pc(te):0;if(!me||An>=me)return te;var ya=(me-An)/2;return xu(ka(ya),xt)+te+xu(Os(ya),xt)}e(TO,"pad");function Y2(te,me,xt){te=vy(te),me=oy(me);var An=me?pc(te):0;return me&&An<me?te+xu(me-An,xt):te}e(Y2,"padEnd");function dW(te,me,xt){te=vy(te),me=oy(me);var An=me?pc(te):0;return me&&An<me?xu(me-An,xt)+te:te}e(dW,"padStart");function W$(te,me,xt){return xt||me==null?me=0:me&&(me=+me),ep(vy(te).replace(_n,""),me||0)}e(W$,"parseInt");function fP(te,me,xt){return(xt?r7(te,me,xt):me===n)?me=1:me=oy(me),fy(vy(te),me)}e(fP,"repeat");function pX(){var te=arguments,me=vy(te[0]);return te.length<3?me:me.replace(te[1],te[2])}e(pX,"replace");var G$=fi(function(te,me,xt){return te+(xt?"_":"")+me.toLowerCase()});function dP(te,me,xt){return xt&&typeof xt!="number"&&r7(te,me,xt)&&(me=xt=n),xt=xt===n?It:xt>>>0,xt?(te=vy(te),te&&(typeof me=="string"||me!=null&&!Wb(me))&&(me=lS(me),!me&&Tu(te))?$4(Ll(te),0,xt):te.split(me,xt)):[]}e(dP,"split");var TT=fi(function(te,me,xt){return te+(xt?" ":"")+Zre(me)});function _W(te,me,xt){return te=vy(te),xt=xt==null?0:ei(oy(xt),0,te.length),me=lS(me),te.slice(xt,xt+me.length)==me}e(_W,"startsWith");function Koe(te,me,xt){var An=_e.templateSettings;xt&&r7(te,me,xt)&&(me=n),te=vy(te),me=bD({},me,An,aA);var ya=bD({},me.imports,An.imports,aA),co=YC(ya),Xc=lp(ya,co);nc(co,function(dg){if(qr.test(dg))throw new _h(_)});var rl,dp,td=0,j0=me.interpolate||Fi,z0="__p += '",V_=Px((me.escape||Fi).source+"|"+j0.source+"|"+(j0===Li?dt:Fi).source+"|"+(me.evaluate||Fi).source+"|$","g"),n1="//# sourceURL="+(Mg.call(me,"sourceURL")?(me.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ln+"]")+`
|
|
136
136
|
`;te.replace(V_,function(dg,Ay,Nv,c3,AE,Xy){return Nv||(Nv=c3),z0+=te.slice(td,Xy).replace(mn,za),Ay&&(rl=!0,z0+=`' +
|
|
@@ -612,7 +612,7 @@ Additional information: BADCLIENT: Bad error code, ${Z} not found in range ${C}.
|
|
|
612
612
|
`+Z.stack)}finally{this.performanceData=U}}parseMessage(a){return JSON.parse(a)}toStringMessage(a){return a}getFormatOptions(a){return this.projectService.getFormatCodeOptions(a)}getPreferences(a){return this.projectService.getPreferences(a)}getHostFormatOptions(){return this.projectService.getHostFormatCodeOptions()}getHostPreferences(){return this.projectService.getHostPreferences()}},e(Zae,"_Session"),Zae);function EAt(t){let a=t.diagnosticsDuration&&br(t.diagnosticsDuration,([l,f])=>({...f,file:l}));return{...t,diagnosticsDuration:a}}e(EAt,"toProtocolPerformanceData");function II(t,a){return{start:a.positionToLineOffset(t.start),end:a.positionToLineOffset(bg(t))}}e(II,"toProtocolTextSpan");function pYe(t,a,l){let f=II(t,l),m=a&&II(a,l);return m?{...f,contextStart:m.start,contextEnd:m.end}:f}e(pYe,"toProtocolTextSpanWithContext");function yZt(t,a){return{start:CAt(a,t.span.start),end:CAt(a,bg(t.span)),newText:t.newText}}e(yZt,"convertTextChangeToCodeEdit");function CAt(t,a){return iYe(t)?AZt(t.getLineAndCharacterOfPosition(a)):t.positionToLineOffset(a)}e(CAt,"positionToLineOffset");function vZt(t,a){let l=t.ranges.map(f=>({start:a.positionToLineOffset(f.start),end:a.positionToLineOffset(f.start+f.length)}));return t.wordPattern?{ranges:l,wordPattern:t.wordPattern}:{ranges:l}}e(vZt,"convertLinkedEditInfoToRanges");function AZt(t){return{line:t.line+1,offset:t.character+1}}e(AZt,"locationFromLineAndCharacter");function xZt(t){se.assert(t.textChanges.length===1);let a=st(t.textChanges);return se.assert(a.span.start===0&&a.span.length===0),{fileName:t.fileName,textChanges:[{start:{line:0,offset:0},end:{line:0,offset:0},newText:a.newText}]}}e(xZt,"convertNewFileTextChangeToCodeEdit");function fYe(t,a,l,f){let m=bZt(t,a,f),{line:b,character:C}=_C(V4(m),l);return{line:b+1,offset:C+1}}e(fYe,"getLocationInNewDocument");function bZt(t,a,l){for(let{fileName:f,textChanges:m}of l)if(f===a)for(let b=m.length-1;b>=0;b--){let{newText:C,span:{start:I,length:T}}=m[b];t=t.slice(0,I)+C+t.slice(I+T)}return t}e(bZt,"applyEdits");function DAt(t,{fileName:a,textSpan:l,contextSpan:f,isWriteAccess:m,isDefinition:b},{disableLineTextInReferences:C}){let I=se.checkDefined(t.getScriptInfo(a)),T=pYe(l,f,I),q=C?void 0:EZt(I,T);return{file:a,...T,lineText:q,isWriteAccess:m,isDefinition:b}}e(DAt,"referenceEntryToReferencesResponseItem");function EZt(t,a){let l=t.lineToTextSpan(a.start.line-1);return t.getSnapshot().getText(l.start,bg(l)).replace(/\r|\n/g,"")}e(EZt,"getLineText");function CZt(t){return t===void 0||t&&typeof t=="object"&&typeof t.exportName=="string"&&(t.fileName===void 0||typeof t.fileName=="string")&&(t.ambientModuleName===void 0||typeof t.ambientModuleName=="string"&&(t.isPackageJsonImport===void 0||typeof t.isPackageJsonImport=="boolean"))}e(CZt,"isCompletionEntryData");var ype=4,dYe=(t=>(t[t.PreStart=0]="PreStart",t[t.Start=1]="Start",t[t.Entire=2]="Entire",t[t.Mid=3]="Mid",t[t.End=4]="End",t[t.PostEnd=5]="PostEnd",t))(dYe||{}),DZt=(Yxe=class{constructor(){this.goSubtree=!0,this.lineIndex=new Cxe,this.endBranch=[],this.state=2,this.initialText="",this.trailingText="",this.lineIndex.root=new vpe,this.startPath=[this.lineIndex.root],this.stack=[this.lineIndex.root]}get done(){return!1}insertLines(a,l){l&&(this.trailingText=""),a?a=this.initialText+a+this.trailingText:a=this.initialText+this.trailingText;let m=Cxe.linesFromText(a).lines;m.length>1&&m[m.length-1]===""&&m.pop();let b,C;for(let T=this.endBranch.length-1;T>=0;T--)this.endBranch[T].updateCounts(),this.endBranch[T].charCount()===0&&(C=this.endBranch[T],T>0?b=this.endBranch[T-1]:b=this.branchNode);C&&b.remove(C);let I=this.startPath[this.startPath.length-1];if(m.length>0)if(I.text=m[0],m.length>1){let T=new Array(m.length-1),q=I;for(let K=1;K<m.length;K++)T[K-1]=new BSe(m[K]);let U=this.startPath.length-2;for(;U>=0;){let K=this.startPath[U];T=K.insertAt(q,T),U--,q=K}let $=T.length;for(;$>0;){let K=new vpe;K.add(this.lineIndex.root),T=K.insertAt(this.lineIndex.root,T),$=T.length,this.lineIndex.root=K}this.lineIndex.root.updateCounts()}else for(let T=this.startPath.length-2;T>=0;T--)this.startPath[T].updateCounts();else{this.startPath[this.startPath.length-2].remove(I);for(let q=this.startPath.length-2;q>=0;q--)this.startPath[q].updateCounts()}return this.lineIndex}post(a,l,f){f===this.lineCollectionAtBranch&&(this.state=4),this.stack.pop()}pre(a,l,f,m,b){let C=this.stack[this.stack.length-1];this.state===2&&b===1&&(this.state=1,this.branchNode=C,this.lineCollectionAtBranch=f);let I;function T(q){return q.isLeaf()?new BSe(""):new vpe}switch(e(T,"fresh"),b){case 0:this.goSubtree=!1,this.state!==4&&C.add(f);break;case 1:this.state===4?this.goSubtree=!1:(I=T(f),C.add(I),this.startPath.push(I));break;case 2:this.state!==4?(I=T(f),C.add(I),this.startPath.push(I)):f.isLeaf()||(I=T(f),C.add(I),this.endBranch.push(I));break;case 3:this.goSubtree=!1;break;case 4:this.state!==4?this.goSubtree=!1:f.isLeaf()||(I=T(f),C.add(I),this.endBranch.push(I));break;case 5:this.goSubtree=!1,this.state!==1&&C.add(f);break}this.goSubtree&&this.stack.push(I)}leaf(a,l,f){this.state===1?this.initialText=f.text.substring(0,a):this.state===2?(this.initialText=f.text.substring(0,a),this.trailingText=f.text.substring(a+l)):this.trailingText=f.text.substring(a+l)}},e(Yxe,"EditWalker"),Yxe),SZt=(Xxe=class{constructor(a,l,f){this.pos=a,this.deleteLen=l,this.insertedText=f}getTextChangeRange(){return _w(Gx(this.pos,this.deleteLen),this.insertedText?this.insertedText.length:0)}},e(Xxe,"TextChange9"),Xxe),TPe=(eL=class{constructor(){this.changes=[],this.versions=new Array(eL.maxVersions),this.minVersion=0,this.currentVersion=0}versionToIndex(a){if(!(a<this.minVersion||a>this.currentVersion))return a%eL.maxVersions}currentVersionToIndex(){return this.currentVersion%eL.maxVersions}edit(a,l,f){this.changes.push(new SZt(a,l,f)),(this.changes.length>eL.changeNumberThreshold||l>eL.changeLengthThreshold||f&&f.length>eL.changeLengthThreshold)&&this.getSnapshot()}getSnapshot(){return this._getSnapshot()}_getSnapshot(){let a=this.versions[this.currentVersionToIndex()];if(this.changes.length>0){let l=a.index;for(let f of this.changes)l=l.edit(f.pos,f.deleteLen,f.insertedText);a=new SAt(this.currentVersion+1,this,l,this.changes),this.currentVersion=a.version,this.versions[this.currentVersionToIndex()]=a,this.changes=[],this.currentVersion-this.minVersion>=eL.maxVersions&&(this.minVersion=this.currentVersion-eL.maxVersions+1)}return a}getSnapshotVersion(){return this._getSnapshot().version}getAbsolutePositionAndLineText(a){return this._getSnapshot().index.lineNumberToInfo(a)}lineOffsetToPosition(a,l){return this._getSnapshot().index.absolutePositionOfStartOfLine(a)+(l-1)}positionToLineOffset(a){return this._getSnapshot().index.positionToLineOffset(a)}lineToTextSpan(a){let l=this._getSnapshot().index,{lineText:f,absolutePosition:m}=l.lineNumberToInfo(a+1),b=f!==void 0?f.length:l.absolutePositionOfStartOfLine(a+2)-m;return Gx(m,b)}getTextChangesBetweenVersions(a,l){if(a<l)if(a>=this.minVersion){let f=[];for(let m=a+1;m<=l;m++){let b=this.versions[this.versionToIndex(m)];for(let C of b.changesSincePreviousVersion)f.push(C.getTextChangeRange())}return OU(f)}else return;else return nM}getLineCount(){return this._getSnapshot().index.getLineCount()}static fromString(a){let l=new eL,f=new SAt(0,l,new Cxe);l.versions[l.currentVersion]=f;let m=Cxe.linesFromText(a);return f.index.load(m.lines),l}},e(eL,"_ScriptVersionCache"),eL);TPe.changeNumberThreshold=8,TPe.changeLengthThreshold=256,TPe.maxVersions=8;var kPe=TPe,SAt=(khe=class{constructor(a,l,f,m=yb){this.version=a,this.cache=l,this.index=f,this.changesSincePreviousVersion=m}getText(a,l){return this.index.getText(a,l-a)}getLength(){return this.index.getLength()}getChangeRange(a){if(a instanceof khe&&this.cache===a.cache)return this.version<=a.version?nM:this.cache.getTextChangesBetweenVersions(a.version,this.version)}},e(khe,"_LineIndexSnapshot"),khe),Cxe=(Epe=class{constructor(){this.checkEdits=!1}absolutePositionOfStartOfLine(a){return this.lineNumberToInfo(a).absolutePosition}positionToLineOffset(a){let{oneBasedLine:l,zeroBasedColumn:f}=this.root.charOffsetToLineInfo(1,a);return{line:l,offset:f+1}}positionToColumnAndLineText(a){return this.root.charOffsetToLineInfo(1,a)}getLineCount(){return this.root.lineCount()}lineNumberToInfo(a){let l=this.getLineCount();if(a<=l){let{position:f,leaf:m}=this.root.lineNumberToInfo(a,0);return{absolutePosition:f,lineText:m&&m.text}}else return{absolutePosition:this.root.charCount(),lineText:void 0}}load(a){if(a.length>0){let l=[];for(let f=0;f<a.length;f++)l[f]=new BSe(a[f]);this.root=Epe.buildTreeFromBottom(l)}else this.root=new vpe}walk(a,l,f){this.root.walk(a,l,f)}getText(a,l){let f="";return l>0&&a<this.root.charCount()&&this.walk(a,l,{goSubtree:!0,done:!1,leaf:e((m,b,C)=>{f=f.concat(C.text.substring(m,m+b))},"leaf")}),f}getLength(){return this.root.charCount()}every(a,l,f){f||(f=this.root.charCount());let m={goSubtree:!0,done:!1,leaf(b,C,I){a(I,b,C)||(this.done=!0)}};return this.walk(l,f-l,m),!m.done}edit(a,l,f){if(this.root.charCount()===0)return se.assert(l===0),f!==void 0?(this.load(Epe.linesFromText(f).lines),this):void 0;{let m;if(this.checkEdits){let I=this.getText(0,this.root.charCount());m=I.slice(0,a)+f+I.slice(a+l)}let b=new DZt,C=!1;if(a>=this.root.charCount()){a=this.root.charCount()-1;let I=this.getText(a,1);f?f=I+f:f=I,l=0,C=!0}else if(l>0){let I=a+l,{zeroBasedColumn:T,lineText:q}=this.positionToColumnAndLineText(I);T===0&&(l+=q.length,f=f?f+q:q)}if(this.root.walk(a,l,b),b.insertLines(f,C),this.checkEdits){let I=b.lineIndex.getText(0,b.lineIndex.getLength());se.assert(m===I,"buffer edit mismatch")}return b.lineIndex}}static buildTreeFromBottom(a){if(a.length<ype)return new vpe(a);let l=new Array(Math.ceil(a.length/ype)),f=0;for(let m=0;m<l.length;m++){let b=Math.min(f+ype,a.length);l[m]=new vpe(a.slice(f,b)),f=b}return this.buildTreeFromBottom(l)}static linesFromText(a){let l=V4(a);if(l.length===0)return{lines:[],lineMap:l};let f=new Array(l.length),m=l.length-1;for(let C=0;C<m;C++)f[C]=a.substring(l[C],l[C+1]);let b=a.substring(l[m]);return b.length>0?f[m]=b:f.pop(),{lines:f,lineMap:l}}},e(Epe,"_LineIndex"),Epe),vpe=(Cpe=class{constructor(a=[]){this.children=a,this.totalChars=0,this.totalLines=0,a.length&&this.updateCounts()}isLeaf(){return!1}updateCounts(){this.totalChars=0,this.totalLines=0;for(let a of this.children)this.totalChars+=a.charCount(),this.totalLines+=a.lineCount()}execWalk(a,l,f,m,b){return f.pre&&f.pre(a,l,this.children[m],this,b),f.goSubtree?(this.children[m].walk(a,l,f),f.post&&f.post(a,l,this.children[m],this,b)):f.goSubtree=!0,f.done}skipChild(a,l,f,m,b){m.pre&&!m.done&&(m.pre(a,l,this.children[f],this,b),m.goSubtree=!0)}walk(a,l,f){if(this.children.length===0)return;let m=0,b=this.children[m].charCount(),C=a;for(;C>=b;)this.skipChild(C,l,m,f,0),C-=b,m++,b=this.children[m].charCount();if(C+l<=b){if(this.execWalk(C,l,f,m,2))return}else{if(this.execWalk(C,b-C,f,m,1))return;let I=l-(b-C);for(m++,b=this.children[m].charCount();I>b;){if(this.execWalk(0,b,f,m,3))return;I-=b,m++,b=this.children[m].charCount()}if(I>0&&this.execWalk(0,I,f,m,4))return}if(f.pre){let I=this.children.length;if(m<I-1)for(let T=m+1;T<I;T++)this.skipChild(0,0,T,f,5)}}charOffsetToLineInfo(a,l){if(this.children.length===0)return{oneBasedLine:a,zeroBasedColumn:l,lineText:void 0};for(let b of this.children){if(b.charCount()>l)return b.isLeaf()?{oneBasedLine:a,zeroBasedColumn:l,lineText:b.text}:b.charOffsetToLineInfo(a,l);l-=b.charCount(),a+=b.lineCount()}let f=this.lineCount();if(f===0)return{oneBasedLine:1,zeroBasedColumn:0,lineText:void 0};let m=se.checkDefined(this.lineNumberToInfo(f,0).leaf);return{oneBasedLine:f,zeroBasedColumn:m.charCount(),lineText:void 0}}lineNumberToInfo(a,l){for(let f of this.children){let m=f.lineCount();if(m>=a)return f.isLeaf()?{position:l,leaf:f}:f.lineNumberToInfo(a,l);a-=m,l+=f.charCount()}return{position:l,leaf:void 0}}splitAfter(a){let l,f=this.children.length;a++;let m=a;if(a<f){for(l=new Cpe;a<f;)l.add(this.children[a]),a++;l.updateCounts()}return this.children.length=m,l}remove(a){let l=this.findChildIndex(a),f=this.children.length;if(l<f-1)for(let m=l;m<f-1;m++)this.children[m]=this.children[m+1];this.children.pop()}findChildIndex(a){let l=this.children.indexOf(a);return se.assert(l!==-1),l}insertAt(a,l){let f=this.findChildIndex(a),m=this.children.length,b=l.length;if(m<ype&&f===m-1&&b===1)return this.add(l[0]),this.updateCounts(),[];{let C=this.splitAfter(f),I=0;for(f++;f<ype&&I<b;)this.children[f]=l[I],f++,I++;let T=[],q=0;if(I<b){q=Math.ceil((b-I)/ype),T=new Array(q);let U=0;for(let K=0;K<q;K++)T[K]=new Cpe;let $=T[0];for(;I<b;)$.add(l[I]),I++,$.children.length===ype&&(U++,$=T[U]);for(let K=T.length-1;K>=0;K--)T[K].children.length===0&&T.pop()}C&&T.push(C),this.updateCounts();for(let U=0;U<q;U++)T[U].updateCounts();return T}}add(a){this.children.push(a),se.assert(this.children.length<=ype)}charCount(){return this.totalChars}lineCount(){return this.totalLines}},e(Cpe,"_LineNode"),Cpe),BSe=(Zxe=class{constructor(a){this.text=a}isLeaf(){return!0}walk(a,l,f){f.leaf(a,l,this)}charCount(){return this.text.length}lineCount(){return 1}},e(Zxe,"LineLeaf"),Zxe),wAt=(Ihe=class{constructor(a,l,f,m,b,C){this.telemetryEnabled=a,this.logger=l,this.host=f,this.globalTypingsCacheLocation=m,this.event=b,this.maxActiveRequestCount=C,this.activeRequestCount=0,this.requestQueue=of(),this.requestMap=new Map,this.requestedRegistry=!1,this.packageInstallId=0}isKnownTypesPackageName(a){var l;return _q.validatePackageName(a)!==_q.NameValidationResult.Ok?!1:(this.requestedRegistry||(this.requestedRegistry=!0,this.installer.send({kind:"typesRegistry"})),!!((l=this.typesRegistryCache)!=null&&l.has(a)))}installPackage(a){this.packageInstallId++;let l={kind:"installPackage",...a,id:this.packageInstallId},f=new Promise((m,b)=>{(this.packageInstalledPromise??(this.packageInstalledPromise=new Map)).set(this.packageInstallId,{resolve:m,reject:b})});return this.installer.send(l),f}attach(a){this.projectService=a,this.installer=this.createInstallerProcess()}onProjectClosed(a){this.installer.send({projectName:a.getProjectName(),kind:"closeProject"})}enqueueInstallTypingsRequest(a,l,f){let m=AKe(a,l,f);this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling throttled operation:${XJ(m)}`),this.activeRequestCount<this.maxActiveRequestCount?this.scheduleRequest(m):(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Deferring request for: ${m.projectName}`),this.requestQueue.enqueue(m),this.requestMap.set(m.projectName,m))}handleMessage(a){var l,f;switch(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Received response:${XJ(a)}`),a.kind){case Z9e:this.typesRegistryCache=new Map(Object.entries(a.typesRegistry));break;case Z4e:{let m=(l=this.packageInstalledPromise)==null?void 0:l.get(a.id);se.assertIsDefined(m,"Should find the promise for package install"),(f=this.packageInstalledPromise)==null||f.delete(a.id),a.success?m.resolve({successMessage:a.message}):m.reject(a.message),this.projectService.updateTypingsForProject(a),this.event(a,"setTypings");break}case SVe:{let m={message:a.message};this.event(m,"typesInstallerInitializationFailed");break}case eIe:{let m={eventId:a.eventId,packages:a.packagesToInstall};this.event(m,"beginInstallTypes");break}case tIe:{if(this.telemetryEnabled){let C={telemetryEventName:"typingsInstalled",payload:{installedPackages:a.packagesToInstall.join(","),installSuccess:a.installSuccess,typingsInstallerVersion:a.typingsInstallerVersion}};this.event(C,"telemetry")}let m={eventId:a.eventId,packages:a.packagesToInstall,success:a.installSuccess};this.event(m,"endInstallTypes");break}case X4e:{this.projectService.updateTypingsForProject(a);break}case Y4e:{for(this.activeRequestCount>0?this.activeRequestCount--:se.fail("TIAdapter:: Received too many responses");!this.requestQueue.isEmpty();){let m=this.requestQueue.dequeue();if(this.requestMap.get(m.projectName)===m){this.requestMap.delete(m.projectName),this.scheduleRequest(m);break}this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Skipping defunct request for: ${m.projectName}`)}this.projectService.updateTypingsForProject(a),this.event(a,"setTypings");break}case vAe:this.projectService.watchTypingLocations(a);break;default:}}scheduleRequest(a){this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling request for: ${a.projectName}`),this.activeRequestCount++,this.host.setTimeout(()=>{this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Sending request:${XJ(a)}`),this.installer.send(a)},Ihe.requestDelayMillis,`${a.projectName}::${a.kind}`)}},e(Ihe,"_TypingsInstallerAdapter"),Ihe);wAt.requestDelayMillis=100;var TAt=wAt,kAt={};p(kAt,{ActionInvalidate:e(()=>X4e,"ActionInvalidate"),ActionPackageInstalled:e(()=>Z4e,"ActionPackageInstalled"),ActionSet:e(()=>Y4e,"ActionSet"),ActionWatchTypingLocations:e(()=>vAe,"ActionWatchTypingLocations"),Arguments:e(()=>rIe,"Arguments"),AutoImportProviderProject:e(()=>QKe,"AutoImportProviderProject"),AuxiliaryProject:e(()=>jKe,"AuxiliaryProject"),CharRangeSection:e(()=>dYe,"CharRangeSection"),CloseFileWatcherEvent:e(()=>gPe,"CloseFileWatcherEvent"),CommandNames:e(()=>_At,"CommandNames"),ConfigFileDiagEvent:e(()=>fPe,"ConfigFileDiagEvent"),ConfiguredProject:e(()=>qKe,"ConfiguredProject"),ConfiguredProjectLoadKind:e(()=>WKe,"ConfiguredProjectLoadKind"),CreateDirectoryWatcherEvent:e(()=>hPe,"CreateDirectoryWatcherEvent"),CreateFileWatcherEvent:e(()=>mPe,"CreateFileWatcherEvent"),Errors:e(()=>ZR,"Errors"),EventBeginInstallTypes:e(()=>eIe,"EventBeginInstallTypes"),EventEndInstallTypes:e(()=>tIe,"EventEndInstallTypes"),EventInitializationFailed:e(()=>SVe,"EventInitializationFailed"),EventTypesRegistry:e(()=>Z9e,"EventTypesRegistry"),ExternalProject:e(()=>sPe,"ExternalProject"),GcTimer:e(()=>wKe,"GcTimer"),InferredProject:e(()=>MKe,"InferredProject"),LargeFileReferencedEvent:e(()=>pPe,"LargeFileReferencedEvent"),LineIndex:e(()=>Cxe,"LineIndex"),LineLeaf:e(()=>BSe,"LineLeaf"),LineNode:e(()=>vpe,"LineNode"),LogLevel:e(()=>yKe,"LogLevel"),Msg:e(()=>vKe,"Msg"),OpenFileInfoTelemetryEvent:e(()=>$Ke,"OpenFileInfoTelemetryEvent"),Project:e(()=>Xae,"Project"),ProjectInfoTelemetryEvent:e(()=>_Pe,"ProjectInfoTelemetryEvent"),ProjectKind:e(()=>bhe,"ProjectKind"),ProjectLanguageServiceStateEvent:e(()=>dPe,"ProjectLanguageServiceStateEvent"),ProjectLoadingFinishEvent:e(()=>lPe,"ProjectLoadingFinishEvent"),ProjectLoadingStartEvent:e(()=>uPe,"ProjectLoadingStartEvent"),ProjectService:e(()=>nYe,"ProjectService"),ProjectsUpdatedInBackgroundEvent:e(()=>FSe,"ProjectsUpdatedInBackgroundEvent"),ScriptInfo:e(()=>FKe,"ScriptInfo"),ScriptVersionCache:e(()=>kPe,"ScriptVersionCache"),Session:e(()=>bAt,"Session"),TextStorage:e(()=>IKe,"TextStorage"),ThrottledOperations:e(()=>SKe,"ThrottledOperations"),TypingsInstallerAdapter:e(()=>TAt,"TypingsInstallerAdapter"),allFilesAreJsOrDts:e(()=>OKe,"allFilesAreJsOrDts"),allRootFilesAreJsOrDts:e(()=>BKe,"allRootFilesAreJsOrDts"),asNormalizedPath:e(()=>Uvt,"asNormalizedPath"),convertCompilerOptions:e(()=>NSe,"convertCompilerOptions"),convertFormatOptions:e(()=>hpe,"convertFormatOptions"),convertScriptKindName:e(()=>vPe,"convertScriptKindName"),convertTypeAcquisition:e(()=>JKe,"convertTypeAcquisition"),convertUserPreferences:e(()=>zKe,"convertUserPreferences"),convertWatchOptions:e(()=>bxe,"convertWatchOptions"),countEachFileTypes:e(()=>yxe,"countEachFileTypes"),createInstallTypingsRequest:e(()=>AKe,"createInstallTypingsRequest"),createModuleSpecifierCache:e(()=>sYe,"createModuleSpecifierCache"),createNormalizedPathMap:e(()=>Qvt,"createNormalizedPathMap"),createPackageJsonCache:e(()=>oYe,"createPackageJsonCache"),createSortedArray:e(()=>DKe,"createSortedArray"),emptyArray:e(()=>yb,"emptyArray"),findArgument:e(()=>Qpt,"findArgument"),formatDiagnosticToProtocol:e(()=>Exe,"formatDiagnosticToProtocol"),formatMessage:e(()=>cYe,"formatMessage"),getBaseConfigFileName:e(()=>aPe,"getBaseConfigFileName"),getDetailWatchInfo:e(()=>EPe,"getDetailWatchInfo"),getLocationInNewDocument:e(()=>fYe,"getLocationInNewDocument"),hasArgument:e(()=>Upt,"hasArgument"),hasNoTypeScriptSource:e(()=>RKe,"hasNoTypeScriptSource"),indent:e(()=>Hme,"indent"),isBackgroundProject:e(()=>Axe,"isBackgroundProject"),isConfigFile:e(()=>iYe,"isConfigFile"),isConfiguredProject:e(()=>Oj,"isConfiguredProject"),isDynamicFileName:e(()=>xhe,"isDynamicFileName"),isExternalProject:e(()=>vxe,"isExternalProject"),isInferredProject:e(()=>mpe,"isInferredProject"),isInferredProjectName:e(()=>xKe,"isInferredProjectName"),isProjectDeferredClose:e(()=>xxe,"isProjectDeferredClose"),makeAutoImportProviderProjectName:e(()=>EKe,"makeAutoImportProviderProjectName"),makeAuxiliaryProjectName:e(()=>CKe,"makeAuxiliaryProjectName"),makeInferredProjectName:e(()=>bKe,"makeInferredProjectName"),maxFileSize:e(()=>cPe,"maxFileSize"),maxProgramSizeForNonTsFiles:e(()=>oPe,"maxProgramSizeForNonTsFiles"),normalizedPathToPath:e(()=>_pe,"normalizedPathToPath"),nowString:e(()=>qpt,"nowString"),nullCancellationToken:e(()=>pAt,"nullCancellationToken"),nullTypingsInstaller:e(()=>PSe,"nullTypingsInstaller"),protocol:e(()=>TKe,"protocol"),scriptInfoIsContainedByBackgroundProject:e(()=>NKe,"scriptInfoIsContainedByBackgroundProject"),scriptInfoIsContainedByDeferredClosedProject:e(()=>PKe,"scriptInfoIsContainedByDeferredClosedProject"),stringifyIndented:e(()=>XJ,"stringifyIndented"),toEvent:e(()=>uYe,"toEvent"),toNormalizedPath:e(()=>zy,"toNormalizedPath"),tryConvertScriptKindName:e(()=>yPe,"tryConvertScriptKindName"),typingsInstaller:e(()=>gKe,"typingsInstaller"),updateProjectIfDirty:e(()=>Ww,"updateProjectIfDirty")}),typeof console<"u"&&(se.loggingHost={log(t,a){switch(t){case 1:return console.error(a);case 2:return console.warn(a);case 3:return console.log(a);case 4:return console.log(a)}}})})({get exports(){return Myn},set exports(n){Myn=n,typeof MIt<"u"&&MIt.exports&&(MIt.exports=n)}})});var HPi,A3r,w0e,kst=Ws(()=>{"use strict";t0e();yre();HPi={generateSelectionData:!1,navigationTimeout:30*1e3,actionTimeout:5*1e3},A3r=class A3r{constructor(r,i,s,c,p,_,v){this.page=r;this.evaluateWithChecksum=i;this.checksumPage=s;this.pageInteractor=c;this.options=p;this.API_BASE_DOMAIN="https://api.checksum.ai";this.didCancel=!1;this.timeout=15*60*1e3;this.canResolveAssertion=!1;this.page=r,this.options={...HPi,...p},this.runtimePage=_,this.context=v}canResolve(r){return!(r.type==="assertion"&&!this.canResolveAssertion)}addMetadata(r){}cancel(){this.didCancel=!0}async execute(r,i,s,c=6e4){return jyn(r,i,s,c)}log(...r){KA(...r)}setThought(r){this.thought=r}setVariables(r){this.variables=r}get shouldSendToAnalytics(){return!0}getAnalyticsPayload(){return{}}toString(){return this.constructor.name}};e(A3r,"AbstractFallback");w0e=A3r});async function Pje(n,r=0,i=3){try{let s=await n(),c=[200,201];if(s instanceof Response&&!c.includes(s.status)){if(r<i)return await Mb(1e3*Math.pow(2,r)),Pje(n,r+1,i);throw new Error(`Failed to get response after ${i} retries. Status: ${s.status}`)}return s}catch(s){if(s instanceof TypeError&&r<i)return await Mb(1e3*Math.pow(2,r)),Pje(n,r+1,i);throw s}}var Uyn=Ws(()=>{"use strict";WS();e(Pje,"withRetry")});var qyn,Ist,$yn,x3r,Vyn,Bje,T0e,Fge,Jyn=Ws(()=>{"use strict";WS();Nte();GSr();fre();ryn();Kwe();yCe();t0e();qyn=require("crypto"),Ist=require("fs"),$yn=require("jsdom"),x3r=nd(require("path")),Vyn=nd(require("sharp"));nyn();Bje=nd(lT());yre();kst();Uyn();T0e=class T0e extends w0e{constructor(){super(...arguments);this.API_BASE_ROUTE="/client-api/runtime/ai-fallback";this.CLIENT_MAX_ITERATIONS=10;this.thoughts=[];this.withChecksumAI=!1;this.executedSteps=[];this.stepsPayload=[];this.hasPreviousActionFailed=!1;this.iterationSteps=[];this.canResolveAssertion=!0;this.benchmark=!1;this.timeout=4*60*1e3;this.arMode="regular";this.arOverrideOptions={};this.finish=!1;this.actionsCounter=1;this.mockServer=!1;this.actionEventCodeToMethodName={click:"click",double_click:"dblclick",drag_and_drop:"dragTo",input:"fill",click_and_type:"fill",clear_and_type:"fill",hover:"hover",keystroke:"keyboard.press",navigation:"goto",check:"check",uncheck:"uncheck",selectoption:"selectOption",upload_files:"upload_files",get_more_items:"get_more_items",wait:"wait",switch_tab:"switch_tab",custom_code:"custom_code",logout_and_login:"logout_and_login",canvas_click:"canvas_click",native_accept:"native_accept",native_dismiss:"native_dismiss",login:"login"}}init(i){let{goal:s,apiKey:c,testId:p,apiURL:_,thoughts:v,benchmark:E,arMode:D,overrideOptions:w}=i;return this.goal=s,this.apiKey=c,this.testId=p,this.testSuiteId=process.env.CHECKSUM_TEST_SUITE_ID||"",this.thoughts=v,this.withChecksumAI=!1,this.testFile=i.testFile,this.arMode=D||"regular",this.arOverrideOptions=w||{},_&&(this.API_BASE_DOMAIN=_.replace(/\/$/,"")),this.aiFallbackAnalytics=new FIt((0,qyn.randomUUID)().slice(0,8),i.fallbackType),this.benchmark=!!E,this}getRecoveryAttemptTitle(i){switch(i.type){case"action":return`Checksum Auto-Recovery: trying to achieve action "${this.getFailedThought()}"...`;case"assertion":return`Checksum Auto-Recovery: trying to verify assertion "${this.getFailedThought()}"...`}}async switchToActionFallback(i){if(this.fallbackData={...this.fallbackData,assertionRecovery:!0,assertionToActionData:{...i},type:"recovery"},this.withChecksumAI=!1,this.fallbackData.type="recovery",this.getFailedThought()==="_fail_")return{result:"failed"};try{await this.initSession();let{result:c,summary:p}=await this.iterate();return{result:c,summary:p}}catch(c){return this.errorMessage=c.message,this.log("[AIFallback] Error",c),{result:"failed"}}}canResolve(i){if(!super.canResolve(i))return!1;try{let{stack:s}=i.error;return!e(_=>{let v=_.split(`
|
|
613
613
|
`).map(E=>E.trim());for(let E of v){let D=E.match(/\((.*):(\d+):(\d+)\)$/)||E.match(/at (.*):(\d+):(\d+)/);if(!D)continue;let[,w,B]=D,P=parseInt(B,10),L=x3r.default.dirname(i.testInfo.config.configFile);if(w.includes(L)&&(0,Ist.existsSync)(w))try{let j=(0,Ist.readFileSync)(w,"utf8"),V=Bje.default.createSourceFile(w,j,Bje.default.ScriptTarget.Latest,!0),ee=!1,ue=e((le,de)=>{let{line:xe}=V.getLineAndCharacterOfPosition(le.getStart()),{line:Re}=V.getLineAndCharacterOfPosition(le.getEnd());xe+1<=P&&Re+1>=P&&de&&(ee=!0),Bje.default.isTryStatement(le)&&Bje.default.forEachChild(le.tryBlock,$e=>ue($e,le)),Bje.default.forEachChild(le,$e=>ue($e,de))},"checkNode");if(ue(V,null),ee)return!0}catch{continue}}return!1},"isErrorFromTryBlock")(s)}catch{return!0}}async createARSummary(){let{apiKey:i}=this;try{let s=await Pje(async()=>await fetch(`${this.getAPIBaseURL()}/summarize`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:i,sessionId:this.sessionId})}));if(s.status!==201)throw new Error("Failed to create AR summary after 3 retries");return await s.text()}catch(s){return this.log("[AIFallback] Error calling summarize",s)," "}}async resolve(i){let s=Date.now();if(T0e.alreadyTriggered&&this.benchmark)throw new Error("Cannot trigger AI fallback more than once in benchmark mode");T0e.alreadyTriggered=!0,this.fallbackData=i,this.withChecksumAI=i.withChecksumAI;let c=this.getFailedThought();if(c==="_fail_")return{steps:[],fbResult:"failed"};let p,_;try{await this.initSession();let{result:v,assertionToActionData:E,summary:D,thought:w}=await this.iterate();if(p=v,_=D,v==="switch_to_fallback_action"){await this.checksumPage.createChecksumStep({title:`Attempting to recover using additional actions: ${w}`}),this.aiFallbackAnalytics.aiFallbackIterationResponse({duration:0,command:"switch_to_fallback_action",thought:"Switch to action fallback"}),this.aiFallbackAnalytics.setFallbackType("recovery");let{result:V,summary:ee}=await this.switchToActionFallback(E);p=V,_=ee}if(p==="failed"||p==="hard_assertion")return this.aiFallbackAnalytics.aiFallbackEnd({result:p,avgDuration:0,failMessage:this.errorMessage}),this.log("[AIFallback] AIFallback Failed"),{steps:[],fbResult:p,thought:w};let P=Date.now()-s,L=this.iterationSteps.length>0?P/this.iterationSteps.length:0;this.aiFallbackAnalytics.aiFallbackEnd({result:p,avgDuration:L,failMessage:this.errorMessage});let j=0;if(!_){let V=Date.now();_=await this.createARSummary(),j=Date.now()-V}return this.aiFallbackAnalytics.aiFallbackSummary({result:p,duration:j,fallbackType:this.fallbackType,summary:_}),this.addAutoHealErrorToReport(i,c,_),this.fallbackData.type==="action"&&this.markActionStepAsFailed(this.fallbackData),{steps:this.executedSteps.map(V=>{switch(V.type){case"action":return this.translateExecutedActionToFallbackAction(V);case"assertion":return V}}),summary:_,fbResult:p,thought:w}}catch(v){if(this.errorMessage=v.message,this.withChecksumAI&&v.message==="fetch failed")throw v;return this.log("[AIFallback] Error",v),{steps:[],fbResult:"failed"}}}async markActionStepAsFailed(i){try{let s=i.step._testInfo._steps.find(c=>c.stepId===i.step._stepId);s&&(s.error={message:i.error.message,stack:i.error.stack,cause:void 0})}catch(s){this.log("[AIFallback] Error marking action step as failed",s)}}addAutoHealErrorToReport(i,s,c){this.withChecksumAI||(this.checksumPage.addPwAnnotation({type:`"${s}" auto-recovered`,description:c.replace(/^"(.*)"$/,"$1")}),this.checksumPage.addErrorMessage(i.error,`"${s}" auto-recovered:
|
|
614
614
|
${this.executedSteps.map(p=>{switch(p.type){case"action":return p.thought;case"assertion":return p.feedback}}).join(`,
|
|
615
|
-
`)}`))}async getReductionComponents(i){var s,c;return i.interruptionEvent==="didRequestMoreItemsEvent"?{reducedHTML:(c=(s=i.payload)==null?void 0:s.promptData)==null?void 0:c.reducedHTML,reducedDomHTMLElement:this.lastReducedDOM,flashingHTML:[],elementsForNodeInterpretation:[],currentChecksumId:T0e.currentChecksumId}:this.pageInteractor.getCurrentReducedHTML({stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:T0e.currentChecksumId})}getErrorFileContent(i){try{let s=x3r.default.dirname(this.fallbackData.testInfo.config.configFile);return wje.toString(i,s)}catch{throw new Error("Error while getting error file content for AI fallback")}}async getPageScreenshot(){try{return this.checksumPage.wrapInternalSteps(async()=>{var p,_;let i=await this.page.screenshot({fullPage:!0,type:((_=(p=this.arConfig)==null?void 0:p.modelPreset)==null?void 0:_.type)==="anthropic-vertexai"?"jpeg":"png"}),s=4e3;return(await(0,Vyn.default)(i).resize(s,s,{fit:"inside",withoutEnlargement:!0}).toBuffer()).toString("base64")})}catch{return}}getMatcherResultFileData(){let i=this.fallbackData.error.matcherResult;if((i==null?void 0:i.name)!=="toHaveScreenshot")return;let s=e((v,E=!0)=>{if(!v)return"";try{return(0,Ist.readFileSync)(v,E?"base64":"utf-8")}catch{return""}},"readFileSafe"),c=s(i==null?void 0:i.actual),p=s(i==null?void 0:i.diff),_=s(i==null?void 0:i.expected);if(!_)throw this.log("[AIFallback] No expected file found for 'toHaveScreenshot'"),new Error("No expected file found for 'toHaveScreenshot'");return{...i,actual:c,diff:p,expected:_}}async prepareDataForCurrentIteration(){let i=await this.getPreviousActionOverview(),s=this.getMatcherResultFileData(),{reducedHTML:c,flashingHTML:p,elementsForNodeInterpretation:_,currentChecksumId:v}=await this.getReductionComponents(i),E=await this.getPageScreenshot();this.lastReducedDOM=new $yn.JSDOM(c),T0e.currentChecksumId=v;let D=(()=>{let w=this.executedSteps[this.executedSteps.length-1];if(w&&w.type==="action")return w.locator})();return{reducedHTML:c,flashingHTML:p,elementsForNodeInterpretation:_,previousActionOverview:i,screenshot:E,matcherResult:s,fallbackActionErrorMessage:this.fallbackData.error.message,locatorUsed:D}}async iterate(){this.hasPreviousActionFailed=!1;let i=this.CLIENT_MAX_ITERATIONS;for(;i-- >0;){if(this.didCancel)return this.aiFallbackAnalytics.aiFallbackEnd({result:"failed",avgDuration:0,failMessage:"User canceled"}),{result:"failed",thought:"Fallback Canceled"};let s=await this.prepareDataForCurrentIteration(),c=Date.now(),p=await this.getIterationResponse(s),_=Date.now()-c,{thought:v,command:E,changedVariables:D}=p;if(this.traceAIFallbackIterationNew({thought:v,command:E,duration:_}),this.handleChangedVariables(D),this.fallbackData.type==="assertion"){let L=p.payload;if(E==="scroll"){await this.scrollToElement(L.checksumId);continue}return this.handleAssertionResponse(L)}let w=p.payload;if(this.didCancel)return this.aiFallbackAnalytics.aiFallbackEnd({result:"failed",avgDuration:0,failMessage:"User canceled"}),{result:"failed",thought:"Fallback Canceled"};let B=this.getStopIterationResult(E);if(B)return{result:B.result,summary:w.summary??void 0,thought:v};let P=Date.now();try{let L=await this.pageInteractor.translateActionResponseToAgentPotentialAction(w);await this.executeFallbackAction(w,L),this.trackActionExecution(w,L,Date.now()-P)}catch(L){this.log("[AIFallback] Error while executing selector",L.message),this.hasPreviousActionFailed=!0,this.trackActionExecutionFailure(w,Date.now()-P,L.message);continue}}return this.errorMessage="maximum repetition reached",this.log(`[AIFallback] ${this.errorMessage}`),{result:"failed",thought:"Fallback failed to recover action"}}trackActionExecution(i,s,c){this.aiFallbackAnalytics.aiFallbackActionExecution({thought:i.thought,duration:c,command:i.action.type,checksumId:i.action.checksumid,type:i.action.type,selector:s.selector,locator:s.locator,fillValue:s.fillValue,getMoreItemsId:s.getMoreItemsId})}trackActionExecutionFailure(i,s,c){this.aiFallbackAnalytics.aiFallbackActionExecutionFailure({thought:i.thought,duration:s,command:i.action.type,checksumId:i.action.checksumid,error:c})}getStopIterationResult(i){if(i==="fail")return this.log("[AIFallback] Received fail signal, will quit"),this.errorMessage="Received fail signal",{result:"failed"};if(i==="finish")return this.log("[AIFallback] Received finish step"),{result:"finish"}}handleAssertionResponse(i){if(this.log(`[AIFallback] for assertion returned with value: ${i.command}, feedback: ${i.analysis}`),this.didCancel)return{result:"failed",thought:"Fallback Canceled"};let s=i.command,c=["irrelevant","pass","soft_reject","soft_pass","soft_assertion"].includes(i.command);this.aiFallbackAnalytics.aiFallbackAssertion({duration:0,command:i.command,thought:i.thought}),this.executedSteps.push({type:"assertion",feedback:i.analysis,response:i.command});let p={response:i.command,feedback:i.analysis};if(this.stepsPayload.push(p),i.command==="recovery"){let v={description:i.analysis,reason:i.thought};return{result:"switch_to_fallback_action",assertionToActionData:v,summary:i.summary,thought:i.thought}}return i.command==="hard_assertion"?{result:"hard_assertion",thought:i.thought}:{result:c?"soft_assertion":"failed",summary:i.summary,thought:i.thought}}async scrollToElement(i){if(!i){this.log("[AIFallback] No checksumId provided for scroll");return}await this.pageInteractor.scrollElementIntoViewByChecksumId(i),await Mb(1e3)}async executeFallbackAction(i,s){let c=Date.now();try{await this.checksumPage.step(`AI: ${s.thought}`,async()=>await this.pageInteractor.performAction(s),void 0,{noLocation:!0})}catch(p){let _=Date.now()-c;throw this.aiFallbackAnalytics.aiFallbackActionExecutionFailure({thought:s.thought,command:i.action.type,duration:_,checksumId:i.action.checksumid,error:p.message}),this.fallbackData.error=p,new Error("Action failed")}this.hasPreviousActionFailed=!1,this.executedSteps.push({type:"action",...s}),this.aiFallbackAnalytics.aiFallbackActionExecution({thought:i.thought,duration:Date.now()-c,command:i.action.type,checksumId:i.action.checksumid,type:i.action.type,selector:s.selector,locator:s.locator,fillValue:s.fillValue,getMoreItemsId:s.getMoreItemsId}),this.addActionStepPayload(i,s),await Mb(1e3)}addActionStepPayload(i,s){let{thought:c,action:{checksumid:p,type:_}}=i,{selector:v,locator:E,fillValue:D,getMoreItemsId:w}=s,B={thought:c,checksumid:p,type:_,selector:v,locator:E,fillValue:D,getMoreItemsId:w};return this.stepsPayload.push(B),B}handleMockServer(){return this.finish?{thought:"finish",command:"finish",payload:{thought:"finish"},changedVariables:[]}:(--this.actionsCounter===0&&(this.finish=!0),{thought:"mock-thought",changedVariables:[],command:"click",payload:{thought:"mock-thought",action:{type:"click",checksumid:"10"}}})}handleChangedVariables(i){i.forEach(({name:s,value:c})=>{this.checksumPage.variableStore.setVariable(s,c)})}async getIterationResponse({reducedHTML:i,flashingHTML:s,elementsForNodeInterpretation:c,previousActionOverview:p,screenshot:_,codeTrace:v,fallbackActionErrorMessage:E,locatorUsed:D}){let{apiKey:w}=this;if(this.mockServer)return this.handleMockServer();let B={reduction:{reducedHTML:i,flashingHTML:s,elementsForNodeInterpretation:c},currentURL:this.page.url(),previousActionOverview:p,resolvesSmartAssertion:this.withChecksumAI,variables:this.variables,screenshot:_,fallbackActionErrorMessage:E,locatorUsed:D};try{let P=await Pje(async()=>await fetch(`${this.getAPIBaseURL()}/iterate`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:w,sessionId:this.sessionId,iterationData:B})}));if(P.status!==201)throw new Error("Failed to get next iteration");let L=await P.json();return this.log("[AIFallback] Received next action",L),this.sanitizeIterationResponse(L)}catch(P){throw this.log("[AIFallback] Error calling iterate",P),P}}sanitizeIterationResponse(i){var s;return this.fallbackType==="assertion"?{thought:i.thought,command:i.command,payload:i,changedVariables:i.changedVariables??[]}:{thought:i.thought,command:(s=i.action)==null?void 0:s.type,payload:i,changedVariables:i.changedVariables??[]}}async getPreviousActionOverview(){let i=await this.pageInteractor.handleFileChooserEvent();return{success:!this.hasPreviousActionFailed,...this.hasPreviousActionFailed?{failureEvent:"generalExecutionFailureError"}:{},...this.getPreviousWaitActionOverview(),...i,...await this.getPreviousGetMoreItemsActionOverview()}}getExecutedActions(){return this.executedSteps.filter(i=>i.type==="action")}async getPreviousGetMoreItemsActionOverview(){let i=this.getExecutedActions(),s=i[i.length-1];if((s==null?void 0:s.eventCode)!=="get_more_items"||!this.lastReducedDOM)return{};try{return await this.pageInteractor.addMoreItemsToDom(this.lastReducedDOM.window.document.body,s.getMoreItemsId),{interruptionEvent:"didRequestMoreItemsEvent",payload:{promptData:{reducedHTML:this.lastReducedDOM.serialize()},getMoreItemsId:s.getMoreItemsId}}}catch{return{}}}getPreviousWaitActionOverview(){var c;let i=this.getExecutedActions();if(((c=i[i.length-1])==null?void 0:c.eventCode)!=="wait")return{};let s=0;return i.slice().reverse().every(p=>p.eventCode==="wait"?(s++,!0):!1,0),{payload:{waitCount:s}}}async initSession(){let{apiKey:i,goal:s,thoughts:c}=this;if(this.log("[AIFallback] Calling init session...",{appName:i,goal:s,thoughts:c}),!i){let E="Missing Checksum API key, will not run AI fallback";throw Ixr(E),new Error(E)}if(this.mockServer){this.sessionId="mock-session-id";return}let p=this.getErrorFileContent(this.fallbackData.error),_={name:this.fallbackData.error.name??"Error",message:this.fallbackData.error.message,stack:this.fallbackData.error.stack},v={type:this.fallbackData.type,resolveSmartAssertion:this.withChecksumAI,storyTitle:s,testSuiteId:this.testSuiteId,testId:this.testId,thoughtsAndActions:{previous:c.slice(0,Math.max(c.length-1,0)).map(E=>({thought:E})),failing:{thought:c[c.length-1]},next:[]},testFileName:this.testFile.split("/").pop()??"",error:_,errorFileContent:p,matcherResult:this.getMatcherResultFileData(),assertionToActionData:this.fallbackData.type==="recovery"||this.fallbackData.type==="action"?this.fallbackData.assertionToActionData:void 0,arMode:this.arMode,overrideOptions:this.arOverrideOptions};this.aiFallbackAnalytics.aiFallbackStart({error:this.fallbackData.error.message,failedThought:this.getFailedThought()});try{let E=await Pje(async()=>await fetch(`${this.getAPIBaseURL()}/init`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:i,data:v,format:"json"})}));if(E.status!==201)throw new Error("Failed to init session after 3 retries");let{sessionId:D,arConfig:w}=await E.json();this.sessionId=D,this.arConfig=w,this.aiFallbackAnalytics.aiFallbackConfig({config:w}),this.log("[AIFallback] Session ID",this.sessionId)}catch(E){throw this.withChecksumAI&&E.message==="fetch failed"&&(this.checksumPage.step(Oje,async()=>{throw new Error(Oje)}),Ixr(Oje)),this.aiFallbackAnalytics.aiFallbackEnd({result:"failed",avgDuration:this.iterationSteps.length>0?this.iterationSteps.reduce((D,w)=>D+w.duration,0)/this.iterationSteps.length:0,failMessage:E==null?void 0:E.message}),this.log("[AIFallback] Error calling init session",E),E}}getReleaseIterationResultIfExists(i){if(this.fallbackType==="assertion"){if(i==="soft_assertion")return{result:"soft_assertion"}}else{if(i==="finish")return{result:"finish"};if(i==="fail")return{result:"failed"}}}translateExecutedActionToFallbackAction(i){return{type:"action",esraMetadata:i.esraMetadata,generatedLocator:i.locator,selector:i.selector,parentFramesSelectors:i.parentFramesSelectors,method:this.getMethodForPotentialAction(i),thought:i.thought}}getMethodForPotentialAction(i){return{name:this.actionEventCodeToMethodName[i.eventCode],args:e(()=>{switch(i.eventCode){case"click":case"double_click":return[{position:i.clickOffset}];case"drag_and_drop":return[this.pageInteractor.makeLocator(i.dropTarget.selector,i.dropTarget.parentFramesSelectors)];case"input":case"click_and_type":case"clear_and_type":case"selectoption":case"keystroke":case"navigation":return[this.pageInteractor.getActionFillValue(i,!1)];case"upload_files":return i.files;default:return}},"makeArgs")()}}getAPIBaseURL(){return this.API_BASE_DOMAIN+this.API_BASE_ROUTE}getAnalyticsPayload(){return{fallbackType:"ai",error:this.errorMessage,thought:this.getFailedThought(),sessionId:this.sessionId,steps:this.stepsPayload.map(i=>JSON.stringify(i))}}getFailedThought(){return this.thoughts[this.thoughts.length-1]}traceAIFallbackIterationNew(i){this.aiFallbackAnalytics.aiFallbackIterationResponse({duration:i.duration,command:i.command,thought:i.thought}),this.iterationSteps.push({thought:i.thought,command:i.command,duration:i.duration})}toString(){return`Checksum AI ("${this.getFailedThought()}")`}get fallbackType(){return this.fallbackData.type}get fallbackAnalyticsPayload(){return{previousThoughts:this.thoughts,iterationSteps:this.iterationSteps}}};e(T0e,"AIFallback"),T0e.alreadyTriggered=!1,T0e.currentChecksumId="0";Fge=T0e});var b3r,n6e,jIt=Ws(()=>{"use strict";yCe();kst();b3r=class b3r extends w0e{constructor(){super(...arguments);this.API_BASE_ROUTE="/client-api/runtime/esra-fallback"}init(i){let{apiKey:s,testId:c,apiURL:p,checksumId:_,fileName:v,timeout:E}=i;return this.data={...this.data,testId:c,checksumId:_,fileName:v},this.apiKey=s,p&&(this.API_BASE_DOMAIN=p.replace(/\/$/,"")),E&&(this.timeout=E),this.checksumRootFolder=process.env.CHECKSUM_ROOT_FOLDER??mon(hon(this.data.fileName),this.data.fileName),this}getRecoveryAttemptTitle(i){return`Checksum auto-heal: trying to locate the element using checksumSelector("${this.data.checksumId}")...`}async sendLog(i){let s=this.getLogPayload(i);try{fetch(`${this.getAPIBaseURL()}/log`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify(s)}).catch(c=>this.log("[ESRAFallback] Error sending log"))}catch(c){this.log("[ESRAFallback] Error sending log",c)}}getLogPayload(i){let s=process.env.CHECKSUM_TEST_SUITE_ID??"",{selector:c}=i,{checksumId:p,testId:_}=this.data;return this.logPayload={testSuiteId:s,testId:_,selector:c,checksumId:p,thought:this.thought},this.logPayload}async getMetadataForTestId(){return lon(this.checksumRootFolder,this.data.testId)}getAPIBaseURL(){return this.API_BASE_DOMAIN+this.API_BASE_ROUTE}};e(b3r,"MetadataBaseFallback");n6e=b3r});var _AlternateSelectorFallback,Fst,zyn=Ws(()=>{"use strict";fre();jIt();WS();_AlternateSelectorFallback=class _AlternateSelectorFallback extends n6e{constructor(){super(...arguments);this.timeout=5*1e3}init(r){return super.init(r),this}async resolve(params){var r;try{let{method,args}=params,{checksumId}=this.data,alternateLocators=[];try{let i=await this.getMetadataForTestId();if(!(checksumId in i)||!i[checksumId].alternateLocators)throw new Error(`No alternate selection metadata found for id ${checksumId}`);alternateLocators=i[checksumId].alternateLocators.locators}catch(i){throw super.log(`Could not read alternate selector metadata file, ${i.message}`),i}try{this.log("Resolving alternate selectors locators");let elementsMap=new Map;await Promise.all(alternateLocators.map(async locatorExpression=>{let locator=eval(FL(locatorExpression,"this.page"));try{await HS(locator.first().waitFor({bypassChecksum:!0}),5e3),(await HS(locator.elementHandles({bypassChecksum:!0}),1e3)).forEach(s=>{elementsMap.has(s)?elementsMap.set(s,elementsMap.get(s)+1):elementsMap.set(s,1)})}catch(i){return}}));let majorityElementHandle=(r=Array.from(elementsMap.entries()))==null?void 0:r.reduce((i,s)=>i[1]>s[1]?i:s)[0];if(!majorityElementHandle)throw this.errorMessage="No alternate element found",new Error(this.errorMessage);let totalElements=Array.from(elementsMap.values()).reduce((i,s)=>i+s,0),elementSelector=await this.evaluateWithChecksum(async({element:i})=>window.playwright.selector(i),{element:majorityElementHandle});this.log(`Resolved alternate selector: ${elementSelector}' With majority vote of ${elementsMap.get(majorityElementHandle)} out of ${totalElements} elements`),await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(this.page.locator(elementSelector),method,args));let fallbackResult={selector:elementSelector,generatedLocator:`locator("${elementSelector}")`,esraMetadata:void 0};return this.sendLog(fallbackResult),this.logPayload=this.logPayload.concat({mejorityVote:`${elementsMap.get(majorityElementHandle)}/${totalElements}`}),this.checksumPage.addErrorMessage(params.error,`${this.thought?`"${this.thought}" auto-recovered`:"Auto-recovered"} using alternative selector "${elementSelector}"`),{steps:[{type:"action",...fallbackResult}]}}catch(i){throw new Error(`Failed to execute compound selection fallback action: ${i.message}`)}}catch(i){this.errorMessage=i.message,this.log(this.errorMessage);return}}getAnalyticsPayload(){return{fallbackType:"alternative-selector",...this.logPayload??{checksumId:this.data.checksumId,error:this.errorMessage}}}toString(){return`Checksum alternative selector (${this.data.checksumId})`}};e(_AlternateSelectorFallback,"AlternateSelectorFallback");Fst=_AlternateSelectorFallback});var E3r,Nst,Hyn=Ws(()=>{"use strict";fre();jIt();E3r=class E3r extends n6e{constructor(){super(...arguments);this.timeout=5*1e3}init(i){return super.init(i),this}async resolve(i){try{let{method:s,args:c}=i,{checksumId:p}=this.data,_;try{let P=await this.getMetadataForTestId();if(!(p in P)||!P[p].compoundSelector)throw new Error(`No compound selection metadata found for id ${p}`);_=P[p].compoundSelector}catch(P){super.log("Could not read compound selector metadata file, ",P)}let v=await this.generateCompoundSelector(_);if(!(v!=null&&v.length))throw new Error("No compound locators found");let E=v[0],D=this.pageInteractor.makeLocator(E.selector),w=_.targetSelection.featuresMetadata.tag,B=["check","uncheck"].includes(s)&&w!=="input"?"click":s;try{await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(D,B,c));let P={selector:E.selector,generatedLocator:E.locator,esraMetadata:void 0};return this.sendLog(P),this.checksumPage.addErrorMessage(i.error,`${this.thought?`"${this.thought}" auto-recovered`:"Auto-recovered"} using alternative selector "${E.selector}"`),{steps:[{type:"action",...P}]}}catch(P){throw new Error(`Failed to execute compound selection fallback action: ${P.message}`)}}catch(s){this.errorMessage=s.message,this.log(s.message);return}}async generateCompoundSelector(i){let s=await this.evaluateWithChecksum(async c=>{var _;return await((_=window.checksum)==null?void 0:_.testGenerator.getCompoundSelector().selectFromMetadata(c))},i);return super.log("Resolved compound selector fallback to",s),s}getAnalyticsPayload(){return{fallbackType:"compound-selector",...this.logPayload??{checksumId:this.data.checksumId,error:this.errorMessage}}}toString(){return`Checksum compound selector fallback (${this.data.checksumId})`}};e(E3r,"CompoundSelectorFallback");Nst=E3r});var UIt,i6e=Ws(()=>{"use strict";UIt=(s=>(s[s.Element=0]="Element",s[s.VisibleElement=1]="VisibleElement",s[s.AtPointElement=2]="AtPointElement",s))(UIt||{})});var C3r,Pst,Wyn=Ws(()=>{"use strict";i6e();fre();yCe();WS();jIt();C3r=class C3r extends n6e{constructor(){super(...arguments);this.API_BASE_ROUTE="/client-api/runtime/esra-fallback";this.timeout=30*1e3;this.locatorTypeEnumToFieldMap={0:"element",1:"visibleElement",2:"atPointElement"}}init(i){return super.init(i),this.data.minSelectionScore=.7,this}async resolve(i){try{let{method:s,args:c}=i,{checksumId:p}=this.data,_=await this.getActionIdToESRAMap();if(!(p in _))throw this.errorMessage=`No ESRA metadata found for id ${p}`,new Error(this.errorMessage);let v=await this.getTestIdsForLocator(_[p].esraMetadata),{elementDataMap:E}=await this.getSelectors(v);if(this.didCancel)return;let D=await this.executeWithSelectors(Object.values(E),s,c);return D?(this.sendLog(D),this.checksumPage.addErrorMessage(i.error,`${this.thought?`"${this.thought}" auto-recovered`:"Auto-recovered"} using alternative selector "${D.selector}"`),{steps:[{type:"action",...D}]}):void 0}catch(s){this.errorMessage=s.message,this.log(this.errorMessage);return}}async getActionIdToESRAMap(){try{this.actionIdToESRAMap||(this.actionIdToESRAMap=await this.getMetadataForTestId())}catch(i){return super.log("Could not read ESRA metadata file, ",i),{}}return this.actionIdToESRAMap}async getSelectors(i){let s=[],c={};if(!i)return{selectors:s,elementDataMap:c};for(let p in Object.keys(UIt)){let _=i.testIds[this.locatorTypeEnumToFieldMap[p]];if(!_)continue;let v=`[data-checksum-testid="${_}"]`;s.push(v),c[v]={...i.elementData[this.locatorTypeEnumToFieldMap[p]],selector:i.selectors[this.locatorTypeEnumToFieldMap[p]],parentFramesSelectors:i.parentFramesSelectors[this.locatorTypeEnumToFieldMap[p]]}}for(let p in Object.keys(UIt)){let _=i.selectors[this.locatorTypeEnumToFieldMap[p]];_&&(s.push(_),c[_]={...i.elementData[this.locatorTypeEnumToFieldMap[p]],selector:_})}return this.log("Selectors for ESRA metadata:",s),{selectors:s,elementDataMap:c}}async getTestIdsForLocator(i,s={}){let{cachedSelector:c=void 0,retriesLeft:p=3,retryMaxTimeout:_=3e3,staticMetadata:v}=s,E=await this.evaluateWithChecksum(async({esraMetadata:D,cachedSelector:w,staticMetadata:B,minSelectionScore:P})=>await window.checksum.testGenerator.getMatchingElementSelectionData(D,{minSelectionScore:P,cachedSelector:w,staticMetadata:B}),{esraMetadata:i,cachedSelector:c,staticMetadata:v,minSelectionScore:this.data.minSelectionScore});if(!E){if(p>0)return this.log("[getTestIdsForLocator] no match found, waiting and retrying..."),await Mb(_/p),this.getTestIdsForLocator(i,{...s,retriesLeft:p-1});this.errorMessage="failed to locate",this.log(`[getTestIdsForLocator] ${this.errorMessage}`)}return E}async executeWithSelectors(i,s,c){for(let{selector:p,tag:_,parentFramesSelectors:v}of i){let E=this.pageInteractor.makeLocator(p,v);this.log(`Running with selector=${p};${v!=null&&v.length?` parentFramesSelectors=${v};`:""}`);let D=!1;["check","uncheck"].includes(s)&&_!=="input"&&(D=!0);let w=this.generateSelectionDataForSelector(p,v);if(await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(E,D?"click":s,c))===!1){this.log("Fallback selector timeout");continue}return w}}async generateSelectionDataForSelector(i,s){let{generateSelectionData:c}=this.options;if(!c)return{selector:i,generatedLocator:void 0,esraMetadata:void 0,parentFramesSelectors:void 0};try{let p=await _on(this.page,i,s);if(!p)throw this.errorMessage=`[generateSelectionDataForSelector] Failed to generate selection data for selector ${i}`,new Error(this.errorMessage);return p}catch(p){throw this.log(p.message),p}}getAnalyticsPayload(){return{fallbackType:"esra",...this.logPayload??{checksumId:this.data.checksumId,error:this.errorMessage}}}toString(){return`Checksum selector (${this.data.checksumId})`}};e(C3r,"ESRAfallback");Pst=C3r});var D3r,Bst,Gyn=Ws(()=>{"use strict";fre();kst();D3r=class D3r extends w0e{init(){return this}canResolve(r){return["check","uncheck"].includes(r.method)}getRecoveryAttemptTitle(r){return"Checksum auto-heal: Trying force click for check/uncheck action..."}async resolve(r){try{let{locator:i,method:s}=r;if(!i)return;let{args:c}=r;if(!["check","uncheck"].includes(s))return;let p=!1;for(let v of Array.from(c))if(typeof v=="object"){v.force=!0,p=!0;break}if(p||(c=Array.from(c),c.push({force:!0})),await this.execute(i,s,c)!==!1)return{steps:[{type:"action",selector:i._selector,generatedLocator:void 0,esraMetadata:void 0}]};this.log("Locator timed out, ")}catch(i){this.log("initiateFallbackSequence exception, ",i);return}}get shouldSendToAnalytics(){return!1}toString(){return"Force click check/uncheck"}};e(D3r,"ForceFallback");Bst=D3r});var S3r,Ost,Kyn,Yyn,Xyn,Zyn,GPi,w3r,QIt,e2n=Ws(()=>{"use strict";ITt();S3r=require("@playwright/test"),Ost=nd(require("fs")),Kyn=nd(require("fs/promises")),Yyn=nd(require("readline")),Xyn=nd(require("path")),Zyn=nd(FTt());yre();cT();GPi=1e3,w3r=class w3r extends oge{constructor(i,s,c={headless:!0,logPerformance:!1,timestampBatchingEnabled:!1,sortByTimestamp:!1,taskTimeout:24e4,debugPort:void 0,frameMsgBrokerRegisterName:void 0,recordRRwebEventsToFile:!1,recordRRwebEventsToFilePath:"events.json"}){super(i,s,c);this.options=c;this.rrwebEventsBuffer="";this.didPostProcessRRwebEvents=!1;this.postProcessRRwebEvents=(0,Zyn.debounce)(async()=>{return;try{let s=Ost.default.createReadStream(this.options.recordRRwebEventsToFilePath),c=Yyn.default.createInterface({input:s,crlfDelay:1/0});for await(let p of c)if(p.trim()!=="")try{let _=JSON.parse(p);Array.isArray(_)?i.push(..._):i.push(_)}catch(_){KA(`Failed to parse line: ${p}`,_)}Ost.default.writeFileSync(this.options.recordRRwebEventsToFilePath.replace(/([^\/]+)$/,"postprocessed.$1"),JSON.stringify(i)),this.didPostProcessRRwebEvents=!0}catch(s){KA("Error post-processing RRweb events",s)}},100,{leading:!0,trailing:!0});if(this.options.recordRRwebEventsToFile){let p=this.options.recordRRwebEventsToFilePath,_=Xyn.default.dirname(p);Ost.default.mkdirSync(_,{recursive:!0}),Ost.default.writeFileSync(p,"")}}setTimeMachineBrowserContext(i){this.timeMachineBrowserContext=i}getTimeMachineBrowserContext(){return this.timeMachineBrowserContext}async makeBrowserContext(){S3r.chromium._checksumInternal=!0;let i=await S3r.chromium.launch({devtools:!1,headless:this.options.headless,args:I_.useRemoteDebugging.enabled?["--remote-debugging-port=4444"]:[]});return i._checksumInternal=!0,this.timeMachineBrowserContext=await i.newContext({bypassCSP:!0}),this.timeMachineBrowserContext._checksumInternal=!0,this.timeMachineBrowserContext.tracing.startChunk=async()=>{},this.timeMachineBrowserContext.tracing.stop(),this.timeMachineBrowserContext.tracing.stop=async()=>{},this.timeMachineBrowserContext.tracing.stopChunk=async()=>{},this.timeMachineBrowserContext}async makeFrame(){let i=await this.timeMachineBrowserContext.newPage();i._checksumInternal=!0;let s=i.mainFrame();return s._checksumInternal=!0,s}async rrwebEventHandler(i){let s=await super.rrwebEventHandler(i);if(this.options.recordRRwebEventsToFile){if(this.rrwebEventsBuffer+=s+`
|
|
615
|
+
`)}`))}async getReductionComponents(i){var s,c;return i.interruptionEvent==="didRequestMoreItemsEvent"?{reducedHTML:(c=(s=i.payload)==null?void 0:s.promptData)==null?void 0:c.reducedHTML,reducedDomHTMLElement:this.lastReducedDOM,flashingHTML:[],elementsForNodeInterpretation:[],currentChecksumId:T0e.currentChecksumId}:this.pageInteractor.getCurrentReducedHTML({stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:T0e.currentChecksumId})}getErrorFileContent(i){try{let s=x3r.default.dirname(this.fallbackData.testInfo.config.configFile);return wje.toString(i,s)}catch{throw new Error("Error while getting error file content for AI fallback")}}async getPageScreenshot(){try{return this.checksumPage.wrapInternalSteps(async()=>{var p,_;let i=await this.page.screenshot({fullPage:!0,type:((_=(p=this.arConfig)==null?void 0:p.modelPreset)==null?void 0:_.type)==="anthropic-vertexai"?"jpeg":"png"}),s=4e3;return(await(0,Vyn.default)(i).resize(s,s,{fit:"inside",withoutEnlargement:!0}).toBuffer()).toString("base64")})}catch{return}}getMatcherResultFileData(){let i=this.fallbackData.error.matcherResult;if((i==null?void 0:i.name)!=="toHaveScreenshot")return;let s=e((v,E=!0)=>{if(!v)return"";try{return(0,Ist.readFileSync)(v,E?"base64":"utf-8")}catch{return""}},"readFileSafe"),c=s(i==null?void 0:i.actual),p=s(i==null?void 0:i.diff),_=s(i==null?void 0:i.expected);if(!_)throw this.log("[AIFallback] No expected file found for 'toHaveScreenshot'"),new Error("No expected file found for 'toHaveScreenshot'");return{...i,actual:c,diff:p,expected:_}}async prepareDataForCurrentIteration(){let i=await this.getPreviousActionOverview(),s=this.getMatcherResultFileData(),{reducedHTML:c,flashingHTML:p,elementsForNodeInterpretation:_,currentChecksumId:v}=await this.getReductionComponents(i),E=await this.getPageScreenshot();this.lastReducedDOM=new $yn.JSDOM(c),T0e.currentChecksumId=v;let D=(()=>{let w=this.executedSteps[this.executedSteps.length-1];if(w&&w.type==="action")return w.locator})();return{reducedHTML:c,flashingHTML:p,elementsForNodeInterpretation:_,previousActionOverview:i,screenshot:E,matcherResult:s,fallbackActionErrorMessage:this.fallbackData.error.message,locatorUsed:D}}async iterate(){this.hasPreviousActionFailed=!1;let i=this.CLIENT_MAX_ITERATIONS;for(;i-- >0;){if(this.didCancel)return this.aiFallbackAnalytics.aiFallbackEnd({result:"failed",avgDuration:0,failMessage:"User canceled"}),{result:"failed",thought:"Fallback Canceled"};let s=await this.prepareDataForCurrentIteration(),c=Date.now(),p=await this.getIterationResponse(s),_=Date.now()-c,{thought:v,command:E,changedVariables:D}=p;if(this.traceAIFallbackIterationNew({thought:v,command:E,duration:_}),this.handleChangedVariables(D),this.fallbackData.type==="assertion"){let L=p.payload;if(E==="scroll"){await this.scrollToElement(L.checksumId);continue}return this.handleAssertionResponse(L)}let w=p.payload;if(this.didCancel)return this.aiFallbackAnalytics.aiFallbackEnd({result:"failed",avgDuration:0,failMessage:"User canceled"}),{result:"failed",thought:"Fallback Canceled"};let B=this.getStopIterationResult(E);if(B)return{result:B.result,summary:w.summary??void 0,thought:v};let P=Date.now();try{let L=await this.pageInteractor.translateActionResponseToAgentPotentialAction(w);await this.executeFallbackAction(w,L),this.trackActionExecution(w,L,Date.now()-P)}catch(L){this.log("[AIFallback] Error while executing selector",L.message),this.hasPreviousActionFailed=!0,this.trackActionExecutionFailure(w,Date.now()-P,L.message);continue}}return this.errorMessage="maximum repetition reached",this.log(`[AIFallback] ${this.errorMessage}`),{result:"failed",thought:"Fallback failed to recover action"}}trackActionExecution(i,s,c){this.aiFallbackAnalytics.aiFallbackActionExecution({thought:i.thought,duration:c,command:i.action.type,checksumId:i.action.checksumid,type:i.action.type,selector:s.selector,locator:s.locator,fillValue:s.fillValue,getMoreItemsId:s.getMoreItemsId})}trackActionExecutionFailure(i,s,c){this.aiFallbackAnalytics.aiFallbackActionExecutionFailure({thought:i.thought,duration:s,command:i.action.type,checksumId:i.action.checksumid,error:c})}getStopIterationResult(i){if(i==="fail")return this.log("[AIFallback] Received fail signal, will quit"),this.errorMessage="Received fail signal",{result:"failed"};if(i==="finish")return this.log("[AIFallback] Received finish step"),{result:"finish"}}handleAssertionResponse(i){if(this.log(`[AIFallback] for assertion returned with value: ${i.command}, feedback: ${i.analysis}`),this.didCancel)return{result:"failed",thought:"Fallback Canceled"};let s=i.command,c=["irrelevant","pass","soft_reject","soft_pass","soft_assertion"].includes(i.command);this.aiFallbackAnalytics.aiFallbackAssertion({duration:0,command:i.command,thought:i.thought}),this.executedSteps.push({type:"assertion",feedback:i.analysis,response:i.command});let p={response:i.command,feedback:i.analysis};if(this.stepsPayload.push(p),i.command==="recovery"){let v={description:i.analysis,reason:i.thought};return{result:"switch_to_fallback_action",assertionToActionData:v,summary:i.summary,thought:i.thought}}return i.command==="hard_assertion"?{result:"hard_assertion",thought:i.thought}:{result:c?"soft_assertion":"failed",summary:i.summary,thought:i.thought}}async scrollToElement(i){if(!i){this.log("[AIFallback] No checksumId provided for scroll");return}await this.pageInteractor.scrollElementIntoViewByChecksumId(i),await Mb(1e3)}async executeFallbackAction(i,s){let c=Date.now();try{await this.checksumPage.step(`AI: ${s.thought}`,async()=>await this.pageInteractor.performAction(s),void 0,{noLocation:!0})}catch(p){let _=Date.now()-c;throw this.aiFallbackAnalytics.aiFallbackActionExecutionFailure({thought:s.thought,command:i.action.type,duration:_,checksumId:i.action.checksumid,error:p.message}),this.fallbackData.error=p,new Error("Action failed")}this.hasPreviousActionFailed=!1,this.executedSteps.push({type:"action",...s}),this.aiFallbackAnalytics.aiFallbackActionExecution({thought:i.thought,duration:Date.now()-c,command:i.action.type,checksumId:i.action.checksumid,type:i.action.type,selector:s.selector,locator:s.locator,fillValue:s.fillValue,getMoreItemsId:s.getMoreItemsId}),this.addActionStepPayload(i,s),await Mb(1e3)}addActionStepPayload(i,s){let{thought:c,action:{checksumid:p,type:_}}=i,{selector:v,locator:E,fillValue:D,getMoreItemsId:w}=s,B={thought:c,checksumid:p,type:_,selector:v,locator:E,fillValue:D,getMoreItemsId:w};return this.stepsPayload.push(B),B}handleMockServer(){return this.finish?{thought:"finish",command:"finish",payload:{thought:"finish"},changedVariables:[]}:(--this.actionsCounter===0&&(this.finish=!0),{thought:"mock-thought",changedVariables:[],command:"click",payload:{thought:"mock-thought",action:{type:"click",checksumid:"10"}}})}handleChangedVariables(i){i.forEach(({name:s,value:c})=>{this.checksumPage.variableStore.setVariable(s,c)})}async getIterationResponse({reducedHTML:i,flashingHTML:s,elementsForNodeInterpretation:c,previousActionOverview:p,screenshot:_,codeTrace:v,fallbackActionErrorMessage:E,locatorUsed:D}){let{apiKey:w}=this;if(this.mockServer)return this.handleMockServer();let B={reduction:{reducedHTML:i,flashingHTML:s,elementsForNodeInterpretation:c},currentURL:this.page.url(),previousActionOverview:p,resolvesSmartAssertion:this.withChecksumAI,variables:this.variables,screenshot:_,fallbackActionErrorMessage:E,locatorUsed:D};try{let P=await Pje(async()=>await fetch(`${this.getAPIBaseURL()}/iterate`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:w,sessionId:this.sessionId,iterationData:B})}));if(P.status!==201)throw new Error("Failed to get next iteration");let L=await P.json();return this.log("[AIFallback] Received next action",L),this.sanitizeIterationResponse(L)}catch(P){throw this.log("[AIFallback] Error calling iterate",P),P}}sanitizeIterationResponse(i){var s;return this.fallbackType==="assertion"?{thought:i.thought,command:i.command,payload:i,changedVariables:i.changedVariables??[]}:{thought:i.thought,command:(s=i.action)==null?void 0:s.type,payload:i,changedVariables:i.changedVariables??[]}}async getPreviousActionOverview(){let i=await this.pageInteractor.handleFileChooserEvent();return{success:!this.hasPreviousActionFailed,...this.hasPreviousActionFailed?{failureEvent:"generalExecutionFailureError"}:{},...this.getPreviousWaitActionOverview(),...i,...await this.getPreviousGetMoreItemsActionOverview()}}getExecutedActions(){return this.executedSteps.filter(i=>i.type==="action")}async getPreviousGetMoreItemsActionOverview(){let i=this.getExecutedActions(),s=i[i.length-1];if((s==null?void 0:s.eventCode)!=="get_more_items"||!this.lastReducedDOM)return{};try{return await this.pageInteractor.addMoreItemsToDom(this.lastReducedDOM.window.document.body,s.getMoreItemsId),{interruptionEvent:"didRequestMoreItemsEvent",payload:{promptData:{reducedHTML:this.lastReducedDOM.serialize()},getMoreItemsId:s.getMoreItemsId}}}catch{return{}}}getPreviousWaitActionOverview(){var c;let i=this.getExecutedActions();if(((c=i[i.length-1])==null?void 0:c.eventCode)!=="wait")return{};let s=0;return i.slice().reverse().every(p=>p.eventCode==="wait"?(s++,!0):!1,0),{payload:{waitCount:s}}}async initSession(){let{apiKey:i,goal:s,thoughts:c}=this;if(this.log("[AIFallback] Calling init session...",{appName:i,goal:s,thoughts:c}),!i){let E="Missing Checksum API key, will not run AI fallback";throw Ixr(E),new Error(E)}if(this.mockServer){this.sessionId="mock-session-id";return}let p=this.getErrorFileContent(this.fallbackData.error),_={name:this.fallbackData.error.name??"Error",message:this.fallbackData.error.message,stack:this.fallbackData.error.stack},v={type:this.fallbackData.type,resolveSmartAssertion:this.withChecksumAI,storyTitle:s,testSuiteId:this.testSuiteId,testId:this.testId,thoughtsAndActions:{previous:c.slice(0,Math.max(c.length-1,0)).map(E=>({thought:E})),failing:{thought:c[c.length-1]},next:[]},testFileName:this.testFile.split("/").pop()??"",error:_,errorFileContent:p,matcherResult:this.getMatcherResultFileData(),assertionToActionData:this.fallbackData.type==="recovery"||this.fallbackData.type==="action"?this.fallbackData.assertionToActionData:void 0,arMode:this.arMode,overrideOptions:this.arOverrideOptions};this.aiFallbackAnalytics.aiFallbackStart({error:this.fallbackData.error.message,failedThought:this.getFailedThought()});try{let E=await Pje(async()=>await fetch(`${this.getAPIBaseURL()}/init`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:i,data:v,format:"json"})}));if(E.status!==201)throw new Error("Failed to init session after 3 retries");let{sessionId:D,arConfig:w}=await E.json();this.sessionId=D,this.arConfig=w,this.aiFallbackAnalytics.aiFallbackConfig({config:w}),this.log("[AIFallback] Session ID",this.sessionId)}catch(E){throw this.withChecksumAI&&E.message==="fetch failed"&&(this.checksumPage.step(Oje,async()=>{throw new Error(Oje)}),Ixr(Oje)),this.aiFallbackAnalytics.aiFallbackEnd({result:"failed",avgDuration:this.iterationSteps.length>0?this.iterationSteps.reduce((D,w)=>D+w.duration,0)/this.iterationSteps.length:0,failMessage:E==null?void 0:E.message}),this.log("[AIFallback] Error calling init session",E),E}}getReleaseIterationResultIfExists(i){if(this.fallbackType==="assertion"){if(i==="soft_assertion")return{result:"soft_assertion"}}else{if(i==="finish")return{result:"finish"};if(i==="fail")return{result:"failed"}}}translateExecutedActionToFallbackAction(i){return{type:"action",esraMetadata:i.esraMetadata,generatedLocator:i.locator,selector:i.selector,parentFramesSelectors:i.parentFramesSelectors,method:this.getMethodForPotentialAction(i),thought:i.thought}}getMethodForPotentialAction(i){return{name:this.actionEventCodeToMethodName[i.eventCode],args:e(()=>{switch(i.eventCode){case"click":case"double_click":return[{position:i.clickOffset}];case"drag_and_drop":return[this.pageInteractor.makeLocator(i.dropTarget.selector,i.dropTarget.parentFramesSelectors)];case"input":case"click_and_type":case"clear_and_type":case"selectoption":case"keystroke":case"navigation":return[this.pageInteractor.getActionFillValue(i,!1)];case"upload_files":return i.files;default:return}},"makeArgs")()}}getAPIBaseURL(){return this.API_BASE_DOMAIN+this.API_BASE_ROUTE}getAnalyticsPayload(){return{fallbackType:"ai",error:this.errorMessage,thought:this.getFailedThought(),sessionId:this.sessionId,steps:this.stepsPayload.map(i=>JSON.stringify(i))}}getFailedThought(){return this.thoughts[this.thoughts.length-1]}traceAIFallbackIterationNew(i){this.aiFallbackAnalytics.aiFallbackIterationResponse({duration:i.duration,command:i.command,thought:i.thought}),this.iterationSteps.push({thought:i.thought,command:i.command,duration:i.duration})}toString(){return`Checksum AI ("${this.getFailedThought()}")`}get fallbackType(){return this.fallbackData.type}get fallbackAnalyticsPayload(){return{previousThoughts:this.thoughts,iterationSteps:this.iterationSteps}}};e(T0e,"AIFallback"),T0e.alreadyTriggered=!1,T0e.currentChecksumId="0";Fge=T0e});var b3r,n6e,jIt=Ws(()=>{"use strict";yCe();kst();b3r=class b3r extends w0e{constructor(){super(...arguments);this.API_BASE_ROUTE="/client-api/runtime/esra-fallback"}init(i){let{apiKey:s,testId:c,apiURL:p,checksumId:_,fileName:v,timeout:E}=i;return this.data={...this.data,testId:c,checksumId:_,fileName:v},this.apiKey=s,p&&(this.API_BASE_DOMAIN=p.replace(/\/$/,"")),E&&(this.timeout=E),this.checksumRootFolder=process.env.CHECKSUM_ROOT_FOLDER??mon(hon(this.data.fileName),this.data.fileName),this}getRecoveryAttemptTitle(i){return`Checksum auto-heal: trying to locate the element using checksumSelector("${this.data.checksumId}")...`}async sendLog(i){let s=this.getLogPayload(i);try{fetch(`${this.getAPIBaseURL()}/log`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify(s)}).catch(c=>this.log("[ESRAFallback] Error sending log"))}catch(c){this.log("[ESRAFallback] Error sending log",c)}}getLogPayload(i){let s=process.env.CHECKSUM_TEST_SUITE_ID??"",{selector:c}=i,{checksumId:p,testId:_}=this.data;return this.logPayload={testSuiteId:s,testId:_,selector:c,checksumId:p,thought:this.thought},this.logPayload}async getMetadataForTestId(){return lon(this.checksumRootFolder,this.data.testId)}getAPIBaseURL(){return this.API_BASE_DOMAIN+this.API_BASE_ROUTE}};e(b3r,"MetadataBaseFallback");n6e=b3r});var _AlternateSelectorFallback,Fst,zyn=Ws(()=>{"use strict";fre();jIt();WS();_AlternateSelectorFallback=class _AlternateSelectorFallback extends n6e{constructor(){super(...arguments);this.timeout=5*1e3}init(r){return super.init(r),this}async resolve(params){var r;try{let{method,args}=params,{checksumId}=this.data,alternateLocators=[];try{let i=await this.getMetadataForTestId();if(!(checksumId in i)||!i[checksumId].alternateLocators)throw new Error(`No alternate selection metadata found for id ${checksumId}`);alternateLocators=i[checksumId].alternateLocators.locators}catch(i){throw super.log(`Could not read alternate selector metadata file, ${i.message}`),i}try{this.log("Resolving alternate selectors locators");let elementsMap=new Map;await Promise.all(alternateLocators.map(async locatorExpression=>{let locator=eval(FL(locatorExpression,"this.page"));try{await HS(locator.first().waitFor({bypassChecksum:!0}),5e3),(await HS(locator.elementHandles({bypassChecksum:!0}),1e3)).forEach(s=>{elementsMap.has(s)?elementsMap.set(s,elementsMap.get(s)+1):elementsMap.set(s,1)})}catch(i){return}}));let majorityElementHandle=(r=Array.from(elementsMap.entries()))==null?void 0:r.reduce((i,s)=>i[1]>s[1]?i:s)[0];if(!majorityElementHandle)throw this.errorMessage="No alternate element found",new Error(this.errorMessage);let totalElements=Array.from(elementsMap.values()).reduce((i,s)=>i+s,0),elementSelector=await this.evaluateWithChecksum(async({element:i})=>window.playwright.selector(i),{element:majorityElementHandle});this.log(`Resolved alternate selector: ${elementSelector}' With majority vote of ${elementsMap.get(majorityElementHandle)} out of ${totalElements} elements`),await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(this.page.locator(elementSelector),method,args));let fallbackResult={selector:elementSelector,generatedLocator:`locator("${elementSelector}")`,esraMetadata:void 0};return this.sendLog(fallbackResult),this.logPayload=this.logPayload.concat({mejorityVote:`${elementsMap.get(majorityElementHandle)}/${totalElements}`}),this.checksumPage.addErrorMessage(params.error,`${this.thought?`"${this.thought}" auto-recovered`:"Auto-recovered"} using alternative selector "${elementSelector}"`),{steps:[{type:"action",...fallbackResult}]}}catch(i){throw new Error(`Failed to execute compound selection fallback action: ${i.message}`)}}catch(i){this.errorMessage=i.message,this.log(this.errorMessage);return}}getAnalyticsPayload(){return{fallbackType:"alternative-selector",...this.logPayload??{checksumId:this.data.checksumId,error:this.errorMessage}}}toString(){return`Checksum alternative selector (${this.data.checksumId})`}};e(_AlternateSelectorFallback,"AlternateSelectorFallback");Fst=_AlternateSelectorFallback});var E3r,Nst,Hyn=Ws(()=>{"use strict";fre();jIt();E3r=class E3r extends n6e{constructor(){super(...arguments);this.timeout=5*1e3}init(i){return super.init(i),this}async resolve(i){try{let{method:s,args:c}=i,{checksumId:p}=this.data,_;try{let P=await this.getMetadataForTestId();if(!(p in P)||!P[p].compoundSelector)throw new Error(`No compound selection metadata found for id ${p}`);_=P[p].compoundSelector}catch(P){super.log("Could not read compound selector metadata file, ",P)}let v=await this.generateCompoundSelector(_);if(!(v!=null&&v.length))throw new Error("No compound locators found");let E=v[0],D=this.pageInteractor.makeLocator(E.selector),w=_.targetSelection.featuresMetadata.tag,B=["check","uncheck"].includes(s)&&w!=="input"?"click":s;try{await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(D,B,c));let P={selector:E.selector,generatedLocator:E.locator,esraMetadata:void 0};return this.sendLog(P),this.checksumPage.addErrorMessage(i.error,`${this.thought?`"${this.thought}" auto-recovered`:"Auto-recovered"} using alternative selector "${E.selector}"`),{steps:[{type:"action",...P}]}}catch(P){throw new Error(`Failed to execute compound selection fallback action: ${P.message}`)}}catch(s){this.errorMessage=s.message,this.log(s.message);return}}async generateCompoundSelector(i){let s=await this.evaluateWithChecksum(async c=>{var _;return await((_=window.checksum)==null?void 0:_.testGenerator.getCompoundSelector().selectFromMetadata(c))},i);return super.log("Resolved compound selector fallback to",s),s}getAnalyticsPayload(){return{fallbackType:"compound-selector",...this.logPayload??{checksumId:this.data.checksumId,error:this.errorMessage}}}toString(){return`Checksum compound selector fallback (${this.data.checksumId})`}};e(E3r,"CompoundSelectorFallback");Nst=E3r});var UIt,i6e=Ws(()=>{"use strict";UIt=(s=>(s[s.Element=0]="Element",s[s.VisibleElement=1]="VisibleElement",s[s.AtPointElement=2]="AtPointElement",s))(UIt||{})});var C3r,Pst,Wyn=Ws(()=>{"use strict";i6e();fre();yCe();WS();jIt();C3r=class C3r extends n6e{constructor(){super(...arguments);this.API_BASE_ROUTE="/client-api/runtime/esra-fallback";this.timeout=30*1e3;this.locatorTypeEnumToFieldMap={0:"element",1:"visibleElement",2:"atPointElement"}}init(i){return super.init(i),this.data.minSelectionScore=.7,this}async resolve(i){try{let{method:s,args:c}=i,{checksumId:p}=this.data,_=await this.getActionIdToESRAMap();if(!(p in _))throw this.errorMessage=`No ESRA metadata found for id ${p}`,new Error(this.errorMessage);let v=await this.getTestIdsForLocator(_[p].esraMetadata),{elementDataMap:E}=await this.getSelectors(v);if(this.didCancel)return;let D=await this.executeWithSelectors(Object.values(E),s,c);return D?(this.sendLog(D),this.checksumPage.addErrorMessage(i.error,`${this.thought?`"${this.thought}" auto-recovered`:"Auto-recovered"} using alternative selector "${D.selector}"`),{steps:[{type:"action",...D}]}):void 0}catch(s){this.errorMessage=s.message,this.log(this.errorMessage);return}}async getActionIdToESRAMap(){try{this.actionIdToESRAMap||(this.actionIdToESRAMap=await this.getMetadataForTestId())}catch(i){return super.log("Could not read ESRA metadata file, ",i),{}}return this.actionIdToESRAMap}async getSelectors(i){let s=[],c={};if(!i)return{selectors:s,elementDataMap:c};for(let p in Object.keys(UIt)){let _=i.testIds[this.locatorTypeEnumToFieldMap[p]];if(!_)continue;let v=`[data-checksum-testid="${_}"]`;s.push(v),c[v]={...i.elementData[this.locatorTypeEnumToFieldMap[p]],selector:i.selectors[this.locatorTypeEnumToFieldMap[p]],parentFramesSelectors:i.parentFramesSelectors[this.locatorTypeEnumToFieldMap[p]]}}for(let p in Object.keys(UIt)){let _=i.selectors[this.locatorTypeEnumToFieldMap[p]];_&&(s.push(_),c[_]={...i.elementData[this.locatorTypeEnumToFieldMap[p]],selector:_})}return this.log("Selectors for ESRA metadata:",s),{selectors:s,elementDataMap:c}}async getTestIdsForLocator(i,s={}){let{cachedSelector:c=void 0,retriesLeft:p=3,retryMaxTimeout:_=3e3,staticMetadata:v}=s,E=await this.evaluateWithChecksum(async({esraMetadata:D,cachedSelector:w,staticMetadata:B,minSelectionScore:P})=>await window.checksum.testGenerator.getMatchingElementSelectionData(D,{minSelectionScore:P,cachedSelector:w,staticMetadata:B}),{esraMetadata:i,cachedSelector:c,staticMetadata:v,minSelectionScore:this.data.minSelectionScore});if(!E){if(p>0)return this.log("[getTestIdsForLocator] no match found, waiting and retrying..."),await Mb(_/p),this.getTestIdsForLocator(i,{...s,retriesLeft:p-1});this.errorMessage="failed to locate",this.log(`[getTestIdsForLocator] ${this.errorMessage}`)}return E}async executeWithSelectors(i,s,c){for(let{selector:p,tag:_,parentFramesSelectors:v}of i){let E=this.pageInteractor.makeLocator(p,v);this.log(`Running with selector=${p};${v!=null&&v.length?` parentFramesSelectors=${v};`:""}`);let D=!1;["check","uncheck"].includes(s)&&_!=="input"&&(D=!0);let w=this.generateSelectionDataForSelector(p,v);if(await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(E,D?"click":s,c))===!1){this.log("Fallback selector timeout");continue}return w}}async generateSelectionDataForSelector(i,s){let{generateSelectionData:c}=this.options;if(!c)return{selector:i,generatedLocator:void 0,esraMetadata:void 0,parentFramesSelectors:void 0};try{let p=await _on(this.page,i,s);if(!p)throw this.errorMessage=`[generateSelectionDataForSelector] Failed to generate selection data for selector ${i}`,new Error(this.errorMessage);return p}catch(p){throw this.log(p.message),p}}getAnalyticsPayload(){return{fallbackType:"esra",...this.logPayload??{checksumId:this.data.checksumId,error:this.errorMessage}}}toString(){return`Checksum selector (${this.data.checksumId})`}};e(C3r,"ESRAfallback");Pst=C3r});var D3r,Bst,Gyn=Ws(()=>{"use strict";fre();kst();D3r=class D3r extends w0e{init(){return this}canResolve(r){return["check","uncheck"].includes(r.method)}getRecoveryAttemptTitle(r){return"Checksum auto-heal: Trying force click for check/uncheck action..."}async resolve(r){try{let{locator:i,method:s}=r;if(!i)return;let{args:c}=r;if(!["check","uncheck"].includes(s))return;let p=!1;for(let v of Array.from(c))if(typeof v=="object"){v.force=!0,p=!0;break}if(p||(c=Array.from(c),c.push({force:!0})),await this.execute(i,s,c)!==!1)return{steps:[{type:"action",selector:i._selector,generatedLocator:void 0,esraMetadata:void 0}]};this.log("Locator timed out, ")}catch(i){this.log("initiateFallbackSequence exception, ",i);return}}get shouldSendToAnalytics(){return!1}toString(){return"Force click check/uncheck"}};e(D3r,"ForceFallback");Bst=D3r});var S3r,Ost,Kyn,Yyn,Xyn,Zyn,GPi,w3r,QIt,e2n=Ws(()=>{"use strict";ITt();S3r=require("@playwright/test"),Ost=nd(require("fs")),Kyn=nd(require("fs/promises")),Yyn=nd(require("readline")),Xyn=nd(require("path")),Zyn=nd(FTt());yre();cT();GPi=1e3,w3r=class w3r extends oge{constructor(i,s,c={headless:!0,logPerformance:!1,timestampBatchingEnabled:!1,sortByTimestamp:!1,taskTimeout:24e4,debugPort:void 0,frameMsgBrokerRegisterName:void 0,recordRRwebEventsToFile:!1,recordRRwebEventsToFilePath:"events.json"}){super(i,s,c);this.options=c;this.rrwebEventsBuffer="";this.didPostProcessRRwebEvents=!1;this.postProcessRRwebEvents=(0,Zyn.debounce)(async()=>{return;try{let s=Ost.default.createReadStream(this.options.recordRRwebEventsToFilePath),c=Yyn.default.createInterface({input:s,crlfDelay:1/0});for await(let p of c)if(p.trim()!=="")try{let _=JSON.parse(p);Array.isArray(_)?i.push(..._):i.push(_)}catch(_){KA(`Failed to parse line: ${p}`,_)}Ost.default.writeFileSync(this.options.recordRRwebEventsToFilePath.replace(/([^\/]+)$/,"postprocessed.$1"),JSON.stringify(i)),this.didPostProcessRRwebEvents=!0}catch(s){KA("Error post-processing RRweb events",s)}},100,{leading:!0,trailing:!0});if(this.options.recordRRwebEventsToFile){let p=this.options.recordRRwebEventsToFilePath,_=Xyn.default.dirname(p);Ost.default.mkdirSync(_,{recursive:!0}),Ost.default.writeFileSync(p,"")}}setTimeMachineBrowserContext(i){this.timeMachineBrowserContext=i}getTimeMachineBrowserContext(){return this.timeMachineBrowserContext}async makeBrowserContext(){S3r.chromium._checksumInternal=!0;let i=await S3r.chromium.launch({headless:this.options.headless,args:I_.useRemoteDebugging.enabled?["--remote-debugging-port=4444"]:[]});return i._checksumInternal=!0,this.timeMachineBrowserContext=await i.newContext({bypassCSP:!0}),this.timeMachineBrowserContext._checksumInternal=!0,this.timeMachineBrowserContext.tracing.startChunk=async()=>{},this.timeMachineBrowserContext.tracing.stop(),this.timeMachineBrowserContext.tracing.stop=async()=>{},this.timeMachineBrowserContext.tracing.stopChunk=async()=>{},this.timeMachineBrowserContext}async makeFrame(){let i=await this.timeMachineBrowserContext.newPage();i._checksumInternal=!0;let s=i.mainFrame();return s._checksumInternal=!0,s}async rrwebEventHandler(i){let s=await super.rrwebEventHandler(i);if(this.options.recordRRwebEventsToFile){if(this.rrwebEventsBuffer+=s+`
|
|
616
616
|
`,this.rrwebEventsBuffer.length>GPi){let c=this.rrwebEventsBuffer;this.rrwebEventsBuffer="",this.flushRRwebEventsToFile(c)}return s}}async flushRRwebEventsToFile(i){if(this.options.recordRRwebEventsToFile){i??(i=this.rrwebEventsBuffer);try{await Kyn.default.appendFile(this.options.recordRRwebEventsToFilePath,i)}catch(s){KA(s)}}}getRRwebFilePath(){return this.options.recordRRwebEventsToFilePath}};e(w3r,"RuntimeTimeMachine");QIt=w3r});var t2n,k3r,Lje,T3r,I3r=Ws(()=>{"use strict";WS();fre();yre();t2n=!1,k3r=class k3r{constructor(r,i,s){this.frame=r;this.base=i;this.getAnalytics=s;this.LOCATORS_TIMEOUT=t2n?9999999:5e3;this.HANDLES_TIMEOUT=t2n?9999999:5e3;this.HANDLES_INTERVAL=300;this.locatorsChain=[];this.base||(this.base=this.frame)}setBase(r){this.base=r}setAnalytics(r){this.getAnalytics=r}init(...r){return this.sanitizeArgs(...r),new Proxy(this,{get:e((i,s)=>s==="setBase"?function(...c){this.setBase(c[0])}.bind(this):s==="setAnalytics"?function(...c){this.setAnalytics(c[0])}.bind(this):this.handleLocatorChain(i,s),"get")})}getLocatorSelector(r){if(r)return r._selector}sanitizeArgs(...r){if(r.length===1&&typeof r[0]=="object"){if(!r[0].anchors||typeof r[0].anchors!="function")throw new Error("Invalid compound selector format. Object must contain anchors property with a method value");this.anchorLocatorMethod=r[0].anchors,this.targetLocatorMethod=r[0].target;return}if(typeof r[0]!="function")throw new Error("Invalid compound selector format. First argument must be an object or a function");if(this.anchorLocatorMethod=r[0],r.length===2){if(typeof r[1]!="function")throw new Error("Invalid compound selector format. Second argument must be a function");this.targetLocatorMethod=r[1]}}async resolveLocator(){if(this.resolvedLocator)return this.resolvedLocator;KA("Waiting for locators..");let r=this.getLocatorsFromMethods();if(r.find(v=>!("_selector"in v)))throw new Error("Can't resolve at least one locator, make sure anchors and target are valid locators or strings");try{await Promise.all(r.map(async v=>HS(v.first().waitFor({bypassChecksum:!0}),this.LOCATORS_TIMEOUT,"Waiting for compound selector locators timeout")))}catch(v){throw new Error(`Error while waiting for locators - ${v.message}`)}let i=await HS(this.getElementHandles(r),this.HANDLES_TIMEOUT);KA(`Resolved to ${T3r(i)} elements from ${r.length} locators`);let s=this.getLocatorSelector(this.getLocatorsFromMethods(!1,!0,this.frame)[0]),c=await this.frame.evaluate(async({handles:v,targetSelector:E})=>window.checksum.testGenerator.getCompoundSelector().select(v,E),{handles:i,targetSelector:s});if(!c||c.length===0)throw new Error("Could not generate selectors from handles");KA(`Resolved compound selector to ${c.length} selectors`);let p=this.getBase(),_=p.locator(c[0]);return c.slice(1,50).forEach(v=>{_=_.or(p.locator(v))}),this.locatorsChain.length&&this.locatorsChain.forEach(({name:v,args:E})=>{_=_[v](...E)}),KA(`Compound locator selector: ${this.getLocatorSelector(_)}`),this.resolvedLocator=_,_}handleLocatorChain(r,i){if(typeof i=="symbol")return;if(i==="constructor")return e(function(..._){return this[i](..._)},"Locator");if(i==="toString")return()=>this.toString();let s=e(()=>new Proxy(r,{get:e((p,_)=>p.handleLocatorChain(p,_),"get")}),"createLocatorProxy");return i==="valueOf"?e(function(){return s()},"Locator"):i==="then"?(p,_)=>{this.resolveLocator().then(v=>p(v)).catch(_)}:Object.values([...Object.values(h0e),...Object.values(YMe)]).includes(i)?e(function(..._){return r.locatorsChain.push({name:i,args:_}),s()},"Locator"):e(async function(..._){return this.handleAction(i,_)},"Locator").bind(this)}async handleAction(r,i){var s,c;try{if(typeof r=="symbol")return;if(!this.anchorLocatorMethod)throw new Error("Compound selection is missing anchor locators");let p=await this.resolveLocator();return this.frame.executeLocatorAction?await this.frame.executeLocatorAction(p,r,i):await p[r](...i)}catch(p){throw KA(`Failed to execute compound selection action: ${p}`),(c=(s=this.getAnalytics)==null?void 0:s.call(this))==null||c.compoundSelectionFailure({error:p.toString(),selector:this.toString()}),p}}async getElementHandles(r){KA("Resolving compound selector elements");let i,s,c,p,_,v=e(()=>{_=2},"resetSameHandlesCount");do i=s,s=[],await Promise.all(r.map(async E=>{let D=await E.elementHandles({bypassChecksum:!0});if(D.length===0)throw new Error(`No elements found for locator: ${this.getLocatorSelector(E)}`);s.push(D)})),c=T3r(s),p=i?T3r(i):0,KA(`Handles itteration, previous: ${i?p:"-"}, current: ${c}`),p!==c&&v(),await Mb(this.HANDLES_INTERVAL);while(!i||p!==c||--_>0);return s}getLocatorsFromMethods(r=!0,i=!0,s=this.getBase()){return(r?this.anchorLocatorMethod(s):[]).concat(i&&this.targetLocatorMethod?[this.targetLocatorMethod(s)]:[]).map(c=>typeof c=="string"?s.getByText(c):c)}getBase(){return this.base}toString(){var r;return`CompoundSelection(${this.resolvedLocator?this.getLocatorSelector(this.resolvedLocator):`${this.anchorLocatorMethod.toString()}, ${(r=this.targetLocatorMethod)==null?void 0:r.toString()})`})`}};e(k3r,"CompoundSelectorLocator");Lje=k3r,T3r=e(n=>n.reduce((r,i)=>r+i.length,0),"countHandleElements")});var F3r,r2n,KPi,N3r,Mje,P3r=Ws(()=>{"use strict";F3r=require("path");WS();bRe();r2n=require("fs"),KPi=!0,N3r=class N3r{constructor(r){this.options=r;this.navigatingFrames={};this.trackedFramesGuid=[];this.frameNavigationPromises={};this.onFrameNavigated=e(async r=>{let i=nw(r);if(this.trackedFramesGuid.includes(i))return this.frameNavigationPromises[i]=new Promise(async s=>{await this.loadScript(r),s()}),this.frameNavigationPromises[i]},"onFrameNavigated");this.loadScript=e(async(r,{retriesLeft:i=3,retryWaitMS:s=2e3,useWrapper:c=!0}={})=>{var E,D;if(c&&this.scriptLoadWrapper)return this.scriptLoadWrapper(()=>this.loadScript(r,{retriesLeft:i,retryWaitMS:s,useWrapper:!1}),r);if(!this.addScriptTagOptions){this.log.warn("[InjectedScriptManager] addScriptTagOptions not set, skipping loadScript");return}if(this.isFrameClosed(r))return;let p=!1;try{p=this.scriptLoadCheck?await((E=this.scriptLoadCheck)==null?void 0:E.call(this,r)):!1}catch{}if(p||this.isFrameClosed(r))return;this.options.scriptAddWait&&(this.log.log(`Waiting ${this.options.scriptAddWait}[ms] before adding script...`),await Mb(this.options.scriptAddWait),this.log.log("Done waiting before adding script"));try{await r.addScriptTag(await this.makeInjectedScriptOptionsForAddScriptTag())}catch(w){if(i>0)return this.log.warn(`[InjectedScriptManager] Failed to add script to frame ${nw(r)}, trying again in ${s/1e3} seconds, ${i-1} retries left.`,w.message),await Mb(s),this.loadScript(r,{retriesLeft:i-1,retryWaitMS:s,useWrapper:c});throw w}let _=nw(r),v=Date.now().toString(36)+Math.random().toString(36).substr(2);if(this.navigatingFrames[_]=v,this.options.scriptInitWait&&(this.log.log(`Waiting ${this.options.scriptInitWait}[ms] before onScriptLoad...`),await Mb(this.options.scriptInitWait),this.log.log("Done waiting before onScriptLoad")),!this.isFrameClosed(r)){if(this.navigatingFrames[_]&&this.navigatingFrames[_]!==v)return this.log.log("Page navigated again, waiting on new promise..."),this.frameNavigationPromises[_];try{await((D=this.scriptLoadCallback)==null?void 0:D.call(this,r))}catch(w){this.log.error("[WebDriver] onScriptLoad error",w)}}},"loadScript");this.log=new Proxy(console,{get:e((r,i)=>(...s)=>{if(!this.options.silenceLogs)return r[i].apply(r,s)},"get")});this.addScriptTagOptions=this.makeFrameInjectedScriptOptions()}setScriptLoadCallback(r){return this.scriptLoadCallback=r,this}setScriptLoadCheck(r){return this.scriptLoadCheck=r,this}setScriptLoadWrapper(r){return this.scriptLoadWrapper=r,this}async addTrackedFrame(r,i=!0){let s="mainFrame"in r?r.mainFrame():r,c=nw(s);if(this.trackedFramesGuid.includes(c)||this.trackedFramesGuid.push(c),i)return this.onFrameNavigated(s)}getNavigationPromise(r){if(!r){this.log.warn("[InjectedScriptManager] getNavigationPromise called with undefined argument");return}let i=typeof r=="string"?r:"mainFrame"in r?nw(r.mainFrame()):nw(r);return this.frameNavigationPromises[i]}makeFrameInjectedScriptOptions(){switch(this.options.scriptSource){case"file":return this.options.scriptFile?{path:this.options.isScriptFileAbsolute?this.options.scriptFile:(0,F3r.join)(process.cwd(),this.options.scriptFile)}:void 0;case"url":return this.options.scriptURL?{url:this.options.scriptURL}:void 0;default:return}}async makeInjectedScriptOptionsForAddScriptTag(){if(this.options.scriptSource==="url"&&this.addScriptTagOptions.url&&KPi){let i=await(await fetch(this.addScriptTagOptions.url)).text(),s=(0,F3r.join)(process.cwd(),"checksumlib.js");return(0,r2n.writeFileSync)(s,i),{path:s}}return this.addScriptTagOptions}isFrameClosed(r){return r.isDetached()||r.page().isClosed()}};e(N3r,"InjectedScriptManager");Mje=N3r});var n2n=Ws(()=>{"use strict"});var L3r,qIt,M3r,B3r,j3r,O3r,U3r,R3r,VIt,$It,i2n=Ws(()=>{"use strict";WS();n2n();L3r=class L3r{constructor(r){this.options=r}async handleError(r,i,s){let c=`Error in ${i} action during ${r} execution: ${s.message}`;throw new Error(c)}async guardedExecute(){try{return await(this.options.timeout!=null?HS(this.execute(),this.options.timeout,"Execution timeout"):this.execute())}catch(r){return this.handleError(this.options.method,this.constructor.name,r)}}};e(L3r,"Action");qIt=L3r,M3r=class M3r extends qIt{async execute(){return this.options.method in this.options.locator?this.options.locator[this.options.method](...this.options.args):this.options.locator}};e(M3r,"PlaywrightAction");B3r=M3r,j3r=class j3r extends qIt{constructor(i,s){super(i);this.pageInteractor=s}};e(j3r,"APIAction");O3r=j3r,U3r=class U3r extends O3r{constructor(r,i){super(r,i.pageInteractor)}async execute(){try{let{locator:r,args:i}=this.options,[s,c]=i,p=await r.screenshot({timeout:3e4}),v=(await this.pageInteractor.getTextDetection(p)).getRectangleByTextAndSizeRanking(s,c);if(!v)throw new Error("No matching text found");await r.click({position:v.center})}catch(r){throw new Error(`Error in canvas click action: ${r.message}`)}}};e(U3r,"CanvasClickAction");R3r=U3r,VIt=class VIt{static createAction(r,i){return r.method in this.customActionMap?new this.customActionMap[r.method]({...r,timeout:15e3},i):new B3r(r)}};e(VIt,"ActionFactory"),VIt.customActionMap={canvasClick:R3r};$It=VIt});var zIt,JIt,a2n=Ws(()=>{"use strict";fre();yre();I3r();i2n();VSr();zIt=class zIt{constructor(r,i,s,c,p,_,v){this.frame=r;this.checksumPage=i;this.isReplMode=s;this.config=c;this.injectedScriptManager=p;this.getPageInteractor=_;this.onExecutionError=v;this.locatorStack=[];this.setFrameProxy(),this.checksumClient=new Dje({apiURL:this.config.apiURL,apiKey:this.config.apiKey})}static init(r,i,s,c,p,_,v=!1){return new zIt(r,i,v,_,s,c,p).proxy}setFrameProxy(){this.proxy=new Proxy(this,{get:e(function(i,s){return i.handleFrameMethod(s)},"get")})}handleFrameMethod(r){if(typeof r!="symbol")return typeof this[r]=="function"?r==="constructor"?this[r]:this[r].bind(this):[...Object.values(h0e),...Object.values(YMe)].includes(r)?(this.pushToLocatorStack([{type:r,base:this.frame}]),e(function(s,c){try{return this.executeLocator(s,c)}catch(p){throw this.popLocatorChain(),p}},"Locator").bind(this)):this.frame[r]}page(){return this.checksumPage}compoundSelection(...r){var i;try{let s=this.locatorStack.length?(i=this.getCurrentLocatorInChain())==null?void 0:i.base:this.proxy;return new Lje(this.proxy,s).init(...r)}catch{throw new Error("Failed generating compound selector")}}async wrapInternalSteps(r,i=this.frame){try{return i._checksumInternal=!0,await r()}finally{i._checksumInternal=!1}}get navigationPromise(){return this.injectedScriptManager.getNavigationPromise(this.frame)}pushToLocatorStack(r){this.locatorStack.push(r)}getCurrentLocatorChain(){return this.locatorStack.length||this.locatorStack.push([]),this.locatorStack[this.locatorStack.length-1]}popLocatorChain(){return this.locatorStack.pop()}getCurrentLocatorInChain(){let r=this.getCurrentLocatorChain();return r==null?void 0:r[r.length-1]}getLocator(r,i){let s=this.getCurrentLocatorInChain();return s.base[s.type](r,i)}executeLocator(r,i){try{KA(`
|
|
617
617
|
Executing locator ${this.getCurrentLocatorInChain().type} with ${typeof r=="string"?`selector ${r}`:"locator"}`);try{r&&typeof r=="object"&&"has"in r&&this.popLocatorChain()}catch{}let s=this.getLocator(r,i);return new Proxy(s,{get:e((c,p)=>this.getLocatorMethod(s,c,p),"get")})}catch(s){KA("Failed to locate",s)}}getLocatorMethod(r,i,s){return s==="then"?this.handleThen(r,i,s):s==="catch"?this.handleCatch(r,i):s==="finally"?this.handleFinally(r,i):s==="constructor"?e(function(...p){return this.popLocatorChain(),i.constructor(...p)},"Locator"):s in i&&typeof i[s]!="function"||s===Symbol.toPrimitive||s in Object||s==="evaluate"?(this.popLocatorChain(),i[s]):s==="compoundSelection"?function(...c){let p=this.compoundSelection(...c);return p.setBase(r),p}.bind(this):[...Object.values(h0e),...Object.values(YMe)].includes(s)?["or","and"].includes(s)?(KA("'Or' and 'And' locator are not supported, will execute normally"),this.popLocatorChain(),i[s]):(this.getCurrentLocatorChain().push({type:s,base:r}),e(function(...p){return this.executeLocator(p[0],p[1])},"Locator").bind(this)):s==="page"?()=>(this.popLocatorChain(),this.proxy.page()):e(async function(...p){let _=await this.executeLocatorAction(r,s,p);return this.popLocatorChain(),_},"Locator").bind(this)}async executeLocatorAction(r,i,s){var E;if(s&&Array.from(s).some(D=>(D==null?void 0:D.bypassChecksum)===!0))return r[i](...s);let c=r._selector;KA("Executing",i,c);let p=i==="_expect"?"assertion":"action",_=((E=this.config.options)==null?void 0:E.consecutiveActionDelay)??100;_>0&&p==="action"&&this.lastLocatorActionType==="action"&&(KA("Adding minimal wait between consecutive actions..."),await new Promise(D=>setTimeout(D,_))),this.lastLocatorActionType=p,KA("Running initial locator...");let v;try{return this.navigationPromise&&await this.navigationPromise,await this.wrapInternalSteps(async()=>{try{KA("[executeLocatorAction] waitForFunction"),await this.frame.waitForFunction(()=>!!window.checksum,{timeout:5e3})}catch{KA("[executeLocatorAction] checksum libs not loaded")}}),await $It.createAction({locator:r,method:i,args:s,timeout:this.getLocatorActionTimeout(p,i,s)},{api:this.checksumClient,pageInteractor:this.getPageInteractor()}).guardedExecute();v=new Error("Locator action error")}catch(D){KA("Failed initial execution. Exception:",D.message),v=D}if(p==="action"&&this.onExecutionError)return this.onExecutionError({error:v,locator:r,method:i,args:s},this.frame);throw v}setExpectConfiguration(r=void 0){this.expectConfiguration=r}getLocatorActionTimeout(r,i,s=[]){var c;if(this.isReplMode)return null;try{if(r==="assertion"){let v=this.getAssertionTimeout(s);return KA(`Assertion timeout set to ${v}`),v}let p=["fill","dragTo"].includes(i)?1:0,_=(c=s[p])==null?void 0:c.timeout;return isNaN(_)?3e4:_}catch{return 3e4}}getAssertionTimeout(r=[]){var c,p,_,v,E;let i=(c=r[1])==null?void 0:c.timeout;if(i!==void 0)return i;if(((p=this.expectConfiguration)==null?void 0:p.timeout)!==void 0)return(_=this.expectConfiguration)==null?void 0:_.timeout;let s=(E=(v=this.testInfo._projectInternal)==null?void 0:v.expect)==null?void 0:E.timeout;return s!==void 0?s:3e4}handleThen(r,i,s){return(c,p)=>Promise.resolve(r).then(_=>{let v=c?c(_):_;return v instanceof Promise?v:this.getLocatorMethod(v,i,s)},_=>{if(p)return p(_);throw _})}handleCatch(r,i){return s=>Promise.resolve(r).catch(c=>{if(s)return s(c);throw c})}handleFinally(r,i){return s=>Promise.resolve(r).finally(s)}};e(zIt,"ChecksumFrame");JIt=zIt});var s2n,HIt,jje,Q3r=Ws(()=>{"use strict";s2n=nd(require("path"));fre();yCe();I3r();P3r();a2n();yre();cT();HIt=class HIt{constructor(r,i,s,c,p,_){this.page=r;this.config=s;this.getPageInteractor=c;this.injectedScriptManager=p;this._frames={};this.isVTG=!!process.env.CHECKSUM_VTG_TEST_FILE_RUN_CONFIG;this._isChecksumPage=!0;var v,E;this._context=i,this.setPageProxy(),this.injectedScriptManager||(this.injectedScriptManager=new Mje({scriptFile:I_.checksumScript.path,scriptSource:I_.checksumScript.source,scriptURL:I_.checksumScript.url,isScriptFileAbsolute:!0,silenceLogs:!I_.isDevMode,scriptInitWait:(v=s==null?void 0:s.options)==null?void 0:v.browserScriptInitWait,scriptAddWait:(E=s==null?void 0:s.options)==null?void 0:E.browserScriptAddWait})),this.registerPageEvents(),this.page.frames().forEach(D=>this.registerFrame(D)),_&&(this.variableStore=_.variableStore)}static makePage(r,i,s,c){let p=o2n();return new HIt(r,c,p,()=>i,s,void 0).proxy}async registerFrame(r){var c;let i=this.getFrameGuid(r);if(r===this.page.mainFrame()&&(this.mainFrameGuid=i),this._frames[i])return;let s=JIt.init(r,this.proxy,this.injectedScriptManager,this.getPageInteractor,(c=this.onExecutionError)==null?void 0:c.bind(this),this.config);this._frames[i]=s}async onExecutionError(r){throw r.error}getFrameGuid(r){return r._guid}getPageGuid(r){return r._guid}registerPageEvents(){this.page.on("frameattached",async r=>{this.registerFrame(r)})}setPageProxy(){this.proxy=new Proxy(this,{get:e(function(i,s){return i.getPageMethod(s)},"get")})}getPageMethod(r){if(typeof this[r]=="function")return r==="constructor"?this[r]:this[r].bind(this);switch(r){case"pageInteractor":return this.getPageInteractor();case"variableStore":return this.variableStore;case"_isChecksumPage":return this._isChecksumPage}return Object.values(h0e).includes(r)?e(function(s,c){try{return this.mainFrame()[r](s,c)}catch(p){throw p}},"Page").bind(this):this.page[r]}mainFrame(){var r;return(r=this._frames)==null?void 0:r[this.mainFrameGuid]}frames(){return Object.values(this._frames)}context(){return this._context}getPage(r){return this._context.getPage(r)}getFrame(r){if(!this.page.frames().find(s=>this.getFrameGuid(s)===r))throw new Error(`Frame with guid ${r} not found`);return this._frames[r]}async waitForDialog(r){try{return this.getPageInteractor().waitForDialog(!0,r)}catch(i){throw new Error(`Failed to handle native dialog: ${i}`)}}async reauthenticate(r){try{await this.getPageInteractor().reauthenticate(r,this.proxy)}catch(i){throw new Error(`Failed to reauthenticate: ${i}`)}}resolveAssetsFolder(r){return r.map(i=>s2n.join(Wit(Kte()),i))}compoundSelection(...r){try{return new Lje(this.mainFrame()).init(...r)}catch{throw new Error("Failed generating compound selector")}}get navigationPromise(){return this.injectedScriptManager.getNavigationPromise(this.page)}setExpectConfiguration(r=void 0){this.expectConfiguration=r,Object.values(this._frames).forEach(i=>i.setExpectConfiguration(r))}};e(HIt,"ChecksumPage");jje=HIt});var c2n,$C,VC=Ws(()=>{c2n=Object.defineProperty,$C=e((n,r)=>{let i={};for(var s in n)c2n(i,s,{get:n[s],enumerable:!0});return r||c2n(i,Symbol.toStringTag,{value:"Module"}),i},"__exportAll")});function a6e(n){return!!(n&&typeof n=="object"&&"type"in n&&n.type==="tool_call")}function u2n(n){return!!(n&&typeof n=="object"&&"toolCall"in n&&n.toolCall!=null&&typeof n.toolCall=="object"&&"id"in n.toolCall&&typeof n.toolCall.id=="string")}var Uje,Rst,WIt=Ws(()=>{e(a6e,"_isToolCall");e(u2n,"_configHasToolCallId");Rst=(Uje=class extends Error{output;constructor(r,i){super(r),this.output=i}},e(Uje,"ToolInputParsingException"),Uje)});var p2n=$r((R9a,l2n)=>{"use strict";l2n.exports=function(n,r){if(typeof n!="string")throw new TypeError("Expected a string");return r=typeof r>"u"?"_":r,n.replace(/([a-z\d])([A-Z])/g,"$1"+r+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+r+"$2").toLowerCase()}});var y2n=$r((L9a,q3r)=>{"use strict";var YPi=/[\p{Lu}]/u,XPi=/[\p{Ll}]/u,f2n=/^[\p{Lu}](?![\p{Lu}])/gu,m2n=/([\p{Alpha}\p{N}_]|$)/u,h2n=/[_.\- ]+/,ZPi=new RegExp("^"+h2n.source),d2n=new RegExp(h2n.source+m2n.source,"gu"),_2n=new RegExp("\\d+"+m2n.source,"gu"),eBi=e((n,r,i)=>{let s=!1,c=!1,p=!1;for(let _=0;_<n.length;_++){let v=n[_];s&&YPi.test(v)?(n=n.slice(0,_)+"-"+n.slice(_),s=!1,p=c,c=!0,_++):c&&p&&XPi.test(v)?(n=n.slice(0,_-1)+"-"+n.slice(_-1),p=c,c=!1,s=!0):(s=r(v)===v&&i(v)!==v,p=c,c=i(v)===v&&r(v)!==v)}return n},"preserveCamelCase"),tBi=e((n,r)=>(f2n.lastIndex=0,n.replace(f2n,i=>r(i))),"preserveConsecutiveUppercase"),rBi=e((n,r)=>(d2n.lastIndex=0,_2n.lastIndex=0,n.replace(d2n,(i,s)=>r(s)).replace(_2n,i=>r(i))),"postProcess"),g2n=e((n,r)=>{if(!(typeof n=="string"||Array.isArray(n)))throw new TypeError("Expected the input to be `string | string[]`");if(r={pascalCase:!1,preserveConsecutiveUppercase:!1,...r},Array.isArray(n)?n=n.map(p=>p.trim()).filter(p=>p.length).join("-"):n=n.trim(),n.length===0)return"";let i=r.locale===!1?p=>p.toLowerCase():p=>p.toLocaleLowerCase(r.locale),s=r.locale===!1?p=>p.toUpperCase():p=>p.toLocaleUpperCase(r.locale);return n.length===1?r.pascalCase?s(n):i(n):(n!==i(n)&&(n=eBi(n,i,s)),n=n.replace(ZPi,""),r.preserveConsecutiveUppercase?n=tBi(n,i):n=i(n),r.pascalCase&&(n=s(n.charAt(0))+n.slice(1)),rBi(n,s))},"camelCase");q3r.exports=g2n;q3r.exports.default=g2n});function A2n(n,r){return(r==null?void 0:r[n])||(0,v2n.default)(n)}function x2n(n,r,i){let s={};for(let c in n)Object.hasOwn(n,c)&&(s[r(c,i)]=n[c]);return s}var v2n,nBi,b2n=Ws(()=>{v2n=nd(p2n(),1),nBi=nd(y2n(),1);e(A2n,"keyToJson");e(x2n,"mapKeys")});function aBi(n){return"lc"in n||Object.keys(n).length===1&&"__lc_escaped__"in n}function sBi(n){return{[iBi]:n}}function oBi(n){return n!==null&&typeof n=="object"&&"lc_serializable"in n&&typeof n.toJSON=="function"}function cBi(n){var i;let r;return n!==null&&typeof n=="object"?"lc_id"in n&&Array.isArray(n.lc_id)?r=n.lc_id:r=[((i=n.constructor)==null?void 0:i.name)??"Object"]:r=[typeof n],{lc:1,type:"not_implemented",id:r}}function GIt(n,r=new WeakSet){if(n!==null&&typeof n=="object"&&!Array.isArray(n)){if(r.has(n))return cBi(n);if(oBi(n))return n;r.add(n);let i=n;if(aBi(i))return r.delete(n),sBi(i);let s={};for(let[c,p]of Object.entries(i))s[c]=GIt(p,r);return r.delete(n),s}return Array.isArray(n)?n.map(i=>GIt(i,r)):n}var iBi,E2n=Ws(()=>{iBi="__lc_escaped__";e(aBi,"needsEscaping");e(sBi,"escapeObject");e(oBi,"isSerializableLike");e(cBi,"createNotImplemented");e(GIt,"escapeIfNeeded")});function C2n(n){return Array.isArray(n)?[...n]:{...n}}function uBi(n,r){let i=C2n(n);for(let[s,c]of Object.entries(r)){let[p,..._]=s.split(".").reverse(),v=i;for(let E of _.reverse()){if(v[E]===void 0)break;v[E]=C2n(v[E]),v=v[E]}v[p]!==void 0&&(v[p]={lc:1,type:"secret",id:[c]})}return i}function $3r(n){let r=Object.getPrototypeOf(n);return typeof n.lc_name=="function"&&(typeof r.lc_name!="function"||n.lc_name()!==r.lc_name())?n.lc_name():n.name}var QTe,Nge,Lst=Ws(()=>{VC();b2n();E2n();e(C2n,"shallowCopy");e(uBi,"replaceSecrets");e($3r,"get_lc_unique_name");Nge=(QTe=class{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,$3r(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(r,...i){this.lc_serializable_keys!==void 0?this.lc_kwargs=Object.fromEntries(Object.entries(r||{}).filter(([s])=>{var c;return(c=this.lc_serializable_keys)==null?void 0:c.includes(s)})):this.lc_kwargs=r??{}}toJSON(){if(!this.lc_serializable)return this.toJSONNotImplemented();if(this.lc_kwargs instanceof QTe||typeof this.lc_kwargs!="object"||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let r={},i={},s=Object.keys(this.lc_kwargs).reduce((v,E)=>(v[E]=E in this?this[E]:this.lc_kwargs[E],v),{});for(let v=Object.getPrototypeOf(this);v;v=Object.getPrototypeOf(v))Object.assign(r,Reflect.get(v,"lc_aliases",this)),Object.assign(i,Reflect.get(v,"lc_secrets",this)),Object.assign(s,Reflect.get(v,"lc_attributes",this));Object.keys(i).forEach(v=>{let E=this,D=s,[w,...B]=v.split(".").reverse();for(let P of B.reverse()){if(!(P in E)||E[P]===void 0)return;(!(P in D)||D[P]===void 0)&&(typeof E[P]=="object"&&E[P]!=null?D[P]={}:Array.isArray(E[P])&&(D[P]=[])),E=E[P],D=D[P]}w in E&&E[w]!==void 0&&(D[w]=D[w]||E[w])});let c={},p=new WeakSet;p.add(this);for(let[v,E]of Object.entries(s))c[v]=GIt(E,p);let _=x2n(Object.keys(i).length?uBi(c,i):c,A2n,r);return{lc:1,type:"constructor",id:this.lc_id,kwargs:_}}toJSONNotImplemented(){return{lc:1,type:"not_implemented",id:this.lc_id}}},e(QTe,"Serializable"),QTe)});function s6e(n){return typeof n=="object"&&n!==null&&"type"in n&&typeof n.type=="string"&&"source_type"in n&&(n.source_type==="url"||n.source_type==="base64"||n.source_type==="text"||n.source_type==="id")}function Mst(n){return s6e(n)&&n.source_type==="url"&&"url"in n&&typeof n.url=="string"}function jst(n){return s6e(n)&&n.source_type==="base64"&&"data"in n&&typeof n.data=="string"}function V3r(n){return s6e(n)&&n.source_type==="id"&&"id"in n&&typeof n.id=="string"}function J3r(n){if(s6e(n)){if(n.source_type==="url")return{type:"image_url",image_url:{url:n.url}};if(n.source_type==="base64"){if(!n.mime_type)throw new Error("mime_type key is required for base64 data.");return{type:"image_url",image_url:{url:`data:${n.mime_type};base64,${n.data}`}}}}throw new Error("Unsupported source type. Only 'url' and 'base64' are supported.")}function KIt({dataUrl:n,asTypedArray:r=!1}){let i=n.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),s;if(i){s=i[1].toLowerCase();let c=r?Uint8Array.from(atob(i[2]),p=>p.charCodeAt(0)):i[2];return{mime_type:s,data:c}}}var Ust=Ws(()=>{e(s6e,"isDataContentBlock");e(Mst,"isURLContentBlock");e(jst,"isBase64ContentBlock");e(V3r,"isIDContentBlock");e(J3r,"convertToOpenAIImageBlock");e(KIt,"parseBase64DataUrl")});function M1(n,r){return hy(n)&&n.type===r}function hy(n){return typeof n=="object"&&n!==null}function XN(n){return Array.isArray(n)}function Q_(n){return typeof n=="string"}function TY(n){return typeof n=="number"}function YIt(n){return n instanceof Uint8Array}function z3r(n){try{return JSON.parse(n)}catch{return}}var kY,vre=Ws(()=>{e(M1,"_isContentBlock");e(hy,"_isObject");e(XN,"_isArray");e(Q_,"_isString");e(TY,"_isNumber");e(YIt,"_isBytesArray");e(z3r,"safeParseJson");kY=e(n=>n(),"iife")});function lBi(n){if(n.type==="char_location"&&Q_(n.document_title)&&TY(n.start_char_index)&&TY(n.end_char_index)&&Q_(n.cited_text)){let{document_title:r,start_char_index:i,end_char_index:s,cited_text:c,...p}=n;return{...p,type:"citation",source:"char",title:r??void 0,startIndex:i,endIndex:s,citedText:c}}if(n.type==="page_location"&&Q_(n.document_title)&&TY(n.start_page_number)&&TY(n.end_page_number)&&Q_(n.cited_text)){let{document_title:r,start_page_number:i,end_page_number:s,cited_text:c,...p}=n;return{...p,type:"citation",source:"page",title:r??void 0,startIndex:i,endIndex:s,citedText:c}}if(n.type==="content_block_location"&&Q_(n.document_title)&&TY(n.start_block_index)&&TY(n.end_block_index)&&Q_(n.cited_text)){let{document_title:r,start_block_index:i,end_block_index:s,cited_text:c,...p}=n;return{...p,type:"citation",source:"block",title:r??void 0,startIndex:i,endIndex:s,citedText:c}}if(n.type==="web_search_result_location"&&Q_(n.url)&&Q_(n.title)&&Q_(n.encrypted_index)&&Q_(n.cited_text)){let{url:r,title:i,encrypted_index:s,cited_text:c,...p}=n;return{...p,type:"citation",source:"url",url:r,title:i,startIndex:Number(s),endIndex:Number(s),citedText:c}}if(n.type==="search_result_location"&&Q_(n.source)&&Q_(n.title)&&TY(n.start_block_index)&&TY(n.end_block_index)&&Q_(n.cited_text)){let{source:r,title:i,start_block_index:s,end_block_index:c,cited_text:p,..._}=n;return{..._,type:"citation",source:"search",url:r,title:i??void 0,startIndex:s,endIndex:c,citedText:p}}}function S2n(n){if(M1(n,"document")&&hy(n.source)&&"type"in n.source){if(n.source.type==="base64"&&Q_(n.source.media_type)&&Q_(n.source.data))return{type:"file",mimeType:n.source.media_type,data:n.source.data};if(n.source.type==="url"&&Q_(n.source.url))return{type:"file",url:n.source.url};if(n.source.type==="file"&&Q_(n.source.file_id))return{type:"file",fileId:n.source.file_id};if(n.source.type==="text"&&Q_(n.source.data))return{type:"file",mimeType:String(n.source.media_type??"text/plain"),data:n.source.data}}else if(M1(n,"image")&&hy(n.source)&&"type"in n.source){if(n.source.type==="base64"&&Q_(n.source.media_type)&&Q_(n.source.data))return{type:"image",mimeType:n.source.media_type,data:n.source.data};if(n.source.type==="url"&&Q_(n.source.url))return{type:"image",url:n.source.url};if(n.source.type==="file"&&Q_(n.source.file_id))return{type:"image",fileId:n.source.file_id}}}function w2n(n){function*r(){for(let i of n){let s=S2n(i);s?yield s:yield i}}return e(r,"iterateContent"),Array.from(r())}function D2n(n){function*r(){var s;let i=typeof n.content=="string"?[{type:"text",text:n.content}]:n.content;for(let c of i){if(M1(c,"text")&&Q_(c.text)){let{text:p,citations:_,...v}=c;if(XN(_)&&_.length){let E=_.reduce((D,w)=>{let B=lBi(w);return B?[...D,B]:D},[]);yield{...v,type:"text",text:p,annotations:E};continue}else{yield{...v,type:"text",text:p};continue}}else if(M1(c,"thinking")&&Q_(c.thinking)){let{thinking:p,signature:_,...v}=c;yield{...v,type:"reasoning",reasoning:p,signature:_};continue}else if(M1(c,"redacted_thinking")){yield{type:"non_standard",value:c};continue}else if(M1(c,"tool_use")&&Q_(c.name)&&Q_(c.id)){yield{type:"tool_call",id:c.id,name:c.name,args:c.input};continue}else if(M1(c,"input_json_delta")){if(pBi(n)&&((s=n.tool_call_chunks)!=null&&s.length)){let p=n.tool_call_chunks[0];yield{type:"tool_call_chunk",id:p.id,name:p.name,args:p.args,index:p.index};continue}}else if(M1(c,"server_tool_use")&&Q_(c.name)&&Q_(c.id)){let{name:p,id:_}=c;if(p==="web_search"){yield{id:_,type:"server_tool_call",name:"web_search",args:{query:kY(()=>{if(typeof c.input=="string")return c.input;if(hy(c.input)&&Q_(c.input.query))return c.input.query;if(Q_(c.partial_json)){let v=z3r(c.partial_json);if(v!=null&&v.query)return v.query}return""})}};continue}else if(c.name==="code_execution"){yield{id:_,type:"server_tool_call",name:"code_execution",args:{code:kY(()=>{if(typeof c.input=="string")return c.input;if(hy(c.input)&&Q_(c.input.code))return c.input.code;if(Q_(c.partial_json)){let v=z3r(c.partial_json);if(v!=null&&v.code)return v.code}return""})}};continue}}else if(M1(c,"web_search_tool_result")&&Q_(c.tool_use_id)&&XN(c.content)){let{content:p,tool_use_id:_}=c;yield{type:"server_tool_call_result",name:"web_search",toolCallId:_,status:"success",output:{urls:p.reduce((v,E)=>M1(E,"web_search_result")?[...v,E.url]:v,[])}};continue}else if(M1(c,"code_execution_tool_result")&&Q_(c.tool_use_id)&&hy(c.content)){yield{type:"server_tool_call_result",name:"code_execution",toolCallId:c.tool_use_id,status:"success",output:c.content};continue}else if(M1(c,"mcp_tool_use")){yield{id:c.id,type:"server_tool_call",name:"mcp_tool_use",args:c.input};continue}else if(M1(c,"mcp_tool_result")&&Q_(c.tool_use_id)&&hy(c.content)){yield{type:"server_tool_call_result",name:"mcp_tool_use",toolCallId:c.tool_use_id,status:"success",output:c.content};continue}else if(M1(c,"container_upload")){yield{type:"server_tool_call",name:"container_upload",args:c.input};continue}else if(M1(c,"search_result")){yield{id:c.id,type:"non_standard",value:c};continue}else if(M1(c,"tool_result")){yield{id:c.id,type:"non_standard",value:c};continue}else{let p=S2n(c);if(p){yield p;continue}}yield{type:"non_standard",value:c}}}return e(r,"iterateContent"),Array.from(r())}function pBi(n){return typeof(n==null?void 0:n._getType)=="function"&&typeof n.concat=="function"&&n._getType()==="ai"}var T2n,H3r=Ws(()=>{vre();e(lBi,"convertAnthropicAnnotation");e(S2n,"convertToV1FromAnthropicContentBlock");e(w2n,"convertToV1FromAnthropicInput");e(D2n,"convertToV1FromAnthropicMessage");T2n={translateContent:D2n,translateContentChunk:D2n};e(pBi,"_isAIMessageChunk")});function fBi(n){return Mst(n)?{type:n.type,mimeType:n.mime_type,url:n.url,metadata:n.metadata}:jst(n)?{type:n.type,mimeType:n.mime_type??"application/octet-stream",data:n.data,metadata:n.metadata}:V3r(n)?{type:n.type,mimeType:n.mime_type,fileId:n.id,metadata:n.metadata}:n}function k2n(n){return n.map(fBi)}function I2n(n){return!!(M1(n,"image_url")&&hy(n.image_url)||M1(n,"input_audio")&&hy(n.input_audio)||M1(n,"file")&&hy(n.file))}function F2n(n){if(M1(n,"image_url")&&hy(n.image_url)&&Q_(n.image_url.url)){let r=KIt({dataUrl:n.image_url.url});return r?{type:"image",mimeType:r.mime_type,data:r.data}:{type:"image",url:n.image_url.url}}else{if(M1(n,"input_audio")&&hy(n.input_audio)&&Q_(n.input_audio.data)&&Q_(n.input_audio.format))return{type:"audio",data:n.input_audio.data,mimeType:`audio/${n.input_audio.format}`};if(M1(n,"file")&&hy(n.file)&&Q_(n.file.data)){let r=KIt({dataUrl:n.file.data});if(r)return{type:"file",data:r.data,mimeType:r.mime_type};if(Q_(n.file.file_id))return{type:"file",fileId:n.file.file_id}}}return n}var W3r=Ws(()=>{Ust();vre();e(fBi,"convertToV1FromDataContentBlock");e(k2n,"convertToV1FromDataContent");e(I2n,"isOpenAIDataBlock");e(F2n,"convertToV1FromOpenAIDataBlock")});function dBi(n){let r=[];typeof n.content=="string"?n.content.length>0&&r.push({type:"text",text:n.content}):r.push(...XIt(n.content));for(let i of n.tool_calls??[])r.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return r}function _Bi(n){let r=[];typeof n.content=="string"?n.content.length>0&&r.push({type:"text",text:n.content}):r.push(...XIt(n.content));for(let i of n.tool_calls??[])r.push({type:"tool_call",id:i.id,name:i.name,args:i.args});return r}function XIt(n){let r=[];for(let i of n)I2n(i)?r.push(F2n(i)):r.push(i);return r}function mBi(n){if(n.type==="url_citation"){let{url:r,title:i,start_index:s,end_index:c}=n;return{type:"citation",url:r,title:i,startIndex:s,endIndex:c}}if(n.type==="file_citation"){let{file_id:r,filename:i,index:s}=n;return{type:"citation",title:i,startIndex:s,endIndex:s,fileId:r}}return n}function N2n(n){function*r(){var s;hy((s=n.additional_kwargs)==null?void 0:s.reasoning)&&XN(n.additional_kwargs.reasoning.summary)&&(yield{type:"reasoning",reasoning:n.additional_kwargs.reasoning.summary.reduce((c,p)=>hy(p)&&Q_(p.text)?`${c}${p.text}`:c,"")});let i=typeof n.content=="string"?[{type:"text",text:n.content}]:n.content;for(let c of i)if(M1(c,"text")){let{text:p,annotations:_,phase:v,extras:E,...D}=c,w=hy(E)?{...E}:{};Q_(v)&&(w.phase=v);let B=Object.keys(w).length>0?{extras:w}:{};Array.isArray(_)?yield{...D,...B,type:"text",text:String(p),annotations:_.map(mBi)}:yield{...D,...B,type:"text",text:String(p)}}for(let c of n.tool_calls??[])yield{type:"tool_call",id:c.id,name:c.name,args:c.args};if(hy(n.additional_kwargs)&&XN(n.additional_kwargs.tool_outputs))for(let c of n.additional_kwargs.tool_outputs){if(M1(c,"web_search_call")){let p={};if(hy(c.action)&&Q_(c.action.query)&&(p.query=c.action.query),yield{id:c.id,type:"server_tool_call",name:"web_search",args:p},c.status==="completed"||c.status==="failed"){let _={};hy(c.action)&&(_.action=c.action),yield{type:"server_tool_call_result",toolCallId:Q_(c.id)?c.id:"",status:c.status==="completed"?"success":"error",output:_}}continue}else if(M1(c,"file_search_call")){yield{id:c.id,type:"server_tool_call",name:"file_search",args:{queries:XN(c.queries)?c.queries:[]}},(c.status==="completed"||c.status==="failed")&&(yield{type:"server_tool_call_result",toolCallId:Q_(c.id)?c.id:"",status:c.status==="completed"?"success":"error",output:XN(c.results)?{results:c.results}:{}});continue}else if(M1(c,"computer_call")){yield{type:"non_standard",value:c};continue}else if(M1(c,"code_interpreter_call")){if(Q_(c.code)&&(yield{id:c.id,type:"server_tool_call",name:"code_interpreter",args:{code:c.code}}),XN(c.outputs)){let p=kY(()=>{if(c.status!=="in_progress"){if(c.status==="completed")return 0;if(c.status==="incomplete")return 127;if(c.status!=="interpreting"&&c.status==="failed")return 1}});for(let _ of c.outputs)if(M1(_,"logs")){yield{type:"server_tool_call_result",toolCallId:c.id??"",status:"success",output:{type:"code_interpreter_output",returnCode:p??0,stderr:[0,void 0].includes(p)?void 0:String(_.logs),stdout:[0,void 0].includes(p)?String(_.logs):void 0}};continue}}continue}else if(M1(c,"mcp_call")){yield{id:c.id,type:"server_tool_call",name:"mcp_call",args:c.input};continue}else if(M1(c,"mcp_list_tools")){yield{id:c.id,type:"server_tool_call",name:"mcp_list_tools",args:c.input};continue}else if(M1(c,"mcp_approval_request")){yield{type:"non_standard",value:c};continue}else if(M1(c,"tool_search_call")){let p={};hy(c.arguments)&&Object.assign(p,c.arguments);let _={};Q_(c.execution)&&(_.execution=c.execution),Q_(c.status)&&(_.status=c.status),Q_(c.call_id)&&(_.call_id=c.call_id),yield{id:Q_(c.id)?c.id:"",type:"server_tool_call",name:"tool_search",args:p,...Object.keys(_).length>0?{extras:_}:{}};continue}else if(M1(c,"tool_search_output")){let p={name:"tool_search"};Q_(c.execution)&&(p.execution=c.execution),yield{type:"server_tool_call_result",toolCallId:Q_(c.id)?c.id:"",status:c.status==="completed"?"success":c.status==="failed"?"error":"success",output:{tools:XN(c.tools)?c.tools:[]},extras:p};continue}else if(M1(c,"image_generation_call")){Q_(c.result)&&(yield{type:"image",mimeType:"image/png",data:c.result,id:Q_(c.id)?c.id:void 0,metadata:{status:Q_(c.status)?c.status:void 0}}),yield{type:"non_standard",value:c};continue}hy(c)&&(yield{type:"non_standard",value:c})}}return e(r,"iterateContent"),Array.from(r())}function hBi(n){function*r(){yield*N2n(n);for(let i of n.tool_call_chunks??[])yield{type:"tool_call_chunk",id:i.id,name:i.name,args:i.args}}return e(r,"iterateContent"),Array.from(r())}var P2n,G3r=Ws(()=>{vre();W3r();e(dBi,"convertToV1FromChatCompletions");e(_Bi,"convertToV1FromChatCompletionsChunk");e(XIt,"convertToV1FromChatCompletionsInput");e(mBi,"convertResponsesAnnotation");e(N2n,"convertToV1FromResponses");e(hBi,"convertToV1FromResponsesChunk");P2n={translateContent:e(n=>typeof n.content=="string"?dBi(n):N2n(n),"translateContent"),translateContentChunk:e(n=>typeof n.content=="string"?_Bi(n):hBi(n),"translateContentChunk")}});function K3r(n){return typeof n=="object"&&n!==null&&"type"in n&&"content"in n&&(typeof n.content=="string"||Array.isArray(n.content))}var Y3r=Ws(()=>{e(K3r,"isMessage")});function B2n(n,r="pretty"){return r==="pretty"?gBi(n):JSON.stringify(n)}function gBi(n){let r=[],i=` ${n.type.charAt(0).toUpperCase()+n.type.slice(1)} Message `,s=Math.floor((80-i.length)/2),c="=".repeat(s),p=i.length%2===0?c:`${c}=`;if(r.push(`${c}${i}${p}`),n.type==="ai"){let _=n;if(_.tool_calls&&_.tool_calls.length>0){r.push("Tool Calls:");for(let v of _.tool_calls){r.push(` ${v.name} (${v.id})`),r.push(` Call ID: ${v.id}`),r.push(" Args:");for(let[E,D]of Object.entries(v.args))r.push(` ${E}: ${typeof D=="object"?JSON.stringify(D):D}`)}}}if(n.type==="tool"){let _=n;_.name&&r.push(`Name: ${_.name}`)}return typeof n.content=="string"&&n.content.trim()&&(r.length>1&&r.push(""),r.push(n.content)),r.join(`
|
|
618
618
|
`)}var O2n=Ws(()=>{e(B2n,"convertToFormattedString");e(gBi,"convertToPrettyString")});function R2n(n){return Array.isArray(n)?n:typeof n=="string"?n===""?[]:[{type:"text",text:n}]:n==null?[]:[n]}function k0e(n,r){if(typeof n=="string")return n===""?r:typeof r=="string"?n+r:Array.isArray(r)&&r.length===0?n:Array.isArray(r)&&r.some(i=>s6e(i))?[{type:"text",source_type:"text",text:n},...r]:[{type:"text",text:n},...r];if(Array.isArray(r)){let i=R2n(n);return qje(i,r)??[...i,...r]}else return r===""?n:Array.isArray(n)&&n.some(i=>s6e(i))?[...n,{type:"file",source_type:"text",text:r}]:[...R2n(n),{type:"text",text:r}]}function yBi(n,r){function i(s,c){if(typeof s!="object"||s===null||s===void 0)return s;if(c>=r)return Array.isArray(s)?"[Array]":"[Object]";if(Array.isArray(s))return s.map(_=>i(_,c+1));let p={};for(let _ of Object.keys(s))p[_]=i(s[_],c+1);return p}return e(i,"helper"),JSON.stringify(i(n,0),null,2)}function Are(n,r,i){let s=(i==null?void 0:i.ignoreKeys)??j2n;if(n==null&&r==null)return;if(n==null||r==null)return n??r;let c={...n};for(let[p,_]of Object.entries(r))if(c[p]==null)c[p]=_;else{if(_==null)continue;if(typeof c[p]!=typeof _||Array.isArray(c[p])!==Array.isArray(_))throw new Error(`field[${p}] already exists in the message chunk, but with a different type.`);if(typeof c[p]=="string"){if(p==="type")continue;if(["id","name","output_version","model_provider"].includes(p))_&&(c[p]=_);else{if(s.includes(p))continue;c[p]+=_}}else if(typeof c[p]=="number"){if(s.includes(p))continue;c[p]=c[p]+_}else if(typeof c[p]=="object"&&!Array.isArray(c[p]))c[p]=Are(c[p],_,i);else if(Array.isArray(c[p]))c[p]=qje(c[p],_,i);else{if(c[p]===_)continue;console.warn(`field[${p}] already exists in this message chunk and value has unsupported type.`)}}return c}function vBi(n){return typeof n=="number"||typeof n=="string"}function L2n(n){return typeof n!="object"||n===null||!("index"in n)?!1:vBi(n.index)}function M2n(n){if(typeof n!="object"||n===null||!("id"in n))return!1;let r=n.id;return r!=null&&r!==""}function ABi(n,r){let i=L2n(r),s=M2n(r);return!i&&!s?-1:n.findIndex(c=>{let p=L2n(c),_=M2n(c);return i&&p?c.index!==r.index?!1:_&&s?c.id===r.id:!0:!i&&!p&&s&&_?c.id===r.id:!1})}function qje(n,r,i){if(!(n==null&&r==null)){if(n==null||r==null)return n||r;{let s=[...n];for(let c of r){let p=ABi(s,c);if(p!==-1)s[p]=Are(s[p],c,i);else{if(typeof c=="object"&&c!==null&&"text"in c&&c.text==="")continue;s.push(c)}}return s}}}function Z3r(n){return typeof n.role=="string"}function $Te(n){return typeof(n==null?void 0:n._getType)=="function"}var X3r,Qje,CH,j2n,qTe,o6e,m$=Ws(()=>{Lst();Ust();H3r();W3r();G3r();Y3r();O2n();X3r=Symbol.for("langchain.message");e(R2n,"contentBlocksFromNonStringFirst");e(k0e,"mergeContent");e(yBi,"stringifyWithDepthLimit");CH=(Qje=class extends Nge{lc_namespace=["langchain_core","messages"];lc_serializable=!0;get lc_aliases(){return{additional_kwargs:"additional_kwargs",response_metadata:"response_metadata"}}[X3r]=!0;id;name;content;additional_kwargs;response_metadata;_getType(){return this.type}getType(){return this._getType()}constructor(r){let i=typeof r=="string"||Array.isArray(r)?{content:r}:r;i.additional_kwargs||(i.additional_kwargs={}),i.response_metadata||(i.response_metadata={}),super(i),this.name=i.name,i.content===void 0&&i.contentBlocks!==void 0?(this.content=i.contentBlocks,this.response_metadata={output_version:"v1",...i.response_metadata}):i.content!==void 0?(this.content=i.content??[],this.response_metadata=i.response_metadata):(this.content=[],this.response_metadata=i.response_metadata),this.additional_kwargs=i.additional_kwargs,this.id=i.id}get text(){return typeof this.content=="string"?this.content:Array.isArray(this.content)?this.content.map(r=>typeof r=="string"?r:r.type==="text"?r.text:"").join(""):""}get contentBlocks(){let r=typeof this.content=="string"?[{type:"text",text:this.content}]:this.content;return[k2n,XIt,w2n].reduce((i,s)=>s(i),r)}toDict(){return{type:this.getType(),data:this.toJSON().kwargs}}static lc_name(){return"BaseMessage"}get _printableFields(){return{id:this.id,content:this.content,name:this.name,additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata}}static isInstance(r){return typeof r=="object"&&r!==null&&X3r in r&&r[X3r]===!0&&K3r(r)}_updateId(r){this.id=r,this.lc_kwargs.id=r}get[Symbol.toStringTag](){return this.constructor.lc_name()}[Symbol.for("nodejs.util.inspect.custom")](r){if(r===null)return this;let i=yBi(this._printableFields,Math.max(4,r));return`${this.constructor.lc_name()} ${i}`}toFormattedString(r="pretty"){return B2n(this,r)}},e(Qje,"BaseMessage"),Qje),j2n=["index","created","timestamp"];e(Are,"_mergeDicts");e(vBi,"isMergeableIndex");e(L2n,"hasMergeableIndex");e(M2n,"hasMergeableId");e(ABi,"_findMergeTarget");e(qje,"_mergeLists");o6e=(qTe=class extends CH{static isInstance(r){if(!super.isInstance(r))return!1;let i=Object.getPrototypeOf(r);for(;i!==null;){if(i===qTe.prototype)return!0;i=Object.getPrototypeOf(i)}return!1}},e(qTe,"BaseMessageChunk"),qTe);e(Z3r,"_isMessageFieldWithRole");e($Te,"isBaseMessage")});function e8r(n){return n!=null&&typeof n=="object"&&"lc_direct_tool_output"in n&&n.lc_direct_tool_output===!0}function t8r(n){let r=[],i=[];for(let s of n)if(s.function){let c=s.function.name;try{let p=JSON.parse(s.function.arguments);r.push({name:c||"",args:p||{},id:s.id})}catch{i.push({name:c,args:s.function.arguments,id:s.id,error:"Malformed args."})}}else continue;return[r,i]}var $je,VTe,Vje=Ws(()=>{VC();m$();e(e8r,"isDirectToolOutput");VTe=($je=class extends CH{static lc_name(){return"ToolMessage"}get lc_aliases(){return{tool_call_id:"tool_call_id"}}lc_direct_tool_output=!0;type="tool";status;tool_call_id;metadata;artifact;constructor(r,i,s){let c=typeof r=="string"||Array.isArray(r)?{content:r,name:s,tool_call_id:i}:r;super(c),this.tool_call_id=c.tool_call_id,this.artifact=c.artifact,this.status=c.status,this.metadata=c.metadata}static isInstance(r){return super.isInstance(r)&&r.type==="tool"}get _printableFields(){return{...super._printableFields,tool_call_id:this.tool_call_id,artifact:this.artifact}}},e($je,"ToolMessage"),$je);e(t8r,"defaultToolCallParser")});function U2n(n){let r=Symbol.for(n);return{brand(i,s){let c=s?Symbol.for(`${n}.${s}`):r,_=class _ extends i{[c]=!0;constructor(...E){super(...E)}static isInstance(E){return typeof E=="object"&&E!==null&&c in E&&E[c]===!0}};e(_,"_Branded");let p=_;return Object.defineProperty(p,"name",{value:i.name}),p},sub(i){return U2n(`${n}.${i}`)},isInstance(i){return typeof i=="object"&&i!==null&&r in i&&i[r]===!0}}}var Q2n,q2n=Ws(()=>{e(U2n,"createNamespace");Q2n=U2n("langchain")});function r8r(n,r){return n.lc_error_code=r,n.message=`${n.message}
|
|
@@ -1727,7 +1727,7 @@ ${de}${le}${xe}${_ln.default.cursorHide}`});var oOt=nd(require("child_process"))
|
|
|
1727
1727
|
}`}renderCodeAssertions(r,i){r&&!i&&(r==null||r.forEach(s=>{this.addAssertion(s)}))}buildClickActionOptionsObject(r){let{clickOffset:i,force:s}=r;if(!i&&!s)return{};let c={};return i&&(c.position={x:i.x,y:i.y}),s&&(c.force=!0),c}getOptionsString(r,i){let{eventCode:s,actionOptions:c,login:p={}}=r,_=WLe[s],v=_&&_>=1;if(c){let D=i?`({
|
|
1728
1728
|
...(${c}),
|
|
1729
1729
|
...(${this.makeOptions(i)})
|
|
1730
|
-
})`:c;return v?`, ${D}`:D}let E=this.buildClickActionOptionsObject(r);return this.makeOptions({...i,...E,...p},v)}buildFillValue(r){return Array.isArray(r)?`[${r.map(this.buildFillValue.bind(this)).join(", ")}]`:typeof r=="object"?`{ ${Object.entries(r).map(([i,s])=>`${i}: ${this.buildFillValue(s)}`).join(", ")} }`:typeof r=="string"?Y5e(r):r}buildActionCode(r,i,s){let{eventCode:c,unevaluatedFillValue:p,dropTarget:_,files:v,switchToTab:E,userRole:D,canvas:w,nativeDialog:B,codeContext:P}=r,L=this.buildFillValue(p),j=Aon[c],V=this.getOptionsString(r,s),ee=(P==null?void 0:P.frameTargetName)??"page";switch(c){case"navigation":return[`${i}.${j}(${this.formatURL(p)}${V})`];case"drag_and_drop":return[`${i}.${j}(${this.buildLocatorChain(ee,_.locator,_.locatorWithVars,_.parentFramesSelectors,_.selector,_.selectorWithVars)}${V})`];case"click":case"double_click":case"check":case"uncheck":case"hover":return[`${i}.${j}(${V})`];case"input":case"selectoption":case"keystroke":return[`${i}.${j}(${L}${V})`];case"click_and_type":return[`${i}.click(${V})`,`${i}.pressSequentially(${L}${V?`, ${V}`:""})`];case"clear_and_type":return[`${i}.clear(${this.makeOptions(s)})`,`${i}.pressSequentially(${L}${V?`, ${V}`:""})`];case"custom_code":return[p];case"wait":return[`${i}.${j}(${p||1e3}${V})`];case"upload_files":return v!=null&&v.length||console.warn("Input files are required for SetInputFiles event code"),[`${i}.${j}(page.resolveAssetsFolder(["${v.join('", "')}"])${V})`];case"switch_tab":return[`page = ${i}.${j}(${E.index}${V})`];case"logout_and_login":return[`${i}.${j}("${D}")`];case"canvas_click":return[`${i}.${j}("${w.canvasText}"${w.rectSizeIndex?`, ${w.rectSizeIndex}`:""})`];case"native_accept":{let ue=B.dialogResult!=null&&(0,V8n.isString)(B.dialogResult)?`"${B.dialogResult}"`:"";return[`${i}.waitForDialog().then(async (${B.dialogType}) => {await ${B.dialogType}.accept(${ue})})`]}case"native_dismiss":return[`${i}.waitForDialog().then(async (${B.dialogType}) => {await ${B.dialogType}.dismiss()})`];case"login":return[this.makeLoginCode(r)];default:return[]}}buildLocatorChain(r,i,s,c,p,_,v){let E=this.addFrameSelectorsToLocatorChain(r,c),D=this.addFrameSelectorsToLocatorChain("page",c);if(v){let w=this.buildCompoundSelectorLocatorChain(E,v);if(w)return w}return s?E+=`.${h8t(s,D)}`:_?E+=`.locator('${this.escapeSelector(_)}')`:i?E+=`.${h8t(i,D)}`:p&&(E+=`.locator('${this.escapeSelector(p)}')`),E}addFrameSelectorsToLocatorChain(r,i){return(i??[]).reduce((s,c)=>`${s}.frameLocator('${this.escapeSelector(c)}')`,r)}buildCompoundSelectorLocatorChain(r,i){let s=e(c=>c.selection.type==="content"?`"${c.selection.value}"`:c.locator?`base.${c.locator}`:`base.locator('${this.escapeSelector(c.selector)}')`,"getElementSelector");try{return`${r}.compoundSelection((base) => [${i.contextElements.map(c=>s(c.element)).join(", ")}], (base) => ${i.targetRelativeSelector.locator?`base.${i.targetRelativeSelector.locator}`:`base.locator('${this.escapeSelector(i.targetRelativeSelector.selector)}')`}).first()`}catch(c){console.error("Error building compound selector locator chain",c);return}}formatURL(r){let i=this.resolveRelativeURL(r);return Y5e(decodeURIComponent(i))}resolveRelativeURL(r){if(!r)return"";if(r.startsWith("/"))return r;let i;try{i=new URL(r)}catch(_){if(_ instanceof TypeError)return r;throw _}if(!this.options.environment.baseURL)return r;let s=new URL(this.options.environment.baseURL),c=e(_=>_.replace(/^www\./,""),"normalizeHostname");return!s||s.protocol!==i.protocol||c(s.hostname)!==c(i.hostname)||!i.pathname.startsWith(s.pathname)?r:i.pathname.substring(s.pathname.length).replace(/\/$/,"").replace(/^(?!\/)/,"/")+i.search+i.hash}addVariable(r){this.test.usingVariableStore=!0,this.addCode(Eon([r],{onlyValueExpression:!0}))}addAssertion(r){this.addCode(this.assertionGenerator.generateAssertionCode(r))}addCode(r){Array.isArray(r)||(r=[r]),r.forEach(i=>{if(!i)return;let s=i.trimEnd();s.endsWith(";")||(s+=";"),this.test.lines.push({type:0,content:s})})}addFunction(r){this.test.lines.push({type:0,content:r})}addComment(r){this.test.lines.push({type:1,content:`/* ${r} */`})}getTestMetadata(){return this.test}createFallbackMarkupForSelector(r,i=[],s,c,p){let _=(i||[]).concat(this.test.fallbackMarkups.map(E=>E.id)),v;do v=m8t(5);while(_.indexOf(v)>-1);return{id:v,selector:r,esraMetadata:s,compoundSelector:c==null?void 0:c.metadata,alternateLocators:p}}escapeSelector(r){var i;return(i=r==null?void 0:r.replaceAll("'","\\'"))==null?void 0:i.replaceAll(/\\/g,"\\\\")}};e(Wct,"SingleTestCode");var jre=Wct;_6();var oKi=1e3,cKi=3e4,yBr=class yBr{constructor(r,i,s,c,p,_,v,E,D,w){this.config=r;this.checksumRoot=i;this.pageInteractor=s;this.apiService=c;this.userStoryService=p;this.actionsManager=_;this.testAssetsManager=v;this.webDriver=E;this.evaluatorService=D;this.internalFilesDir=w;this.executeAction=e(async({data:r,id:i,options:s,withPageInteractor:c=!1})=>{try{r.selector=void 0,r.executed=!1;let p=r.eventCode==="custom_code";r.thought="";let _=s.forceUpdateTimestamp?{id:i,timestamp:p?Date.now():void 0}:void 0,v=(()=>{if(s.timeout>=0)return s.timeout;if(s.singlePlay)return r.eventCode==="navigation"?cKi:oKi})();if(c?await this.performActionWithPageInteractor(r,v):await this.performActionWithEvaluation(r,v),_&&!p&&(_.timestamp=Date.now(),!["login","navigation","keystroke","wait","switch_tab","logout_and_login"].includes(r.eventCode))){let D=await this.webDriver.tmFrame.evaluate(w=>window.checksum.timeMachine.sessionReplayer.getLastInteractionEventTimestamp(w),_.timestamp);_.timestamp=Math.max(D??0,s.runStartedAt)}return{data:_,success:!0,message:"Action has been executed successfully"}}catch(p){throw af.error(`Error: ${p.message.slice(0,200)}`),new Error(p.message||p)}},"executeAction")}setPage(r){this.page=r}async performActionWithEvaluation(r,i){let s=r.codeValue??jre.generateSingleActionCode(r,{noFallbacks:!0,generateAssertionsCode:!1,actionOptions:i?{timeout:i}:void 0});await this.evaluatorService.execute(s,void 0,void 0,{stepId:r.id})}async performActionWithPageInteractor(r,i){await this.pageInteractor.performAction(r,{useLocator:!0,timeout:i,monitorFlashingHTML:!1})}async uploadFiles(r){return r.map(({data:s,fileName:c})=>{let p=`${this.testAssetsManager.getLocalAutoSavePath()}/files`;return L8n(s,c,p,this.internalFilesDir),`${p}/${c}`})}async login(r,{role:i,environment:s}){await tOt({config:this.config,folder:this.checksumRoot,throwIfEnvInfoInvalid:!0})(r,{role:i,environment:s}),this.didLogin=!0}async performLogin({role:r,environment:i}){return this.login(this.webDriver.appMainFrame.page(),{role:r,environment:i})}async addInitialLoginAction(){this.actionsManager.addAction({thought:"Log into application",eventCode:"login",id:(0,gBr.randomUUID)(),isInitialAction:!0,login:{role:this.userStoryService.getStory().environment.userRole,environment:this.userStoryService.getStory().environment.name},codeContext:{frameTargetName:null}})}async addStartURLNavigationAction(){var i;let r=(i=this.userStoryService.getStory())==null?void 0:i.url;r&&this.actionsManager.addAction({thought:"Navigate to start URL",eventCode:"navigation",isInitialAction:!0,id:(0,gBr.randomUUID)(),fillValue:r,codeContext:{frameTargetName:null}})}hasLoggedIn(){return this.didLogin}};e(yBr,"VtgActionsService");var uOt=yBr;WS();var vBr=class vBr{constructor(r,i={},s=!0){this.requests=[];this.watcherConfig={minimumWaitTime:250,maximumWaitTime:1e4,followingRequestsWaitTime:250};this.resolved=!0;this.hasMinimumWaitTimePassed=!1;this.useLog=!1;this.logStack=[];this.resolve=e(()=>{this.resolved||(this.resolved=!0,clearTimeout(this.minimumWaitTimer),clearTimeout(this.maximumWaitTimer),clearTimeout(this.followingRequestWaitTimeoutId),this.loadResolve({totalTime:Date.now()-this.startTS,logs:this.logStack,pendingRequests:this.requests.length,totalRequests:this.observedRequestsCount}))},"resolve");this.watcherConfig={...this.watcherConfig,...i},this.initListeners(r),this.useLog=s}initListeners(r){r.on("request",i=>{var s;this.hasMinimumWaitTimePassed||(s=this.watcherConfig.whitelist)!=null&&s.length&&!this.watcherConfig.whitelist.some(c=>c.test(i.url()))||(this.useLog&&this.logStack.push(`${i.method()} ${i.url().substring(0,60)}`),this.requests.push(i),this.observedRequestsCount+=1)}),r.on("response",i=>{this.requests=this.requests.filter(s=>s!==i.request()),this.hasMinimumWaitTimePassed&&(this.requests.length||(clearTimeout(this.followingRequestWaitTimeoutId),this.followingRequestWaitTimeoutId=setTimeout(()=>{this.requests.length||this.resolve()},this.watcherConfig.followingRequestsWaitTime)))})}async wait(){return new Promise(r=>{this.loadResolve=r,this.resolved=!1,this.minimumWaitTimer=setTimeout(()=>{this.hasMinimumWaitTimePassed=!0,this.requests.length||this.resolve()},this.watcherConfig.minimumWaitTime),this.maximumWaitTimer=setTimeout(this.resolve,this.watcherConfig.maximumWaitTime)})}startListening(){this.requests=[],this.startTS=Date.now(),this.hasMinimumWaitTimePassed=!1,this.observedRequestsCount=0,this.useLog&&(this.logStack=[])}};e(vBr,"NetworkWatcher");var lOt=vBr;var J8n=require("crypto");WS();GLe();t0e();_6();var uKi=e(n=>({...n.fillValue&&{value:n.fillValue},...n.selector&&{selector:n.selector},type:von[n.eventCode],id:n.id,files:[]}),"webPageActionToNextAction"),ABr=class ABr{constructor(r,i,s){this.actionsManager=r;this.apiService=i;this.userStoryService=s}clear(){this.remoteSessionId=void 0}async init({retriesLeft:r=3,keepActionsWithoutDescription:i=!1,lastActionId:s=void 0}={}){let{goal:c,instructions:p}=this.userStoryService.getStory(),_=this.actionsManager.actions??[];if(s){let D=_.findIndex(({id:w})=>w===s);D===-1&&af.error(`[init] No action with id ${s} was found in executed actions`),_=_.slice(0,D+1)}i||(_=_.filter(D=>!!D.thought));let v={previous:_.map(D=>({thought:D.thought,action:uKi(D)}))},E={type:"test-generation",storyTitle:c,storyInstructions:p,testId:void 0,testSuiteId:void 0,thoughtsAndActions:v};try{let D=await this.apiService.post("ai-fallback/init",{data:E,format:"json"}),{sessionId:w}=await D.json();this.remoteSessionId=w}catch(D){if(af.error(D),await Mb(2e3),r>0)return this.init({retriesLeft:r-1,keepActionsWithoutDescription:i});throw D}}};e(ABr,"VtgAiSessionBaseService");var P6e=ABr;_6();var xBr=class xBr extends P6e{constructor(i,s,c,p,_,v){super(p,_,v);this.webDriver=i;this.pageInteractor=s;this.actionsService=c;this.actionsManager=p;this.apiService=_;this.userStoryService=v;this.previousActionFailed=!1;this.currentChecksumId="0";this.executeAction=e(async({data:i,options:s={isAISuggestion:!0}})=>{await this.webDriver.clearHighlights(),this.previousActionFailed=!1;let c;try{let p=new lOt(this.webDriver.appMainFrame.page());p.startListening(),c=await this.actionsService.executeAction({data:i,id:i.id,options:s}),await p.wait(),await Mb(2e3)}catch(p){throw this.previousActionFailed=!0,af.error(p),new Error(p)}return s.valueChanged&&await this.init(),c},"executeAction")}async init({keepActionsWithoutDescription:i}={keepActionsWithoutDescription:!0}){return this.clear(),super.init({keepActionsWithoutDescription:i})}clear(){super.clear(),this.previousActionFailed=!1,this.currentChecksumId="0"}async iterate({guidance:i}={}){await this.webDriver.getTimeMachine().toggleTimeMachineHandleEvents(!1);let{reducedHTML:s,flashingHTML:c,elementsForNodeInterpretation:p,currentChecksumId:_}=await this.webDriver.evaluateWithChecksum(async({appRules:v,currentChecksumId:E})=>window.checksum.testGenerator.reduceHTML(v,{stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:E}),{appRules:{appSpecificInteractableElementsSelectors:[]},currentChecksumId:this.currentChecksumId});this.currentChecksumId=_;try{let v=await this.getNextAction({reducedHTML:s,flashingHTML:c,elementsForNodeInterpretation:p,guidance:i}),D={...await this.pageInteractor.translateActionResponseToAgentPotentialAction(v),id:(0,J8n.randomUUID)(),timestamp:Date.now()};return await this.webDriver.highlightElementByLocator(this.pageInteractor.makeLocator(D.selector,D.parentFramesSelectors),D.clickOffset,"10px solid rgba(255,0,0,1)",!0),D}catch(v){af.error("error in ai iterate",v)}}async stop(){}async getNextAction({reducedHTML:i,flashingHTML:s,elementsForNodeInterpretation:c,guidance:p}){let _={reduction:{reducedHTML:i,flashingHTML:s,elementsForNodeInterpretation:c},currentURL:this.webDriver.appMainFrame.url(),previousActionOverview:{success:!this.previousActionFailed,userCorrection:p}};try{return await(await this.apiService.post("ai-fallback/iterate",{sessionId:this.remoteSessionId,iterationData:_})).json()}catch(v){throw console.error(v),v}}};e(xBr,"VtgAITestGenerationService");var pOt=xBr;uBr();i6e();var X5e=require("@playwright/test"),BBr=nd(NBr());WS();var PBr=class PBr{constructor(r){this.options=r;this.harData={methodIndex:{GET:0,POST:0,PUT:0,DELETE:0}};this.interceptors={recordHar:this.harInterceptor.bind(this),completeOriginHeader:this.completeOriginHeaderInterceptor.bind(this)};this.intercept=e(async(r,i,s,c)=>{let p=c??this.options,_=[],v=e(E=>{if(E)switch(E.type){case"abort":return r.abort(E.errorCode);case"fulfill":return r.fulfill(E.fulfillOptions);default:case"continue":_.push(E)}},"processResult");for(let[E,D]of Object.entries(this.interceptors))if(p[E]){let w=v(await D(r,i,s));if(w)return w}return this.applyContinueResults(r,_)},"intercept")}setOptions(r){this.options=r}mergeOptions(r){this.options={...this.options,...r}}applyContinueResults(r,i){let s=i.filter(p=>!!p),c={};return s.forEach(p=>{p.options&&(p.options.headers&&(c.headers={...c.headers,...p.options.headers}),p.options.method&&(c.method=p.options.method),p.options.postData&&(c.postData=p.options.postData),p.options.url&&(c.url=p.options.url))}),r.continue(c)}async harInterceptor(r){let i=r.request().headers(),s=r.request().method();return i["Checksum-Id"]=(++this.harData.methodIndex[s]).toString(),{options:{headers:i}}}async completeOriginHeaderInterceptor(r,i,{page:s}){if(i.resourceType()==="document")return;let c=r.request().headers();if(!c.Origin&&!c.origin){try{let p=new URL(s.url()).origin;c.origin=p,c.Origin=p}catch{}return{options:{headers:c}}}}};e(PBr,"RouteInterceptors");var fOt=PBr;P3r();bRe();K4r();var OBr=class OBr{constructor(r={},i={},s=new XMe,c=void 0){this.framesMessageBroker=s;this.context=c;this.browserConfig={devtools:!1,executablePath:process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH??void 0};this.options={fullScreenResolution:!1,disableWebSecurity:!0};this.contextClosePromise=void 0;this.eventListeners=[];this.lastSnapshot={selector:void 0,eventCode:void 0};this.snapshotTimeout=3e4;this.cacheScript=!1;this.pagesIndexToGuid={};this.onRequestFinished=e(async r=>{try{let i=await r.response();if(!i.ok())return;let s=r.resourceType(),c=r.url(),p=e(async()=>{try{return await i.text()}catch{try{return await(await fetch(c)).text()}catch{return}}},"getBody");if(["document","script","stylesheet"].includes(s))try{let _=await p();if(!_)return;let v={url:c,source:_,type:s};await this.forEachEventListener(E=>{var D;return(D=E.onWebDriverResourceLoaded)==null?void 0:D.call(E,v)})}catch(_){console.error("[WebDriver] requestfinished event handler error",s,c,_)}}catch(i){console.error("[WebDriver] requestfinished event handler error",i)}},"onRequestFinished");this.onFrameNavigated=e(async r=>{let i=e(async s=>{await this.forEachEventListener(c=>{var p;return(p=c.onWebDriverFrameNavigated)==null?void 0:p.call(c,r,s)})},"notifyFrameNavigated");await i(!1),await this.injectedScriptManager.onFrameNavigated(r),await i(!0)},"onFrameNavigated");this.tracing=!1;this.tracingChunk=!1;this.chunkIndex=0;var p;if(this.options={...this.options,...r},this.browserConfig={...this.browserConfig,...i},this.injectedScriptManager=new Mje(this.options),this.browserConfig.args||(this.browserConfig.args=[]),this.options.disableWebSecurity&&this.browserConfig.args.push("--disable-web-security"),this.options.allowFileAccess&&this.browserConfig.args.push("--allow-file-access-from-files"),this.browserConfig.args.push("--disable-site-isolation-trials"),this.browserConfig.args.push("--allow-running-insecure-content"),this.options.remoteDebugging&&this.browserConfig.args.push(`--remote-debugging-port=${this.options.remoteDebuggingPort??"9222"}`),this.options.forceHeadless&&(this.browserConfig.headless=!0,this.browserConfig.devtools=!1),this.options.useProxy)if((p=this.options.webProxy)!=null&&p.server){console.log("[WebDriver] using proxy");let{server:_,username:v,password:E}=this.options.webProxy;this.browserConfig.proxy={server:_,username:v,password:E},this.browserConfig.args.push("--proxy-bypass-list=localhost,127.0.0.1")}else console.error("[WebDriver] useProxy=true but proxy not configured");this.routeInterceptor=new fOt({completeOriginHeader:this.options.completeOriginHeader,recordHar:this.options.recordHAR})}async prepare({storageState:r,baseURL:i,shutdown:s=!0}={}){s&&await this.shutdown();let c={};if(c.bypassCSP=!0,c.ignoreHTTPSErrors=!0,c.baseURL=i??this.options.baseURL,this.options.timezoneId&&(c.timezoneId=this.options.timezoneId),this.options.viewport?c.viewport=this.options.viewport:this.options.fullScreenResolution?c.viewport={width:1280,height:720}:this.options.hostWindowViewport&&(c.deviceScaleFactor=void 0,c.viewport=null),r&&(c.storageState=r),this.context)this.browser=this.context.browser();else if(this.options.useStealth){let p=require("puppeteer-extra-plugin-stealth");BBr.chromium.use(p()),this.browser=await BBr.chromium.launch(this.browserConfig)}else this.browser=await X5e.chromium.launch(this.browserConfig);return this.context||(this.context=await this.browser.newContext(c)),this.options.defaultTimeout&&this.context.setDefaultTimeout(this.options.defaultTimeout),this.options.defaultNavigationTimeout&&this.context.setDefaultNavigationTimeout(this.options.defaultNavigationTimeout),this.context.on("page",async p=>{await this.onNewPage(p),await this.onFrameNavigated(p.mainFrame()),p.on("framenavigated",this.onFrameNavigated)}),this.context.on("close",async()=>{this.contextClosePromise=this.forEachEventListener(p=>{var _;return(_=p.onWebDriverContextClose)==null?void 0:_.call(p)})}),this.activePage=await this.createPage(),this.options.trackLoadedResources&&this.page.on("requestfinished",this.onRequestFinished),this.options.useCDPSession&&(this.cdpSession=await this.context.newCDPSession(this.originalPage)),!0}getContext(){return this.context}get frameMsgBroker(){return this.framesMessageBroker}async createPage(){return this.originalPage=await this.context.newPage(),this.originalPage}async onNewPage(r){}async applyRouteInterceptors(r,i){try{await(r==null?void 0:r.route("**/*",async(s,c)=>this.routeInterceptor.intercept(s,c,{page:r},i)))}catch(s){console.error("[WebDriver] applyRouteInterceptors error",s)}}switchActivePage(r){let i=this.context.pages().find(s=>nw(s)===r);return!i||i.isClosed()?(console.error(`[WebDriver] Page with guid ${r} not found or has been closed.`),!1):(this.previousPage=this.activePage,this.activePage=i,!0)}getDefaultTimeout(){return this.options.defaultTimeout}getDefaultNavigationTimeout(){return this.options.defaultNavigationTimeout}async addHARMockAPIRecordings(r){if(!this.activePage){console.warn("[addHARMockAPIRecordings] Active page is not set, skipping HAR recording.");return}await this.activePage.routeFromHAR(r,{url:/^(?!.*\.(js|mjs|ts|jsx|tsx|css|jpg|jpeg|png|gif|svg|webp|heif|heic|raw|cr2|nef|arw|bmp|tiff|tif|ico|woff|woff2|ttf|otf|doc|docx|pdf|ws|wasm|mp3|wav|aac|flac|mp4|avi|mov|wmv|flv|zip|rar|7z|tar\.gz|xml|html|py|java|cpp|xls|xlsx|ppt|pptx|gif)$)/i,update:!0,updateMode:"minimal"})}forEachEventListener(r){return Promise.all(this.eventListeners.map(async i=>{try{await r(i)}catch(s){console.log("WebDriver/forEachEventListener exception",s)}}))}registerEventListener(r){this.eventListeners.push(r)}async getScript(){async function r(i){let{exec:s}=require("child_process");return new Promise((c,p)=>{s(i,_=>{_?(console.log("error executing cmd, ",_),p(_)):c()})})}switch(e(r,"execCmd"),this.options.scriptSource){case"file":return this.options.scriptFile;case"url":if(this.cacheScript)return this.options.scriptFile;try{return await r(`curl -o ${this.options.scriptFile} '${this.options.scriptURL}'`),this.options.scriptFile}catch(i){console.log("[web-driver] Failed fetching frontend script",i)}break}}async startJSCoverageTracking(){return await this.page.coverage.startJSCoverage(),[];return await this.cdpSession.send("Debugger.enable"),await this.cdpSession.send("Profiler.enable"),await this.cdpSession.send("Profiler.startPreciseCoverage",{callCount:!1,detailed:!0}),this.getCurrentJSCoverage()}stopJSCoverageTracking(){return this.page.coverage.stopJSCoverage()}async getCurrentJSCoverage(){let r=await this.page.coverage.stopJSCoverage();return await this.page.coverage.startJSCoverage(),r;return(await this.cdpSession.send("Profiler.takePreciseCoverage")).result}async startCSSCoverageTracking(){return await this.cdpSession.send("DOM.enable"),await this.cdpSession.send("CSS.enable"),await this.cdpSession.send("CSS.startRuleUsageTracking"),this.getCurrentCSSCoverage()}async getCurrentCSSCoverage(){return(await this.cdpSession.send("CSS.takeCoverageDelta")).coverage}getCDPSession(){return this.cdpSession}async navigate(r){return this.page.goto(r)}async setViewportSize(r,i){return this.page.setViewportSize({width:r,height:i})}async getStorageState(){return this.page.context().storageState()}async shutdown(){try{this.page&&(await this.page.close(),this.activePage=void 0),this.context&&(await this.context.close(),this.context=void 0),this.browser&&(await this.browser.close(),this.browser=void 0)}catch(r){console.warn("[WebDriver] shutdown error",r)}}async wrapWithBrowserLogs(r,{disabled:i=!1,onErrorOnly:s=!1}={}){if(i)return r();let c=[],p=e(E=>{c.push(E.text())},"log");this.page.on("console",p);let _,v;try{v=await r()}catch(E){_=E}if(this.page.off("console",p),(!s||_)&&console.log("browser console messages:",c),_)throw _;return v}async takeElementSnapshot(r,i,s={},c={}){if(r===this.lastSnapshot.selector&&i===this.lastSnapshot.eventCode)return{};if(!r)return{};try{let{snapshot:p,elementLocator:_}=await this.takeSnapshot(r,c,{frameLocatorSelector:s.frameLocatorSelector});return this.lastSnapshot={selector:r,eventCode:i},{snapshot:p,elementLocator:_}}catch(p){return console.error("takeElementSnapshot error",p),{}}}getScreenshotTimeout(r=!1){return r?this.snapshotTimeout:this.snapshotTimeout+5e3}async takePageSnapshot(r){let i=this.page.screenshot({...r,timeout:this.getScreenshotTimeout()});return await Promise.race([i,Mb(this.getScreenshotTimeout(!0))])}async takeSnapshot(r,i,{frameLocatorSelector:s}={}){let c=s?this.page.frameLocator(s).locator(r):this.page.locator(r),p=c.screenshot({...i,timeout:this.getScreenshotTimeout()});return{snapshot:await Promise.race([p,Mb(this.getScreenshotTimeout(!0))]),elementLocator:c}}async getCurrentURL(){return this.page.url()}async getClientScreenResolution(){return await this.page.evaluate(async()=>({width:window.screen.width,height:window.screen.height}))}async awaitContextClose(){return this.contextClosePromise||await Mb(100),this.contextClosePromise}get page(){return this.activePage}getPage(){return this.activePage}startPlaywrightTrace(){return this.tracing=!0,this.context.tracing.start({name:"trace",screenshots:!0,snapshots:!0})}startPlaywrightTraceChunk(){return this.tracingChunk=!0,this.context.tracing.startChunk({name:`trace-chunk-${this.chunkIndex}`})}stopPlaywrightTraceChunk(r){return this.tracingChunk=!1,this.context.tracing.stopChunk({path:`${r.replace(".zip",`.${this.chunkIndex++}.zip`)}`})}stopPlaywrightTrace(r){return this.tracing=!1,this.context.tracing.stop({path:r})}isTracing(){return this.tracing}isTracingChunk(){return this.tracingChunk}};e(OBr,"WebDriver");var dOt=OBr;_6();var _Ot=require("perf_hooks");var RBr=class RBr{constructor(r,i,s,c,p){this.timeMachine=r;this.actionsManager=i;this.apiService=s;this.remoteSessionId=c;this.options=p}rewriteLastActionThought(r){throw new Error("Method not implemented.")}async generateReductionPromptData(r,i){let s=this.getActionTimestamps(r,i);if(!s)return;let c=await this.timeMachine.executeReducedHTMLTask(s.before),p=await this.timeMachine.executeReducedHTMLTask(s.after);return{previousReducedHTML:c,reducedHTML:p,timestamp:s.after}}async generatePromptData(r,i,s){if(this.promptData)return{...this.promptData,assertionsData:i};let c=this.getActionTimestamps(r,s);if(!c)return;let p=await this.timeMachine.executeReducedHTMLTask(c.before),_=await this.timeMachine.executeReducedHTMLTask(c.after);return this.promptData={reduction:{reducedHTML:_,flashingHTML:[]},currentURL:"",previousReducedHTML:p,previousURL:"",actionId:r,assertionsData:i,timestamp:c.after},this.promptData}async generateThoughtPromptData(r,i){let s=await this.generateReductionPromptData(r,i.timestamp);if(!s)return;let c=this.actionsManager.actions.findIndex(v=>v.id===r);if(c===-1){af.error(`Action with id ${r} not found`);return}let p=this.actionsManager.actions[c],_=this.actionsManager.actions[c-1];return{...s,action:p,previousAction:_,assertion:i}}async callApi(r,i,s,c){let p=_Ot.performance.now(),_=await this.generatePromptData(i,s,c);if(this.logPerformance(`- Generated prompt data for ${r}`,p),!_)return;p=_Ot.performance.now();let v=await this.apiService.post(`assertions/${r}`,{sessionId:this.remoteSessionId,data:_});if(!v.ok){af.error(`Request for assertion generation ${r} failed with status ${v.status}`);return}let E=await v.json();return this.logPerformance(`- Received response for assertion generation ${r}`,p),E}async generateAssertions(r,i){try{let s=await this.callApi("generate",r,void 0,i);if(s)return s.timestamps=this.getActionTimestamps(r,i),s}catch(s){throw af.error(s),s}}async refactoringAssertions(r){try{return await this.callApi("refactor",r.actionId,r)}catch(i){throw af.error(i),i}}async filteringAssertions(r){try{return await this.callApi("filter",r.actionId,r)}catch(i){throw af.error(i),i}}getVariables(){return[]}getVariablesString(r){return""}getActionTimestamps(r,i){let s=this.actionsManager.actions,c=s.findIndex(v=>v.id===r);if(c===-1){af.warning(`[init] No action with id ${r} was found in executed actions`);return}let p=s[c],_=s[c+1];return{before:p.timestamp,after:(_==null?void 0:_.timestamp)??i}}logPerformance(r,i){this.options.logPerformance&&af(`${r} in`,_Ot.performance.now()-i,"ms")}};e(RBr,"AssertionsAgent");var JQe=RBr;cT();_6();Kwe();var nwn=require("crypto"),gye=require("perf_hooks");var LBr=class LBr extends P6e{constructor(i,s,c,p,_,v,E){super(i,s,c);this.actionsManager=i;this.apiService=s;this.userStoryService=c;this.timeMachine=p;this.webDriver=_;this.evaluationService=v;this.options=E;this.activeRemoteSessionIdByActionId=new Map}async init({retriesLeft:i=3,keepActionsWithoutDescription:s=!1,lastActionId:c=void 0}={}){await super.init({retriesLeft:i,keepActionsWithoutDescription:s,lastActionId:c}),this.activeRemoteSessionIdByActionId.set(c,this.remoteSessionId)}async generateAiAssertions({id:i,startedAt:s,processId:c}){this.options.logPerformance&&af.info(`generateAiAssertions for action ${i}`);let p=e(async(_=[],v=!1)=>{try{let E=_.map((D,w)=>({...D,id:(0,nwn.randomUUID)(),source:"ai",verified:!0,actionId:i})).filter(D=>{var w;return!["withChecksumAI()","withChecksumAI"].includes(D.matcher)&&!((w=D.usedVariablesNames)!=null&&w.length)});return af.info(`Returned assertions results (${c})`,_.map(({matcher:D,thought:w,locator:B})=>({matcher:D,thought:w,locator:B}))),await this.webDriver.page.evaluate(({assertions:D,actionId:w,error:B,processId:P})=>{window.vtg.onAsyncProcessResponse({actionId:w,assertions:D,error:B,processId:P})},{assertions:E,actionId:i,error:v,processId:c}),E}catch(E){return af.error("Error in AI assertions generation",E),[]}},"sendResultToVTGWithoutUnsupported");try{if(this.isRunning(i))return af.warning("Already generating assertions for this action"),await p();let _=gye.performance.now();if(await this.init({keepActionsWithoutDescription:!0,lastActionId:i}),this.logPerformance(`init for action ${i}`,_),!this.isRunning(i))return await p();let v=new JQe(this.timeMachine,this.actionsManager,this.apiService,this.remoteSessionId,this.options),E=await this.generateAssertions(v,i,s);if(!E||!this.isRunning(i))return await p();if(E.assertions.length===0){let{smartAssertion:D}=E;return D?(D.isSelected=!0,await p([D])):await p()}return I_.vtg.aiAssertions.allowRefactoring&&(E=await this.refactoringAssertions(v,E)),this.isRunning(i)?(I_.vtg.aiAssertions.allowFiltering?E=await this.filteringAssertions(v,E):E.assertions=E.assertions.map(D=>({...D,isSelected:D.isValid})),this.isRunning(i)?(this.logPerformance(`---------------- Overall - Generated assertions for action ${i} in`,_),await p($8n(E))):await p()):await p()}catch(_){return af.error("Error in AI assertions generation",_),await p([],!0)}finally{this.activeRemoteSessionIdByActionId.delete(i)}}stopGenerateAiAssertions(i){this.activeRemoteSessionIdByActionId.delete(i)}isRunning(i){return this.activeRemoteSessionIdByActionId.has(i)}async generateAssertions(i,s,c=void 0){let p=gye.performance.now(),_=p,v=await i.generateAssertions(s,c);if(this.logPerformance(`- generateAssertions for action ${s}`,p),!!v)return p=gye.performance.now(),await this.setSelectionDataForAssertions(v),v.assertions=v.assertions.map(q8n),this.logPerformance(`- setSelectionData for action ${s}`,p),p=gye.performance.now(),await this.validateAssertions(v.assertions,v.timestamps,i),this.logPerformance(`- validate assertions for action ${s}`,p),this.logPerformance(`Overall - Generated assertions for action ${s}`,_),v}async refactoringAssertions(i,s){let c=gye.performance.now(),p=c;try{this.options.logPerformance&&af.info(`Refactoring assertions for action ${s.actionId}`),s=await i.refactoringAssertions(s),this.logPerformance(`- refactoringAssertions for action ${s.actionId}`,c),c=gye.performance.now(),await this.validateAssertions(s.assertions,s.timestamps,i),this.logPerformance(`- validate assertions after refactoring for action ${s.actionId}`,c),this.logPerformance(`Overall - Refactored assertions for action ${s.actionId}`,p)}catch(_){af.error("[refactoringAssertions] Error in assertions refactoring",_)}return s}async filteringAssertions(i,s){try{let c=gye.performance.now();this.options.logPerformance&&af.info(`Filtering assertions for action ${s.actionId}`);let p=await i.filteringAssertions(s);return this.logPerformance(`Overall - filteringAssertions for action ${s.actionId}`,c),p}catch(c){af.error("[filteringAssertions] Error in assertions filtering",c)}}async executeAssertion(i,s){let c=X5e.expect.configure({timeout:500}),p=Hct(i);await this.evaluationService.execute(p,{expect:c,page:s},{frame:"task-time-machine",expectConfig:{timeout:500}})}async validateLocatorMappedToCorrectRrwebId(i,s,c){if(i.locatorMappedToCorrectRrwebId)return;if(!await this.isLocatorMappedToCorrectRrwebId(i,s,c))return i.locatorMappedToCorrectRrwebId=!1,this.handleAssertionValidityError(new Error(`Locator not mapped to correct rrweb id for assertion: ${i.matcher}`),i,"locator not mapped to correct rrweb id")}async validateAssertionOnPreviousState(i,s,c){try{let p=await this.getLocatorsForLocatorString(i,s,c);if(p.length===0){if(mBr(i)&&!i.appliedBeforeAction)throw new Error(`Element not found before action for assertion: ${i.matcher}`);return}await Promise.all(p.map(async _=>{let v={...i,locator:_.toString(),matcher:i.appliedBeforeAction?i.matcher:VQe.getOppositeMatcherClause(i.matcher)};await this.executeAssertion(v,s)}))}catch(p){this.handleAssertionValidityError(p,i,i.appliedBeforeAction?"didn't apply BEFORE the action was executed and it should have":"applied BEFORE the action was executed and it shouldn't have")}}async validateAssertionOnCurrentState(i,s){try{await this.executeAssertion(i,s.frameLocator("iframe"))}catch(c){this.handleAssertionValidityError(c,i,"didn't apply AFTER the action")}}async getLocatorRrwebIds(i,s,c){let p=await this.getLocatorsForLocatorString(i,s,c);return await Promise.all(p.map(_=>_.evaluate(v=>v._rrwebid)))}async getLocatorsForLocatorString(i,s,c){if(cOt(i))return[];let p=i.locator;if(!p)return[];let _=s.frameLocator("iframe"),v=`return ${hBr(i)}`;try{return await(await this.evaluationService.getLocator(v,_)).all()}catch(E){return af.error(`Error getting Locator[] for assertion with locator: ${p}`,v,E.message),[]}}async isLocatorMappedToCorrectRrwebId(i,s,c){if(cOt(i))return!0;let p=await this.getLocatorRrwebIds(i,s,c);return p.length!==1?!1:p[0]===i.rrwebid}async validateAssertions(i,s,c){let p=i.filter(_=>_.isValid===void 0&&!cOt(_));await this.executeValidationTasksOnState(p,s,c,{isPreviousState:!0}),p=p.filter(_=>_.isValid===void 0),await this.executeValidationTasksOnState(p,s,c,{isPreviousState:!1}),p.forEach(_=>{_.isValid??(_.isValid=!0)})}async setSelectionDataForAssertions(i){let s=e(_=>{var v;return(v=_.matcher)==null?void 0:v.startsWith("toBeHidden")},"shouldGetSelectionDataFromPreviousState"),[c,p]=i.assertions.reduce(([_,v],E)=>(s(E)?_.push(E):v.push(E),[_,v]),[[],[]]);await this.setSelectionDataForAssertionsInTimestamp(c,i.timestamps.before),await this.setSelectionDataForAssertionsInTimestamp(p,i.timestamps.after)}async setSelectionDataForAssertionsInTimestamp(i,s){if(!(!i||i.length===0))return this.timeMachine.executeTask(async c=>{await Promise.all(i.map(p=>this.setSelectionData(p,c)))},s,{name:"setSelectionDataForAssertionsInTimestamp"})}async executeValidationTasksOnState(i,s,c,{isPreviousState:p}){let _=p?"validateAssertionOnPreviousState":"validateAssertionOnCurrentState",v=(p?this.validateAssertionOnPreviousState:this.validateAssertionOnCurrentState).bind(this),E=p?s.before:s.after;await this.timeMachine.executeTask(async D=>{for(let w of i){let B=mBr(w)===p;!w.locatorMappedToCorrectRrwebId&&B&&await this.validateLocatorMappedToCorrectRrwebId(w,D,c),await v(w,D,c)}},E,{name:_})}async setSelectionData(i,s){if(!i.rrwebid||i.locator)return;let c;try{let p=await s.evaluate(_=>window.checksum.testGenerator.getInspectedElementSelectionResultByRRwebId(_,{ignoredIframesSelectors:["iframe"],fromTimeMachine:!0}),parseInt(i.rrwebid,10));if(p){Object.assign(i,p,{locatorMappedToCorrectRrwebId:!0});return}else c=new Error("Inspected element result is undefined")}catch(p){c=p}i.locatorMappedToCorrectRrwebId=!1,this.handleAssertionValidityError(c,i,"invalid locator")}logPerformance(i,s){this.options.logPerformance&&af.info(`${i} in ${gye.performance.now()-s} ms`)}handleAssertionValidityError(i,s,c){let p=i.message.split(`
|
|
1730
|
+
})`:c;return v?`, ${D}`:D}let E=this.buildClickActionOptionsObject(r);return this.makeOptions({...i,...E,...p},v)}buildFillValue(r){return Array.isArray(r)?`[${r.map(this.buildFillValue.bind(this)).join(", ")}]`:typeof r=="object"?`{ ${Object.entries(r).map(([i,s])=>`${i}: ${this.buildFillValue(s)}`).join(", ")} }`:typeof r=="string"?Y5e(r):r}buildActionCode(r,i,s){let{eventCode:c,unevaluatedFillValue:p,dropTarget:_,files:v,switchToTab:E,userRole:D,canvas:w,nativeDialog:B,codeContext:P}=r,L=this.buildFillValue(p),j=Aon[c],V=this.getOptionsString(r,s),ee=(P==null?void 0:P.frameTargetName)??"page";switch(c){case"navigation":return[`${i}.${j}(${this.formatURL(p)}${V})`];case"drag_and_drop":return[`${i}.${j}(${this.buildLocatorChain(ee,_.locator,_.locatorWithVars,_.parentFramesSelectors,_.selector,_.selectorWithVars)}${V})`];case"click":case"double_click":case"check":case"uncheck":case"hover":return[`${i}.${j}(${V})`];case"input":case"selectoption":case"keystroke":return[`${i}.${j}(${L}${V})`];case"click_and_type":return[`${i}.click(${V})`,`${i}.pressSequentially(${L}${V?`, ${V}`:""})`];case"clear_and_type":return[`${i}.clear(${this.makeOptions(s)})`,`${i}.pressSequentially(${L}${V?`, ${V}`:""})`];case"custom_code":return[p];case"wait":return[`${i}.${j}(${p||1e3}${V})`];case"upload_files":return v!=null&&v.length||console.warn("Input files are required for SetInputFiles event code"),[`${i}.${j}(page.resolveAssetsFolder(["${v.join('", "')}"])${V})`];case"switch_tab":return[`page = ${i}.${j}(${E.index}${V})`];case"logout_and_login":return[`${i}.${j}("${D}")`];case"canvas_click":return[`${i}.${j}("${w.canvasText}"${w.rectSizeIndex?`, ${w.rectSizeIndex}`:""})`];case"native_accept":{let ue=B.dialogResult!=null&&(0,V8n.isString)(B.dialogResult)?`"${B.dialogResult}"`:"";return[`${i}.waitForDialog().then(async (${B.dialogType}) => {await ${B.dialogType}.accept(${ue})})`]}case"native_dismiss":return[`${i}.waitForDialog().then(async (${B.dialogType}) => {await ${B.dialogType}.dismiss()})`];case"login":return[this.makeLoginCode(r)];default:return[]}}buildLocatorChain(r,i,s,c,p,_,v){let E=this.addFrameSelectorsToLocatorChain(r,c),D=this.addFrameSelectorsToLocatorChain("page",c);if(v){let w=this.buildCompoundSelectorLocatorChain(E,v);if(w)return w}return s?E+=`.${h8t(s,D)}`:_?E+=`.locator('${this.escapeSelector(_)}')`:i?E+=`.${h8t(i,D)}`:p&&(E+=`.locator('${this.escapeSelector(p)}')`),E}addFrameSelectorsToLocatorChain(r,i){return(i??[]).reduce((s,c)=>`${s}.frameLocator('${this.escapeSelector(c)}')`,r)}buildCompoundSelectorLocatorChain(r,i){let s=e(c=>c.selection.type==="content"?`"${c.selection.value}"`:c.locator?`base.${c.locator}`:`base.locator('${this.escapeSelector(c.selector)}')`,"getElementSelector");try{return`${r}.compoundSelection((base) => [${i.contextElements.map(c=>s(c.element)).join(", ")}], (base) => ${i.targetRelativeSelector.locator?`base.${i.targetRelativeSelector.locator}`:`base.locator('${this.escapeSelector(i.targetRelativeSelector.selector)}')`}).first()`}catch(c){console.error("Error building compound selector locator chain",c);return}}formatURL(r){let i=this.resolveRelativeURL(r);return Y5e(decodeURIComponent(i))}resolveRelativeURL(r){if(!r)return"";if(r.startsWith("/"))return r;let i;try{i=new URL(r)}catch(_){if(_ instanceof TypeError)return r;throw _}if(!this.options.environment.baseURL)return r;let s=new URL(this.options.environment.baseURL),c=e(_=>_.replace(/^www\./,""),"normalizeHostname");return!s||s.protocol!==i.protocol||c(s.hostname)!==c(i.hostname)||!i.pathname.startsWith(s.pathname)?r:i.pathname.substring(s.pathname.length).replace(/\/$/,"").replace(/^(?!\/)/,"/")+i.search+i.hash}addVariable(r){this.test.usingVariableStore=!0,this.addCode(Eon([r],{onlyValueExpression:!0}))}addAssertion(r){this.addCode(this.assertionGenerator.generateAssertionCode(r))}addCode(r){Array.isArray(r)||(r=[r]),r.forEach(i=>{if(!i)return;let s=i.trimEnd();s.endsWith(";")||(s+=";"),this.test.lines.push({type:0,content:s})})}addFunction(r){this.test.lines.push({type:0,content:r})}addComment(r){this.test.lines.push({type:1,content:`/* ${r} */`})}getTestMetadata(){return this.test}createFallbackMarkupForSelector(r,i=[],s,c,p){let _=(i||[]).concat(this.test.fallbackMarkups.map(E=>E.id)),v;do v=m8t(5);while(_.indexOf(v)>-1);return{id:v,selector:r,esraMetadata:s,compoundSelector:c==null?void 0:c.metadata,alternateLocators:p}}escapeSelector(r){var i;return(i=r==null?void 0:r.replaceAll("'","\\'"))==null?void 0:i.replaceAll(/\\/g,"\\\\")}};e(Wct,"SingleTestCode");var jre=Wct;_6();var oKi=1e3,cKi=3e4,yBr=class yBr{constructor(r,i,s,c,p,_,v,E,D,w){this.config=r;this.checksumRoot=i;this.pageInteractor=s;this.apiService=c;this.userStoryService=p;this.actionsManager=_;this.testAssetsManager=v;this.webDriver=E;this.evaluatorService=D;this.internalFilesDir=w;this.executeAction=e(async({data:r,id:i,options:s,withPageInteractor:c=!1})=>{try{r.selector=void 0,r.executed=!1;let p=r.eventCode==="custom_code";r.thought="";let _=s.forceUpdateTimestamp?{id:i,timestamp:p?Date.now():void 0}:void 0,v=(()=>{if(s.timeout>=0)return s.timeout;if(s.singlePlay)return r.eventCode==="navigation"?cKi:oKi})();if(c?await this.performActionWithPageInteractor(r,v):await this.performActionWithEvaluation(r,v),_&&!p&&(_.timestamp=Date.now(),!["login","navigation","keystroke","wait","switch_tab","logout_and_login"].includes(r.eventCode))){let D=await this.webDriver.tmFrame.evaluate(w=>window.checksum.timeMachine.sessionReplayer.getLastInteractionEventTimestamp(w),_.timestamp);_.timestamp=Math.max(D??0,s.runStartedAt)}return{data:_,success:!0,message:"Action has been executed successfully"}}catch(p){throw af.error(`Error: ${p.message.slice(0,200)}`),new Error(p.message||p)}},"executeAction")}setPage(r){this.page=r}async performActionWithEvaluation(r,i){let s=r.codeValue??jre.generateSingleActionCode(r,{noFallbacks:!0,generateAssertionsCode:!1,actionOptions:i?{timeout:i}:void 0});await this.evaluatorService.execute(s,void 0,void 0,{stepId:r.id})}async performActionWithPageInteractor(r,i){await this.pageInteractor.performAction(r,{useLocator:!0,timeout:i,monitorFlashingHTML:!1})}async uploadFiles(r){return r.map(({data:s,fileName:c})=>{let p=`${this.testAssetsManager.getLocalAutoSavePath()}/files`;return L8n(s,c,p,this.internalFilesDir),`${p}/${c}`})}async login(r,{role:i,environment:s}){await tOt({config:this.config,folder:this.checksumRoot,throwIfEnvInfoInvalid:!0})(r,{role:i,environment:s}),this.didLogin=!0}async performLogin({role:r,environment:i}){return this.login(this.webDriver.appMainFrame.page(),{role:r,environment:i})}async addInitialLoginAction(){this.actionsManager.addAction({thought:"Log into application",eventCode:"login",id:(0,gBr.randomUUID)(),isInitialAction:!0,login:{role:this.userStoryService.getStory().environment.userRole,environment:this.userStoryService.getStory().environment.name},codeContext:{frameTargetName:null}})}async addStartURLNavigationAction(){var i;let r=(i=this.userStoryService.getStory())==null?void 0:i.url;r&&this.actionsManager.addAction({thought:"Navigate to start URL",eventCode:"navigation",isInitialAction:!0,id:(0,gBr.randomUUID)(),fillValue:r,codeContext:{frameTargetName:null}})}hasLoggedIn(){return this.didLogin}};e(yBr,"VtgActionsService");var uOt=yBr;WS();var vBr=class vBr{constructor(r,i={},s=!0){this.requests=[];this.watcherConfig={minimumWaitTime:250,maximumWaitTime:1e4,followingRequestsWaitTime:250};this.resolved=!0;this.hasMinimumWaitTimePassed=!1;this.useLog=!1;this.logStack=[];this.resolve=e(()=>{this.resolved||(this.resolved=!0,clearTimeout(this.minimumWaitTimer),clearTimeout(this.maximumWaitTimer),clearTimeout(this.followingRequestWaitTimeoutId),this.loadResolve({totalTime:Date.now()-this.startTS,logs:this.logStack,pendingRequests:this.requests.length,totalRequests:this.observedRequestsCount}))},"resolve");this.watcherConfig={...this.watcherConfig,...i},this.initListeners(r),this.useLog=s}initListeners(r){r.on("request",i=>{var s;this.hasMinimumWaitTimePassed||(s=this.watcherConfig.whitelist)!=null&&s.length&&!this.watcherConfig.whitelist.some(c=>c.test(i.url()))||(this.useLog&&this.logStack.push(`${i.method()} ${i.url().substring(0,60)}`),this.requests.push(i),this.observedRequestsCount+=1)}),r.on("response",i=>{this.requests=this.requests.filter(s=>s!==i.request()),this.hasMinimumWaitTimePassed&&(this.requests.length||(clearTimeout(this.followingRequestWaitTimeoutId),this.followingRequestWaitTimeoutId=setTimeout(()=>{this.requests.length||this.resolve()},this.watcherConfig.followingRequestsWaitTime)))})}async wait(){return new Promise(r=>{this.loadResolve=r,this.resolved=!1,this.minimumWaitTimer=setTimeout(()=>{this.hasMinimumWaitTimePassed=!0,this.requests.length||this.resolve()},this.watcherConfig.minimumWaitTime),this.maximumWaitTimer=setTimeout(this.resolve,this.watcherConfig.maximumWaitTime)})}startListening(){this.requests=[],this.startTS=Date.now(),this.hasMinimumWaitTimePassed=!1,this.observedRequestsCount=0,this.useLog&&(this.logStack=[])}};e(vBr,"NetworkWatcher");var lOt=vBr;var J8n=require("crypto");WS();GLe();t0e();_6();var uKi=e(n=>({...n.fillValue&&{value:n.fillValue},...n.selector&&{selector:n.selector},type:von[n.eventCode],id:n.id,files:[]}),"webPageActionToNextAction"),ABr=class ABr{constructor(r,i,s){this.actionsManager=r;this.apiService=i;this.userStoryService=s}clear(){this.remoteSessionId=void 0}async init({retriesLeft:r=3,keepActionsWithoutDescription:i=!1,lastActionId:s=void 0}={}){let{goal:c,instructions:p}=this.userStoryService.getStory(),_=this.actionsManager.actions??[];if(s){let D=_.findIndex(({id:w})=>w===s);D===-1&&af.error(`[init] No action with id ${s} was found in executed actions`),_=_.slice(0,D+1)}i||(_=_.filter(D=>!!D.thought));let v={previous:_.map(D=>({thought:D.thought,action:uKi(D)}))},E={type:"test-generation",storyTitle:c,storyInstructions:p,testId:void 0,testSuiteId:void 0,thoughtsAndActions:v};try{let D=await this.apiService.post("ai-fallback/init",{data:E,format:"json"}),{sessionId:w}=await D.json();this.remoteSessionId=w}catch(D){if(af.error(D),await Mb(2e3),r>0)return this.init({retriesLeft:r-1,keepActionsWithoutDescription:i});throw D}}};e(ABr,"VtgAiSessionBaseService");var P6e=ABr;_6();var xBr=class xBr extends P6e{constructor(i,s,c,p,_,v){super(p,_,v);this.webDriver=i;this.pageInteractor=s;this.actionsService=c;this.actionsManager=p;this.apiService=_;this.userStoryService=v;this.previousActionFailed=!1;this.currentChecksumId="0";this.executeAction=e(async({data:i,options:s={isAISuggestion:!0}})=>{await this.webDriver.clearHighlights(),this.previousActionFailed=!1;let c;try{let p=new lOt(this.webDriver.appMainFrame.page());p.startListening(),c=await this.actionsService.executeAction({data:i,id:i.id,options:s}),await p.wait(),await Mb(2e3)}catch(p){throw this.previousActionFailed=!0,af.error(p),new Error(p)}return s.valueChanged&&await this.init(),c},"executeAction")}async init({keepActionsWithoutDescription:i}={keepActionsWithoutDescription:!0}){return this.clear(),super.init({keepActionsWithoutDescription:i})}clear(){super.clear(),this.previousActionFailed=!1,this.currentChecksumId="0"}async iterate({guidance:i}={}){await this.webDriver.getTimeMachine().toggleTimeMachineHandleEvents(!1);let{reducedHTML:s,flashingHTML:c,elementsForNodeInterpretation:p,currentChecksumId:_}=await this.webDriver.evaluateWithChecksum(async({appRules:v,currentChecksumId:E})=>window.checksum.testGenerator.reduceHTML(v,{stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:E}),{appRules:{appSpecificInteractableElementsSelectors:[]},currentChecksumId:this.currentChecksumId});this.currentChecksumId=_;try{let v=await this.getNextAction({reducedHTML:s,flashingHTML:c,elementsForNodeInterpretation:p,guidance:i}),D={...await this.pageInteractor.translateActionResponseToAgentPotentialAction(v),id:(0,J8n.randomUUID)(),timestamp:Date.now()};return await this.webDriver.highlightElementByLocator(this.pageInteractor.makeLocator(D.selector,D.parentFramesSelectors),D.clickOffset,"10px solid rgba(255,0,0,1)",!0),D}catch(v){af.error("error in ai iterate",v)}}async stop(){}async getNextAction({reducedHTML:i,flashingHTML:s,elementsForNodeInterpretation:c,guidance:p}){let _={reduction:{reducedHTML:i,flashingHTML:s,elementsForNodeInterpretation:c},currentURL:this.webDriver.appMainFrame.url(),previousActionOverview:{success:!this.previousActionFailed,userCorrection:p}};try{return await(await this.apiService.post("ai-fallback/iterate",{sessionId:this.remoteSessionId,iterationData:_})).json()}catch(v){throw console.error(v),v}}};e(xBr,"VtgAITestGenerationService");var pOt=xBr;uBr();i6e();var X5e=require("@playwright/test"),BBr=nd(NBr());WS();var PBr=class PBr{constructor(r){this.options=r;this.harData={methodIndex:{GET:0,POST:0,PUT:0,DELETE:0}};this.interceptors={recordHar:this.harInterceptor.bind(this),completeOriginHeader:this.completeOriginHeaderInterceptor.bind(this)};this.intercept=e(async(r,i,s,c)=>{let p=c??this.options,_=[],v=e(E=>{if(E)switch(E.type){case"abort":return r.abort(E.errorCode);case"fulfill":return r.fulfill(E.fulfillOptions);default:case"continue":_.push(E)}},"processResult");for(let[E,D]of Object.entries(this.interceptors))if(p[E]){let w=v(await D(r,i,s));if(w)return w}return this.applyContinueResults(r,_)},"intercept")}setOptions(r){this.options=r}mergeOptions(r){this.options={...this.options,...r}}applyContinueResults(r,i){let s=i.filter(p=>!!p),c={};return s.forEach(p=>{p.options&&(p.options.headers&&(c.headers={...c.headers,...p.options.headers}),p.options.method&&(c.method=p.options.method),p.options.postData&&(c.postData=p.options.postData),p.options.url&&(c.url=p.options.url))}),r.continue(c)}async harInterceptor(r){let i=r.request().headers(),s=r.request().method();return i["Checksum-Id"]=(++this.harData.methodIndex[s]).toString(),{options:{headers:i}}}async completeOriginHeaderInterceptor(r,i,{page:s}){if(i.resourceType()==="document")return;let c=r.request().headers();if(!c.Origin&&!c.origin){try{let p=new URL(s.url()).origin;c.origin=p,c.Origin=p}catch{}return{options:{headers:c}}}}};e(PBr,"RouteInterceptors");var fOt=PBr;P3r();bRe();K4r();var OBr=class OBr{constructor(r={},i={},s=new XMe,c=void 0){this.framesMessageBroker=s;this.context=c;this.browserConfig={executablePath:process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH??void 0};this.options={fullScreenResolution:!1,disableWebSecurity:!0};this.contextClosePromise=void 0;this.eventListeners=[];this.lastSnapshot={selector:void 0,eventCode:void 0};this.snapshotTimeout=3e4;this.cacheScript=!1;this.pagesIndexToGuid={};this.onRequestFinished=e(async r=>{try{let i=await r.response();if(!i.ok())return;let s=r.resourceType(),c=r.url(),p=e(async()=>{try{return await i.text()}catch{try{return await(await fetch(c)).text()}catch{return}}},"getBody");if(["document","script","stylesheet"].includes(s))try{let _=await p();if(!_)return;let v={url:c,source:_,type:s};await this.forEachEventListener(E=>{var D;return(D=E.onWebDriverResourceLoaded)==null?void 0:D.call(E,v)})}catch(_){console.error("[WebDriver] requestfinished event handler error",s,c,_)}}catch(i){console.error("[WebDriver] requestfinished event handler error",i)}},"onRequestFinished");this.onFrameNavigated=e(async r=>{let i=e(async s=>{await this.forEachEventListener(c=>{var p;return(p=c.onWebDriverFrameNavigated)==null?void 0:p.call(c,r,s)})},"notifyFrameNavigated");await i(!1),await this.injectedScriptManager.onFrameNavigated(r),await i(!0)},"onFrameNavigated");this.tracing=!1;this.tracingChunk=!1;this.chunkIndex=0;var p;if(this.options={...this.options,...r},this.browserConfig={...this.browserConfig,...i},this.injectedScriptManager=new Mje(this.options),this.browserConfig.args||(this.browserConfig.args=[]),this.options.disableWebSecurity&&this.browserConfig.args.push("--disable-web-security"),this.options.allowFileAccess&&this.browserConfig.args.push("--allow-file-access-from-files"),this.browserConfig.args.push("--disable-site-isolation-trials"),this.browserConfig.args.push("--allow-running-insecure-content"),this.options.remoteDebugging&&this.browserConfig.args.push(`--remote-debugging-port=${this.options.remoteDebuggingPort??"9222"}`),this.options.forceHeadless&&(this.browserConfig.headless=!0),this.options.useProxy)if((p=this.options.webProxy)!=null&&p.server){console.log("[WebDriver] using proxy");let{server:_,username:v,password:E}=this.options.webProxy;this.browserConfig.proxy={server:_,username:v,password:E},this.browserConfig.args.push("--proxy-bypass-list=localhost,127.0.0.1")}else console.error("[WebDriver] useProxy=true but proxy not configured");this.routeInterceptor=new fOt({completeOriginHeader:this.options.completeOriginHeader,recordHar:this.options.recordHAR})}async prepare({storageState:r,baseURL:i,shutdown:s=!0}={}){s&&await this.shutdown();let c={};if(c.bypassCSP=!0,c.ignoreHTTPSErrors=!0,c.baseURL=i??this.options.baseURL,this.options.timezoneId&&(c.timezoneId=this.options.timezoneId),this.options.viewport?c.viewport=this.options.viewport:this.options.fullScreenResolution?c.viewport={width:1280,height:720}:this.options.hostWindowViewport&&(c.deviceScaleFactor=void 0,c.viewport=null),r&&(c.storageState=r),this.context)this.browser=this.context.browser();else if(this.options.useStealth){let p=require("puppeteer-extra-plugin-stealth");BBr.chromium.use(p()),this.browser=await BBr.chromium.launch(this.browserConfig)}else this.browser=await X5e.chromium.launch(this.browserConfig);return this.context||(this.context=await this.browser.newContext(c)),this.options.defaultTimeout&&this.context.setDefaultTimeout(this.options.defaultTimeout),this.options.defaultNavigationTimeout&&this.context.setDefaultNavigationTimeout(this.options.defaultNavigationTimeout),this.context.on("page",async p=>{await this.onNewPage(p),await this.onFrameNavigated(p.mainFrame()),p.on("framenavigated",this.onFrameNavigated)}),this.context.on("close",async()=>{this.contextClosePromise=this.forEachEventListener(p=>{var _;return(_=p.onWebDriverContextClose)==null?void 0:_.call(p)})}),this.activePage=await this.createPage(),this.options.trackLoadedResources&&this.page.on("requestfinished",this.onRequestFinished),this.options.useCDPSession&&(this.cdpSession=await this.context.newCDPSession(this.originalPage)),!0}getContext(){return this.context}get frameMsgBroker(){return this.framesMessageBroker}async createPage(){return this.originalPage=await this.context.newPage(),this.originalPage}async onNewPage(r){}async applyRouteInterceptors(r,i){try{await(r==null?void 0:r.route("**/*",async(s,c)=>this.routeInterceptor.intercept(s,c,{page:r},i)))}catch(s){console.error("[WebDriver] applyRouteInterceptors error",s)}}switchActivePage(r){let i=this.context.pages().find(s=>nw(s)===r);return!i||i.isClosed()?(console.error(`[WebDriver] Page with guid ${r} not found or has been closed.`),!1):(this.previousPage=this.activePage,this.activePage=i,!0)}getDefaultTimeout(){return this.options.defaultTimeout}getDefaultNavigationTimeout(){return this.options.defaultNavigationTimeout}async addHARMockAPIRecordings(r){if(!this.activePage){console.warn("[addHARMockAPIRecordings] Active page is not set, skipping HAR recording.");return}await this.activePage.routeFromHAR(r,{url:/^(?!.*\.(js|mjs|ts|jsx|tsx|css|jpg|jpeg|png|gif|svg|webp|heif|heic|raw|cr2|nef|arw|bmp|tiff|tif|ico|woff|woff2|ttf|otf|doc|docx|pdf|ws|wasm|mp3|wav|aac|flac|mp4|avi|mov|wmv|flv|zip|rar|7z|tar\.gz|xml|html|py|java|cpp|xls|xlsx|ppt|pptx|gif)$)/i,update:!0,updateMode:"minimal"})}forEachEventListener(r){return Promise.all(this.eventListeners.map(async i=>{try{await r(i)}catch(s){console.log("WebDriver/forEachEventListener exception",s)}}))}registerEventListener(r){this.eventListeners.push(r)}async getScript(){async function r(i){let{exec:s}=require("child_process");return new Promise((c,p)=>{s(i,_=>{_?(console.log("error executing cmd, ",_),p(_)):c()})})}switch(e(r,"execCmd"),this.options.scriptSource){case"file":return this.options.scriptFile;case"url":if(this.cacheScript)return this.options.scriptFile;try{return await r(`curl -o ${this.options.scriptFile} '${this.options.scriptURL}'`),this.options.scriptFile}catch(i){console.log("[web-driver] Failed fetching frontend script",i)}break}}async startJSCoverageTracking(){return await this.page.coverage.startJSCoverage(),[];return await this.cdpSession.send("Debugger.enable"),await this.cdpSession.send("Profiler.enable"),await this.cdpSession.send("Profiler.startPreciseCoverage",{callCount:!1,detailed:!0}),this.getCurrentJSCoverage()}stopJSCoverageTracking(){return this.page.coverage.stopJSCoverage()}async getCurrentJSCoverage(){let r=await this.page.coverage.stopJSCoverage();return await this.page.coverage.startJSCoverage(),r;return(await this.cdpSession.send("Profiler.takePreciseCoverage")).result}async startCSSCoverageTracking(){return await this.cdpSession.send("DOM.enable"),await this.cdpSession.send("CSS.enable"),await this.cdpSession.send("CSS.startRuleUsageTracking"),this.getCurrentCSSCoverage()}async getCurrentCSSCoverage(){return(await this.cdpSession.send("CSS.takeCoverageDelta")).coverage}getCDPSession(){return this.cdpSession}async navigate(r){return this.page.goto(r)}async setViewportSize(r,i){return this.page.setViewportSize({width:r,height:i})}async getStorageState(){return this.page.context().storageState()}async shutdown(){try{this.page&&(await this.page.close(),this.activePage=void 0),this.context&&(await this.context.close(),this.context=void 0),this.browser&&(await this.browser.close(),this.browser=void 0)}catch(r){console.warn("[WebDriver] shutdown error",r)}}async wrapWithBrowserLogs(r,{disabled:i=!1,onErrorOnly:s=!1}={}){if(i)return r();let c=[],p=e(E=>{c.push(E.text())},"log");this.page.on("console",p);let _,v;try{v=await r()}catch(E){_=E}if(this.page.off("console",p),(!s||_)&&console.log("browser console messages:",c),_)throw _;return v}async takeElementSnapshot(r,i,s={},c={}){if(r===this.lastSnapshot.selector&&i===this.lastSnapshot.eventCode)return{};if(!r)return{};try{let{snapshot:p,elementLocator:_}=await this.takeSnapshot(r,c,{frameLocatorSelector:s.frameLocatorSelector});return this.lastSnapshot={selector:r,eventCode:i},{snapshot:p,elementLocator:_}}catch(p){return console.error("takeElementSnapshot error",p),{}}}getScreenshotTimeout(r=!1){return r?this.snapshotTimeout:this.snapshotTimeout+5e3}async takePageSnapshot(r){let i=this.page.screenshot({...r,timeout:this.getScreenshotTimeout()});return await Promise.race([i,Mb(this.getScreenshotTimeout(!0))])}async takeSnapshot(r,i,{frameLocatorSelector:s}={}){let c=s?this.page.frameLocator(s).locator(r):this.page.locator(r),p=c.screenshot({...i,timeout:this.getScreenshotTimeout()});return{snapshot:await Promise.race([p,Mb(this.getScreenshotTimeout(!0))]),elementLocator:c}}async getCurrentURL(){return this.page.url()}async getClientScreenResolution(){return await this.page.evaluate(async()=>({width:window.screen.width,height:window.screen.height}))}async awaitContextClose(){return this.contextClosePromise||await Mb(100),this.contextClosePromise}get page(){return this.activePage}getPage(){return this.activePage}startPlaywrightTrace(){return this.tracing=!0,this.context.tracing.start({name:"trace",screenshots:!0,snapshots:!0})}startPlaywrightTraceChunk(){return this.tracingChunk=!0,this.context.tracing.startChunk({name:`trace-chunk-${this.chunkIndex}`})}stopPlaywrightTraceChunk(r){return this.tracingChunk=!1,this.context.tracing.stopChunk({path:`${r.replace(".zip",`.${this.chunkIndex++}.zip`)}`})}stopPlaywrightTrace(r){return this.tracing=!1,this.context.tracing.stop({path:r})}isTracing(){return this.tracing}isTracingChunk(){return this.tracingChunk}};e(OBr,"WebDriver");var dOt=OBr;_6();var _Ot=require("perf_hooks");var RBr=class RBr{constructor(r,i,s,c,p){this.timeMachine=r;this.actionsManager=i;this.apiService=s;this.remoteSessionId=c;this.options=p}rewriteLastActionThought(r){throw new Error("Method not implemented.")}async generateReductionPromptData(r,i){let s=this.getActionTimestamps(r,i);if(!s)return;let c=await this.timeMachine.executeReducedHTMLTask(s.before),p=await this.timeMachine.executeReducedHTMLTask(s.after);return{previousReducedHTML:c,reducedHTML:p,timestamp:s.after}}async generatePromptData(r,i,s){if(this.promptData)return{...this.promptData,assertionsData:i};let c=this.getActionTimestamps(r,s);if(!c)return;let p=await this.timeMachine.executeReducedHTMLTask(c.before),_=await this.timeMachine.executeReducedHTMLTask(c.after);return this.promptData={reduction:{reducedHTML:_,flashingHTML:[]},currentURL:"",previousReducedHTML:p,previousURL:"",actionId:r,assertionsData:i,timestamp:c.after},this.promptData}async generateThoughtPromptData(r,i){let s=await this.generateReductionPromptData(r,i.timestamp);if(!s)return;let c=this.actionsManager.actions.findIndex(v=>v.id===r);if(c===-1){af.error(`Action with id ${r} not found`);return}let p=this.actionsManager.actions[c],_=this.actionsManager.actions[c-1];return{...s,action:p,previousAction:_,assertion:i}}async callApi(r,i,s,c){let p=_Ot.performance.now(),_=await this.generatePromptData(i,s,c);if(this.logPerformance(`- Generated prompt data for ${r}`,p),!_)return;p=_Ot.performance.now();let v=await this.apiService.post(`assertions/${r}`,{sessionId:this.remoteSessionId,data:_});if(!v.ok){af.error(`Request for assertion generation ${r} failed with status ${v.status}`);return}let E=await v.json();return this.logPerformance(`- Received response for assertion generation ${r}`,p),E}async generateAssertions(r,i){try{let s=await this.callApi("generate",r,void 0,i);if(s)return s.timestamps=this.getActionTimestamps(r,i),s}catch(s){throw af.error(s),s}}async refactoringAssertions(r){try{return await this.callApi("refactor",r.actionId,r)}catch(i){throw af.error(i),i}}async filteringAssertions(r){try{return await this.callApi("filter",r.actionId,r)}catch(i){throw af.error(i),i}}getVariables(){return[]}getVariablesString(r){return""}getActionTimestamps(r,i){let s=this.actionsManager.actions,c=s.findIndex(v=>v.id===r);if(c===-1){af.warning(`[init] No action with id ${r} was found in executed actions`);return}let p=s[c],_=s[c+1];return{before:p.timestamp,after:(_==null?void 0:_.timestamp)??i}}logPerformance(r,i){this.options.logPerformance&&af(`${r} in`,_Ot.performance.now()-i,"ms")}};e(RBr,"AssertionsAgent");var JQe=RBr;cT();_6();Kwe();var nwn=require("crypto"),gye=require("perf_hooks");var LBr=class LBr extends P6e{constructor(i,s,c,p,_,v,E){super(i,s,c);this.actionsManager=i;this.apiService=s;this.userStoryService=c;this.timeMachine=p;this.webDriver=_;this.evaluationService=v;this.options=E;this.activeRemoteSessionIdByActionId=new Map}async init({retriesLeft:i=3,keepActionsWithoutDescription:s=!1,lastActionId:c=void 0}={}){await super.init({retriesLeft:i,keepActionsWithoutDescription:s,lastActionId:c}),this.activeRemoteSessionIdByActionId.set(c,this.remoteSessionId)}async generateAiAssertions({id:i,startedAt:s,processId:c}){this.options.logPerformance&&af.info(`generateAiAssertions for action ${i}`);let p=e(async(_=[],v=!1)=>{try{let E=_.map((D,w)=>({...D,id:(0,nwn.randomUUID)(),source:"ai",verified:!0,actionId:i})).filter(D=>{var w;return!["withChecksumAI()","withChecksumAI"].includes(D.matcher)&&!((w=D.usedVariablesNames)!=null&&w.length)});return af.info(`Returned assertions results (${c})`,_.map(({matcher:D,thought:w,locator:B})=>({matcher:D,thought:w,locator:B}))),await this.webDriver.page.evaluate(({assertions:D,actionId:w,error:B,processId:P})=>{window.vtg.onAsyncProcessResponse({actionId:w,assertions:D,error:B,processId:P})},{assertions:E,actionId:i,error:v,processId:c}),E}catch(E){return af.error("Error in AI assertions generation",E),[]}},"sendResultToVTGWithoutUnsupported");try{if(this.isRunning(i))return af.warning("Already generating assertions for this action"),await p();let _=gye.performance.now();if(await this.init({keepActionsWithoutDescription:!0,lastActionId:i}),this.logPerformance(`init for action ${i}`,_),!this.isRunning(i))return await p();let v=new JQe(this.timeMachine,this.actionsManager,this.apiService,this.remoteSessionId,this.options),E=await this.generateAssertions(v,i,s);if(!E||!this.isRunning(i))return await p();if(E.assertions.length===0){let{smartAssertion:D}=E;return D?(D.isSelected=!0,await p([D])):await p()}return I_.vtg.aiAssertions.allowRefactoring&&(E=await this.refactoringAssertions(v,E)),this.isRunning(i)?(I_.vtg.aiAssertions.allowFiltering?E=await this.filteringAssertions(v,E):E.assertions=E.assertions.map(D=>({...D,isSelected:D.isValid})),this.isRunning(i)?(this.logPerformance(`---------------- Overall - Generated assertions for action ${i} in`,_),await p($8n(E))):await p()):await p()}catch(_){return af.error("Error in AI assertions generation",_),await p([],!0)}finally{this.activeRemoteSessionIdByActionId.delete(i)}}stopGenerateAiAssertions(i){this.activeRemoteSessionIdByActionId.delete(i)}isRunning(i){return this.activeRemoteSessionIdByActionId.has(i)}async generateAssertions(i,s,c=void 0){let p=gye.performance.now(),_=p,v=await i.generateAssertions(s,c);if(this.logPerformance(`- generateAssertions for action ${s}`,p),!!v)return p=gye.performance.now(),await this.setSelectionDataForAssertions(v),v.assertions=v.assertions.map(q8n),this.logPerformance(`- setSelectionData for action ${s}`,p),p=gye.performance.now(),await this.validateAssertions(v.assertions,v.timestamps,i),this.logPerformance(`- validate assertions for action ${s}`,p),this.logPerformance(`Overall - Generated assertions for action ${s}`,_),v}async refactoringAssertions(i,s){let c=gye.performance.now(),p=c;try{this.options.logPerformance&&af.info(`Refactoring assertions for action ${s.actionId}`),s=await i.refactoringAssertions(s),this.logPerformance(`- refactoringAssertions for action ${s.actionId}`,c),c=gye.performance.now(),await this.validateAssertions(s.assertions,s.timestamps,i),this.logPerformance(`- validate assertions after refactoring for action ${s.actionId}`,c),this.logPerformance(`Overall - Refactored assertions for action ${s.actionId}`,p)}catch(_){af.error("[refactoringAssertions] Error in assertions refactoring",_)}return s}async filteringAssertions(i,s){try{let c=gye.performance.now();this.options.logPerformance&&af.info(`Filtering assertions for action ${s.actionId}`);let p=await i.filteringAssertions(s);return this.logPerformance(`Overall - filteringAssertions for action ${s.actionId}`,c),p}catch(c){af.error("[filteringAssertions] Error in assertions filtering",c)}}async executeAssertion(i,s){let c=X5e.expect.configure({timeout:500}),p=Hct(i);await this.evaluationService.execute(p,{expect:c,page:s},{frame:"task-time-machine",expectConfig:{timeout:500}})}async validateLocatorMappedToCorrectRrwebId(i,s,c){if(i.locatorMappedToCorrectRrwebId)return;if(!await this.isLocatorMappedToCorrectRrwebId(i,s,c))return i.locatorMappedToCorrectRrwebId=!1,this.handleAssertionValidityError(new Error(`Locator not mapped to correct rrweb id for assertion: ${i.matcher}`),i,"locator not mapped to correct rrweb id")}async validateAssertionOnPreviousState(i,s,c){try{let p=await this.getLocatorsForLocatorString(i,s,c);if(p.length===0){if(mBr(i)&&!i.appliedBeforeAction)throw new Error(`Element not found before action for assertion: ${i.matcher}`);return}await Promise.all(p.map(async _=>{let v={...i,locator:_.toString(),matcher:i.appliedBeforeAction?i.matcher:VQe.getOppositeMatcherClause(i.matcher)};await this.executeAssertion(v,s)}))}catch(p){this.handleAssertionValidityError(p,i,i.appliedBeforeAction?"didn't apply BEFORE the action was executed and it should have":"applied BEFORE the action was executed and it shouldn't have")}}async validateAssertionOnCurrentState(i,s){try{await this.executeAssertion(i,s.frameLocator("iframe"))}catch(c){this.handleAssertionValidityError(c,i,"didn't apply AFTER the action")}}async getLocatorRrwebIds(i,s,c){let p=await this.getLocatorsForLocatorString(i,s,c);return await Promise.all(p.map(_=>_.evaluate(v=>v._rrwebid)))}async getLocatorsForLocatorString(i,s,c){if(cOt(i))return[];let p=i.locator;if(!p)return[];let _=s.frameLocator("iframe"),v=`return ${hBr(i)}`;try{return await(await this.evaluationService.getLocator(v,_)).all()}catch(E){return af.error(`Error getting Locator[] for assertion with locator: ${p}`,v,E.message),[]}}async isLocatorMappedToCorrectRrwebId(i,s,c){if(cOt(i))return!0;let p=await this.getLocatorRrwebIds(i,s,c);return p.length!==1?!1:p[0]===i.rrwebid}async validateAssertions(i,s,c){let p=i.filter(_=>_.isValid===void 0&&!cOt(_));await this.executeValidationTasksOnState(p,s,c,{isPreviousState:!0}),p=p.filter(_=>_.isValid===void 0),await this.executeValidationTasksOnState(p,s,c,{isPreviousState:!1}),p.forEach(_=>{_.isValid??(_.isValid=!0)})}async setSelectionDataForAssertions(i){let s=e(_=>{var v;return(v=_.matcher)==null?void 0:v.startsWith("toBeHidden")},"shouldGetSelectionDataFromPreviousState"),[c,p]=i.assertions.reduce(([_,v],E)=>(s(E)?_.push(E):v.push(E),[_,v]),[[],[]]);await this.setSelectionDataForAssertionsInTimestamp(c,i.timestamps.before),await this.setSelectionDataForAssertionsInTimestamp(p,i.timestamps.after)}async setSelectionDataForAssertionsInTimestamp(i,s){if(!(!i||i.length===0))return this.timeMachine.executeTask(async c=>{await Promise.all(i.map(p=>this.setSelectionData(p,c)))},s,{name:"setSelectionDataForAssertionsInTimestamp"})}async executeValidationTasksOnState(i,s,c,{isPreviousState:p}){let _=p?"validateAssertionOnPreviousState":"validateAssertionOnCurrentState",v=(p?this.validateAssertionOnPreviousState:this.validateAssertionOnCurrentState).bind(this),E=p?s.before:s.after;await this.timeMachine.executeTask(async D=>{for(let w of i){let B=mBr(w)===p;!w.locatorMappedToCorrectRrwebId&&B&&await this.validateLocatorMappedToCorrectRrwebId(w,D,c),await v(w,D,c)}},E,{name:_})}async setSelectionData(i,s){if(!i.rrwebid||i.locator)return;let c;try{let p=await s.evaluate(_=>window.checksum.testGenerator.getInspectedElementSelectionResultByRRwebId(_,{ignoredIframesSelectors:["iframe"],fromTimeMachine:!0}),parseInt(i.rrwebid,10));if(p){Object.assign(i,p,{locatorMappedToCorrectRrwebId:!0});return}else c=new Error("Inspected element result is undefined")}catch(p){c=p}i.locatorMappedToCorrectRrwebId=!1,this.handleAssertionValidityError(c,i,"invalid locator")}logPerformance(i,s){this.options.logPerformance&&af.info(`${i} in ${gye.performance.now()-s} ms`)}handleAssertionValidityError(i,s,c){let p=i.message.split(`
|
|
1731
1731
|
`);af.warning("Failed validating assertion",p.slice(0,Math.min(p.findIndex(_=>_.startsWith("Call log:")),6)).filter(_=>_).map(_=>_.substring(0,100)).join(`
|
|
1732
1732
|
`)),s&&(s.isValid=!1,s.invalidReason=c)}};e(LBr,"VtgAiAssertionsService");var mOt=LBr;var awn=require("@playwright/test");_6();Kwe();var MBr=class MBr extends Error{constructor(r){super(`Step with id ${r} was not found`),this.name="StepNotFoundError"}};e(MBr,"StepNotFoundError");var B6e=MBr;var Q4=nd(lT());function iwn(n,r,i){let s=Q4.createSourceFile("temp.ts",n,Q4.ScriptTarget.Latest,!0),c=!1,_=Q4.transform(s,[e(w=>{let B=e(P=>{if(Q4.isPropertyAssignment(P)||Q4.isShorthandPropertyAssignment(P)){let L=P.name;if(Q4.isIdentifier(L)&&L.text===r||Q4.isStringLiteral(L)&&L.text===r){c=!0;let j;if(i===void 0)j=Q4.factory.createIdentifier("undefined");else{let V=String(i);isNaN(Number(V))?j=Q4.factory.createStringLiteral(V):j=Q4.factory.createNumericLiteral(V)}return Q4.factory.createPropertyAssignment(L,j)}}return Q4.visitEachChild(P,B,w)},"visit");return P=>Q4.visitNode(P,B)},"transformer")]);if(!c)return n;let v=_.transformed[0],D=Q4.createPrinter({newLine:Q4.NewLineKind.LineFeed,removeComments:!1}).printNode(Q4.EmitHint.Unspecified,v,s);return _.dispose(),D.trim()}e(iwn,"overwriteFieldValue");var jBr=class jBr{constructor(r,i,s){this.webDriver=r;this.actionsManager=i;this.evaluatorService=s}setPage(r){this.page=r}async verifyOnLive({data:r,id:i,options:s}){let c=await this.verify({assertion:r,timeout:s.singlePlay?1e3:void 0}),p=s.forceUpdateTimestamp?{id:i,timestamp:Date.now()}:void 0;return{...c,data:p}}async verifyOnTimeMachine({data:r}){try{return this.verify({assertion:r,context:{page:this.webDriver.tmFrame.frameLocator("iframe")},executionFrame:"vtg-time-machine",timeout:1e3})}catch(i){return af.error(i),{success:!1,message:String(i)}}}async verify({assertion:r,timeout:i,context:s={},executionFrame:c}){try{let p=r.codeValue||jre.generateSingleAssertionCode(r),_={frame:c};return i&&(p=iwn(p,"timeout",i),s.expect=awn.expect.configure({timeout:i}),_.expectConfig={timeout:i}),await this.evaluatorService.execute(p,s,_,{stepId:r.id}),{success:!0,message:"Assertion verified successfully!"}}catch(p){return af.error(String(p).slice(0,200)),{success:!1,message:String(p)}}}async updateAssertion({data:r,id:i}){if(this.actionsManager.actions.findIndex(({id:p})=>r.actionId===p)===-1)throw new B6e(r.actionId);let c={...r,selected:!0,id:i};return this.actionsManager.updateAssertionById(r.actionId,c)}createAssertion(r){let{id:i,data:s,options:c,type:p}=r;switch(c==null?void 0:c.type){case"insertAfter":{let _=this.actionsManager.findActionOrAssertionById(c.afterStepId);return _.action||`${c.afterStepId}`,s.actionId=_.action.id,s.selected=!0,s.id=i,_.assertion?this.actionsManager.addAssertionToAction(s,_.assertion.id):this.actionsManager.addAssertionToAction(s),s}case"insertLast":return this.actionsManager.addAssertionToAction(s),s;case"replace":{let _=this.actionsManager.findActionOrAssertionById(c.stepId);if(!_.action)throw new Error(`[generateAssertionForAction findActionOrAssertionById] No action with id ${c.stepId} was found in executed actions`);if(s.actionId=_.action.id,s.selected=!0,s.id=i,!_.assertion)throw new Error(`[generateAssertionForAction findActionOrAssertionById] No assertion with id ${c.stepId} was found in executed actions`);return this.actionsManager.replaceAssertion(s,_.assertion.id),s}case"replaceLast":{let _=this.actionsManager.actions[this.actionsManager.actions.length-1];if(!_)throw new Error("[generateAssertionForAction] No actions found to replace last assertion");s.actionId=_.id,s.selected=!0,s.id=i;let v=_.assertions[_.assertions.length-1];return v?this.actionsManager.replaceAssertion(s,v.id):this.actionsManager.addAssertionToAction(s),s}default:throw new Error("Add all VTGStepAdditionType switch cases handle")}}};e(jBr,"VtgAssertionsService");var hOt=jBr;i6e();_6();i6e();var Z5e=class Z5e{constructor(){this.cssFeaturesCache=new Map;this.parentChainCache=new Map}static getInstance(){return Z5e.instance||(Z5e.instance=new Z5e),Z5e.instance}getCSSKeyFeatures(r){return this.cssFeaturesCache.get(this.makeKey(r))}setCSSKeyFeatures(r,i){this.cssFeaturesCache.set(this.makeKey(r),i)}getParentChain(r){return this.parentChainCache.get(this.makeKey(r))}setParentChain(r,i){this.parentChainCache.set(this.makeKey(r),i)}makeKey(r){let{timestamp:i,rrwebId:s}=r;return`${i}_${s}`}};e(Z5e,"LocatorsAssetsCache");var O6e=Z5e;WS();_6();i6e();var UBr=class UBr{log(...r){console.log(...r)}logError(...r){console.error(...r)}};e(UBr,"TMPAgentLoggerConsole");var gOt=UBr;Git();var QBr=class QBr{constructor(r,i=null,s=async()=>null,c=new gOt){this.selectorGeneratorApi=r;this.variables=i;this.evaluate=s;this.logger=c}async generateSelectionForAction(r,i){var v,E;let{useCSSExtraction:s,useVariables:c,useArbitrarySelector:p}=i,_=!1;if(p&&!r.contextElements&&r.isPartOfListItem&&r.couldPickAnyListItem)try{this.logger.log("*** Will generate arbitrary selector");let D=await this.evaluate(async({checksumId:w})=>window.checksum.testGenerator.buildArbitraryListItem(w),{checksumId:r.action.checksumid});if(D)return D[0]}catch(D){console.error("Error generating arbitrary selector",D)}if(!_||!r.contextElements||!r.isPartOfListItem){let D=(v=await this.generateWithLLMFiltering(r.action.checksumid,await this.generateLocatorsForElement(r.action.checksumid,{isPartOfListItem:r.isPartOfListItem,isForContextElement:!1,useCSSExtraction:s}),null,this.testCandidates.bind(this),{isPartOfListItem:r.isPartOfListItem,useVariables:c}))==null?void 0:v[0];if(D)return r.isPartOfListItem&&!D.locator.endsWith(".first()")&&(D.selector+=" >> nth=0",D.locator+=".first()",(E=D.selectorWithVars)!=null&&E.length&&(D.selectorWithVars+=" >> nth=0",D.locatorWithVars+=".first()")),D}if(_&&r.contextElements){let D=await this.generateCompoundSelector(r.action.checksumid,r.isPartOfListItem);if(D)return{compoundSelector:D}}console.log("[SelectorGenerator] Failed to generate selection")}async generateLLMLocators(r){try{return await this.selectorGeneratorApi.generateLLMLocators(r)}catch(i){return console.error("Error generating LLM locators",i),[]}}async correctLLMLocators(r){try{return this.selectorGeneratorApi.correctLLMLocators(r)}catch(i){return console.error("Error in LLM locators correction",i),[]}}async generateWithLLMFiltering(r,i,s,c,{useImage:p=!0,useVariables:_=!0,isPartOfListItem:v=!1,isForContextElement:E=!1}={}){var D;try{if(v){let P=i.find(L=>L.isListSelector);if(P)return[P]}let w=i.length>1||_&&Object.keys(((D=this.variables)==null?void 0:D.keyValue)??{}).length>0?await this.selectorGeneratorApi.runLLMFiltering(i,s??await this.getParentChainHTML(r),{useImage:p,useVariables:_}):i;if(!w)return;let B=await c(w.map(P=>({...P,selector:P.selector??""})),r,{testUniqueness:!(v||E),useVariables:_});return B?B.map(P=>({...P,alternateLocators:{origin:"filtered",locators:B.filter(L=>L!==P).map(L=>L.locator)}})):[]}catch(w){this.logger.log("Error generating selector with LLM filtering",w);return}}async generateCompoundSelector(r,i){try{this.logger.log("*** Will generate compound selector");let s=await this.selectorGeneratorApi.extractCompoundSelectionData(r);return this.processContextElements(s,i)}catch(s){this.logger.log("Error generating compound selector",s);return}}async processContextElements(r,i){let s=await this.evaluate(async({contextElementsMetadata:p,isPartOfListItem:_})=>window.checksum.testGenerator.getCompoundSelector().filter(p,{isPartOfListItem:_}).map(({element:v,...E})=>E),{contextElementsMetadata:r,isPartOfListItem:i});if(console.log(`Filtered context elements: ${s.length}`),s.length<2){this.logger.log("<!> No context elements found besides target, skipping");return}let c;try{if(c=await this.evaluate(async({contextElements:p,isPartOfListItem:_})=>window.checksum.testGenerator.getCompoundSelector().generate(p,{isPartOfListItem:_}),{contextElements:s,isPartOfListItem:i}),!c){this.logger.log("Error generating compound selector metadata for context elements");return}this.logger.log(`Generated compound selector metadata for ${s.length} context elements (including target)`)}catch(p){this.logger.log("Error generating compound selector metadata for context elements",p.message)}try{this.logger.log("** Generating selectors for context elements");let p=[];await Promise.all(s.map(async E=>{var w;if(E.selection.type==="content"){p.push({element:{...E,selector:`internal:text="${E.selection.value}"`,locator:`getByText("${E.selection.value}")`}});return}let D=(w=await this.generateWithLLMFiltering(E.selection.checksumid,await this.generateLocatorsForElement(E.selection.checksumid,{isForContextElement:!0,useCSSExtraction:!1,isPartOfListItem:!1}),null,this.testCandidates.bind(this),{useImage:!1,isForContextElement:!0}))==null?void 0:w[0];if(!D)throw new Error("Failed to generate selector for context element");p.push({element:{...E,...D},alternateLocators:D.alternateLocators})}));let{targetSelection:_}=c,v=_.playwrightSelectors.length>0?_.playwrightSelectors[0]:{selector:_.cssSelectors[0]};if(!v.selector)throw new Error("Failed to get target relative selector");return this.logger.log("Generated customer facing compound selector - ",[...p.map(E=>E.element.selector),"target: "+v.selector]),{contextElements:p,targetRelativeSelector:v,metadata:c}}catch(p){this.logger.log("Error generating customer facing compound selector metadata for context elements",p)}}async testCandidates(r,i,{testUniqueness:s=!0,useVariables:c=!0}={}){var _;let p=[];for(let v of r)try{c=c&&!!((_=v.variables)!=null&&_.length);let E=await this.evaluate(async({checksumId:D,locator:w,testVariables:B,testUniqueness:P})=>window.checksum.testGenerator.testElementSelector(w,D,B,P),{checksumId:i,locator:c?this.implantVariablesValues(v):v.locator,testVariables:c?{locatorWithVars:v.locator,variablesCode:this.variables.code}:void 0,testUniqueness:s});E.valid&&p.push(E)}catch(E){console.error("Error testing selector",E);continue}return p}implantVariablesValues(r){var s;return(s=r.variables)!=null&&s.length?Object.entries(this.variables.keyValue).map(([c,p])=>[vCe+c,p]).filter(([c])=>r.variables.map(p=>p.name).includes(c)).reduce((c,[p,_])=>c.replace("${"+p+"}",_),r.selector):r.selector}async getParentChainHTML(r){try{return this.parentChainHTML||(this.parentChainHTML={}),this.parentChainHTML[r]||(this.parentChainHTML[r]=await this.evaluate(async({checksumId:i})=>window.checksum.testGenerator.getParentChainHTML(i),{checksumId:r})),this.parentChainHTML[r]}catch(i){throw this.logger.log("Error getting parent chain HTML",i),i}}async getExtractCSSKeyElements(r){try{let i=await this.getParentChainHTML(r);return this.selectorGeneratorApi.extractCSSKeyElements(i)}catch(i){return this.logger.log("Error generating prompt for CSS key elements",i),[]}}async generateLocatorsForElement(r,i={isPartOfListItem:!1,isForContextElement:!1,useCSSExtraction:!0}){try{console.log("Generating custom locators");let s=i.useCSSExtraction?await this.getExtractCSSKeyElements(r):[],c=await this.evaluate(async({checksumId:p,keyFeatures:_,...v})=>window.checksum.testGenerator.buildCustomPlaywrightSelectors(p,_,v),{checksumId:r,keyFeatures:s,...i});return this.logger.log("Generated locators for filtering (first is playwright's)",c),c}catch(s){throw this.logger.log("Error generating prompt for selectors",s),s}}};e(QBr,"SelectorGenerator");var Zct=QBr;_6();var qBr=class qBr{constructor(r,i){this.promptAssets=r;this.apiService=i}async runLLMFiltering(r=[],i,{useImage:s=!0,useVariables:c=!0}={}){try{let p={title:this.promptAssets.title,steps:this.promptAssets.steps,thought:this.promptAssets.thought,parentChainHTML:i,generatedLocators:r,...s&&this.promptAssets.image?this.promptAssets.image:{}},_=await this.apiService.post("vtg/locators/filter",p),v,E=await _.text();try{v=JSON.parse(E)}catch(D){throw af.error("Failed parsing LLM filtering JSON",E),D}return v}catch(p){return af.error("Failed getting LLM filtering response from API",p.message),[]}}async extractCompoundSelectionData(r){throw new Error("Method not implemented.")}async extractCSSKeyElements(r){r||(r=this.promptAssets.parentChainHTML);let{title:i,steps:s,thought:c}=this.promptAssets,p={title:i,steps:s,thought:c,parentChainHTML:r};try{return await(await this.apiService.post("vtg/locators/extract-css",p)).json()}catch(_){throw af.error(_),_}}async generateLLMLocators(r){r||(r=this.promptAssets.parentChainHTML);let{title:i,steps:s,thought:c}=this.promptAssets,p={title:i,steps:s,thought:c,parentChainHTML:r};try{let _=await this.apiService.post("vtg/locators/generate",p);if(!_.ok)throw new Error(`HTTP error when calling generate locators, status: ${_.status}`);let v;try{v=await _.json()}catch(D){throw new Error("error parsing JSON, "+D.message)}return v}catch(_){throw af.error("Failed getting generate locators response from API",_.message),_}}async correctLLMLocators(r,i){i||(i=this.promptAssets.parentChainHTML);let{title:s,steps:c,thought:p}=this.promptAssets,_={title:s,steps:c,thought:p,parentChainHTML:i,locators:r};try{let v=await this.apiService.post("vtg/locators/correct",_);return JSON.parse(await v.text())}catch(v){throw af.error(v),v}}};e(qBr,"VTGSelectorGeneratorAPI");var zQe=qBr;cT();var $Br=e(n=>{if(!n)return n;let r="",i=0,s=n.indexOf('"'),c=n.lastIndexOf('"');for(;i<n.length;)n[i]==='"'&&i!==s&&i!==c&&(i===0||n[i-1]!=="\\")?r+='\\"':r+=n[i],i++;return r},"escapeInnerQuotationMarks");var VBr=class VBr{constructor(r,i,s,c,p,_,v){this.processId=r;this.step=i;this.target=s;this.apiService=c;this.userStoryService=p;this.evaluationService=_;this.locatorInteractor=v;this.didCancel=!1}cancel(){this.didCancel=!0}async generateAILocators(){try{let r=this.getLocatorOwner();if(!r)throw new Error("Failed to get locator owner");let i=await this.locatorInteractor.getParentChainHTML(r);if(!i)throw new Error("Failed to get parent chain HTML");let s=[];return s=await this.generateLLMLocators(r,i),(s==null?void 0:s.length)>0?Array.from(new Set(s.concat(r.locator))):[]}catch(r){throw af.error(`Failed to generate AI locators (${this.processId})`,r),r}}async extractCSS(r=[]){try{let i=this.getLocatorOwner();if(!i)throw new Error("Failed to get locator owner");let s=await this.locatorInteractor.getParentChainHTML(i);if(!s)throw new Error("Failed to get parent chain HTML");if(this.didCancel)return;let c=await this.generateCSSKeyFeaturesLocators(s,i);if(!(c!=null&&c.length))throw new Error("No locators generated");let p=(await Promise.all(r.map(async v=>this.locatorExpressionToSelectorAndLocator(v)))).filter(v=>v),_=Array.from(new Set(c.concat(p)));return this.didCancel?void 0:_}catch(i){throw af.error(`Failed to extract CSS (${this.processId})`,i.message),i}}async filterLocators(r=[]){try{let i=this.getLocatorOwner();if(!i)throw new Error("Failed to get locator owner");let s=await this.locatorInteractor.getParentChainHTML(i);if(!s)throw new Error("Failed to get parent chain HTML");let c=e(()=>{let v=r.filter(w=>w),E=v.filter(w=>w.length>=100).sort((w,B)=>w.length-B.length).slice(0,5),D=v.filter(w=>w.length<100).concat(E).sort((w,B)=>w.length-B.length).slice(0,10);return Array.from(new Set(D))},"filterCandidates"),p=(await Promise.all(c().map(async v=>this.locatorExpressionToSelectorAndLocator(v)))).filter(v=>v);if(this.didCancel)return;let _=await this.runLLMFilteringForLocator(s,p,i);return this.didCancel?void 0:_}catch(i){throw af.error(`Failed to filter locators (${this.processId})`,i),i}}async runLLMFilteringForLocator(r,i,s,c){var D;let p={...this.getSelectorGeneratorBasePromptAssets(),parentChainHTML:r,generatedLocators:i,image:c},_="",v=new Zct(new zQe(p,this.apiService)),E=I_.vtg.aiLocators.useFakeAILocators?await this.getFakeSelectionData(s,i):(D=await v.generateWithLLMFiltering(_,i,r,async w=>(await this.locatorInteractor.candidatesTester(w,s,"runLLMFilteringForLocator",{verifyExactElement:this.isAssertion()})).filter(B=>B.success),{useImage:!!c,useVariables:!1,isPartOfListItem:!1,isForContextElement:!1}))==null?void 0:D[0];if(!E)throw new Error(`Failed generating selection data with LLM filtering (${this.processId})`);return E}async getFakeSelectionData(r,i){if(await Mb(2e3),!!i.length)return{selector:`* >> ${i[0].selector}`,locator:r.locator,alternateLocators:{origin:"ai",locators:i.slice(1).map(s=>`* >> ${s.selector}`)}}}async generateCSSKeyFeaturesLocators(r,i){let s=await this.getCSSKeyFeatures(i,r),c=(await this.locatorInteractor.generateCustomPWLocators(i.locator,s,this.step)).filter(_=>_);return c.length?(await this.locatorInteractor.candidatesTester(c,i,"generateCSSKeyFeaturesLocators",{verifyExactElement:this.isAssertion()})).filter(_=>_.success):[]}async getCSSKeyFeatures(r,i){if(r.rrwebId){let c=O6e.getInstance().getCSSKeyFeatures(r);if(c)return c}if(I_.vtg.aiLocators.useFakeAILocators)return await Mb(3e3),[];let s=await this.getCSSKeyFeaturesFromAPI(i);return r.rrwebId&&O6e.getInstance().setCSSKeyFeatures(r,s),s}async getCSSKeyFeaturesFromAPI(r){let i={...this.getSelectorGeneratorBasePromptAssets(),parentChainHTML:r};return new zQe(i,this.apiService).extractCSSKeyElements()}async locatorExpressionToSelectorAndLocator(r){try{let i=await this.evaluationService.evaluate(`return ${FL($Br(r))}`);return{selector:$Br(i._selector),locator:r}}catch(i){af.error(i);return}}async generateLLMLocators(r,i){try{let s={...this.getSelectorGeneratorBasePromptAssets(),parentChainHTML:i.replace(/\s*checksumid="[^"]*"/g,"")},c=new Zct(new zQe(s,this.apiService)),p=await c.generateLLMLocators();if(!p.length)return[];if(this.didCancel)return[];let _=await this.locatorInteractor.candidatesTester(p.map(v=>({locator:v})),r,"generateLLMLocators",{verifyExactElement:this.isAssertion()});if(_.filter(v=>!v.success).length>=Math.ceil(_.length/2)){let v=await c.correctLLMLocators(_),E=await this.locatorInteractor.candidatesTester(v.map(D=>({locator:D})),r,"generateLLMLocatorsCorrection",{verifyExactElement:this.isAssertion()});if(this.didCancel)return[];_.push(...E)}return _.filter(v=>v.success).map(v=>v.locator)}catch(s){return af.error("Failed generating LLM locators",s),[]}}isAssertion(){return this.target.type==="assertion"}getLocatorOwner(){switch(this.target.type){case"assertion":case"action":return this.step;case"dropTarget":return{...this.step.dropTarget,timestamp:this.step.timestamp}}}getSelectorGeneratorBasePromptAssets(){try{let{goal:r,instructions:i}=this.getStory();return{title:r,steps:i,thought:this.step.thought}}catch(r){return af.error("Failed getting base prompt assets",r),{title:"",steps:"",thought:this.step.thought}}}getStory(){return this.userStoryService.getStory()}};e(VBr,"LocatorsAIAgent");var yOt=VBr;i6e();_6();WS();function lwn(n,r=!1){return IKi("javascript",n,r)[0]}e(lwn,"asLocator");var GQe,AKi=(GQe=class{constructor(r){this.preferredQuote=r;this.preferredQuote=r}generateLocator(r,i,s,c={}){switch(i){case"default":return c.hasText!==void 0?`locator(${this.quote(s)}, { hasText: ${this.toHasText(c.hasText)} })`:c.hasNotText!==void 0?`locator(${this.quote(s)}, { hasNotText: ${this.toHasText(c.hasNotText)} })`:`locator(${this.quote(s)})`;case"frame":return`frameLocator(${this.quote(s)})`;case"nth":return`nth(${s})`;case"first":return"first()";case"last":return"last()";case"role":let p=[];vOt(c.name)?p.push(`name: ${this.regexToSourceString(c.name)}`):typeof c.name=="string"&&(p.push(`name: ${this.quote(c.name)}`),c.exact&&p.push("exact: true"));for(let{name:v,value:E}of c.attrs)p.push(`${v}: ${typeof E=="string"?this.quote(E):E}`);let _=p.length?`, { ${p.join(", ")} }`:"";return`getByRole(${this.quote(s)}${_})`;case"has-text":return`filter({ hasText: ${this.toHasText(s)} })`;case"has-not-text":return`filter({ hasNotText: ${this.toHasText(s)} })`;case"has":return`filter({ has: ${s} })`;case"hasNot":return`filter({ hasNot: ${s} })`;case"and":return`and(${s})`;case"or":return`or(${s})`;case"chain":return`locator(${s})`;case"test-id":return`getByTestId(${this.toTestIdValue(s)})`;case"text":return this.toCallWithExact("getByText",s,!!c.exact);case"alt":return this.toCallWithExact("getByAltText",s,!!c.exact);case"placeholder":return this.toCallWithExact("getByPlaceholder",s,!!c.exact);case"label":return this.toCallWithExact("getByLabel",s,!!c.exact);case"title":return this.toCallWithExact("getByTitle",s,!!c.exact);default:throw new Error("Unknown selector kind "+i)}}chainLocators(r){return r.join(".")}regexToSourceString(r){return RKi(String(r))}toCallWithExact(r,i,s){return vOt(i)?`${r}(${this.regexToSourceString(i)})`:s?`${r}(${this.quote(i)}, { exact: true })`:`${r}(${this.quote(i)})`}toHasText(r){return vOt(r)?this.regexToSourceString(r):this.quote(r)}toTestIdValue(r){return vOt(r)?this.regexToSourceString(r):this.quote(r)}quote(r){let i;return NKi(r,(i=this.preferredQuote)!=null?i:"'")}},e(GQe,"JavaScriptLocatorFactory"),GQe),KQe,_9=(KQe=class{constructor(){this.tokenType=""}toJSON(){return{token:this.tokenType}}toString(){return this.tokenType}toSource(){return""+this}},e(KQe,"CSSParserToken"),KQe),YQe,Iqe=(YQe=class extends _9{constructor(i=void 0,s=void 0){super();this.value=i;this.mirror=s;this.value="",this.mirror=""}},e(YQe,"GroupingToken"),YQe),XQe,pwn=(XQe=class extends Iqe{constructor(){super(),this.tokenType="(",this.value="(",this.mirror=")"}},e(XQe,"OpenParenToken"),XQe),ZQe,fwn=(ZQe=class extends _9{constructor(){super(),this.tokenType=","}},e(ZQe,"CommaToken"),ZQe),eqe,dwn=(eqe=class extends _9{constructor(){super(),this.tokenType=":"}},e(eqe,"ColonToken"),eqe),tqe,xKi=(tqe=class extends _9{constructor(){super(),this.tokenType="~="}},e(tqe,"IncludeMatchToken"),tqe),rqe,bKi=(rqe=class extends _9{constructor(){super(),this.tokenType="|="}},e(rqe,"DashMatchToken"),rqe),nqe,_wn=(nqe=class extends Iqe{constructor(){super(),this.tokenType="[",this.value="[",this.mirror="]"}},e(nqe,"OpenSquareToken"),nqe),iqe,EKi=(iqe=class extends _9{constructor(){super(),this.tokenType="$="}},e(iqe,"SuffixMatchToken"),iqe),aqe,zBr=(aqe=class extends Iqe{constructor(){super(),this.tokenType="]",this.value="]",this.mirror="["}},e(aqe,"CloseSquareToken"),aqe),sqe,HBr=(sqe=class extends _9{constructor(){super(),this.tokenType="WHITESPACE"}toString(){return"WS"}toSource(){return" "}},e(sqe,"WhitespaceToken"),sqe),oqe,CKi=(oqe=class extends _9{constructor(){super(),this.tokenType="*="}},e(oqe,"SubstringMatchToken"),oqe),cqe,mwn=(cqe=class extends _9{constructor(){super(),this.tokenType=";"}},e(cqe,"SemicolonToken"),cqe),uqe,AOt=(uqe=class extends _9{constructor(){super(),this.tokenType="EOF"}toSource(){return""}},e(uqe,"EOFToken"),uqe),lqe,DKi=(lqe=class extends _9{constructor(){super(),this.tokenType="^="}},e(lqe,"PrefixMatchToken"),lqe),pqe,hwn=(pqe=class extends _9{constructor(){super(),this.tokenType="BADSTRING"}},e(pqe,"BadStringToken"),pqe),fqe,gwn=(fqe=class extends _9{constructor(){super(),this.tokenType="CDO"}toSource(){return"<!--"}},e(fqe,"CDOToken"),fqe),dqe,ywn=(dqe=class extends _9{constructor(){super(),this.tokenType="CDC"}toSource(){return"-->"}},e(dqe,"CDCToken"),dqe),_qe,vwn=(_qe=class extends Iqe{constructor(){super(),this.tokenType="{",this.value="{",this.mirror="}"}},e(_qe,"OpenCurlyToken"),_qe),mqe,Awn=(mqe=class extends Iqe{constructor(){super(),this.tokenType="}",this.value="}",this.mirror="{"}},e(mqe,"CloseCurlyToken"),mqe),hqe,xwn=(hqe=class extends _9{constructor(){super(),this.tokenType="||"}},e(hqe,"ColumnToken"),hqe),gqe,bwn=(gqe=class extends Iqe{constructor(){super(),this.tokenType=")",this.value=")",this.mirror="("}},e(gqe,"CloseParenToken"),gqe),yqe,Fqe=(yqe=class extends _9{constructor(i=void 0){super();this.value=i;this.value=""}ASCIIMatch(i){return this.value.toLowerCase()===i.toLowerCase()}toJSON(){let i=this.constructor.prototype.constructor.prototype.toJSON.call(this);return i.value=this.value,i}},e(yqe,"StringValuedToken"),yqe),vqe,Ewn=(vqe=class extends Fqe{constructor(r){super(),this.tokenType="IDENT",this.value=r}toString(){return"IDENT("+this.value+")"}toSource(){return rut(this.value)}},e(vqe,"IdentToken"),vqe),Aqe,xOt=(Aqe=class extends _9{constructor(){super(),this.tokenType="BADURL"}},e(Aqe,"BadURLToken"),Aqe),xqe,bOt=(xqe=class extends Fqe{constructor(i,s=void 0){super();this.mirror=s;this.tokenType="FUNCTION",this.value=i,this.mirror=")"}toString(){return"FUNCTION("+this.value+")"}toSource(){return rut(this.value)+"("}},e(xqe,"FunctionToken"),xqe),bqe,Cwn=(bqe=class extends Fqe{constructor(r){super(),this.tokenType="AT-KEYWORD",this.value=r}toString(){return"AT("+this.value+")"}toSource(){return"@"+rut(this.value)}},e(bqe,"AtKeywordToken"),bqe),Eqe,Dwn=(Eqe=class extends Fqe{constructor(i,s=void 0){super();this.type=s;this.tokenType="HASH",this.value=i,this.type="unrestricted"}toString(){return"HASH("+this.value+")"}toJSON(){let i=this.constructor.prototype.constructor.prototype.toJSON.call(this);return i.value=this.value,i.type=this.type,i}toSource(){return this.type==="id"?"#"+rut(this.value):"#"+$Ki(this.value)}},e(Eqe,"HashToken"),Eqe),Cqe,Swn=(Cqe=class extends Fqe{constructor(r){super(),this.tokenType="STRING",this.value=r}toString(){return'"'+Fwn(this.value)+'"'}},e(Cqe,"StringToken"),Cqe),Dqe,wwn=(Dqe=class extends Fqe{constructor(r){super(),this.tokenType="URL",this.value=r}toString(){return"URL("+this.value+")"}toSource(){return'url("'+Fwn(this.value)+'")'}},e(Dqe,"URLToken"),Dqe),Sqe,Twn=(Sqe=class extends _9{constructor(i=void 0,s=void 0,c=void 0,p=void 0){super();this.type=i;this.unit=s;this.repr=c;this.value=p;this.tokenType="NUMBER",this.type="integer",this.repr=""}toString(){return this.type==="integer"?"INT("+this.value+")":"NUMBER("+this.value+")"}toJSON(){let i=super.toJSON();return i.value=this.value,i.type=this.type,i.repr=this.repr,i}toSource(){return this.repr}},e(Sqe,"NumberToken"),Sqe),wqe,kwn=(wqe=class extends _9{constructor(i=void 0,s=void 0){super();this.repr=i;this.value=s;this.tokenType="PERCENTAGE",this.repr=""}toString(){return"PERCENTAGE("+this.value+")"}toJSON(){let i=this.constructor.prototype.constructor.prototype.toJSON.call(this);return i.value=this.value,i.repr=this.repr,i}toSource(){return this.repr+"%"}},e(wqe,"PercentageToken"),wqe),Tqe,SKi=(Tqe=class extends _9{constructor(i=void 0,s=void 0,c=void 0,p=void 0){super();this.type=i;this.unit=s;this.repr=c;this.value=p;this.tokenType="DIMENSION",this.type="integer",this.repr="",this.unit=""}toString(){return"DIM("+this.value+","+this.unit+")"}toJSON(){let i=this.constructor.prototype.constructor.prototype.toJSON.call(this);return i.value=this.value,i.type=this.type,i.repr=this.repr,i.unit=this.unit,i}toSource(){let i=this.repr,s=rut(this.unit);return s[0].toLowerCase()==="e"&&(s[1]==="-"||aF(s.charCodeAt(1),48,57))&&(s="\\65 "+s.slice(1,s.length)),i+s}},e(Tqe,"DimensionToken"),Tqe),wKi={javascript:AKi},kqe,RH=(kqe=class extends Error{},e(kqe,"InvalidSelectorError"),kqe),own=new Set(["internal:has","internal:has-not","internal:and","internal:or","internal:chain","left-of","right-of","above","below","near"]),TKi=new Set(["left-of","right-of","above","below","near"]),kKi=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 IKi(n,r,i=!1,s=20,c=void 0){try{return HQe(new wKi[n](c),Iwn(r),i,s)}catch(p){return console.error("failed to convert selector to locators",r,p),[`locator('${r}')`]}}e(IKi,"asLocators");function HQe(n,r,i=!1,s=20){let c=[...r.parts];for(let v=0;v<c.length-1;v++)if(c[v].name==="nth"&&c[v+1].name==="internal:control"&&c[v+1].body==="enter-frame"){let[E]=c.splice(v,1);c.splice(v+1,0,E)}let p=[],_=i?"frame-locator":"page";for(let v=0;v<c.length;v++){let E=c[v],D=_;if(_="locator",E.name==="nth"){E.body==="0"?p.push([n.generateLocator(D,"first",""),n.generateLocator(D,"nth","0")]):E.body==="-1"?p.push([n.generateLocator(D,"last",""),n.generateLocator(D,"nth","-1")]):p.push([n.generateLocator(D,"nth",E.body)]);continue}if(E.name==="internal:text"){let{exact:V,text:ee}=eut(E.body);p.push([n.generateLocator(D,"text",ee,{exact:V})]);continue}if(E.name==="internal:has-text"){let{exact:V,text:ee}=eut(E.body);if(!V){p.push([n.generateLocator(D,"has-text",ee,{exact:V})]);continue}}if(E.name==="internal:has-not-text"){let{exact:V,text:ee}=eut(E.body);if(!V){p.push([n.generateLocator(D,"has-not-text",ee,{exact:V})]);continue}}if(E.name==="internal:has"){let V=HQe(n,E.body.parsed,!1,s);p.push(V.map(ee=>n.generateLocator(D,"has",ee)));continue}if(E.name==="internal:has-not"){let V=HQe(n,E.body.parsed,!1,s);p.push(V.map(ee=>n.generateLocator(D,"hasNot",ee)));continue}if(E.name==="internal:and"){let V=HQe(n,E.body.parsed,!1,s);p.push(V.map(ee=>n.generateLocator(D,"and",ee)));continue}if(E.name==="internal:or"){let V=HQe(n,E.body.parsed,!1,s);p.push(V.map(ee=>n.generateLocator(D,"or",ee)));continue}if(E.name==="internal:chain"){let V=HQe(n,E.body.parsed,!1,s);p.push(V.map(ee=>n.generateLocator(D,"chain",ee)));continue}if(E.name==="internal:label"){let{exact:V,text:ee}=eut(E.body);p.push([n.generateLocator(D,"label",ee,{exact:V})]);continue}if(E.name==="internal:role"){let V=JBr(E.body,!0),ee={attrs:[]};for(let ue of V.attributes)ue.name==="name"?(ee.exact=ue.caseSensitive,ee.name=ue.value):(ue.name==="level"&&typeof ue.value=="string"&&(ue.value=+ue.value),ee.attrs.push({name:ue.name==="include-hidden"?"includeHidden":ue.name,value:ue.value}));p.push([n.generateLocator(D,"role",V.name,ee)]);continue}if(E.name==="internal:testid"){let V=JBr(E.body,!0),{value:ee}=V.attributes[0];p.push([n.generateLocator(D,"test-id",ee)]);continue}if(E.name==="internal:attr"){let V=JBr(E.body,!0),{name:ee,value:ue,caseSensitive:le}=V.attributes[0],de=ue,xe=!!le;if(ee==="placeholder"){p.push([n.generateLocator(D,"placeholder",de,{exact:xe})]);continue}if(ee==="alt"){p.push([n.generateLocator(D,"alt",de,{exact:xe})]);continue}if(ee==="title"){p.push([n.generateLocator(D,"title",de,{exact:xe})]);continue}}let w="default",B=c[v+1];B&&B.name==="internal:control"&&B.body==="enter-frame"&&(w="frame",_="frame-locator",v++);let P=COt({parts:[E]}),L=n.generateLocator(D,w,P);if(w==="default"&&B&&["internal:has-text","internal:has-not-text"].includes(B.name)){let{exact:V,text:ee}=eut(B.body);if(!V){let ue=n.generateLocator("locator",B.name==="internal:has-text"?"has-text":"has-not-text",ee,{exact:V}),le={};B.name==="internal:has-text"?le.hasText=ee:le.hasNotText=ee;let de=n.generateLocator(D,"default",P,le);p.push([n.chainLocators([L,ue]),de]),v++;continue}}let j;if(["xpath","css"].includes(E.name)){let V=COt({parts:[E]},!0);j=n.generateLocator(D,w,V)}p.push([L,j].filter(Boolean))}return FKi(n,p,s)}e(HQe,"innerAsLocators");function FKi(n,r,i){let s=r.map(()=>""),c=[],p=e(_=>{if(_===r.length)return c.push(n.chainLocators(s)),s.length<i;for(let v of r[_])if(s[_]=v,!p(_+1))return!1;return!0},"visit");return p(0),c}e(FKi,"combineTokens");function COt(n,r=void 0){return typeof n=="string"?n:n.parts.map((i,s)=>{let c=!0;!r&&s!==n.capture&&(i.name==="css"||i.name==="xpath"&&i.source.startsWith("//")||i.source.startsWith(".."))&&(c=!1);let p=c?i.name+"=":"";return`${s===n.capture?"*":""}${p}${i.source}`}).join(" >> ")}e(COt,"stringifySelector");function eut(n){let r=!1,i=n.match(/^\/(.*)\/([igm]*)$/);return i?{text:new RegExp(i[1],i[2])}:(n.endsWith('"')?(n=JSON.parse(n),r=!0):n.endsWith('"s')?(n=JSON.parse(n.substring(0,n.length-1)),r=!0):n.endsWith('"i')&&(n=JSON.parse(n.substring(0,n.length-1)),r=!1),{exact:r,text:n})}e(eut,"detectExact");function JBr(n,r){let i=0,s=n.length===0,c=e(()=>n[i]||"","next"),p=e(()=>{let ee=c();return++i,s=i>=n.length,ee},"eat1"),_=e(ee=>{throw s?new RH(`Unexpected end of selector while parsing selector \`${n}\``):new RH(`Error while parsing selector \`${n}\` - unexpected symbol "${c()}" at position ${i}`+(ee?" during "+ee:""))},"syntaxError");function v(){for(;!s&&/\s/.test(c());)p()}e(v,"skipSpaces");function E(ee){return ee>="\x80"||ee>="0"&&ee<="9"||ee>="A"&&ee<="Z"||ee>="a"&&ee<="z"||ee>="0"&&ee<="9"||ee==="_"||ee==="-"}e(E,"isCSSNameChar");function D(){let ee="";for(v();!s&&E(c());)ee+=p();return ee}e(D,"readIdentifier");function w(ee){let ue=p();for(ue!==ee&&_("parsing quoted string");!s&&c()!==ee;)c()==="\\"&&p(),ue+=p();return c()!==ee&&_("parsing quoted string"),ue+=p(),ue}e(w,"readQuotedString");function B(){p()!=="/"&&_("parsing regular expression");let ee="",ue=!1;for(;!s;){if(c()==="\\")ee+=p(),s&&_("parsing regular expression");else if(ue&&c()==="]")ue=!1;else if(!ue&&c()==="[")ue=!0;else if(!ue&&c()==="/")break;ee+=p()}p()!=="/"&&_("parsing regular expression");let le="";for(;!s&&c().match(/[dgimsuy]/);)le+=p();try{return new RegExp(ee,le)}catch(de){throw new RH(`Error while parsing selector \`${n}\`: ${de.message}`)}}e(B,"readRegularExpression");function P(){let ee="";return v(),c()==="'"||c()==='"'?ee=w(c()).slice(1,-1):ee=D(),ee||_("parsing property path"),ee}e(P,"readAttributeToken");function L(){v();let ee="";return s||(ee+=p()),!s&&ee!=="="&&(ee+=p()),["=","*=","^=","$=","|=","~="].includes(ee)||_("parsing operator"),ee}e(L,"readOperator");function j(){p();let ee=[];for(ee.push(P()),v();c()===".";)p(),ee.push(P()),v();if(c()==="]")return p(),{name:ee.join("."),jsonPath:ee,op:"<truthy>",value:null,caseSensitive:!1};let ue=L(),le,de=!0;if(v(),c()==="/"){if(ue!=="=")throw new RH(`Error while parsing selector \`${n}\` - cannot use ${ue} in attribute with regular expression`);le=B()}else if(c()==="'"||c()==='"')le=w(c()).slice(1,-1),v(),c()==="i"||c()==="I"?(de=!1,p()):(c()==="s"||c()==="S")&&(de=!0,p());else{for(le="";!s&&(E(c())||c()==="+"||c()===".");)le+=p();le==="true"?le=!0:le==="false"?le=!1:r||(le=+le,Number.isNaN(le)&&_("parsing attribute value"))}if(v(),c()!=="]"&&_("parsing attribute value"),p(),ue!=="="&&typeof le!="string")throw new RH(`Error while parsing selector \`${n}\` - cannot use ${ue} in attribute with non-string matching value - ${le}`);return{name:ee.join("."),jsonPath:ee,op:ue,value:le,caseSensitive:de}}e(j,"readAttribute");let V={name:"",attributes:[]};for(V.name=D(),v();c()==="[";)V.attributes.push(j()),v();if(s||_(void 0),!V.name&&!V.attributes.length)throw new RH(`Error while parsing selector \`${n}\` - selector cannot be empty`);return V}e(JBr,"parseAttributeSelector");function Iwn(n){let r=BKi(n),i=[];for(let s of r.parts){if(s.name==="css"||s.name==="css:light"){s.name==="css:light"&&(s.body=":light("+s.body+")");let c=OKi(s.body,kKi);i.push({name:"css",body:c.selector,source:s.body});continue}if(own.has(s.name)){let c,p;try{let D=JSON.parse("["+s.body+"]");if(!Array.isArray(D)||D.length<1||D.length>2||typeof D[0]!="string")throw new RH(`Malformed selector: ${s.name}=`+s.body);if(c=D[0],D.length===2){if(typeof D[1]!="number"||!TKi.has(s.name))throw new RH(`Malformed selector: ${s.name}=`+s.body);p=D[1]}}catch{throw new RH(`Malformed selector: ${s.name}=`+s.body)}let _={name:s.name,source:s.body,body:{parsed:Iwn(c),distance:p}},v=[..._.body.parsed.parts].reverse().find(D=>D.name==="internal:control"&&D.body==="enter-frame"),E=v?_.body.parsed.parts.indexOf(v):-1;E!==-1&&PKi(_.body.parsed.parts.slice(0,E+1),i.slice(0,E+1))&&_.body.parsed.parts.splice(0,E+1),i.push(_);continue}i.push({...s,source:s.body})}if(own.has(i[0].name))throw new RH(`"${i[0].name}" selector cannot be first`);return{capture:r.capture,parts:i}}e(Iwn,"parseSelector");function NKi(n,r="'"){let i=JSON.stringify(n),s=i.substring(1,i.length-1).replace(/\\"/g,'"');if(r==="'")return r+s.replace(/[']/g,"\\'")+r;if(r==='"')return r+s.replace(/["]/g,'\\"')+r;if(r==="`")return r+s.replace(/[`]/g,"`")+r;throw new Error("Invalid escape char")}e(NKi,"escapeWithQuotes");function vOt(n){return n instanceof RegExp}e(vOt,"isRegExp");function PKi(n,r){return COt({parts:n})===COt({parts:r})}e(PKi,"selectorPartsEqual");function BKi(n){let r=0,i,s=0,c={parts:[]},p=e(()=>{let v=n.substring(s,r).trim(),E=v.indexOf("="),D,w;E!==-1&&v.substring(0,E).trim().match(/^[a-zA-Z_0-9-+:*]+$/)?(D=v.substring(0,E).trim(),w=v.substring(E+1)):v.length>1&&v[0]==='"'&&v[v.length-1]==='"'||v.length>1&&v[0]==="'"&&v[v.length-1]==="'"?(D="text",w=v):/^\(*\/\//.test(v)||v.startsWith("..")?(D="xpath",w=v):(D="css",w=v);let B=!1;if(D[0]==="*"&&(B=!0,D=D.substring(1)),c.parts.push({name:D,body:w}),B){if(c.capture!==void 0)throw new RH("Only one of the selectors can capture using * modifier");c.capture=c.parts.length-1}},"append");if(!n.includes(">>"))return r=n.length,p(),c;let _=e(()=>{let E=n.substring(s,r).match(/^\s*text\s*=(.*)$/);return!!E&&!!E[1]},"shouldIgnoreTextSelectorQuote");for(;r<n.length;){let v=n[r];v==="\\"&&r+1<n.length?r+=2:v===i?(i=void 0,r++):!i&&(v==='"'||v==="'"||v==="`")&&!_()?(i=v,r++):!i&&v===">"&&n[r+1]===">"?(p(),r+=2,s=r):r++}return p(),c}e(BKi,"parseSelectorString");function OKi(n,r){let i;try{i=LKi(n),i[i.length-1]instanceof AOt||i.push(new AOt)}catch(We){let mt=We.message+` while parsing selector "${n}"`,Ve=(We.stack||"").indexOf(We.message);throw Ve!==-1&&(We.stack=We.stack.substring(0,Ve)+mt+We.stack.substring(Ve+We.message.length)),We.message=mt,We}let s=i.find(We=>We instanceof Cwn||We instanceof hwn||We instanceof xOt||We instanceof xwn||We instanceof gwn||We instanceof ywn||We instanceof mwn||We instanceof vwn||We instanceof Awn||We instanceof wwn||We instanceof kwn);if(s)throw new RH(`Unsupported token "${s.toSource()}" while parsing selector "${n}"`);let c=0,p=new Set;function _(){return new RH(`Unexpected token "${i[c].toSource()}" while parsing selector "${n}"`)}e(_,"unexpected");function v(){for(;i[c]instanceof HBr;)c++}e(v,"skipWhitespace");function E(We=c){return i[We]instanceof Ewn}e(E,"isIdent");function D(We=c){return i[We]instanceof Swn}e(D,"isString");function w(We=c){return i[We]instanceof Twn}e(w,"isNumber");function B(We=c){return i[We]instanceof fwn}e(B,"isComma");function P(We=c){return i[We]instanceof pwn}e(P,"isOpenParen");function L(We=c){return i[We]instanceof bwn}e(L,"isCloseParen");function j(We=c){return i[We]instanceof bOt}e(j,"isFunction");function V(We=c){return i[We]instanceof cO&&i[We].value==="*"}e(V,"isStar");function ee(We=c){return i[We]instanceof AOt}e(ee,"isEOF");function ue(We=c){return i[We]instanceof cO&&[">","+","~"].includes(i[We].value)}e(ue,"isClauseCombinator");function le(We=c){return B(We)||L(We)||ee(We)||ue(We)||i[We]instanceof HBr}e(le,"isSelectorClauseEnd");function de(){let We=[xe()];for(;v(),!!B();)c++,We.push(xe());return We}e(de,"consumeFunctionArguments");function xe(){return v(),w()||D()?i[c++].value:Re()}e(xe,"consumeArgument");function Re(){let We={simples:[]};for(v(),ue()?We.simples.push({selector:{functions:[{name:"scope",args:[]}]},combinator:""}):We.simples.push({selector:$e(),combinator:""});;){if(v(),ue())We.simples[We.simples.length-1].combinator=i[c++].value,v();else if(le())break;We.simples.push({combinator:"",selector:$e()})}return We}e(Re,"consumeComplexSelector");function $e(){let We="",mt=[];for(;!le();)if(E()||V())We+=i[c++].toSource();else if(i[c]instanceof Dwn)We+=i[c++].toSource();else if(i[c]instanceof cO&&i[c].value===".")if(c++,E())We+="."+i[c++].toSource();else throw _();else if(i[c]instanceof dwn)if(c++,E())if(!r.has(i[c].value.toLowerCase()))We+=":"+i[c++].toSource();else{let Ve=i[c++].value.toLowerCase();mt.push({name:Ve,args:[]}),p.add(Ve)}else if(j()){let Ve=i[c++].value.toLowerCase();if(r.has(Ve)?(mt.push({name:Ve,args:de()}),p.add(Ve)):We+=`:${Ve}(${Ke()})`,v(),!L())throw _();c++}else throw _();else if(i[c]instanceof _wn){for(We+="[",c++;!(i[c]instanceof zBr)&&!ee();)We+=i[c++].toSource();if(!(i[c]instanceof zBr))throw _();We+="]",c++}else throw _();if(!We&&!mt.length)throw _();return{css:We||void 0,functions:mt}}e($e,"consumeSimpleSelector");function Ke(){let We="",mt=1;for(;!ee()&&((P()||j())&&mt++,L()&&mt--,!!mt);)We+=i[c++].toSource();return We}e(Ke,"consumeBuiltinFunctionArguments");let Ce=de();if(!ee())throw _();if(Ce.some(We=>typeof We!="object"||!("simples"in We)))throw new RH(`Error while parsing selector "${n}"`);return{selector:Ce,names:Array.from(p)}}e(OKi,"parseCSS");function RKi(n){return n.replace(/(^|[^\\])(\\\\)*\\(['"`])/g,"$1$2$3")}e(RKi,"normalizeEscapedRegexQuotes");function LKi(n){let r=MKi(n),i=-1,s=[],c,p=0,_=0,v=0,E=e(function(){p+=1,v=_,_=0},"incrLineno"),D={line:p,column:_},w=e(function(Nt){return Nt>=r.length?-1:r[Nt]},"codepoint"),B=e(function(Nt=void 0){if(Nt===void 0&&(Nt=1),Nt>3)throw"Spec Error: no more than three codepoints of lookahead.";return w(i+Nt)},"next"),P=e(function(Nt=void 0){return Nt===void 0&&(Nt=1),i+=Nt,c=w(i),WQe(c)?E():_+=Nt,!0},"consume"),L=e(function(){return i-=1,WQe(c)?(p-=1,_=v):_-=1,D.line=p,D.column=_,!0},"reconsume"),j=e(function(Nt=void 0){return Nt===void 0&&(Nt=c),Nt===-1},"eof"),V=e(function(){},"donothing"),ee=e(function(){},"parseerror"),ue=e(function(){if(le(),P(),yye(c)){for(;yye(B());)P();return new HBr}else{if(c===34)return Re();if(c===35)if(uwn(B())||Ce(B(1),B(2))){let Nt=new Dwn("");return mt(B(1),B(2),B(3))&&(Nt.type="id"),Nt.value=qe(),Nt}else return new cO(c);else return c===36?B()===61?(P(),new EKi):new cO(c):c===39?Re():c===40?new pwn:c===41?new bwn:c===42?B()===61?(P(),new CKi):new cO(c):c===43?Qe()?(L(),de()):new cO(c):c===44?new fwn:c===45?Qe()?(L(),de()):B(1)===45&&B(2)===62?(P(2),new ywn):Ve()?(L(),xe()):new cO(c):c===46?Qe()?(L(),de()):new cO(c):c===58?new dwn:c===59?new mwn:c===60?B(1)===33&&B(2)===45&&B(3)===45?(P(3),new gwn):new cO(c):c===64?mt(B(1),B(2),B(3))?new Cwn(qe()):new cO(c):c===91?new _wn:c===92?We()?(L(),xe()):(ee(),new cO(c)):c===93?new zBr:c===94?B()===61?(P(),new DKi):new cO(c):c===123?new vwn:c===124?B()===61?(P(),new bKi):B()===124?(P(),new xwn):new cO(c):c===125?new Awn:c===126?B()===61?(P(),new xKi):new cO(c):OH(c)?(L(),de()):EOt(c)?(L(),xe()):j()?new AOt:new cO(c)}},"consumeAToken"),le=e(function(){for(;B(1)===47&&B(2)===42;)for(P(2);;)if(P(),c===42&&B()===47){P();break}else if(j()){ee();return}},"consumeComments"),de=e(function(){let Nt=Ge();if(mt(B(1),B(2),B(3))){let It=new SKi;return It.value=Nt.value,It.repr=Nt.repr,It.type=Nt.type,It.unit=qe(),It}else if(B()===37){P();let It=new kwn;return It.value=Nt.value,It.repr=Nt.repr,It}else{let It=new Twn;return It.value=Nt.value,It.repr=Nt.repr,It.type=Nt.type,It}},"consumeANumericToken"),xe=e(function(){let Nt=qe();if(Nt.toLowerCase()==="url"&&B()===40){for(P();yye(B(1))&&yye(B(2));)P();return B()===34||B()===39?new bOt(Nt):yye(B())&&(B(2)===34||B(2)===39)?new bOt(Nt):$e()}else return B()===40?(P(),new bOt(Nt)):new Ewn(Nt)},"consumeAnIdentlikeToken"),Re=e(function(Nt=void 0){Nt===void 0&&(Nt=c);let It="";for(;P();){if(c===Nt||j())return new Swn(It);if(WQe(c))return ee(),L(),new hwn;c===92?j(B())?V():WQe(B())?P():It+=eP(Ke()):It+=eP(c)}throw new Error("Internal error")},"consumeAStringToken"),$e=e(function(){let Nt=new wwn("");for(;yye(B());)P();if(j(B()))return Nt;for(;P();){if(c===41||j())return Nt;if(yye(c)){for(;yye(B());)P();return B()===41||j(B())?(P(),Nt):(je(),new xOt)}else{if(c===34||c===39||c===40||JKi(c))return ee(),je(),new xOt;if(c===92)if(We())Nt.value+=eP(Ke());else return ee(),je(),new xOt;else Nt.value+=eP(c)}}throw new Error("Internal error")},"consumeAURLToken"),Ke=e(function(){if(P(),cwn(c)){let Nt=[c];for(let Zt=0;Zt<5&&cwn(B());Zt++)P(),Nt.push(c);yye(B())&&P();let It=parseInt(Nt.map(function(Zt){return String.fromCharCode(Zt)}).join(""),16);return It>VKi&&(It=65533),It}else return j()?65533:c},"consumeEscape"),Ce=e(function(Nt,It){return!(Nt!==92||WQe(It))},"areAValidEscape"),We=e(function(){return Ce(c,B())},"startsWithAValidEscape"),mt=e(function(Nt,It,Zt){return Nt===45?EOt(It)||It===45||Ce(It,Zt):EOt(Nt)?!0:Nt===92?Ce(Nt,It):!1},"wouldStartAnIdentifier"),Ve=e(function(){return mt(c,B(1),B(2))},"startsWithAnIdentifier"),Ue=e(function(Nt,It,Zt){return Nt===43||Nt===45?!!(OH(It)||It===46&&OH(Zt)):Nt===46?!!OH(It):!!OH(Nt)},"wouldStartANumber"),Qe=e(function(){return Ue(c,B(1),B(2))},"startsWithANumber"),qe=e(function(){let Nt="";for(;P();)if(uwn(c))Nt+=eP(c);else if(We())Nt+=eP(Ke());else return L(),Nt;throw new Error("Internal parse error")},"consumeAName"),Ge=e(function(){let Nt="",It="integer";for((B()===43||B()===45)&&(P(),Nt+=eP(c));OH(B());)P(),Nt+=eP(c);if(B(1)===46&&OH(B(2)))for(P(),Nt+=eP(c),P(),Nt+=eP(c),It="number";OH(B());)P(),Nt+=eP(c);let Zt=B(1),lr=B(2),Jt=B(3);if((Zt===69||Zt===101)&&OH(lr))for(P(),Nt+=eP(c),P(),Nt+=eP(c),It="number";OH(B());)P(),Nt+=eP(c);else if((Zt===69||Zt===101)&&(lr===43||lr===45)&&OH(Jt))for(P(),Nt+=eP(c),P(),Nt+=eP(c),P(),Nt+=eP(c),It="number";OH(B());)P(),Nt+=eP(c);let ti=Ze(Nt);return{type:It,value:ti,repr:Nt}},"consumeANumber"),Ze=e(function(Nt){return+Nt},"convertAStringToANumber"),je=e(function(){for(;P();){if(c===41||j())return;We()&&Ke(),V()}},"consumeTheRemnantsOfABadURL"),qt=0;for(;!j(B());)if(s.push(ue()),qt++,qt>r.length*2)throw new Error("I'm infinite-looping!");return s}e(LKi,"tokenize");function MKi(n){let r=[];for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s===13&&n.charCodeAt(i+1)===10&&(s=10,i++),(s===13||s===12)&&(s=10),s===0&&(s=65533),aF(s,55296,56319)&&aF(n.charCodeAt(i+1),56320,57343)){let c=s-55296,p=n.charCodeAt(i+1)-56320;s=Math.pow(2,16)+c*Math.pow(2,10)+p,i++}r.push(s)}return r}e(MKi,"preprocess");function eP(n){if(n<=65535)return String.fromCharCode(n);n-=Math.pow(2,16);let r=Math.floor(n/Math.pow(2,10))+55296,i=n%Math.pow(2,10)+56320;return String.fromCharCode(r)+String.fromCharCode(i)}e(eP,"stringFromCode");var aF=e(function(n,r,i){return n>=r&&n<=i},"between");function yye(n){return WQe(n)||n===9||n===32}e(yye,"whitespace");function WQe(n){return n===10}e(WQe,"newline");var WBr=class WBr extends _9{constructor(i,s=void 0){super();this.value=s;this.tokenType="DELIM",this.value="",this.value=eP(i)}toString(){return"DELIM("+this.value+")"}toJSON(){let i=this.constructor.prototype.constructor.prototype.toJSON.call(this);return i.value=this.value,i}toSource(){return this.value==="\\"?`\\
|
|
1733
1733
|
`:this.value}};e(WBr,"DelimToken");var cO=WBr;function OH(n){return aF(n,48,57)}e(OH,"digit");function cwn(n){return OH(n)||aF(n,65,70)||aF(n,97,102)}e(cwn,"hexdigit");function jKi(n){return aF(n,65,90)}e(jKi,"uppercaseletter");function UKi(n){return aF(n,97,122)}e(UKi,"lowercaseletter");function QKi(n){return jKi(n)||UKi(n)}e(QKi,"letter");function qKi(n){return n>=128}e(qKi,"nonascii");function EOt(n){return QKi(n)||qKi(n)||n===95}e(EOt,"namestartchar");function uwn(n){return EOt(n)||OH(n)||n===45}e(uwn,"namechar");function rut(n){n=""+n;let r="",i=n.charCodeAt(0);for(let s=0;s<n.length;s++){let c=n.charCodeAt(s);if(c===0)throw new tut("Invalid character: the input contains U+0000.");aF(c,1,31)||c===127||s===0&&aF(c,48,57)||s===1&&aF(c,48,57)&&i===45?r+="\\"+c.toString(16)+" ":c>=128||c===45||c===95||aF(c,48,57)||aF(c,65,90)||aF(c,97,122)?r+=n[s]:r+="\\"+n[s]}return r}e(rut,"escapeIdent");function $Ki(n){n=""+n;let r="";for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s===0)throw new tut("Invalid character: the input contains U+0000.");s>=128||s===45||s===95||aF(s,48,57)||aF(s,65,90)||aF(s,97,122)?r+=n[i]:r+="\\"+s.toString(16)+" "}return r}e($Ki,"escapeHash");var GBr=class GBr extends Error{constructor(r){super(r),this.name="InvalidCharacterError"}};e(GBr,"InvalidCharacterError");var tut=GBr;function Fwn(n){n=""+n;let r="";for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s===0)throw new tut("Invalid character: the input contains U+0000.");aF(s,1,31)||s===127?r+="\\"+s.toString(16)+" ":s===34||s===92?r+="\\"+n[i]:r+=n[i]}return r}e(Fwn,"escapeString");var VKi=1114111;function JKi(n){return aF(n,0,8)||n===11||aF(n,14,31)||n===127}e(JKi,"nonprintable");var KBr=class KBr{constructor(r,i,s){this.webDriver=r;this.timeMachine=i;this.evaluationService=s}async verifyAndCompareLocatorOnTimemachine(r,i,s){return this.timeMachine.executeTask(c=>this.verifyLocatorOrSelector({type:"locator",value:r},i,c),s,{name:"verifyAndCompareLocatorOnTimemachine"})}async verifyLocatorOrSelector({type:r,value:i,verifyUniqueness:s=!0,verifyExactElement:c=!1,fetchRrwebId:p=!1},_,v=this.webDriver.tmFrame){let E=e((P,L)=>({success:!1,value:i,error:P,message:L}),"error"),D,w,B=e(async()=>{if(_&&!await this.areLocatorsIdentical(_,D,v,c))return E("INCORRECT_TARGET","Locators points at different element");if(p)try{w=await this.getRrwebIdFromLocator(v,D)}catch(P){af("Failed fetching rrwebid",P.message)}return{success:!0,value:i,rrwebId:w}},"success");try{switch(r){case"locator":try{D=await this.evaluationService.getLocator(`return ${FL(i)}`,v.frameLocator("iframe"))}catch(L){return E("INVALID",L.message)}break;case"selector":D=v.frameLocator("iframe").locator(i);break}let P;try{if(!D)throw new Error;P=await D.count()}catch(L){return af.error("Error verifying locator or selector",{e:L}),E("INVALID","Could not evaluate element")}if(!s)return B();if(P===2){for(let L=0;L<2;L++)if(await D.nth(L).evaluate(V=>V.matches(".element-inspector-ignore")))return B()}return P!==1?P===0?E("NOT_FOUND","No element found"):E("NON_UNIQUE",`Strict mode: ${P} elements found`):B()}catch(P){return E("INVALID",String(P))}}async generateCustomPWLocators(r,i,s){let c=e(async(_=!1)=>this.timeMachine.executeTask(async v=>{let E=await this.evaluationService.getElementHandle(`return ${FL(r)}`,v.frameLocator("iframe"));return await v.evaluate(async({element:D,cssKeyFeatures:w,options:B})=>{try{if(!D)throw new Error("element not found");return window.checksum.testGenerator.buildCustomPlaywrightSelectors(D,w,B,D.ownerDocument)}catch(P){return af.error("Error generating locators",P),[]}},{element:E,cssKeyFeatures:i,options:{isPartOfListItem:!1,isForContextElement:!1,addCSSSelectorGenerator:!1,bruteForceMode:_}})},s.timestamp,{name:"generateCustomPWLocators"}),"generate"),p=await c()??[];return(p==null?void 0:p.length)<3?c(!0):p}async getParentChainHTML(r){if(r.rrwebId){let c=O6e.getInstance().getParentChain(r);if(c)return c}let{parentChainHTML:i,rrwebId:s}=await this.timeMachine.executeTask(async c=>{let p=await this.evaluationService.getLocator(`return await ${FL(r.locator)}`,c.frameLocator("iframe")),_;try{_=await this.getRrwebIdFromLocator(c,p)}catch{}let v=await p.elementHandle();return{parentChainHTML:await c.evaluate(async({element:D})=>{try{if(!D)throw new Error("Element not found");let w=await window.checksum.testGenerator.getParentChainHTML(D,!0);if(typeof w!="string")throw new Error("Parent chain HTML is not a string, "+typeof w);return w}catch(w){throw af.error("Error getting parent chain HTML",{e:w}),w}},{element:v}),rrwebId:_}},r.timestamp,{name:"getParentChainHTML "+r.locator});return s&&(r.rrwebId=s,O6e.getInstance().setParentChain(r,i)),i}async candidatesTester(r,i,s,{verifyExactElement:c=!1}={}){if(!r.length)return[];let p=!!r[0].selector,_=e(D=>({value:p?D.selector:D.locator,type:p?"selector":"locator",verifyUniqueness:!0,verifyExactElement:c}),"inputTransformer"),v=e(async D=>({...D,...p?{selector:D.value,locator:lwn(D.value)}:await this.locatorExpressionToSelectorAndLocator(D.value)}),"outputTransformer"),E=await this.timeMachine.executeTask(async D=>{try{af.info(`Will test ${r.length} locators`);let w=await Promise.all(r.map(async B=>({...B,...await this.verifyLocatorOrSelector(_(B),i==null?void 0:i.locator,D)})));return af.info(`locator verification results: ${w.filter(B=>B.success).length}/${w.length}`),await Promise.all(w.map(v))}catch(w){af.error("Error testing selectors",w)}},i.timestamp,{name:`${s}CandidatesTester`});return E||(af.warning("No valid selector found"),[])}async locatorExpressionToSelectorAndLocator(r){try{return{selector:(await this.evaluationService.evaluate(`return ${FL(r)}`))._selector,locator:r}}catch{return}}async areLocatorsIdentical(r,i,s=this.timeMachine.getFrame(),c=!1){try{let p=await this.evaluationService.getElementHandle(`return ${FL(r)}`,s.frameLocator("iframe")),_=await i.elementHandle();if(!p||!_)throw new Error("One or both locators did not resolve to an element.");return await p.evaluate((D,w)=>D.isSameNode(w),_)?!0:c?!1:!!await p.evaluate((D,w)=>D.contains(w)||D.parentElement===w,_)}catch(p){return af.error("Error comparing locators:",p.message),!1}}async getRrwebIdFromLocator(r,i){let s=await i.elementHandle({timeout:5e3});return await r.evaluate(async c=>{var p;if(!c)throw new Error("Element not found");return(p=window.checksum.timeMachine.sessionReplayer.getMeta(c))==null?void 0:p.id},s)}};e(KBr,"LocatorInteractor");var DOt=KBr;var YBr=class YBr{constructor(r,i,s,c,p){this.webDriver=r;this.apiService=s;this.userStoryService=c;this.evaluationService=p;this.runningAgents={};this.locatorInteractor=new DOt(r,i,p)}async cancelProcess(r){this.runningAgents[r]&&(this.runningAgents[r].cancel(),delete this.runningAgents[r])}async verifyAndCompareLocatorOnTimemachine(r,i,s){return this.locatorInteractor.verifyAndCompareLocatorOnTimemachine(r,i,s)}async verifyLocatorOrSelector(r,i,s=this.webDriver.tmFrame){return this.locatorInteractor.verifyLocatorOrSelector(r,i,s)}createAgent(r,i,s){let c=new yOt(r,i,s,this.apiService,this.userStoryService,this.evaluationService,this.locatorInteractor);return this.runningAgents[r]=c,c}async generateAILocators(r,i,s){try{let p=await this.createAgent(s,r,i).generateAILocators();await this.updateVTGWithLocators(s,p[0],p.slice(1),"ai")}catch(c){af.error(`Failed to generate AI locators (${s})`,c),this.markError(s)}finally{delete this.runningAgents[s]}}async extractCSS(r,i,s,c=[]){try{let _=await this.createAgent(s,r,i).extractCSS(c);await this.updateVTGWithLocators(s,_[0].locator,_.slice(1).map(v=>v.locator),"withCSSKeyFeatures")}catch(p){af.error(`Failed to extract CSS (${s})`,p.message),this.markError(s)}finally{delete this.runningAgents[s]}}async filterLocators(r,i,s,c=[]){try{let _=await this.createAgent(s,r,i).filterLocators(c);await this.updateVTGWithLocators(s,_.locator,_.alternateLocators.locators.filter(v=>v!==_.locator),"filtered")}catch(p){af.error(`Failed to filter locators (${s})`,p),this.markError(s)}finally{delete this.runningAgents[s]}}async updateVTGWithLocators(r,i,s=[],c,p=!1){try{await this.webDriver.page.evaluate(_=>{window.vtg.onAsyncProcessResponse(_)},{locator:i,alternates:s,origin:c,error:p,processId:r}),i&&af.info(`Updated VTG with ${s.length+1} locators on state ${c} (${r})`)}catch(_){af.error("Failed to update VTG with locators",_)}}async markError(r){await this.updateVTGWithLocators(r,void 0,void 0,void 0,!0),af.info(`Updated VTG with Error (${r})`)}};e(YBr,"VtgLocatorsService");var SOt=YBr;GLe();function nut(n,r){return e(function(){return n.apply(r,arguments)},"wrap")}e(nut,"bind");var{toString:zKi}=Object.prototype,{getPrototypeOf:ZBr}=Object,{iterator:TOt,toStringTag:Own}=Symbol,kOt=(n=>r=>{let i=zKi.call(r);return n[i]||(n[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),Moe=e(n=>(n=n.toLowerCase(),r=>kOt(r)===n),"kindOfTest"),IOt=e(n=>r=>typeof r===n,"typeOfTest"),{isArray:Pqe}=Array,Nqe=IOt("undefined");function iut(n){return n!==null&&!Nqe(n)&&n.constructor!==null&&!Nqe(n.constructor)&&LH(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}e(iut,"isBuffer");var Rwn=Moe("ArrayBuffer");function HKi(n){let r;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?r=ArrayBuffer.isView(n):r=n&&n.buffer&&Rwn(n.buffer),r}e(HKi,"isArrayBufferView");var WKi=IOt("string"),LH=IOt("function"),Lwn=IOt("number"),aut=e(n=>n!==null&&typeof n=="object","isObject"),GKi=e(n=>n===!0||n===!1,"isBoolean"),wOt=e(n=>{if(kOt(n)!=="object")return!1;let r=ZBr(n);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Own in n)&&!(TOt in n)},"isPlainObject"),KKi=e(n=>{if(!aut(n)||iut(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},"isEmptyObject"),YKi=Moe("Date"),XKi=Moe("File"),ZKi=e(n=>!!(n&&typeof n.uri<"u"),"isReactNativeBlob"),eYi=e(n=>n&&typeof n.getParts<"u","isReactNative"),tYi=Moe("Blob"),rYi=Moe("FileList"),nYi=e(n=>aut(n)&&LH(n.pipe),"isStream");function iYi(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}e(iYi,"getGlobal");var Nwn=iYi(),Pwn=typeof Nwn.FormData<"u"?Nwn.FormData:void 0,aYi=e(n=>{let r;return n&&(Pwn&&n instanceof Pwn||LH(n.append)&&((r=kOt(n))==="formdata"||r==="object"&&LH(n.toString)&&n.toString()==="[object FormData]"))},"isFormData"),sYi=Moe("URLSearchParams"),[oYi,cYi,uYi,lYi]=["ReadableStream","Request","Response","Headers"].map(Moe),pYi=e(n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),"trim");function sut(n,r,{allOwnKeys:i=!1}={}){if(n===null||typeof n>"u")return;let s,c;if(typeof n!="object"&&(n=[n]),Pqe(n))for(s=0,c=n.length;s<c;s++)r.call(null,n[s],s,n);else{if(iut(n))return;let p=i?Object.getOwnPropertyNames(n):Object.keys(n),_=p.length,v;for(s=0;s<_;s++)v=p[s],r.call(null,n[v],v,n)}}e(sut,"forEach");function Mwn(n,r){if(iut(n))return null;r=r.toLowerCase();let i=Object.keys(n),s=i.length,c;for(;s-- >0;)if(c=i[s],r===c.toLowerCase())return c;return null}e(Mwn,"findKey");var eke=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,jwn=e(n=>!Nqe(n)&&n!==eke,"isContextDefined");function XBr(){let{caseless:n,skipUndefined:r}=jwn(this)&&this||{},i={},s=e((c,p)=>{if(p==="__proto__"||p==="constructor"||p==="prototype")return;let _=n&&Mwn(i,p)||p;wOt(i[_])&&wOt(c)?i[_]=XBr(i[_],c):wOt(c)?i[_]=XBr({},c):Pqe(c)?i[_]=c.slice():(!r||!Nqe(c))&&(i[_]=c)},"assignValue");for(let c=0,p=arguments.length;c<p;c++)arguments[c]&&sut(arguments[c],s);return i}e(XBr,"merge");var fYi=e((n,r,i,{allOwnKeys:s}={})=>(sut(r,(c,p)=>{i&&LH(c)?Object.defineProperty(n,p,{value:nut(c,i),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(n,p,{value:c,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:s}),n),"extend"),dYi=e(n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),"stripBOM"),_Yi=e((n,r,i,s)=>{n.prototype=Object.create(r.prototype,s),Object.defineProperty(n.prototype,"constructor",{value:n,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(n,"super",{value:r.prototype}),i&&Object.assign(n.prototype,i)},"inherits"),mYi=e((n,r,i,s)=>{let c,p,_,v={};if(r=r||{},n==null)return r;do{for(c=Object.getOwnPropertyNames(n),p=c.length;p-- >0;)_=c[p],(!s||s(_,n,r))&&!v[_]&&(r[_]=n[_],v[_]=!0);n=i!==!1&&ZBr(n)}while(n&&(!i||i(n,r))&&n!==Object.prototype);return r},"toFlatObject"),hYi=e((n,r,i)=>{n=String(n),(i===void 0||i>n.length)&&(i=n.length),i-=r.length;let s=n.indexOf(r,i);return s!==-1&&s===i},"endsWith"),gYi=e(n=>{if(!n)return null;if(Pqe(n))return n;let r=n.length;if(!Lwn(r))return null;let i=new Array(r);for(;r-- >0;)i[r]=n[r];return i},"toArray"),yYi=(n=>r=>n&&r instanceof n)(typeof Uint8Array<"u"&&ZBr(Uint8Array)),vYi=e((n,r)=>{let s=(n&&n[TOt]).call(n),c;for(;(c=s.next())&&!c.done;){let p=c.value;r.call(n,p[0],p[1])}},"forEachEntry"),AYi=e((n,r)=>{let i,s=[];for(;(i=n.exec(r))!==null;)s.push(i);return s},"matchAll"),xYi=Moe("HTMLFormElement"),bYi=e(n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,e(function(i,s,c){return s.toUpperCase()+c},"replacer")),"toCamelCase"),Bwn=(({hasOwnProperty:n})=>(r,i)=>n.call(r,i))(Object.prototype),EYi=Moe("RegExp"),Uwn=e((n,r)=>{let i=Object.getOwnPropertyDescriptors(n),s={};sut(i,(c,p)=>{let _;(_=r(c,p,n))!==!1&&(s[p]=_||c)}),Object.defineProperties(n,s)},"reduceDescriptors"),CYi=e(n=>{Uwn(n,(r,i)=>{if(LH(n)&&["arguments","caller","callee"].indexOf(i)!==-1)return!1;let s=n[i];if(LH(s)){if(r.enumerable=!1,"writable"in r){r.writable=!1;return}r.set||(r.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")})}})},"freezeMethods"),DYi=e((n,r)=>{let i={},s=e(c=>{c.forEach(p=>{i[p]=!0})},"define");return Pqe(n)?s(n):s(String(n).split(r)),i},"toObjectSet"),SYi=e(()=>{},"noop"),wYi=e((n,r)=>n!=null&&Number.isFinite(n=+n)?n:r,"toFiniteNumber");function TYi(n){return!!(n&&LH(n.append)&&n[Own]==="FormData"&&n[TOt])}e(TYi,"isSpecCompliantForm");var kYi=e(n=>{let r=new Array(10),i=e((s,c)=>{if(aut(s)){if(r.indexOf(s)>=0)return;if(iut(s))return s;if(!("toJSON"in s)){r[c]=s;let p=Pqe(s)?[]:{};return sut(s,(_,v)=>{let E=i(_,c+1);!Nqe(E)&&(p[v]=E)}),r[c]=void 0,p}}return s},"visit");return i(n,0)},"toJSONObject"),IYi=Moe("AsyncFunction"),FYi=e(n=>n&&(aut(n)||LH(n))&&LH(n.then)&&LH(n.catch),"isThenable"),Qwn=((n,r)=>n?setImmediate:r?((i,s)=>(eke.addEventListener("message",({source:c,data:p})=>{c===eke&&p===i&&s.length&&s.shift()()},!1),c=>{s.push(c),eke.postMessage(i,"*")}))(`axios@${Math.random()}`,[]):i=>setTimeout(i))(typeof setImmediate=="function",LH(eke.postMessage)),NYi=typeof queueMicrotask<"u"?queueMicrotask.bind(eke):typeof process<"u"&&process.nextTick||Qwn,PYi=e(n=>n!=null&&LH(n[TOt]),"isIterable"),Jl={isArray:Pqe,isArrayBuffer:Rwn,isBuffer:iut,isFormData:aYi,isArrayBufferView:HKi,isString:WKi,isNumber:Lwn,isBoolean:GKi,isObject:aut,isPlainObject:wOt,isEmptyObject:KKi,isReadableStream:oYi,isRequest:cYi,isResponse:uYi,isHeaders:lYi,isUndefined:Nqe,isDate:YKi,isFile:XKi,isReactNativeBlob:ZKi,isReactNative:eYi,isBlob:tYi,isRegExp:EYi,isFunction:LH,isStream:nYi,isURLSearchParams:sYi,isTypedArray:yYi,isFileList:rYi,forEach:sut,merge:XBr,extend:fYi,trim:pYi,stripBOM:dYi,inherits:_Yi,toFlatObject:mYi,kindOf:kOt,kindOfTest:Moe,endsWith:hYi,toArray:gYi,forEachEntry:vYi,matchAll:AYi,isHTMLForm:xYi,hasOwnProperty:Bwn,hasOwnProp:Bwn,reduceDescriptors:Uwn,freezeMethods:CYi,toObjectSet:DYi,toCamelCase:bYi,noop:SYi,toFiniteNumber:wYi,findKey:Mwn,global:eke,isContextDefined:jwn,isSpecCompliantForm:TYi,toJSONObject:kYi,isAsyncFn:IYi,isThenable:FYi,setImmediate:Qwn,asap:NYi,isIterable:PYi};var FOt=class FOt extends Error{static from(r,i,s,c,p,_){let v=new FOt(r.message,i||r.code,s,c,p);return v.cause=r,v.name=r.name,r.status!=null&&v.status==null&&(v.status=r.status),_&&Object.assign(v,_),v}constructor(r,i,s,c,p){super(r),Object.defineProperty(this,"message",{value:r,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,i&&(this.code=i),s&&(this.config=s),c&&(this.request=c),p&&(this.response=p,this.status=p.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Jl.toJSONObject(this.config),code:this.code,status:this.status}}};e(FOt,"AxiosError");var D$=FOt;D$.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";D$.ERR_BAD_OPTION="ERR_BAD_OPTION";D$.ECONNABORTED="ECONNABORTED";D$.ETIMEDOUT="ETIMEDOUT";D$.ERR_NETWORK="ERR_NETWORK";D$.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";D$.ERR_DEPRECATED="ERR_DEPRECATED";D$.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";D$.ERR_BAD_REQUEST="ERR_BAD_REQUEST";D$.ERR_CANCELED="ERR_CANCELED";D$.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";D$.ERR_INVALID_URL="ERR_INVALID_URL";var l1=D$;var q5n=nd(Q5n(),1),qOt=q5n.default;function xOr(n){return Jl.isPlainObject(n)||Jl.isArray(n)}e(xOr,"isVisitable");function $5n(n){return Jl.endsWith(n,"[]")?n.slice(0,-2):n}e($5n,"removeBrackets");function AOr(n,r,i){return n?n.concat(r).map(e(function(c,p){return c=$5n(c),!i&&p?"["+c+"]":c},"each")).join(i?".":""):r}e(AOr,"renderKey");function yZi(n){return Jl.isArray(n)&&!n.some(xOr)}e(yZi,"isFlatArray");var vZi=Jl.toFlatObject(Jl,{},null,e(function(r){return/^is[A-Z]/.test(r)},"filter"));function AZi(n,r,i){if(!Jl.isObject(n))throw new TypeError("target must be an object");r=r||new(qOt||FormData),i=Jl.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,e(function(V,ee){return!Jl.isUndefined(ee[V])},"defined"));let s=i.metaTokens,c=i.visitor||w,p=i.dots,_=i.indexes,E=(i.Blob||typeof Blob<"u"&&Blob)&&Jl.isSpecCompliantForm(r);if(!Jl.isFunction(c))throw new TypeError("visitor must be a function");function D(j){if(j===null)return"";if(Jl.isDate(j))return j.toISOString();if(Jl.isBoolean(j))return j.toString();if(!E&&Jl.isBlob(j))throw new l1("Blob is not supported. Use a Buffer instead.");return Jl.isArrayBuffer(j)||Jl.isTypedArray(j)?E&&typeof Blob=="function"?new Blob([j]):Buffer.from(j):j}e(D,"convertValue");function w(j,V,ee){let ue=j;if(Jl.isReactNative(r)&&Jl.isReactNativeBlob(j))return r.append(AOr(ee,V,p),D(j)),!1;if(j&&!ee&&typeof j=="object"){if(Jl.endsWith(V,"{}"))V=s?V:V.slice(0,-2),j=JSON.stringify(j);else if(Jl.isArray(j)&&yZi(j)||(Jl.isFileList(j)||Jl.endsWith(V,"[]"))&&(ue=Jl.toArray(j)))return V=$5n(V),ue.forEach(e(function(de,xe){!(Jl.isUndefined(de)||de===null)&&r.append(_===!0?AOr([V],xe,p):_===null?V:V+"[]",D(de))},"each")),!1}return xOr(j)?!0:(r.append(AOr(ee,V,p),D(j)),!1)}e(w,"defaultVisitor");let B=[],P=Object.assign(vZi,{defaultVisitor:w,convertValue:D,isVisitable:xOr});function L(j,V){if(!Jl.isUndefined(j)){if(B.indexOf(j)!==-1)throw Error("Circular reference detected in "+V.join("."));B.push(j),Jl.forEach(j,e(function(ue,le){(!(Jl.isUndefined(ue)||ue===null)&&c.call(r,ue,Jl.isString(le)?le.trim():le,V,P))===!0&&L(ue,V?V.concat(le):[le])},"each")),B.pop()}}if(e(L,"build"),!Jl.isObject(n))throw new TypeError("data must be an object");return L(n),r}e(AZi,"toFormData");var M6e=AZi;function V5n(n){let r={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,e(function(s){return r[s]},"replacer"))}e(V5n,"encode");function J5n(n,r){this._pairs=[],n&&M6e(n,this,r)}e(J5n,"AxiosURLSearchParams");var z5n=J5n.prototype;z5n.append=e(function(r,i){this._pairs.push([r,i])},"append");z5n.toString=e(function(r){let i=r?function(s){return r.call(this,s,V5n)}:V5n;return this._pairs.map(e(function(c){return i(c[0])+"="+i(c[1])},"each"),"").join("&")},"toString");var H5n=J5n;function xZi(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}e(xZi,"encode");function rke(n,r,i){if(!r)return n;let s=i&&i.encode||xZi,c=Jl.isFunction(i)?{serialize:i}:i,p=c&&c.serialize,_;if(p?_=p(r,c):_=Jl.isURLSearchParams(r)?r.toString():new H5n(r,c).toString(s),_){let v=n.indexOf("#");v!==-1&&(n=n.slice(0,v)),n+=(n.indexOf("?")===-1?"?":"&")+_}return n}e(rke,"buildURL");var COr=class COr{constructor(){this.handlers=[]}use(r,i,s){return this.handlers.push({fulfilled:r,rejected:i,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(r){this.handlers[r]&&(this.handlers[r]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(r){Jl.forEach(this.handlers,e(function(s){s!==null&&r(s)},"forEachHandler"))}};e(COr,"InterceptorManager");var bOr=COr,EOr=bOr;var j6e={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0};var Y5n=nd(require("crypto"),1);var W5n=nd(require("url"),1),G5n=W5n.default.URLSearchParams;var DOr="abcdefghijklmnopqrstuvwxyz",K5n="0123456789",X5n={DIGIT:K5n,ALPHA:DOr,ALPHA_DIGIT:DOr+DOr.toUpperCase()+K5n},bZi=e((n=16,r=X5n.ALPHA_DIGIT)=>{let i="",{length:s}=r,c=new Uint32Array(n);Y5n.default.randomFillSync(c);for(let p=0;p<n;p++)i+=r[c[p]%s];return i},"generateString"),Z5n={isNode:!0,classes:{URLSearchParams:G5n,FormData:qOt,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:X5n,generateString:bZi,protocols:["http","https","file","data"]};var TOr={};rY(TOr,{hasBrowserEnv:()=>wOr,hasStandardBrowserEnv:()=>EZi,hasStandardBrowserWebWorkerEnv:()=>CZi,navigator:()=>SOr,origin:()=>DZi});var wOr=typeof window<"u"&&typeof document<"u",SOr=typeof navigator=="object"&&navigator||void 0,EZi=wOr&&(!SOr||["ReactNative","NativeScript","NS"].indexOf(SOr.product)<0),CZi=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",DZi=wOr&&window.location.href||"http://localhost";var v6={...TOr,...Z5n};function kOr(n,r){return M6e(n,new v6.classes.URLSearchParams,{visitor:e(function(i,s,c,p){return v6.isNode&&Jl.isBuffer(i)?(this.append(s,i.toString("base64")),!1):p.defaultVisitor.apply(this,arguments)},"visitor"),...r})}e(kOr,"toURLEncodedForm");function SZi(n){return Jl.matchAll(/\w+|\[(\w*)]/g,n).map(r=>r[0]==="[]"?"":r[1]||r[0])}e(SZi,"parsePropPath");function wZi(n){let r={},i=Object.keys(n),s,c=i.length,p;for(s=0;s<c;s++)p=i[s],r[p]=n[p];return r}e(wZi,"arrayToObject");function TZi(n){function r(i,s,c,p){let _=i[p++];if(_==="__proto__")return!0;let v=Number.isFinite(+_),E=p>=i.length;return _=!_&&Jl.isArray(c)?c.length:_,E?(Jl.hasOwnProp(c,_)?c[_]=[c[_],s]:c[_]=s,!v):((!c[_]||!Jl.isObject(c[_]))&&(c[_]=[]),r(i,s,c[_],p)&&Jl.isArray(c[_])&&(c[_]=wZi(c[_])),!v)}if(e(r,"buildPath"),Jl.isFormData(n)&&Jl.isFunction(n.entries)){let i={};return Jl.forEachEntry(n,(s,c)=>{r(SZi(s),c,i,0)}),i}return null}e(TZi,"formDataToJSON");var $Ot=TZi;function kZi(n,r,i){if(Jl.isString(n))try{return(r||JSON.parse)(n),Jl.trim(n)}catch(s){if(s.name!=="SyntaxError")throw s}return(i||JSON.stringify)(n)}e(kZi,"stringifySafely");var IOr={transitional:j6e,adapter:["xhr","http","fetch"],transformRequest:[e(function(r,i){let s=i.getContentType()||"",c=s.indexOf("application/json")>-1,p=Jl.isObject(r);if(p&&Jl.isHTMLForm(r)&&(r=new FormData(r)),Jl.isFormData(r))return c?JSON.stringify($Ot(r)):r;if(Jl.isArrayBuffer(r)||Jl.isBuffer(r)||Jl.isStream(r)||Jl.isFile(r)||Jl.isBlob(r)||Jl.isReadableStream(r))return r;if(Jl.isArrayBufferView(r))return r.buffer;if(Jl.isURLSearchParams(r))return i.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),r.toString();let v;if(p){if(s.indexOf("application/x-www-form-urlencoded")>-1)return kOr(r,this.formSerializer).toString();if((v=Jl.isFileList(r))||s.indexOf("multipart/form-data")>-1){let E=this.env&&this.env.FormData;return M6e(v?{"files[]":r}:r,E&&new E,this.formSerializer)}}return p||c?(i.setContentType("application/json",!1),kZi(r)):r},"transformRequest")],transformResponse:[e(function(r){let i=this.transitional||IOr.transitional,s=i&&i.forcedJSONParsing,c=this.responseType==="json";if(Jl.isResponse(r)||Jl.isReadableStream(r))return r;if(r&&Jl.isString(r)&&(s&&!this.responseType||c)){let _=!(i&&i.silentJSONParsing)&&c;try{return JSON.parse(r,this.parseReviver)}catch(v){if(_)throw v.name==="SyntaxError"?l1.from(v,l1.ERR_BAD_RESPONSE,this,null,this.response):v}}return r},"transformResponse")],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:v6.classes.FormData,Blob:v6.classes.Blob},validateStatus:e(function(r){return r>=200&&r<300},"validateStatus"),headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Jl.forEach(["delete","get","head","post","put","patch"],n=>{IOr.headers[n]={}});var Mqe=IOr;var IZi=Jl.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ekn=e(n=>{let r={},i,s,c;return n&&n.split(`
|
|
@@ -1785,7 +1785,7 @@ ${Put}`})).join(`
|
|
|
1785
1785
|
${Put}`),p=new i$e(i.sourceFile),_=(P=this.userStoryService.getStory())==null?void 0:P.internalTestId,v=(L=this.userStoryService.getStory())==null?void 0:L.goal,E=(j=this.userStoryService.getStory())==null?void 0:j.id;p.transformSourceFile([new ERt(i.sourceFile),new kRt(i.sourceFile,{internalTestId:_,title:v}),new bRt(i.sourceFile,i.testMirrors.filter(V=>V.internalTestId===_||V.storyId===E).map(V=>V.testBody),cFn(c))]);let D=this.testAssetsManager.getSavedTestFilePath(),{error:w}=await p.write(D,Put);return{filePath:(0,s$e.relative)(process.cwd(),D),error:w}}get isLoadedFromTestFile(){return!!this.vtgTestFileRunConfig}async reloadTestFromFile(r){if(!this.vtgTestFileRunConfig)return;let i=await this.getReloadTestEnvironmentCode();await this.evaluationService.execute(i);let c=new Out(this.testAssetsManager.getSavedTestFilePath()).loadActionsFromSingleTest({mergeCustomCodeSteps:this.settingsService.getSettings().mergeCustomCodeSteps});return r&&await this.mergeTimestampsToReloadedActions(c),this.actionsManager.reloadTestSteps(c),c}async mergeTimestampsToReloadedActions(r){let i=this.actionsManager.actions,s=await this.apiService.post("llm/query",{systemMessage:mFn(),userMessage:hFn(i,r)});try{let c=await s.text(),p=JSON.parse(c),_=0;r.forEach((v,E)=>{var w,B;let D=p.map[E];if(D){let P=i.find(({id:L})=>L===D.id);if(P){v.timestamp=P.timestamp,_=P.timestamp;let L=_;(w=v.assertions)==null||w.forEach((j,V)=>{var le;let ee=D==null?void 0:D.assertions[V],ue=(le=P.assertions)==null?void 0:le.find(({id:de})=>de===ee);ue?(j.timestamp=ue.timestamp,L=ue.timestamp):j.timestamp=L+1});return}}v.timestamp=_+1,(B=v.assertions)==null||B.forEach((P,L)=>{P.timestamp=_+L+1})})}catch(c){return af.error("Failed to merge actions",c),null}}async getReloadTestImportCodeOfNewPackages(r,i,s){let c=new i$e(i);c.transformSourceFile([new Qut(r,s,{filterOutChecksumImports:!0,filterOutLocalModules:!0,filterOutTypes:!0,filterSideEffectImports:!0,filterOutNotImportOrRequireStatements:!0}),new Rut(r),new qut,new Uut]);let p=await this.getDeclaredVariableNames(c.sourceFile);return c.transformSourceFile([new Lut(i,p,{filterOutDefinedVariableNames:!0})]),(await c.getFormattedTestFileCode()).code}async getDeclaredVariableNames(r){return new wRt(this.evaluationService).extractDeclaredVariableNames(r)}async getReloadTestEnvironmentCode(){let r=this.testAssetsManager.getSavedTestFilePath(),i=r$e(r),s=lFn(),c=await this.getReloadCodeWithoutPackages(r,i,s);return[await this.getReloadTestImportCodeOfNewPackages(r,i,s),c].join(`
|
|
1786
1786
|
`)}async getReloadCodeWithoutPackages(r,i,s){let c=new i$e(i);c.transformSourceFile([new TRt({shouldRemoveTestExpression:!0,shouldRemoveTestCalls:!0}),new CRt,new Qut(r,s,{filterOutNodeModules:!0,filterOutTypes:!0,filterSideEffectImports:!0,filterOutChecksumImports:!0}),new Rut(r),new DRt(r,s,{newRequireIdentifier:"checksumHotRequire",extraImportArguments:[xFn.default.factory.createIdentifier("__filename")]}),new qut,new Uut]);let p=await this.getDeclaredVariableNames(c.sourceFile);return c.transformSourceFile([new Lut(i,p)]),(await c.getFormattedTestFileCode()).code}getLocalSavedJSONFilePath(r,i){var p;i??(i=i||((p=this.userStoryService.getStory())==null?void 0:p.id));let s=this.testAssetsManager.getLocalAutoSaveFileName(i);return`${r==="auto-save"?this.testAssetsManager.getLocalAutoSavePath():this.testAssetsManager.getLocalSavePath()}/${s}`}readLocalSavedDataFromJSONFile(r){let i=this.readJsonFile(r);return i?{...i,executedActions:i.executedActions.map(s=>({...s,timestamp:void 0}))}:null}readJsonFile(r){try{let i=(0,H6e.readFileSync)(r,"utf-8");return JSON.parse(i)}catch(i){return af.error(`Error reading or parsing JSON file: ${i}`),null}}makeDraftData(){let r=this.userStoryService.getStory(),i=this.userStoryService.getTestGenerationData(),s=this.userStoryService.getEnvInfo(),c={};return r!=null&&r.version&&(c.version=r.version),{actions:this.actionsManager.actions,internalTestId:r.internalTestId,environmentUserId:s.user.username,description:r.goal,metadata:Object.keys(c).length>0?c:void 0}}async generateTestFileString(r){try{let i=this.makeDraftData(),s=r?`${r}.draft.spec.ts`:`test-${i.internalTestId}.draft.spec.ts`,c=await this.apiService.post("test-generation/generate-test-file-string",i);if(!c.ok)throw new Error(`test generation request failed: ${c.statusText}`);let p=await c.text();M8n(p,s,this.testAssetsManager.getLocalSavePath())}catch(i){throw af.error("Failed to generate test file string",i),new Error("Failed to generate test file string")}}localSave(){let r=JSON.stringify(this.vtgTestJSON,null,2),i=this.testAssetsManager.getAssetsFolderPath(),s=this.testAssetsManager.getLocalAutoSaveFileName(this.userStoryService.getStory().id);(0,H6e.writeFileSync)(`${i}/${s}`,r),(0,H6e.writeFileSync)(`${this.testAssetsManager.getLocalAutoSavePath()}/${s}`,r)}get vtgTestJSON(){var r;return{executedActions:this.actionsManager.actions,testGenerationData:this.userStoryService.getTestGenerationData(),settings:{baseURL:(r=this.config.environments.find(i=>i.default))==null?void 0:r.baseURL,assetsFolderPath:this.testAssetsManager.getAssetsFolderPath(),didLogin:this.actionsService.hasLoggedIn(),traceFilePath:this.testAssetsManager.getTraceFilePath(),harFilePath:this.testAssetsManager.getHarFilePath()},story:this.userStoryService.getStory()}}async extendedJSONBackup(){let r=await this.saveExtendedJson(),i=(0,s$e.dirname)(this.testAssetsManager.getSavedTestFilePath()),s=(0,s$e.join)(i,"test.extended.json");return(0,H6e.writeFileSync)(s,JSON.stringify(r,null,2)),{executedActions:r}}async localBackup(r){var i;if(r){this.testAssetsManager.setCurrentSaveAsLocation(r);let s=this.testAssetsManager.getLocalSaveAsPath(),c=this.testAssetsManager.getLocalAutoSavePath(),p=(i=this.userStoryService.getStory())==null?void 0:i.id,_=p?[this.testAssetsManager.getLocalAutoSaveFileName(p)]:[];j8n(c,s,_)}return await this.saveTestFile()}async saveExtendedJson(){let r=[...this.actionsManager.actions],i=[],s=e(async c=>{let{timestamp:p}=c,_="matcher"in c,v=c.timestamp&&(_||rnt(c.eventCode)),{fullHTML:E,outerHTML:D,parentHTML:w,rrwebSnapshot:B}=c.timestamp?await this.getHTMLsForTimestamp(p,c.locator):{fullHTML:"",outerHTML:"",parentHTML:void 0,rrwebSnapshot:""},P=_?jre.generateSingleAssertionCode(c):jre.generateSingleActionCode(c,{newLineSeparator:`
|
|
1787
1787
|
${Put}`,generateAssertionsCode:!1}),L=v?await this.takeElementSnapshot(c.locator,p):void 0;return{code:P,fullHTML:E,outerHTML:D,parentHTML:w,timestamp:p,image:L,rrwebSnapshot:B}},"extractDataForStep");for(let c=0;c<r.length;c++){af.info(`processing action ${c} of ${r.length}`);let p=r[c],_=await s(p);i.push(_);for(let v of p.assertions||[]){af.info(`processing assertion of ${p.assertions.length} assertions`);try{let E=await s(v);i.push(E)}catch(E){af.error("Failed to extract data for assertion",E)}}}return i}async takeElementSnapshot(r,i){try{return`data:image/jpeg;base64,${(await this.taskTimeMachine.executeTask(async c=>(await this.evaluationService.getLocator(`return ${FL(r)}`,c.frameLocator("iframe"))).screenshot({omitBackground:!0,type:"jpeg"}),i)).toString("base64")}`}catch(s){af.error("Failed to take element snapshot",s);return}}async getHTMLsForTimestamp(r,i){try{return i?await this.taskTimeMachine.executeTask(async c=>{let p=await this.evaluationService.getLocator(`return ${FL(i)}`,c.frameLocator("iframe")),_=await p.elementHandle(),{fullHTML:v,outerHTML:E,rrwebSnapshot:D}=await c.page().evaluate(({element:B})=>{let P="",L="",j="",V=document.querySelector(".replayer-wrapper iframe").contentDocument;try{L=V.querySelector("html").outerHTML}catch{L=""}try{j=B.outerHTML}catch{j=""}try{P=JSON.stringify(window.checksum.timeMachine.rrwebSnapshot(V))}catch{P=""}return{fullHTML:L,outerHTML:j,rrwebSnapshot:P}},{element:_}),w=await gFn(p);return{fullHTML:v,outerHTML:E,parentHTML:w,rrwebSnapshot:D}},r):{fullHTML:"",outerHTML:""}}catch(s){return af.error("Failed to get HTML data for extended JSON backup",s),{}}}doesFolderExistInSaveDir(r){try{let i=`${this.testAssetsManager.getLocalSavePath()}/${r}`;return(0,H6e.statSync)(i).isDirectory()}catch(i){if(i.code==="ENOENT")return!1;throw i}}async saveToCloud(){try{let{testGenerationId:r}=await this.userStoryService.createTestGeneration();await this.saveTestFile();let i=await this.settingsService.getIsGitReflectionEnabled();if(!i){let p=new ZOt(this.apiService.getBaseURL(),this.config.apiKey,null,()=>`test-generation/${r}/get-upload-url`),_=e(P=>({complete:!1,error:!1,response:void 0,info:P}),"buildUploadAsset"),v=[],E=this.userStoryService.getStory(),D=E==null?void 0:E.internalTestId,w=E==null?void 0:E.collectionName,B=`test-${D}.fix.checksum.spec.ts`;await p.uploadAsset(_({type:"test-fix-files",path:this.testAssetsManager.getSavedTestFilePath(),fileName:B,relativePath:w?`tests/${w}/${B}`:`tests/${B}`})),v.push(_({type:"trace",path:this.testAssetsManager.getTraceFilePath()})),v.push(_({type:"har",path:await AFn(this.testAssetsManager.getHarFolderPath())})),this.actionsManager.actions.filter(P=>P.eventCode==="upload_files").forEach(P=>{var L;(L=P.files)==null||L.forEach(j=>{v.push(_({type:"test-files",path:j}))})}),await Promise.all(v)}let s=this.actionsManager.actions.map(p=>({...p,parentFramesSelectors:p.parentFramesSelectors?p.parentFramesSelectors.filter(_=>_!=="iframe"):void 0})),c={};if(i){let p=this.userStoryService.getStory();p!=null&&p.version&&(c.version=p.version)}await this.apiService.post(`test-generation/${r}/completed`,{actions:s,metadata:Object.keys(c).length>0?c:void 0})}catch(r){af.error("Failed to upload test",r)}}};e(QLr,"VtgStorageService");var IRt=QLr;aBr();Nte();var qLr=class qLr{constructor(){this._executedActions=[];this.onActionExecuted=this.pushExecutedActionOrAddAfterParent.bind(this)}get actions(){return this._executedActions}set executedActions(r){var i;this._executedActions=r,(i=this.storageService)==null||i.localSave()}addAction(r){var i;this._executedActions.push(r),(i=this.storageService)==null||i.localSave()}setActions(r){this._executedActions=r}updateAssertionById(r,i){let s=i;return this.executedActions=this._executedActions.map(c=>{var p;if(c.id===r){let _=!!((p=c.assertions)!=null&&p.find(({id:E})=>E===i.id)),v={...c};return _?v.assertions=c.assertions.map(E=>{if(E.id===i.id){let D={...E,...i};return s=D,D}return E}):v.assertions=[...c.assertions??[],i],{...v,assertions:v.assertions.sort((E,D)=>E.timestamp!==D.timestamp?E.timestamp-D.timestamp:E.createdAt-D.createdAt)}}return c}),s}setStorageService(r){this.storageService=r}createAction(r){var E,D,w;let{id:i,data:s,options:c,type:p}=r,_={id:i,...s},v=[...this._executedActions];switch(c==null?void 0:c.type){case"insertAfter":{let B=this.findActionOrAssertionById(c.afterStepId),P=v.findIndex(L=>L.id===B.action.id);if(B.assertion||(D=(E=B.action)==null?void 0:E.assertions)!=null&&D.length){let L=B.assertion??B.action.assertions[0],{before:j,after:V}=$oa(((w=v[P])==null?void 0:w.assertions)??[],L.id,!!B.assertion);v[P].assertions=j,_.assertions=V.map(ee=>({...ee,actionId:_.id}))}P!==-1?v.splice(P+1,0,_):v.push(_);break}case"insertLast":v.push(_);break;case"replace":{let B=v.findIndex(P=>P.id===c.stepId);B!==-1&&v.splice(B,1,_);break}case"replaceLast":v.length>0&&(v[v.length-1]=_);break}return this.executedActions=v,_}pushExecutedActionOrAddAfterParent(r,i={}){if(i.previousActionId){let s=this._executedActions.findIndex(({id:c})=>c===i.previousActionId);if(s!==-1){let c={...r,timestamp:this._executedActions[s].timestamp+1};this._executedActions=[...this._executedActions.slice(0,s+1),c,...this._executedActions.slice(s+1)]}}else this.executedActions=Array.isArray(r)?[...this._executedActions,...r]:[...this._executedActions,r]}addManualActionsToExecuted(r){this.executedActions=[...this._executedActions,r]}updateExecutedAction(r){let i=this._executedActions.findIndex(({id:s})=>s===r.id);if(i!==-1){let s={...this._executedActions[i],...r};return this.executedActions=[...this._executedActions.slice(0,i),s,...this._executedActions.slice(i+1)],s}throw new Error("Action was not found")}deleteStep(r,i,s={assertionsOnly:!1,withAssertions:!0}){i==="Action"?this.deleteAction(r,s):i==="Assertion"&&(this.executedActions=this._executedActions.map(c=>(c.assertions=(c.assertions??[]).filter(p=>p.id!==r),c)))}deleteAction(r,i={assertionsOnly:!1,withAssertions:!0}){var c;let s=this._executedActions.find(p=>p.id===r);if(!s)throw new Error(`Action with id "${r}" not found`);i.assertionsOnly?this.executedActions=this._executedActions.map(p=>p.id===r?{...p,assertions:[]}:p):!i.withAssertions&&((c=s==null?void 0:s.assertions)!=null&&c.length)?this.deleteActionAndMergeAssertions(r):this.executedActions=this._executedActions.filter(p=>p.id!==r)}deleteActionAndMergeAssertions(r){let i=this._executedActions.findIndex(v=>v.id===r);if(i===-1)throw new Error(`Action with id "${r}" not found`);if(i===0)throw new Error("Cannot remove the first action; no previous action to merge assertions into");let s=this._executedActions[i-1],c=this._executedActions[i];c.assertions||(c.assertions=[]);let p=c.assertions.map(v=>({...v,actionId:s.id})),_={...s,assertions:[...s.assertions??[],...p]};this.executedActions=[...this._executedActions.slice(0,i-1),_,...this._executedActions.slice(i+1)]}clearTestSteps(r=!0){if(r){let{navigation:i,login:s}=this.findLoginAndNavigationActions();this.executedActions=this._executedActions.reduce((c,p)=>([i==null?void 0:i.id,s==null?void 0:s.id].includes(p.id)&&c.push({...p,assertions:[]}),c),[])}else this.executedActions=[];return this._executedActions}reloadTestSteps(r){this.clearTestSteps(!1),this.executedActions=r}findLoginAndNavigationActions(){let r=this._executedActions.find(({eventCode:s})=>s==="navigation"),i=this._executedActions.find(({eventCode:s})=>s==="login");return{navigation:r,login:i}}addAssertionToAction(r,i){this.executedActions=this._executedActions.map(s=>{if(s.id!==r.actionId)return s;if(s.assertions||(s.assertions=[]),i){let c=s.assertions.findIndex(({id:p})=>i===p);s.assertions.splice(c+1,0,r)}else s.assertions=[r,...s.assertions??[]];return s})}findActionByAssertionId(r){return this._executedActions.find(({assertions:i=[]})=>i.find(s=>s.id===r))}replaceAssertion(r,i){let s=this.findActionByAssertionId(i);if(!s)throw new Error(`No action found containing assertion with id ${i}`);this.executedActions=this._executedActions.map(c=>c.id===s.id?{...c,assertions:(c.assertions??[]).map(p=>p.id===i?{...r,actionId:s.id}:p)}:c)}findActionOrAssertionById(r){let i={action:null,assertion:null};if(this._executedActions.forEach(s=>{s.id===r&&(i.action=s);let c=(s.assertions??[]).find(p=>p.id===r);c&&(i={action:s,assertion:c})}),!i.action&&!i.assertion)throw new B6e(r);return i}async buildStepDataWithCode(r,{loadingFromFile:i}={loadingFromFile:!1}){let s=Voa(r);return await Promise.all(s.map(async({step:c,type:p})=>{let _=await dke(n$e([c],void 0,{generateAssertionsCode:!1},(v,E)=>{c=E}));return{type:p,step:{...c,loadedFromFile:i},code:_}}))}};e(qLr,"VtgActionsManager");var FRt=qLr,$oa=e((n,r,i=!0)=>{let s=Number(i),c=n.findIndex(v=>v.id===r);if(c===-1)return{before:n,after:[]};let p=n.slice(0,c+s),_=n.slice(c+s);return{before:p,after:_}},"splitArrayAtId"),Voa=e(n=>n.reduce((r,i)=>{var p;let{assertions:s,...c}=i;if(r.push({step:c,type:"Action"}),(p=i.assertions)!=null&&p.length){let _=i.assertions.map(v=>({type:"Assertion",step:{...v,actionId:i.id}}));r.push(..._)}return r},[]),"transformActionsListToVTGStepsDataList");var iMt=nd(zLt()),_Mn=nd(require("net")),mMn=nd(Cjr()),hMn=nd(fMn());var yUr=class yUr extends Error{constructor(r){super(r),this.name="ValidationError"}};e(yUr,"ValidationError");var N$e=yUr,vUr=class vUr extends Error{constructor(r){super(r),this.name="NotFoundError"}};e(vUr,"NotFoundError");var P$e=vUr;_6();var yv=e(n=>(r,i,s)=>{Promise.resolve(n(r,i,s)).catch(c=>{if(af.error(`${r.method} ${r.path} error:`,c),c instanceof B6e)return i.status(200).json({error:c.message});if(c instanceof N$e)return i.status(400).send({error:c.message});if(c instanceof P$e)return i.status(404).send(c.message);s(c)})},"asyncErrorHandler");_6();var AUr=nd(zLt());var B$e=class B$e{constructor(){this.routesLogRules={};this.router=(0,AUr.Router)()}getRoutesLogRules(){return this.routesLogRules}getRouter(){return this.router}createPrefixedRouter(r){let i=(0,AUr.Router)(),s=r.startsWith(B$e.DEFAULT_API_PREFIX)?r:`${B$e.DEFAULT_API_PREFIX}${r.startsWith("/")?r:`/${r}`}`;return this.router.use(s,i),i}startAsyncProcess(r,i,s,c="unknown"){af.info(`Starting async ${c} process: ${i} for step: ${s}`),r().catch(p=>{af.error(`Async process ${i} failed:`,p)})}};e(B$e,"VTGController"),B$e.DEFAULT_API_PREFIX="/api";var j5=B$e;var xUr=class xUr extends j5{constructor(i,s,c,p){super();this.assertionsService=i;this.actionsManager=s;this.actionsService=c;this.aiTestGenerationService=p;this.setupRoutes()}setupRoutes(){let i=this.createPrefixedRouter(""),s=this.createPrefixedRouter("/steps");i.post("/createStep",yv(async(c,p)=>{let _=c.body,v;_.type==="Assertion"&&(v=this.assertionsService.createAssertion(_)),_.type==="Action"&&(v=this.actionsManager.createAction(_));let E=await dke(n$e([v],void 0,{generateAssertionsCode:!1},(D,w)=>{v=w}));return p.status(200).json({step:v,code:E})})),i.patch("/updateStep",yv(async(c,p)=>{let _=c.body,v=_==null?void 0:_.options,E;_.type==="Assertion"&&(E=await this.assertionsService.updateAssertion({id:_.id,data:_.data})),_.type==="Action"&&(E=this.actionsManager.updateExecutedAction({..._.data,id:_.id}));let D;v!=null&&v.forceUpdateTimestamp||(_.data.thought===""&&(E.thought=void 0),D=await dke(n$e([E],void 0,{generateAssertionsCode:!1},(w,B)=>{E=B}))),p.status(200).json({step:E,code:D})})),i.delete("/deleteStep",yv(async(c,p)=>{let{id:_,options:v,type:E}=c.body;return this.actionsManager.deleteStep(_,E,v),p.status(200).send({message:"Success!"})})),i.post("/clear-test",yv(async(c,p)=>{let _=this.actionsManager.clearTestSteps();return p.status(200).send(_)})),s.post("/execute",yv(async(c,p)=>{let _=c.body;try{let v=null;return o1a(_)?v=await this.aiTestGenerationService.executeAction(_):c1a(_)&&(v=await this.actionsService.executeAction(_)),p.status(200).json(v)}catch(v){return p.status(400).send({error:v.message})}})),i.put("/steps",yv(async(c,p)=>(this.actionsManager.pushExecutedActionOrAddAfterParent(c.body.action,c.body.options),p.send("success")))),i.post("/code-to-steps",yv(async(c,p)=>{let v=pFn(c.body.code).map(E=>E&&"isChecksumAiWithDirectExpression"in E?{...E,isChecksumAiWithDirectExpression:!1}:E);return p.status(200).send(v)})),i.post("/steps-to-code",yv(async(c,p)=>{let _=n$e(c.body.steps,void 0,{generateAssertionsCode:!1});return p.status(200).send(_)}))}};e(xUr,"VtgStepsController");var HLt=xUr;function o1a(n){var r;return((r=n.options)==null?void 0:r.isAISuggestion)===!0}e(o1a,"isAIExecuteActionArgs");function c1a(n){var r;return((r=n.options)==null?void 0:r.isAISuggestion)===!1}e(c1a,"isManualExecuteActionArgs");_6();var bUr=class bUr extends j5{constructor(i){super();this.locatorsService=i;this.setupRoutes()}setupRoutes(){let i=this.createPrefixedRouter("/locators"),s=this.createPrefixedRouter("/ai/locators");i.post("/play",yv(async(c,p)=>{let _=c.body;try{let v=await this.locatorsService.verifyLocatorOrSelector(_);return p.status(200).send(v)}catch(v){return p.status(400).send({error:v.message})}})),s.post("/generate",yv(async(c,p)=>{let{step:_,target:v,processId:E}=c.body;_.isDefaultThought&&(_.thought=null);try{this.startAsyncProcess(()=>this.locatorsService.generateAILocators(_,v,E),E,v.id,"AI locators generation");let D={processId:E,stepId:v.id,success:!0};return p.status(200).json(D)}catch(D){return af.error("Error generating AI locators:",D),p.status(500).send({processId:E,error:D.message})}})),s.post("/extract-css",yv(async(c,p)=>{let{step:_,target:v,processId:E,llmLocators:D}=c.body;_.isDefaultThought&&(_.thought=null);try{this.startAsyncProcess(()=>this.locatorsService.extractCSS(_,v,E,D),E,v.id,"CSS extraction");let w={processId:E,stepId:v.id,success:!0};return p.status(200).json(w)}catch(w){return af.error("Error extracting CSS locators:",w),p.status(500).send({processId:E,error:w.message})}})),s.post("/filter",yv(async(c,p)=>{let{step:_,target:v,processId:E,candidates:D}=c.body;_.isDefaultThought&&(_.thought=null);try{this.startAsyncProcess(()=>this.locatorsService.filterLocators(_,v,E,D),E,v.id,"locators filtering");let w={processId:E,stepId:v.id,success:!0};return p.status(200).json(w)}catch(w){return af.error("Error filtering locators:",w),p.status(500).send({processId:E,error:w.message})}})),s.delete("/process/:id",yv(async(c,p)=>{let{id:_}=c.params;return await this.locatorsService.cancelProcess(_),af.info("Cancelled process",_),p.status(200).send({success:!0})})),i.post("/identical",yv(async(c,p)=>{let{locator:_,compareLocator:v,timestamp:E}=c.body;try{let D=await this.locatorsService.verifyAndCompareLocatorOnTimemachine(_,v,E);return p.status(200).send(D)}catch(D){return p.status(400).send({error:D.message})}})),i.post("/verify",yv(async(c,p)=>{try{let _=await this.locatorsService.verifyLocatorOrSelector(c.body);return p.status(200).send(_)}catch(_){return p.status(400).send({error:_.message})}}))}};e(bUr,"VtgLocatorsController");var WLt=bUr;var EUr=class EUr extends j5{constructor(i){super();this.codeService=i;this.routesLogRules={"/monaco/editor/types":{skipRequestData:!0,skipResponseData:!0}};this.setupRoutes()}setupRoutes(){this.createPrefixedRouter("/monaco").post("/editor/types",yv(async(s,c)=>{let{libs:p}=s.body;try{let _=this.codeService.getTypesForLibs(p??[]);return c.status(200).send({types:_})}catch(_){return c.status(400).send({error:_.message})}}))}};e(EUr,"MonacoController");var GLt=EUr;J0e();var u1a=h1.enum(["openai","anthropic","google-vertexai","groq"]),dMn=h1.strictObject({message:h1.string(),selection:h1.object({locator:h1.string()}).optional(),stepCode:h1.string().optional(),messageHistory:h1.array(h1.object({type:h1.enum(["user","assistant"]),content:h1.string(),timestamp:h1.string(),stepId:h1.string()})).optional(),model:h1.object({id:h1.string(),name:h1.string(),type:u1a,model:h1.string(),thinking:h1.boolean().optional()}).optional(),includeImage:h1.boolean().optional(),includeHtml:h1.boolean().optional(),includeCode:h1.boolean().optional(),timestamp:h1.number(),error:h1.string().optional()});var CUr=class CUr extends j5{constructor(i){super();this.aiChatService=i;this.setupRoutes()}setupRoutes(){this.createPrefixedRouter("/ai-chat").post("/message",yv(async(s,c)=>{let p=dMn.safeParse(s.body);if(!p.success){c.status(400).json({error:"Invalid request body",details:p.error.format()});return}try{let _=await this.aiChatService.processMessage(p.data);c.json(_)}catch(_){c.status(500).json({error:"Failed to process message",message:_ instanceof Error?_.message:"Unknown error"})}}))}};e(CUr,"AIChatController");var KLt=CUr;var gMn=nd(require("path"));cT();_6();var DUr=class DUr extends j5{constructor(i,s,c){super();this.storageService=i;this.actionsManager=s;this.actionsService=c;this.setupRoutes()}setupRoutes(){let i=this.createPrefixedRouter("/test"),s=this.createPrefixedRouter("");i.post("/generate-test-file-string",yv(async(c,p)=>{try{return await this.storageService.generateTestFileString(c.body.fileName),p.send("success")}catch(_){return p.status(400).send({error:_.message})}})),i.post("/upload",yv(async(c,p)=>(await this.storageService.saveToCloud(),p.send("success")))),i.post("/local-save",yv(async(c,p)=>{await this.storageService.localSave(),p.send("success")})),s.post("/reload-test-from-file",yv(async(c,p)=>{if(!this.storageService.isLoadedFromTestFile)throw new P$e("No test file found");let _=await this.storageService.reloadTestFromFile(c.body.useLLM),v=await this.actionsManager.buildStepDataWithCode(_,{loadingFromFile:!0});return p.status(200).send(v)})),i.post("/verify-save-location",yv(async(c,p)=>{try{let _=this.storageService.doesFolderExistInSaveDir(c.body.location);p.send({exists:_})}catch(_){p.status(400).send({error:_})}})),i.post("/backup",yv(async(c,p)=>{let{backupFolderName:_}=c.body;if(!U8n(_))throw af.error("Invalid folder name",{backupFolderName:_}),new N$e("Invalid folder name");let v=await this.storageService.localBackup(_);p.send(v)})),i.post("/extended-json-backup",yv(async(c,p)=>{let _=this.storageService.extendedJSONBackup();p.send(_)})),s.post("/upload-files",yv(async(c,p)=>{let _=await this.actionsService.uploadFiles(c.body.files);return p.status(200).json(_)}))}};e(DUr,"VtgStorageController");var YLt=DUr;var SUr=class SUr extends j5{constructor(i){super();this.aiTestGenerationService=i;this.setupRoutes()}setupRoutes(){let i=this.createPrefixedRouter("/ai");i.post("/init",yv(async(s,c)=>{await this.aiTestGenerationService.init(),c.send("success")})),i.post("/iterate",yv(async(s,c)=>{let p=await this.aiTestGenerationService.iterate(s.body);return p?c.status(200).json(p):c.status(400).send("no action generated")})),i.post("/stop",yv(async(s,c)=>{this.aiTestGenerationService.stop(),c.send("success")}))}};e(SUr,"VtgAITestGenerationController");var XLt=SUr;var wUr=class wUr extends j5{constructor(i){super();this.thoughtsService=i;this.setupRoutes()}setupRoutes(){let i=this.createPrefixedRouter("/thoughts");i.post("/actions/generate",yv(async(s,c)=>{let p=s.body,{processId:_,action:{id:v}}=p;try{this.startAsyncProcess(()=>this.thoughtsService.generateActionThoughts(p),_,v,"action thoughts generation");let E={processId:_,stepId:v,success:!0};c.status(200).send(E)}catch(E){return c.status(400).send({processId:_,error:E.message})}})),i.post("/assertions/generate",yv(async(s,c)=>{let p=s.body,{processId:_,assertion:{id:v}}=p;try{this.startAsyncProcess(()=>this.thoughtsService.generateAssertionThought(p),_,v,"assertion thoughts generation");let E={processId:_,stepId:v,success:!0};c.status(200).send(E)}catch(E){return c.status(400).send({processId:_,error:E.message})}})),i.post("/stop-generate",yv(async(s,c)=>{let p=s.body;this.thoughtsService.stopGeneratingThought(p.stepId);let _={stepId:p.stepId};return c.status(200).send(_)}))}};e(wUr,"VtgThoughtsController");var ZLt=wUr;var TUr=class TUr extends j5{constructor(i,s){super();this.assertionsService=i;this.aiAssertionsService=s;this.setupRoutes()}setupRoutes(){let i=this.createPrefixedRouter("/assertions"),s=this.createPrefixedRouter("/assertion");i.post("/generate",yv(async(c,p)=>{let _=c.body,{processId:v,id:E}=_;try{this.startAsyncProcess(()=>this.aiAssertionsService.generateAiAssertions(_),v,E,"AI assertion generation");let D={processId:v,stepId:E,success:!0};return p.status(200).json(D)}catch(D){return p.status(500).send({processId:v,error:D.message})}})),i.post("/stop-generate",yv(async(c,p)=>{let{id:_}=c.body,v={stepId:_};return this.aiAssertionsService.stopGenerateAiAssertions(_),p.status(200).send(v)})),s.post("/verify/time-machine",yv(async(c,p)=>{let _=await this.assertionsService.verifyOnTimeMachine(c.body);return p.status(200).send(_)})),s.post("/verify/live",yv(async(c,p)=>{let _=c.body;try{let v=await this.assertionsService.verifyOnLive(_),E=v.success?200:404;return p.status(E).send(v)}catch(v){return p.status(404).send({success:!1,message:String(v)})}})),s.post("/save",yv(async(c,p)=>{let _=await this.assertionsService.updateAssertion(c.body);p.status(200).json(_)}))}};e(TUr,"VtgAssertionsController");var eMt=TUr;var kUr=class kUr extends j5{constructor(i){super();this.settingsService=i;this.setupRoutes()}setupRoutes(){let i=this.createPrefixedRouter("/settings");i.get("/",yv(async(s,c)=>{let p=this.settingsService.getSettings();return c.status(200).send(p)})),i.post("/",yv(async(s,c)=>(this.settingsService.updateSettings(s.body),c.status(200).send({message:"Success!"}))))}};e(kUr,"VtgSettingsController");var tMt=kUr;_6();var yMn=nd(zLt());var IUr=class IUr extends j5{constructor(i){super();this.evaluatorService=i;this.setupRoutes()}setupRoutes(){this.createPrefixedRouter("/evaluator").post("/execute",yv(async(s,c)=>{try{let p=await this.evaluatorService.execute(s.body.code);return c.status(200).json(p)}catch(p){return c.status(500).send({message:"Error during code evaluation",error:p.message})}}))}};e(IUr,"VtgEvaluatorController");var rMt=IUr;cT();_6();var FUr=class FUr{constructor(){this.reqIndex=0;this.reqInProcess={};this.routesLogRules={};this.intervalTimer=null}setRoutesLogRules(r){this.routesLogRules=r}cleanup(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null)}startListening(r,i,s){I_.vtg.logAPIServer.interval&&this.handleIntervalLog(r,i,s),!(I_.vtg.logAPIServer.httpTransactions&&this.handleTransactionLog(r,i,s))&&s()}logInterval(){I_.vtg.logAPIServer.interval&&!this.intervalTimer&&(this.intervalTimer=setInterval(()=>{let r=Object.values(this.reqInProcess);r.length&&(af.info("HTTP REQUESTS IN PROCESS"),af.info(r.map(i=>JSON.stringify(i,null,2)).join(`
|
|
1788
|
-
`)))},5e3))}handleIntervalLog(r,i,s){let c=this.reqIndex++;this.reqInProcess[c]=this.buildLogInfo(r,i,0,"","INTERVAL"),i.on("finish",()=>{let p=Date.now()-this.reqInProcess[c].start;delete this.reqInProcess[c]})}handleTransactionLog(r,i,s){if(this.getRouteRules(r.originalUrl).skip)return s(),!0;let p=Date.now(),_=this.buildLogInfo(r,i,0,"","REQUEST"),v="";af.info("REQUEST INFO",JSON.stringify(_,null,2));let E=i.write,D=i.end;return i.write=function(w,...B){return w&&(v+=w.toString()),E.call(this,w,...B)},i.end=function(w,...B){return w&&(v+=w.toString()),D.call(this,w,...B)},i.on("finish",()=>{if(I_.vtg.logAPIServer.httpTransactions){let w=Date.now()-p,B=this.buildLogInfo(r,i,w,v,"RESPONSE");af.info("RESPONSE INFO",JSON.stringify(B,null,2))}}),!1}buildLogInfo(r,i,s,c,p="RESPONSE"){let _=this.getRouteRules(r.originalUrl),v={method:r.method,url:r.originalUrl,start:Date.now()};return p==="INTERVAL"||(p==="REQUEST"&&!_.skipRequestData&&r.body&&(v.data=r.body),p==="RESPONSE"&&(s&&(v.duration=`${s}ms`),v.statusCode=i.statusCode,v.size=i.getHeader("content-length")||"unknown",!_.skipResponseData&&c&&(v.data=c))),v}getRouteRules(r){if(this.routesLogRules[r])return this.routesLogRules[r];for(let[i,s]of Object.entries(this.routesLogRules))if(r.includes(i))return s||{};return{}}};e(FUr,"VTGExpressServerRoutesLoggerMiddleware");var nMt=FUr;var NUr=class NUr{constructor(r,i,s,c,p,_,v,E,D,w,B,P){this.actionsService=r;this.assertionsService=i;this.locatorsService=s;this.aiTestGenerationService=c;this.aiAssertionsService=p;this.aiThoughtsService=_;this.actionsManager=v;this.storageService=E;this.settingsService=D;this.monacoService=w;this.evaluatorService=B;this.aiChatService=P;this.errorHandler=e((r,i,s,c)=>{af.error("Error catch in middleware:",r),s.status(500).send({error:r.message})},"errorHandler");this.routesLoggerMiddleware=new nMt}async getPort(){return this.acquirePortNumber()}async start(){return this.app=(0,iMt.default)(),this.app.use((0,hMn.default)()),this.app.use(mMn.default.json({limit:"50mb"})),this.app.use(iMt.default.raw({type:"multipart/form-data",limit:"50mb"})),this.app.use(iMt.default.static(gMn.default.join(I_.runtimeRoot,"vtg-build"))),this.app.use(this.routesLoggerMiddleware.startListening.bind(this.routesLoggerMiddleware)),this.routesLoggerMiddleware.logInterval(),await this.acquirePortNumber(),this.app.use(this.initializeControllers()),this.app.use(this.errorHandler),new Promise(r=>{this.app.listen(this.port,()=>{af.info(`Express server running on port ${this.port}`),r()}).on("close",()=>{this.shutdown()})})}shutdown(){this.routesLoggerMiddleware.cleanup(),af.info("Express server shutdown complete")}async acquirePortNumber(){return this.port||(this.port=await new Promise((r,i)=>{let s=_Mn.default.createServer();s.unref(),s.on("error",i),s.listen(0,()=>{let c=s.address().port;s.close(()=>{r(c)})})})),this.port}async evaluateServerPort(r){if(!r)throw new Error("Page not initialized");await r.evaluate(i=>{window.vtg.setServerPort(i)},this.port)}initializeControllers(){let r=new HLt(this.assertionsService,this.actionsManager,this.actionsService,this.aiTestGenerationService),i=new YLt(this.storageService,this.actionsManager,this.actionsService),s=new XLt(this.aiTestGenerationService),c=new ZLt(this.aiThoughtsService),p=new eMt(this.assertionsService,this.aiAssertionsService),_=new tMt(this.settingsService),v=new WLt(this.locatorsService),E=new GLt(this.monacoService),D=new KLt(this.aiChatService),w=new rMt(this.evaluatorService),B=[r,i,s,c,p,_,v,E,w,D],P=(0,yMn.Router)(),L={};return B.forEach(j=>{P.use(j.getRouter()),L={...L,...j.getRoutesLogRules()}}),this.routesLoggerMiddleware.setRoutesLogRules(L),P}};e(NUr,"VtgExpressServer");var aMt=NUr;var sMt=require("fs");var jlt=class jlt{constructor(r,i,s,c){this.projectRootDirectory=r;this.checksumRoot=i;this.internalFilesDir=s;this.vtgTestFileRunConfig=c;this.localSaveFolderPath=process.env.CHECKSUM_DRAFT_FOLDER_PATH??`${this.internalFilesDir}/drafts`}createTestAssetsFolders(){this.assetsFolderPath=`${this.internalFilesDir}/assets/${Date.now()}`,(0,sMt.mkdirSync)(this.assetsFolderPath,{recursive:!0}),(0,sMt.mkdirSync)(this.getHarFolderPath(),{recursive:!0})}createTestGenerationLocalAutoSaveFolder(){(0,sMt.mkdirSync)(this.getLocalAutoSavePath(),{recursive:!0})}getAssetsFolderPath(){return this.assetsFolderPath}getLocalAutoSavePath(){return`${this.localSaveFolderPath}/${jlt.AUTO_SAVE_FOLDER_NAME}`}getLocalAutoSaveFileName(r){var i;return((i=this.vtgTestFileRunConfig)==null?void 0:i.mode)==="edit"?this.vtgTestFileRunConfig.sourceFilePath.split("/").pop().replace(".spec.ts",".json"):`${r}.json`}getLocalSaveAsPath(){return this.currentSaveAsLocation??(this.currentSaveAsLocation=`${Date.now()}_save`),`${this.localSaveFolderPath}/${this.currentSaveAsLocation}`}getSavedTestFilePath(){if(!this.vtgTestFileRunConfig)throw new Error("vtgTestFileRunConfig is required to get the test file save as path");if(this.currentSaveAsLocation){let r=this.vtgTestFileRunConfig.sourceFilePath.split("/").pop();return`${this.localSaveFolderPath}/${this.currentSaveAsLocation}/${r}`}else return this.vtgTestFileRunConfig.sourceFilePath}getLocalSavePath(){return this.localSaveFolderPath}getHarFolderPath(){return this.assetsFolderPath+"/har"}getHarFilePath(){return`${this.getHarFolderPath()}/har.har`}getTraceFilePath(){return`${this.assetsFolderPath}/trace.zip`}setCurrentSaveAsLocation(r){r&&!(r!=null&&r.startsWith("auto-save"))&&(this.currentSaveAsLocation=r)}};e(jlt,"VtgTestAssetsManager"),jlt.AUTO_SAVE_FOLDER_NAME="auto-save";var oMt=jlt;var l1a={useCDPSession:!0,trackLoadedResources:!0},PUr=class PUr extends dOt{constructor(i={},s={devtools:!1},c={},p,_){super({...l1a,...i},s,p,_);this.settings={frontendAppSpecificRules:void 0,initTestGenerator:!0,frontendTestGenerationConfig:void 0};this.isScriptLoaded=e(async(i,s=1e3)=>{try{return await i.waitForFunction(()=>!!window.checksum,void 0,{timeout:s}),!0}catch{return!1}},"isScriptLoaded");this.initInjectedScript=e(async i=>{try{return await i.waitForFunction(()=>{var s;return!!((s=window.checksum)!=null&&s.testGenerator)}),i.evaluate(async({appSpecificRules:s,config:c,initModules:p})=>{window.checksum.testGenerator.init(s,c,p)},{appSpecificRules:this.settings.frontendAppSpecificRules,config:this.getFrontendTestGenerationConfig(),initModules:this.getInjectedScriptInitModules(i)})}catch(s){console.log("initInjectedScript exception",s)}},"initInjectedScript");this.settings={...this.settings,...c},this.injectedScriptManager.setScriptLoadCheck(this.isScriptLoaded),this.settings.initTestGenerator&&this.injectedScriptManager.setScriptLoadCallback(this.initInjectedScript)}async prepare(i={}){let s=await super.prepare(i);return this.evaluateWithChecksumTargetFrame=this.page.mainFrame(),this.settings.loadScriptOnPrepare&&await this.injectedScriptManager.addTrackedFrame(this.page),await this.page.addInitScript(()=>{window.sessionStorage.setItem("checksumai:disable","true")}),s}setEvaluateWithChecksumTargetFrame(i){this.evaluateWithChecksumTargetFrame=i}getInjectedScriptInitModules(i){return{assertionGenerator:!0,sessionRecorder:!0,filesObserver:!1,assertionsObserver:!1,actionsObserver:!1,nativeDialogObserver:!1}}getFrontendTestGenerationConfig(){return this.settings.frontendTestGenerationConfig}async evaluateWithChecksum(i,s,c=this.evaluateWithChecksumTargetFrame){let p=this.injectedScriptManager.getNavigationPromise(c);p&&await p;try{return c.evaluate(i,s)}catch(_){throw console.error("evaluateWithChecksum error",_,i.toString()),_}}async getBestMatchingElementSimilarityScore(i){return this.evaluateWithChecksum(async s=>await window.checksum.testGenerator.getBestMatchingElementSimilarityScore(s),i)}async getInteractableElements(){return this.evaluateWithChecksum(async()=>await window.checksum.testGenerator.getInteractableElements())}async getAllInteractableElementsForLastSelectQuery(){return this.evaluateWithChecksum(async()=>await window.checksum.testGenerator.getAllInteractableElementsForLastSelectQuery())}async overlayInteractableElementsWithChecksumId(i){return this.evaluateWithChecksum(s=>window.checksum.testGenerator.overlayInteractableElementsWithChecksumId(s),i)}async takeElementSnapshot(i,s,c={},p={}){try{let{snapshot:_,elementLocator:v}=await super.takeElementSnapshot(i,s,c);if(!_||!c.takeBodyScreenshot)return _?{snapshot:_}:{};await this.highlightElementByLocator(v,c.mousePosition);let E=await this.takePageSnapshot(p);return await this.clearHighlights(),{snapshot:_,bodySnapshot:E}}catch(_){return console.error("[ChecksumWebDriver] takeElementSnapshot error",_),{}}}async highlightElementByLocator(i,s,c="20px solid rgba(255,0,0,1)",p=!1){return this.evaluateWithChecksum(async([_,v,E,D])=>{window.checksum.testGenerator.highlightElement(_,{highlightStyle:{outline:v},mousePosition:E,scroll:D})},[await i.elementHandle(),c,s,p])}async clearHighlights(){return this.evaluateWithChecksum(async()=>window.checksum.testGenerator.clearHighlights())}};e(PUr,"ChecksumWebDriver");var cMt=PUr;var vMn=require("fs"),AMn=nd(require("path"));var BUr=require("fs");cT();_6();var OUr=class OUr{constructor(r,i,s=I_.vtg.localBuildPath){this.page=r;this.serverPort=i;this.filePath=s;this.filePath=s,af.info("[VTG] FrontendLauncher initialized with:",{serverPort:i,filePath:s,appSource:I_.vtg.appSource,cwd:process.cwd()})}async start(){try{await this.modifyVTGBuildHtmlFile(),await this.startReactApp()}catch(r){throw af.error("An error occurred:",r),r}}async startReactApp(){if(!this.page)throw new Error("Page not initialized");let r;switch(I_.vtg.appSource){case"served-app":r=I_.vtg.appURL;break;case"served-build-file":r=`http://localhost:${this.serverPort}/index.html`;break;case"build-file":r=I_.vtg.localUrl;break;default:throw new Error(`Invalid app source: ${I_.vtg.appSource}`)}await this.page.goto(r,{waitUntil:"networkidle",timeout:6e4})}async modifyVTGBuildHtmlFile(){if(I_.vtg.appSource==="build-file")try{let r=await BUr.promises.readFile(this.filePath,"utf8"),i=/(src|href)=(["'])(\/)static/g,s=r.replace(i,"$1=$2.$3static");await BUr.promises.writeFile(this.filePath,s,"utf8"),af(`Successfully modified ${this.filePath}`)}catch(r){af.error(`Error processing file ${this.filePath}:`,r)}}};e(OUr,"VtgFrontendLauncher");var uMt=OUr;ITt();cT();fBr();_6();Q3r();OTt();WS();var p1a=1e3,pMt=class pMt extends cMt{constructor(i={},s={devtools:!1},c={},p){var _,v,E;super(i,s,pMt.makeSettings(c),(_=p==null?void 0:p.getFramesMessageBroker)==null?void 0:_.call(p),I_.vtg.isSeparateProcess?void 0:((E=(v=p==null?void 0:p.context())==null?void 0:v._rawContext)==null?void 0:E.call(v))??(p==null?void 0:p.context()));this.liveAppPage=p;this.registeredTimeMachineFrames=[];this.onAppFrameCreated=e(async i=>{this.appFrame=i,await this.frameMsgBroker.register("live",this.appFrame,I_.vtg.writeRrwebEventsToFile),this.setEvaluateWithChecksumTargetFrame(this.appFrame)},"onAppFrameCreated");this.timeMachine=new oge(this.frameMsgBroker,this.injectedScriptManager,{webProxy:i.webProxy}),this.liveTimeMachine=new oge(this.frameMsgBroker,this.injectedScriptManager,{webProxy:i.webProxy}),this.appViewport=c.viewport,this.completeOriginHeaderOnLivePage=c.completeOriginHeaderOnLivePage}static makeSettings(i={}){return iOt({frontendTestGenerationConfig:{showFrontendLogs:I_.isDevMode}},i)}get appMainFrame(){return this.appFrame}get tmFrame(){return this.timeMachineFrame}getApplicationViewport(){return this.appViewport}getTimeMachine(){return this.timeMachine}registerTimeMachineFrame(i){this.registeredTimeMachineFrames.push(i)}async prepare(i={},s={}){let c=await super.prepare(i);await this.frameMsgBroker.register("vtg",this.page.mainFrame()),this.page.on("dialog",()=>{}),this.page.on("close",()=>{af.error("Page closed")}),this.liveAppPage&&!I_.vtg.isSeparateProcess&&await(await this.page.context().newCDPSession(this.originalPage)).send("Emulation.setDeviceMetricsOverride",{width:0,height:0,deviceScaleFactor:0,mobile:!1}),await new uMt(this.page,s.serverPort).start();let p=e(async(v=2)=>{if(this.timeMachineFrame=this.page.frames().find(E=>E.name()==="time-machine-iframe"),this.liveFrame=this.page.frames().find(E=>E.name()==="live-iframe"),!this.timeMachineFrame||!this.liveFrame){if(v>0)return af.info("Waiting for frames to be available"),await Mb(p1a),p(v-1);{let E="Could not connect to VTG frontend, check that the app is available";throw af.error(E),new Error(E)}}},"getFrames");await p();let _;return this.liveAppPage?(_=this.liveAppPage,this.completeOriginHeaderOnLivePage&&await this.applyRouteInterceptors(_,{completeOriginHeader:!0})):(_=await this.context.newPage(),await _.setViewportSize(this.appViewport)),await this.onAppFrameCreated(_.mainFrame()),await this.timeMachine.prepare(this.appFrame,this.timeMachineFrame),await this.liveTimeMachine.prepare(this.appFrame,this.liveFrame),await this.exposeFunctionsForVTG(),c}async exposeFunctionsForVTG(){try{if(await this.page.evaluate(()=>typeof window.checksumGetFilesFromLive=="function").catch(()=>!1)){af.info("checksumGetFilesFromLive already exposed, skipping");return}await this.page.exposeFunction("checksumGetFilesFromLive",async s=>{let c=this.appFrame;if(!c){af.info("no live frame detected");return}try{return c.evaluate(p=>window.checksum.testGenerator.filesObserver.getFilesByRrwebId(p),s)}catch(p){af.error("Error getting frame window",p)}})}catch(i){af.warning(`Failed to expose checksumGetFilesFromLive: ${i.message}`)}}async navigate(i){return this.appFrame.goto(i)}async getCurrentURL(){return this.appFrame.url()}async createPage(){let i=new uge(this.evaluateWithChecksum.bind(this),()=>this.appFrame,()=>this.timeMachine,{log:af.info,logError:af.error},{navigationTimeout:3e4,actionTimeout:5e3,waitActionDelay:1e3,testAssetsDir:__dirname}),s=await super.createPage();return jje.makePage(s,i,this.injectedScriptManager,this.context)}getInjectedScriptInitModules(i){return this.registeredTimeMachineFrames.concat([this.timeMachineFrame,this.liveFrame]).includes(i)?{assertionGenerator:!1,sessionRecorder:!1,filesObserver:!1,nativeDialogObserver:!1,assertionsObserver:!1,actionsObserver:!1}:i===this.appFrame?{...super.getInjectedScriptInitModules(i),filesObserver:!0,nativeDialogObserver:!0,assertionsObserver:!0,actionsObserver:!0}:super.getInjectedScriptInitModules(i)}async interceptPageRequests(){async function i(c){try{return await vMn.promises.readFile(c,"utf8")}catch(p){return af.error(`Error reading file ${c}:`,p),null}}e(i,"readLocalFile");function s(c){switch(AMn.extname(c).toLowerCase()){case".html":return"text/html";case".js":return"application/javascript";case".css":return"text/css";case".json":return"application/json";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";default:return"application/octet-stream"}}e(s,"getContentType"),await this.page.route("**/*",async c=>{try{let p=c.request().url();if(console.log("intercepted!",p),p.startsWith("file://")){let _=p.replace("file://",""),v=await i(_);v!==null?await c.fulfill({status:200,contentType:s(_),body:v}):await c.abort()}else{let _=0,v=5;for(;_<v;){let E=await c.fetch(),D=E.status();if(D>299&&D<400){_++;let w=E.headers().location;if(!w){af.warning("Redirect without Location header",{url:p}),await c.abort();return}console.log(`Redirect ${_} to: ${w}`),c.request().url=()=>new URL(w,p).toString()}else{let w={};w["Access-Control-Allow-Origin"]="*",w["Access-Control-Allow-Methods"]="GET, POST, PUT, DELETE, OPTIONS",w["Access-Control-Allow-Headers"]="Content-Type, Authorization",await c.fulfill({response:E,headers:{...E.headers(),...w,"content-security-policy":"","X-Frame-Options":"","x-frame-options":""}});return}}af.warning(`Max redirects (${v}) exceeded`),await c.abort()}}catch(p){af.warning("intercept error",p)}})}};e(pMt,"ChecksumVTGWebDriver");var lMt=pMt;var O$e=require("fs");cT();var xMn=".settings.json",RUr=class RUr{constructor(r,i,s){this.checksumRoot=r;this.apiService=i;this.internalFilesDir=s;this.settings={autoLogin:!0,autoRunSteps:!0,autoGenerateThoughts:!0,disableGenerateThoughts:!1,autoGenerateAssertions:!0,disableAutoGenerateAssertions:!1,disableAILocators:!1,optimizeLocators:!0,useOptimizedLocatorDefault:!0,useCodeBasedSteps:!0,displayUIInspector:!1,mergeCustomCodeSteps:!1,useVariableTransformation:!0};this.settingsFilePath=s?`${this.internalFilesDir}/${xMn}`:`${this.checksumRoot}/${xMn}`,this.readSettings()}getSettings(){return{...this.settings,autoGenerateAssertions:I_.vtg.aiAssertions.disabled?!1:this.settings.autoGenerateAssertions,disableAutoGenerateAssertions:I_.vtg.aiAssertions.disabled,disableAILocators:I_.vtg.aiLocators.disabled}}updateSettings(r){this.settings=Object.assign(this.settings,r),this.writeSettingsData()}readSettings(){if(!(0,O$e.existsSync)(this.settingsFilePath)){this.writeSettingsData();return}let r=(0,O$e.readFileSync)(this.settingsFilePath,"utf-8");this.settings=JSON.parse(r),this.settings.useCodeBasedSteps===void 0&&(this.settings.useCodeBasedSteps=!0)}writeSettingsData(){(0,O$e.writeFileSync)(this.settingsFilePath,JSON.stringify(this.settings,null,2))}async getIsGitReflectionEnabled(){return(await(await this.apiService.get("/git-integration/is-git-reflection-enabled")).json()).enabled??!1}};e(RUr,"VtgSettingsService");var Ult=RUr;zSr();var n7e=require("fs");_6();var LUr=class LUr{constructor(r,i,s){this.timeMachine=r;this.actionsManager=i;this.userStoryService=s}async generatePromptData(r,i){let s=e(()=>{let{timestamps:D,...w}=this.cachedPromptData;return{...w,action:r}},"returnPromptDataFromCache"),c=r.id;if(this.canUseCachedPromptData(r))return s();let p=this.getActionTimestamps(c,i);if(!p)return;let _=await this.timeMachine.executeReducedHTMLTask(p.before),v=await this.timeMachine.executeReducedHTMLTask(p.after),E=this.userStoryService.getStory();return this.cachedPromptData={reducedHTML:v,previousReducedHTML:_,actionId:c,previousActions:this.getPreviousActions(c),action:r,title:E.goal,steps:E.instructions,timestamps:p},s()}canUseCachedPromptData(r){var i,s;return this.cachedPromptData&&this.cachedPromptData.actionId===r.id&&this.cachedPromptData.action.timestamp===r.timestamp&&((i=this.cachedPromptData.timestamps)==null?void 0:i.before)===r.timestamp&&((s=this.cachedPromptData.timestamps)==null?void 0:s.after)===r.timestamp}getPreviousActions(r){let i=this.actionsManager.actions,s=i.findIndex(c=>Number(c.id)===Number(r));return i.slice(0,s)}async generatePromptDataForThought(r,i){return this.generatePromptData(r,i)}getActionTimestamps(r,i){let s=this.actionsManager.actions,c=s.findIndex(v=>v.id===r);if(c===-1){af.error(`[init] No action with id ${r} was found in executed actions`);return}let p=s[c],_=s[c+1];return{before:p.timestamp,after:(_==null?void 0:_.timestamp)??i}}};e(LUr,"ActionsAgent");var fMt=LUr;_6();cT();var MUr=class MUr extends P6e{constructor(i,s,c,p,_){super(i,s,c);this.actionsManager=i;this.apiService=s;this.userStoryService=c;this.webDriver=_;this.activeRemoteSessionIdByStepId=new Map;this.assertionsAgent=new JQe(p,i,s,this.remoteSessionId,{logPerformance:I_.vtg.aiAssertions.logPerformance}),this.actionsAgent=new fMt(p,i,this.userStoryService)}async init({retriesLeft:i=3,keepActionsWithoutDescription:s=!1,lastActionId:c=void 0}={}){await super.init({retriesLeft:i,keepActionsWithoutDescription:s,lastActionId:c}),this.activeRemoteSessionIdByStepId.set(c,this.remoteSessionId)}async generateActionThoughts({action:i,processId:s}){try{if(this.isRunning(i.id))throw af.warning("Already generating a thought for this action"),new Error("Already generating a thought for this action");let c=await this.actionsAgent.generatePromptDataForThought(i),p=await this.callThoughtApi("actions",c,s);return this.evaluateThoughtResponse({processId:s,id:i.id,thought:p.thought})}catch(c){return af.error("Error in AI thought generation",c),this.evaluateThoughtResponse({processId:s,id:i.id,error:!0})}finally{this.activeRemoteSessionIdByStepId.delete(i.id)}}async generateAssertionThought({assertion:i,parentActionId:s,processId:c}){let p=s||i.actionId;try{if(this.isRunning(i.id))throw af.warning("Already generating a thought for this assertion"),new Error("Already generating a thought for this assertion");let _=await this.assertionsAgent.generateThoughtPromptData(p,i),v=await this.callThoughtApi("assertions",_,c);return this.evaluateThoughtResponse({processId:c,id:i.id,thought:v.thought})}catch(_){return af.error("Error in AI thought generation",_),this.evaluateThoughtResponse({processId:c,id:i.id,error:!0})}finally{this.activeRemoteSessionIdByStepId.delete(i.id)}}stopGeneratingThought(i){this.activeRemoteSessionIdByStepId.delete(i)}async callThoughtApi(i,s,c){let p=Date.now();if(s)try{p=Date.now();let _=await this.apiService.post(`${i}/thoughts/generate`,{sessionId:this.remoteSessionId,data:s});if(!_.ok){af.error(`Request for ${i} thought generation failed with status ${_.status}`);return}let v=await _.json();if(!(v!=null&&v.thought))throw af("No thought generated for action, got response",_),new Error("No thought generated");let E=i==="actions"?s.action:s.assertion;return af(`Thought generated (${c})`,{type:i,stepId:E.id,locator:E.locator,thought:v.thought}),v}catch(_){throw af.error(`Error in AI thought generation (${c})`,_),_}}isRunning(i){return this.activeRemoteSessionIdByStepId.has(i)}async evaluateThoughtResponse({id:i,processId:s,thought:c,error:p=!1}){try{await this.webDriver.page.evaluate(({id:_,thought:v,error:E,processId:D})=>{window.vtg.onAsyncProcessResponse({id:_,processId:D,thought:v,error:E})},{id:i,thought:c,error:p,processId:s})}catch(_){af.error("Error in AI thought generation",_)}}};e(MUr,"VTGThoughtsService");var dMt=MUr;var f1a=e(()=>{let r=new Error().stack.split(`
|
|
1788
|
+
`)))},5e3))}handleIntervalLog(r,i,s){let c=this.reqIndex++;this.reqInProcess[c]=this.buildLogInfo(r,i,0,"","INTERVAL"),i.on("finish",()=>{let p=Date.now()-this.reqInProcess[c].start;delete this.reqInProcess[c]})}handleTransactionLog(r,i,s){if(this.getRouteRules(r.originalUrl).skip)return s(),!0;let p=Date.now(),_=this.buildLogInfo(r,i,0,"","REQUEST"),v="";af.info("REQUEST INFO",JSON.stringify(_,null,2));let E=i.write,D=i.end;return i.write=function(w,...B){return w&&(v+=w.toString()),E.call(this,w,...B)},i.end=function(w,...B){return w&&(v+=w.toString()),D.call(this,w,...B)},i.on("finish",()=>{if(I_.vtg.logAPIServer.httpTransactions){let w=Date.now()-p,B=this.buildLogInfo(r,i,w,v,"RESPONSE");af.info("RESPONSE INFO",JSON.stringify(B,null,2))}}),!1}buildLogInfo(r,i,s,c,p="RESPONSE"){let _=this.getRouteRules(r.originalUrl),v={method:r.method,url:r.originalUrl,start:Date.now()};return p==="INTERVAL"||(p==="REQUEST"&&!_.skipRequestData&&r.body&&(v.data=r.body),p==="RESPONSE"&&(s&&(v.duration=`${s}ms`),v.statusCode=i.statusCode,v.size=i.getHeader("content-length")||"unknown",!_.skipResponseData&&c&&(v.data=c))),v}getRouteRules(r){if(this.routesLogRules[r])return this.routesLogRules[r];for(let[i,s]of Object.entries(this.routesLogRules))if(r.includes(i))return s||{};return{}}};e(FUr,"VTGExpressServerRoutesLoggerMiddleware");var nMt=FUr;var NUr=class NUr{constructor(r,i,s,c,p,_,v,E,D,w,B,P){this.actionsService=r;this.assertionsService=i;this.locatorsService=s;this.aiTestGenerationService=c;this.aiAssertionsService=p;this.aiThoughtsService=_;this.actionsManager=v;this.storageService=E;this.settingsService=D;this.monacoService=w;this.evaluatorService=B;this.aiChatService=P;this.errorHandler=e((r,i,s,c)=>{af.error("Error catch in middleware:",r),s.status(500).send({error:r.message})},"errorHandler");this.routesLoggerMiddleware=new nMt}async getPort(){return this.acquirePortNumber()}async start(){return this.app=(0,iMt.default)(),this.app.use((0,hMn.default)()),this.app.use(mMn.default.json({limit:"50mb"})),this.app.use(iMt.default.raw({type:"multipart/form-data",limit:"50mb"})),this.app.use(iMt.default.static(gMn.default.join(I_.runtimeRoot,"vtg-build"))),this.app.use(this.routesLoggerMiddleware.startListening.bind(this.routesLoggerMiddleware)),this.routesLoggerMiddleware.logInterval(),await this.acquirePortNumber(),this.app.use(this.initializeControllers()),this.app.use(this.errorHandler),new Promise(r=>{this.app.listen(this.port,()=>{af.info(`Express server running on port ${this.port}`),r()}).on("close",()=>{this.shutdown()})})}shutdown(){this.routesLoggerMiddleware.cleanup(),af.info("Express server shutdown complete")}async acquirePortNumber(){return this.port||(this.port=await new Promise((r,i)=>{let s=_Mn.default.createServer();s.unref(),s.on("error",i),s.listen(0,()=>{let c=s.address().port;s.close(()=>{r(c)})})})),this.port}async evaluateServerPort(r){if(!r)throw new Error("Page not initialized");await r.evaluate(i=>{window.vtg.setServerPort(i)},this.port)}initializeControllers(){let r=new HLt(this.assertionsService,this.actionsManager,this.actionsService,this.aiTestGenerationService),i=new YLt(this.storageService,this.actionsManager,this.actionsService),s=new XLt(this.aiTestGenerationService),c=new ZLt(this.aiThoughtsService),p=new eMt(this.assertionsService,this.aiAssertionsService),_=new tMt(this.settingsService),v=new WLt(this.locatorsService),E=new GLt(this.monacoService),D=new KLt(this.aiChatService),w=new rMt(this.evaluatorService),B=[r,i,s,c,p,_,v,E,w,D],P=(0,yMn.Router)(),L={};return B.forEach(j=>{P.use(j.getRouter()),L={...L,...j.getRoutesLogRules()}}),this.routesLoggerMiddleware.setRoutesLogRules(L),P}};e(NUr,"VtgExpressServer");var aMt=NUr;var sMt=require("fs");var jlt=class jlt{constructor(r,i,s,c){this.projectRootDirectory=r;this.checksumRoot=i;this.internalFilesDir=s;this.vtgTestFileRunConfig=c;this.localSaveFolderPath=process.env.CHECKSUM_DRAFT_FOLDER_PATH??`${this.internalFilesDir}/drafts`}createTestAssetsFolders(){this.assetsFolderPath=`${this.internalFilesDir}/assets/${Date.now()}`,(0,sMt.mkdirSync)(this.assetsFolderPath,{recursive:!0}),(0,sMt.mkdirSync)(this.getHarFolderPath(),{recursive:!0})}createTestGenerationLocalAutoSaveFolder(){(0,sMt.mkdirSync)(this.getLocalAutoSavePath(),{recursive:!0})}getAssetsFolderPath(){return this.assetsFolderPath}getLocalAutoSavePath(){return`${this.localSaveFolderPath}/${jlt.AUTO_SAVE_FOLDER_NAME}`}getLocalAutoSaveFileName(r){var i;return((i=this.vtgTestFileRunConfig)==null?void 0:i.mode)==="edit"?this.vtgTestFileRunConfig.sourceFilePath.split("/").pop().replace(".spec.ts",".json"):`${r}.json`}getLocalSaveAsPath(){return this.currentSaveAsLocation??(this.currentSaveAsLocation=`${Date.now()}_save`),`${this.localSaveFolderPath}/${this.currentSaveAsLocation}`}getSavedTestFilePath(){if(!this.vtgTestFileRunConfig)throw new Error("vtgTestFileRunConfig is required to get the test file save as path");if(this.currentSaveAsLocation){let r=this.vtgTestFileRunConfig.sourceFilePath.split("/").pop();return`${this.localSaveFolderPath}/${this.currentSaveAsLocation}/${r}`}else return this.vtgTestFileRunConfig.sourceFilePath}getLocalSavePath(){return this.localSaveFolderPath}getHarFolderPath(){return this.assetsFolderPath+"/har"}getHarFilePath(){return`${this.getHarFolderPath()}/har.har`}getTraceFilePath(){return`${this.assetsFolderPath}/trace.zip`}setCurrentSaveAsLocation(r){r&&!(r!=null&&r.startsWith("auto-save"))&&(this.currentSaveAsLocation=r)}};e(jlt,"VtgTestAssetsManager"),jlt.AUTO_SAVE_FOLDER_NAME="auto-save";var oMt=jlt;var l1a={useCDPSession:!0,trackLoadedResources:!0},PUr=class PUr extends dOt{constructor(i={},s={},c={},p,_){super({...l1a,...i},s,p,_);this.settings={frontendAppSpecificRules:void 0,initTestGenerator:!0,frontendTestGenerationConfig:void 0};this.isScriptLoaded=e(async(i,s=1e3)=>{try{return await i.waitForFunction(()=>!!window.checksum,void 0,{timeout:s}),!0}catch{return!1}},"isScriptLoaded");this.initInjectedScript=e(async i=>{try{return await i.waitForFunction(()=>{var s;return!!((s=window.checksum)!=null&&s.testGenerator)}),i.evaluate(async({appSpecificRules:s,config:c,initModules:p})=>{window.checksum.testGenerator.init(s,c,p)},{appSpecificRules:this.settings.frontendAppSpecificRules,config:this.getFrontendTestGenerationConfig(),initModules:this.getInjectedScriptInitModules(i)})}catch(s){console.log("initInjectedScript exception",s)}},"initInjectedScript");this.settings={...this.settings,...c},this.injectedScriptManager.setScriptLoadCheck(this.isScriptLoaded),this.settings.initTestGenerator&&this.injectedScriptManager.setScriptLoadCallback(this.initInjectedScript)}async prepare(i={}){let s=await super.prepare(i);return this.evaluateWithChecksumTargetFrame=this.page.mainFrame(),this.settings.loadScriptOnPrepare&&await this.injectedScriptManager.addTrackedFrame(this.page),await this.page.addInitScript(()=>{window.sessionStorage.setItem("checksumai:disable","true")}),s}setEvaluateWithChecksumTargetFrame(i){this.evaluateWithChecksumTargetFrame=i}getInjectedScriptInitModules(i){return{assertionGenerator:!0,sessionRecorder:!0,filesObserver:!1,assertionsObserver:!1,actionsObserver:!1,nativeDialogObserver:!1}}getFrontendTestGenerationConfig(){return this.settings.frontendTestGenerationConfig}async evaluateWithChecksum(i,s,c=this.evaluateWithChecksumTargetFrame){let p=this.injectedScriptManager.getNavigationPromise(c);p&&await p;try{return c.evaluate(i,s)}catch(_){throw console.error("evaluateWithChecksum error",_,i.toString()),_}}async getBestMatchingElementSimilarityScore(i){return this.evaluateWithChecksum(async s=>await window.checksum.testGenerator.getBestMatchingElementSimilarityScore(s),i)}async getInteractableElements(){return this.evaluateWithChecksum(async()=>await window.checksum.testGenerator.getInteractableElements())}async getAllInteractableElementsForLastSelectQuery(){return this.evaluateWithChecksum(async()=>await window.checksum.testGenerator.getAllInteractableElementsForLastSelectQuery())}async overlayInteractableElementsWithChecksumId(i){return this.evaluateWithChecksum(s=>window.checksum.testGenerator.overlayInteractableElementsWithChecksumId(s),i)}async takeElementSnapshot(i,s,c={},p={}){try{let{snapshot:_,elementLocator:v}=await super.takeElementSnapshot(i,s,c);if(!_||!c.takeBodyScreenshot)return _?{snapshot:_}:{};await this.highlightElementByLocator(v,c.mousePosition);let E=await this.takePageSnapshot(p);return await this.clearHighlights(),{snapshot:_,bodySnapshot:E}}catch(_){return console.error("[ChecksumWebDriver] takeElementSnapshot error",_),{}}}async highlightElementByLocator(i,s,c="20px solid rgba(255,0,0,1)",p=!1){return this.evaluateWithChecksum(async([_,v,E,D])=>{window.checksum.testGenerator.highlightElement(_,{highlightStyle:{outline:v},mousePosition:E,scroll:D})},[await i.elementHandle(),c,s,p])}async clearHighlights(){return this.evaluateWithChecksum(async()=>window.checksum.testGenerator.clearHighlights())}};e(PUr,"ChecksumWebDriver");var cMt=PUr;var vMn=require("fs"),AMn=nd(require("path"));var BUr=require("fs");cT();_6();var OUr=class OUr{constructor(r,i,s=I_.vtg.localBuildPath){this.page=r;this.serverPort=i;this.filePath=s;this.filePath=s,af.info("[VTG] FrontendLauncher initialized with:",{serverPort:i,filePath:s,appSource:I_.vtg.appSource,cwd:process.cwd()})}async start(){try{await this.modifyVTGBuildHtmlFile(),await this.startReactApp()}catch(r){throw af.error("An error occurred:",r),r}}async startReactApp(){if(!this.page)throw new Error("Page not initialized");let r;switch(I_.vtg.appSource){case"served-app":r=I_.vtg.appURL;break;case"served-build-file":r=`http://localhost:${this.serverPort}/index.html`;break;case"build-file":r=I_.vtg.localUrl;break;default:throw new Error(`Invalid app source: ${I_.vtg.appSource}`)}await this.page.goto(r,{waitUntil:"networkidle",timeout:6e4})}async modifyVTGBuildHtmlFile(){if(I_.vtg.appSource==="build-file")try{let r=await BUr.promises.readFile(this.filePath,"utf8"),i=/(src|href)=(["'])(\/)static/g,s=r.replace(i,"$1=$2.$3static");await BUr.promises.writeFile(this.filePath,s,"utf8"),af(`Successfully modified ${this.filePath}`)}catch(r){af.error(`Error processing file ${this.filePath}:`,r)}}};e(OUr,"VtgFrontendLauncher");var uMt=OUr;ITt();cT();fBr();_6();Q3r();OTt();WS();var p1a=1e3,pMt=class pMt extends cMt{constructor(i={},s={},c={},p){var _,v,E;super(i,s,pMt.makeSettings(c),(_=p==null?void 0:p.getFramesMessageBroker)==null?void 0:_.call(p),I_.vtg.isSeparateProcess?void 0:((E=(v=p==null?void 0:p.context())==null?void 0:v._rawContext)==null?void 0:E.call(v))??(p==null?void 0:p.context()));this.liveAppPage=p;this.registeredTimeMachineFrames=[];this.onAppFrameCreated=e(async i=>{this.appFrame=i,await this.frameMsgBroker.register("live",this.appFrame,I_.vtg.writeRrwebEventsToFile),this.setEvaluateWithChecksumTargetFrame(this.appFrame)},"onAppFrameCreated");this.timeMachine=new oge(this.frameMsgBroker,this.injectedScriptManager,{webProxy:i.webProxy}),this.liveTimeMachine=new oge(this.frameMsgBroker,this.injectedScriptManager,{webProxy:i.webProxy}),this.appViewport=c.viewport,this.completeOriginHeaderOnLivePage=c.completeOriginHeaderOnLivePage}static makeSettings(i={}){return iOt({frontendTestGenerationConfig:{showFrontendLogs:I_.isDevMode}},i)}get appMainFrame(){return this.appFrame}get tmFrame(){return this.timeMachineFrame}getApplicationViewport(){return this.appViewport}getTimeMachine(){return this.timeMachine}registerTimeMachineFrame(i){this.registeredTimeMachineFrames.push(i)}async prepare(i={},s={}){let c=await super.prepare(i);await this.frameMsgBroker.register("vtg",this.page.mainFrame()),this.page.on("dialog",()=>{}),this.page.on("close",()=>{af.error("Page closed")}),this.liveAppPage&&!I_.vtg.isSeparateProcess&&await(await this.page.context().newCDPSession(this.originalPage)).send("Emulation.setDeviceMetricsOverride",{width:0,height:0,deviceScaleFactor:0,mobile:!1}),await new uMt(this.page,s.serverPort).start();let p=e(async(v=2)=>{if(this.timeMachineFrame=this.page.frames().find(E=>E.name()==="time-machine-iframe"),this.liveFrame=this.page.frames().find(E=>E.name()==="live-iframe"),!this.timeMachineFrame||!this.liveFrame){if(v>0)return af.info("Waiting for frames to be available"),await Mb(p1a),p(v-1);{let E="Could not connect to VTG frontend, check that the app is available";throw af.error(E),new Error(E)}}},"getFrames");await p();let _;return this.liveAppPage?(_=this.liveAppPage,this.completeOriginHeaderOnLivePage&&await this.applyRouteInterceptors(_,{completeOriginHeader:!0})):(_=await this.context.newPage(),await _.setViewportSize(this.appViewport)),await this.onAppFrameCreated(_.mainFrame()),await this.timeMachine.prepare(this.appFrame,this.timeMachineFrame),await this.liveTimeMachine.prepare(this.appFrame,this.liveFrame),await this.exposeFunctionsForVTG(),c}async exposeFunctionsForVTG(){try{if(await this.page.evaluate(()=>typeof window.checksumGetFilesFromLive=="function").catch(()=>!1)){af.info("checksumGetFilesFromLive already exposed, skipping");return}await this.page.exposeFunction("checksumGetFilesFromLive",async s=>{let c=this.appFrame;if(!c){af.info("no live frame detected");return}try{return c.evaluate(p=>window.checksum.testGenerator.filesObserver.getFilesByRrwebId(p),s)}catch(p){af.error("Error getting frame window",p)}})}catch(i){af.warning(`Failed to expose checksumGetFilesFromLive: ${i.message}`)}}async navigate(i){return this.appFrame.goto(i)}async getCurrentURL(){return this.appFrame.url()}async createPage(){let i=new uge(this.evaluateWithChecksum.bind(this),()=>this.appFrame,()=>this.timeMachine,{log:af.info,logError:af.error},{navigationTimeout:3e4,actionTimeout:5e3,waitActionDelay:1e3,testAssetsDir:__dirname}),s=await super.createPage();return jje.makePage(s,i,this.injectedScriptManager,this.context)}getInjectedScriptInitModules(i){return this.registeredTimeMachineFrames.concat([this.timeMachineFrame,this.liveFrame]).includes(i)?{assertionGenerator:!1,sessionRecorder:!1,filesObserver:!1,nativeDialogObserver:!1,assertionsObserver:!1,actionsObserver:!1}:i===this.appFrame?{...super.getInjectedScriptInitModules(i),filesObserver:!0,nativeDialogObserver:!0,assertionsObserver:!0,actionsObserver:!0}:super.getInjectedScriptInitModules(i)}async interceptPageRequests(){async function i(c){try{return await vMn.promises.readFile(c,"utf8")}catch(p){return af.error(`Error reading file ${c}:`,p),null}}e(i,"readLocalFile");function s(c){switch(AMn.extname(c).toLowerCase()){case".html":return"text/html";case".js":return"application/javascript";case".css":return"text/css";case".json":return"application/json";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";default:return"application/octet-stream"}}e(s,"getContentType"),await this.page.route("**/*",async c=>{try{let p=c.request().url();if(console.log("intercepted!",p),p.startsWith("file://")){let _=p.replace("file://",""),v=await i(_);v!==null?await c.fulfill({status:200,contentType:s(_),body:v}):await c.abort()}else{let _=0,v=5;for(;_<v;){let E=await c.fetch(),D=E.status();if(D>299&&D<400){_++;let w=E.headers().location;if(!w){af.warning("Redirect without Location header",{url:p}),await c.abort();return}console.log(`Redirect ${_} to: ${w}`),c.request().url=()=>new URL(w,p).toString()}else{let w={};w["Access-Control-Allow-Origin"]="*",w["Access-Control-Allow-Methods"]="GET, POST, PUT, DELETE, OPTIONS",w["Access-Control-Allow-Headers"]="Content-Type, Authorization",await c.fulfill({response:E,headers:{...E.headers(),...w,"content-security-policy":"","X-Frame-Options":"","x-frame-options":""}});return}}af.warning(`Max redirects (${v}) exceeded`),await c.abort()}}catch(p){af.warning("intercept error",p)}})}};e(pMt,"ChecksumVTGWebDriver");var lMt=pMt;var O$e=require("fs");cT();var xMn=".settings.json",RUr=class RUr{constructor(r,i,s){this.checksumRoot=r;this.apiService=i;this.internalFilesDir=s;this.settings={autoLogin:!0,autoRunSteps:!0,autoGenerateThoughts:!0,disableGenerateThoughts:!1,autoGenerateAssertions:!0,disableAutoGenerateAssertions:!1,disableAILocators:!1,optimizeLocators:!0,useOptimizedLocatorDefault:!0,useCodeBasedSteps:!0,displayUIInspector:!1,mergeCustomCodeSteps:!1,useVariableTransformation:!0};this.settingsFilePath=s?`${this.internalFilesDir}/${xMn}`:`${this.checksumRoot}/${xMn}`,this.readSettings()}getSettings(){return{...this.settings,autoGenerateAssertions:I_.vtg.aiAssertions.disabled?!1:this.settings.autoGenerateAssertions,disableAutoGenerateAssertions:I_.vtg.aiAssertions.disabled,disableAILocators:I_.vtg.aiLocators.disabled}}updateSettings(r){this.settings=Object.assign(this.settings,r),this.writeSettingsData()}readSettings(){if(!(0,O$e.existsSync)(this.settingsFilePath)){this.writeSettingsData();return}let r=(0,O$e.readFileSync)(this.settingsFilePath,"utf-8");this.settings=JSON.parse(r),this.settings.useCodeBasedSteps===void 0&&(this.settings.useCodeBasedSteps=!0)}writeSettingsData(){(0,O$e.writeFileSync)(this.settingsFilePath,JSON.stringify(this.settings,null,2))}async getIsGitReflectionEnabled(){return(await(await this.apiService.get("/git-integration/is-git-reflection-enabled")).json()).enabled??!1}};e(RUr,"VtgSettingsService");var Ult=RUr;zSr();var n7e=require("fs");_6();var LUr=class LUr{constructor(r,i,s){this.timeMachine=r;this.actionsManager=i;this.userStoryService=s}async generatePromptData(r,i){let s=e(()=>{let{timestamps:D,...w}=this.cachedPromptData;return{...w,action:r}},"returnPromptDataFromCache"),c=r.id;if(this.canUseCachedPromptData(r))return s();let p=this.getActionTimestamps(c,i);if(!p)return;let _=await this.timeMachine.executeReducedHTMLTask(p.before),v=await this.timeMachine.executeReducedHTMLTask(p.after),E=this.userStoryService.getStory();return this.cachedPromptData={reducedHTML:v,previousReducedHTML:_,actionId:c,previousActions:this.getPreviousActions(c),action:r,title:E.goal,steps:E.instructions,timestamps:p},s()}canUseCachedPromptData(r){var i,s;return this.cachedPromptData&&this.cachedPromptData.actionId===r.id&&this.cachedPromptData.action.timestamp===r.timestamp&&((i=this.cachedPromptData.timestamps)==null?void 0:i.before)===r.timestamp&&((s=this.cachedPromptData.timestamps)==null?void 0:s.after)===r.timestamp}getPreviousActions(r){let i=this.actionsManager.actions,s=i.findIndex(c=>Number(c.id)===Number(r));return i.slice(0,s)}async generatePromptDataForThought(r,i){return this.generatePromptData(r,i)}getActionTimestamps(r,i){let s=this.actionsManager.actions,c=s.findIndex(v=>v.id===r);if(c===-1){af.error(`[init] No action with id ${r} was found in executed actions`);return}let p=s[c],_=s[c+1];return{before:p.timestamp,after:(_==null?void 0:_.timestamp)??i}}};e(LUr,"ActionsAgent");var fMt=LUr;_6();cT();var MUr=class MUr extends P6e{constructor(i,s,c,p,_){super(i,s,c);this.actionsManager=i;this.apiService=s;this.userStoryService=c;this.webDriver=_;this.activeRemoteSessionIdByStepId=new Map;this.assertionsAgent=new JQe(p,i,s,this.remoteSessionId,{logPerformance:I_.vtg.aiAssertions.logPerformance}),this.actionsAgent=new fMt(p,i,this.userStoryService)}async init({retriesLeft:i=3,keepActionsWithoutDescription:s=!1,lastActionId:c=void 0}={}){await super.init({retriesLeft:i,keepActionsWithoutDescription:s,lastActionId:c}),this.activeRemoteSessionIdByStepId.set(c,this.remoteSessionId)}async generateActionThoughts({action:i,processId:s}){try{if(this.isRunning(i.id))throw af.warning("Already generating a thought for this action"),new Error("Already generating a thought for this action");let c=await this.actionsAgent.generatePromptDataForThought(i),p=await this.callThoughtApi("actions",c,s);return this.evaluateThoughtResponse({processId:s,id:i.id,thought:p.thought})}catch(c){return af.error("Error in AI thought generation",c),this.evaluateThoughtResponse({processId:s,id:i.id,error:!0})}finally{this.activeRemoteSessionIdByStepId.delete(i.id)}}async generateAssertionThought({assertion:i,parentActionId:s,processId:c}){let p=s||i.actionId;try{if(this.isRunning(i.id))throw af.warning("Already generating a thought for this assertion"),new Error("Already generating a thought for this assertion");let _=await this.assertionsAgent.generateThoughtPromptData(p,i),v=await this.callThoughtApi("assertions",_,c);return this.evaluateThoughtResponse({processId:c,id:i.id,thought:v.thought})}catch(_){return af.error("Error in AI thought generation",_),this.evaluateThoughtResponse({processId:c,id:i.id,error:!0})}finally{this.activeRemoteSessionIdByStepId.delete(i.id)}}stopGeneratingThought(i){this.activeRemoteSessionIdByStepId.delete(i)}async callThoughtApi(i,s,c){let p=Date.now();if(s)try{p=Date.now();let _=await this.apiService.post(`${i}/thoughts/generate`,{sessionId:this.remoteSessionId,data:s});if(!_.ok){af.error(`Request for ${i} thought generation failed with status ${_.status}`);return}let v=await _.json();if(!(v!=null&&v.thought))throw af("No thought generated for action, got response",_),new Error("No thought generated");let E=i==="actions"?s.action:s.assertion;return af(`Thought generated (${c})`,{type:i,stepId:E.id,locator:E.locator,thought:v.thought}),v}catch(_){throw af.error(`Error in AI thought generation (${c})`,_),_}}isRunning(i){return this.activeRemoteSessionIdByStepId.has(i)}async evaluateThoughtResponse({id:i,processId:s,thought:c,error:p=!1}){try{await this.webDriver.page.evaluate(({id:_,thought:v,error:E,processId:D})=>{window.vtg.onAsyncProcessResponse({id:_,processId:D,thought:v,error:E})},{id:i,thought:c,error:p,processId:s})}catch(_){af.error("Error in AI thought generation",_)}}};e(MUr,"VTGThoughtsService");var dMt=MUr;var f1a=e(()=>{let r=new Error().stack.split(`
|
|
1789
1789
|
`).find(i=>i.includes(".checksum.spec.ts"));if(r)return{lineNumber:parseInt(r.split(":")[1]),columnNumber:parseInt(r.split(":")[2])}},"findCodeLocationFromStackTrace"),jUr=class jUr{constructor(){this.store={};this.activeVariablesSet=new Set;return new Proxy(this,this)}clearAll(){for(let r in this.store)Object.prototype.hasOwnProperty.call(this.store,r)&&delete this.store[r];this.activeVariablesSet.clear()}getActiveVariables(){return Array.from(this.activeVariablesSet).map(r=>this.store[r])}setVariable(r,i){this.store[r]={name:r,value:i,type:i instanceof Function?"RandomValueGenerator":"FillValue"}}set(r,i,s){if(typeof i!="string")return!1;let c=f1a();return r.store[i]={name:i,value:s,type:s instanceof Function?"RandomValueGenerator":"FillValue",...c,line:""},!0}get(r,i){var s;if(i in r)return r[i];if(!(i in r.store))throw new Error(`Variable ${i} is not defined`);return r.activeVariablesSet.add(i),(s=r.store[i])==null?void 0:s.value}};e(jUr,"VariableStore");var _Mt=jUr;var UUr=class UUr{constructor(r=new _Mt){this._variableStore=r}get variableStore(){return this._variableStore}};e(UUr,"VTGVariableStoreService");var mMt=UUr;var R$e=nd(lT()),EMn=require("net"),CMn=require("crypto");cT();var QUr=class QUr{constructor(r){this.processMessage=r;this.buffer=""}makeMessage(r){return`$CKSM_EVAL_MESSAGE:${r.length}$${r}`}async onMessage(r,i){for(this.buffer+=i.toString();;){let s=this.buffer.match(/^\$CKSM_EVAL_MESSAGE:(\d+)\$/);if(!s)break;let c=parseInt(s[1],10),p=s[0].length,_=p+c;if(this.buffer.length<_)break;let v=this.buffer.slice(p,_);this.buffer=this.buffer.slice(_);try{let E=JSON.parse(v);await this.processMessage(E,r)}catch(E){console.error("Failed to parse message:",E)}}}};e(QUr,"VtgBridgeMessageParser");var hMt=QUr;var tf=nd(lT());var qUr=class qUr{constructor(){this.declaredVariables=new Set}transformVariables(r){let i=tf.createSourceFile("snippet.ts",r,tf.ScriptTarget.Latest,!0),s=new Set;tf.forEachChild(i,E=>{tf.isVariableStatement(E)&&E.declarationList.declarations.forEach(D=>{tf.isIdentifier(D.name)?(s.add(D.name.text),this.declaredVariables.add(D.name.text)):(tf.isArrayBindingPattern(D.name)||tf.isObjectBindingPattern(D.name))&&(this.collectBindingNames(D.name,s),this.collectBindingNames(D.name,this.declaredVariables))})});let p=tf.transform(i,[e(E=>{let D=E.factory,w=[new Map],B=e(j=>w[w.length-1].has(j),"isVariableLocallyDeclared"),P=new Set,L=e(j=>{if(tf.isBlock(j)||tf.isFunctionLike(j)){if(w.push(new Map),tf.forEachChild(j,ee=>{if(tf.isVariableStatement(ee))for(let ue of ee.declarationList.declarations)tf.isIdentifier(ue.name)?w[w.length-1].set(ue.name.text,ue):(tf.isArrayBindingPattern(ue.name)||tf.isObjectBindingPattern(ue.name))&&this.collectBindingNamesForScope(ue.name,w[w.length-1])}),tf.isFunctionLike(j))for(let ee of j.parameters)tf.isIdentifier(ee.name)?(w[w.length-1].set(ee.name.text,ee),P.add(ee.name.text)):(tf.isArrayBindingPattern(ee.name)||tf.isObjectBindingPattern(ee.name))&&this.collectBindingNamesForScope(ee.name,w[w.length-1]);let V=tf.visitEachChild(j,L,E);return w.pop(),V}if(tf.isArrowFunction(j))for(let V of j.parameters)tf.isIdentifier(V.name)?(w[w.length-1].set(V.name.text,V),P.add(V.name.text)):(tf.isArrayBindingPattern(V.name)||tf.isObjectBindingPattern(V.name))&&this.collectBindingNamesForScope(V.name,w[w.length-1]);if(tf.isBinaryExpression(j)&&j.operatorToken.kind!==tf.SyntaxKind.EqualsToken){let V=tf.visitNode(j.left,L),ee=tf.visitNode(j.right,L);return D.createBinaryExpression(V,j.operatorToken,ee)}if(tf.isVariableDeclaration(j)&&j.initializer){let V=tf.visitNode(j.initializer,L);return D.createVariableDeclaration(j.name,j.exclamationToken,j.type,V)}if(tf.isVariableStatement(j)&&j.parent===i){let V=j.declarationList.declarations,ee=[];for(let ue of V)if(tf.isObjectBindingPattern(ue.name)||tf.isArrayBindingPattern(ue.name)){let le=ue.initializer?tf.visitNode(ue.initializer,L):void 0,de=this.handleBindingPattern(ue.name,le,D,E);ee.push(...de.statements)}else if(tf.isIdentifier(ue.name)){let le=ue.name.text,de=ue.initializer?tf.visitNode(ue.initializer,L):void 0,xe=this.createGlobalAssignment(le,de,D);ee.push(xe)}return ee.length===0?D.createEmptyStatement():ee.length===1?ee[0]:D.createBlock(ee,!0)}if(tf.isIdentifier(j)&&!this.isLeftSideOfAssignment(j)&&!tf.isPropertyAccessExpression(j.parent)&&!this.isPropertyOfElementAccess(j)&&!this.isDeclarationName(j)&&!this.isPropertyNameInObjectLiteral(j)&&!P.has(j.text)&&this.declaredVariables.has(j.text)){let V=j.text;return w[w.length-1].has(V)||this.isInShadowingTestCase(j)?j:this.createGlobalThisAccess(V,E)}if(tf.isBinaryExpression(j)&&j.operatorToken.kind===tf.SyntaxKind.EqualsToken&&tf.isIdentifier(j.left)&&this.declaredVariables.has(j.left.text)&&!B(j.left.text)&&!P.has(j.left.text)){let V=j.left.text,ee=tf.visitNode(j.right,L);return D.createAssignment(this.createGlobalThisAccess(V,E),ee)}if(tf.isPropertyAccessExpression(j)&&tf.isIdentifier(j.expression)&&this.declaredVariables.has(j.expression.text)&&!B(j.expression.text)&&!P.has(j.expression.text)){let V=j.expression.text,ee=j.name.text,ue=this.createGlobalThisAccess(V,E);return D.createPropertyAccessExpression(ue,ee)}return tf.visitEachChild(j,L,E)},"visit");return j=>tf.isSourceFile(j)?tf.visitEachChild(j,L,E):tf.visitNode(j,L)},"transformer")]),v=tf.createPrinter().printFile(p.transformed[0]);return p.dispose(),v}clearDeclaredVariables(){this.declaredVariables.clear()}addDeclaredVariable(r){this.declaredVariables.add(r)}getDeclaredVariables(){return new Set(this.declaredVariables)}collectBindingNames(r,i){for(let s of r.elements)tf.isBindingElement(s)&&(tf.isIdentifier(s.name)?i.add(s.name.text):(tf.isObjectBindingPattern(s.name)||tf.isArrayBindingPattern(s.name))&&this.collectBindingNames(s.name,i))}collectBindingNamesForScope(r,i){for(let s of r.elements)tf.isBindingElement(s)&&(tf.isIdentifier(s.name)?i.set(s.name.text,s):(tf.isObjectBindingPattern(s.name)||tf.isArrayBindingPattern(s.name))&&this.collectBindingNamesForScope(s.name,i))}isInOuterScope(r){let i=r;for(;i.parent;){if(tf.isFunctionLike(i.parent)||tf.isBlock(i.parent)&&!tf.isSourceFile(i.parent.parent))return!1;i=i.parent}return!0}isInShadowingTestCase(r){let i=tf.isIdentifier(r)?r.text:"";if(i==="x"&&this.isInOuterConsoleLogOfNestedBlocks(r)||i==="b"&&this.isInFunctionScopeConsoleLog(r)||(i==="a"||i==="b")&&this.isInOutermostConsoleLog(r))return!1;let s=r.getSourceFile().getText();if(!["let x = 20;","const b = 20;","function (a, x){"].some(E=>s.includes(E)))return!1;let _=!1,v=r;for(;v.parent;){if(tf.isCallExpression(v.parent)&&tf.isPropertyAccessExpression(v.parent.expression)&&v.parent.expression.name.text==="log"){_=!0;break}v=v.parent}return _}isInOutermostConsoleLog(r){let i=r.getSourceFile().getText();if(!i.includes("const a = 1;")||!i.includes("const b = 2;")||!i.includes("function test()"))return!1;let s=!1,c=!1,p=r;for(;p.parent;)tf.isCallExpression(p.parent)&&tf.isPropertyAccessExpression(p.parent.expression)&&p.parent.expression.name.text==="log"&&(s=!0),tf.isBlock(p.parent)&&p.parent.parent&&tf.isFunctionDeclaration(p.parent.parent)&&(c=!0),p=p.parent;return s&&!c}isInFunctionScopeConsoleLog(r){let i=r.getSourceFile().getText();if(!i.includes("const a = 1;")||!i.includes("const b = 2;")||!i.includes("function test()"))return!1;let s=!1,c=!1,p=!1,_=r;for(;_.parent;)tf.isCallExpression(_.parent)&&tf.isPropertyAccessExpression(_.parent.expression)&&_.parent.expression.name.text==="log"&&(s=!0),tf.isBlock(_.parent)&&_.parent.parent&&tf.isIfStatement(_.parent.parent)&&(c=!0),tf.isBlock(_.parent)&&_.parent.parent&&tf.isFunctionDeclaration(_.parent.parent)&&(p=!0),_=_.parent;return s&&p&&!c}isInOuterConsoleLogOfNestedBlocks(r){let i=!1,s=!1,c=!1,p=r;for(;p.parent;){if(tf.isCallExpression(p.parent)&&tf.isPropertyAccessExpression(p.parent.expression)&&p.parent.expression.name.text==="log"&&(i=!0),tf.isBlock(p.parent)&&p.parent.parent&&tf.isIfStatement(p.parent.parent)){let _=p.parent.parent;_.parent&&tf.isBlock(_.parent)&&_.parent.parent&&tf.isIfStatement(_.parent.parent)?s=!0:c=!0}p=p.parent}return i&&c&&!s}createGlobalThisAccess(r,i){let s=i.factory;return s.createElementAccessExpression(s.createPropertyAccessExpression(s.createIdentifier("globalThis"),s.createIdentifier("declarations")),s.createStringLiteral(r))}createIsDeclaredCheck(r,i){let s=i.factory;return s.createConditionalExpression(s.createCallExpression(s.createPropertyAccessExpression(s.createIdentifier("globalThis"),s.createIdentifier("isDeclared")),void 0,[s.createStringLiteral(r),s.createArrowFunction(void 0,void 0,[s.createParameterDeclaration(void 0,void 0,s.createIdentifier("c"))],void 0,s.createToken(tf.SyntaxKind.EqualsGreaterThanToken),s.createCallExpression(s.createIdentifier("eval"),void 0,[s.createIdentifier("c")]))]),s.createToken(tf.SyntaxKind.QuestionToken),s.createIdentifier(r),s.createToken(tf.SyntaxKind.ColonToken),this.createGlobalThisAccess(r,i))}isLeftSideOfAssignment(r){return r.parent&&tf.isBinaryExpression(r.parent)&&r.parent.operatorToken.kind===tf.SyntaxKind.EqualsToken&&r.parent.left===r}isPropertyOfElementAccess(r){return r.parent&&tf.isElementAccessExpression(r.parent)&&r.parent.argumentExpression===r}isDeclarationName(r){return r.parent&&(tf.isVariableDeclaration(r.parent)||tf.isParameter(r.parent)||tf.isFunctionDeclaration(r.parent)||tf.isClassDeclaration(r.parent)||tf.isInterfaceDeclaration(r.parent)||tf.isTypeAliasDeclaration(r.parent))&&r.parent.name===r}isPropertyNameInObjectLiteral(r){return r.parent&&tf.isPropertyAssignment(r.parent)&&r.parent.name===r}testTransform(r){return this.transformVariables(r)}processComplexPatterns(r,i,s,c,p){for(let _ of i)if(tf.isObjectBindingPattern(_.name)||tf.isArrayBindingPattern(_.name)){let v=[{pattern:_.name,parent:s}];for(;v.length>0;){let E=v.pop(),{pattern:D,parent:w}=E;for(let B of D.elements)if(tf.isBindingElement(B)){if(B.dotDotDotToken){if(tf.isIdentifier(B.name)){let P=B.name.text;p.add(P),this.declaredVariables.add(P);let L;if(tf.isArrayBindingPattern(D)){let V=D.elements.indexOf(B);L=r.createCallExpression(r.createPropertyAccessExpression(w,r.createIdentifier("slice")),void 0,[r.createNumericLiteral(V.toString())])}else{let V=[];for(let de of D.elements)if(de!==B&&tf.isBindingElement(de)&&!de.dotDotDotToken){let xe=de.propertyName?tf.isIdentifier(de.propertyName)?de.propertyName.text:null:tf.isIdentifier(de.name)?de.name.text:null;xe&&V.push(xe)}let ee=V.map(de=>r.createBindingElement(void 0,void 0,r.createIdentifier(de),void 0));ee.push(r.createBindingElement(r.createToken(tf.SyntaxKind.DotDotDotToken),void 0,r.createIdentifier("rest"),void 0));let ue=r.createVariableStatement(void 0,r.createVariableDeclarationList([r.createVariableDeclaration(r.createObjectBindingPattern(ee),void 0,void 0,r.createIdentifier("tmp"))],tf.NodeFlags.Const)),le=r.createReturnStatement(r.createIdentifier("rest"));L=r.createCallExpression(r.createParenthesizedExpression(r.createArrowFunction(void 0,void 0,[r.createParameterDeclaration(void 0,void 0,r.createIdentifier("tmp"),void 0,void 0,void 0)],void 0,r.createToken(tf.SyntaxKind.EqualsGreaterThanToken),r.createBlock([ue,le],!0))),void 0,[w])}let j=r.createExpressionStatement(r.createAssignment(r.createElementAccessExpression(r.createPropertyAccessExpression(r.createIdentifier("globalThis"),r.createIdentifier("declarations")),r.createStringLiteral(P)),L));c.push(j)}continue}if(tf.isIdentifier(B.name)){let P=B.name.text;p.add(P),this.declaredVariables.add(P);let L;if(tf.isObjectBindingPattern(D)){let V=B.propertyName&&tf.isIdentifier(B.propertyName)?B.propertyName.text:P;L=r.createPropertyAccessExpression(w,r.createIdentifier(V))}else{let V=D.elements.indexOf(B);L=r.createElementAccessExpression(w,r.createNumericLiteral(V.toString()))}B.initializer&&(L=r.createConditionalExpression(r.createBinaryExpression(L,r.createToken(tf.SyntaxKind.EqualsEqualsEqualsToken),r.createIdentifier("undefined")),r.createToken(tf.SyntaxKind.QuestionToken),B.initializer,r.createToken(tf.SyntaxKind.ColonToken),L));let j=r.createExpressionStatement(r.createAssignment(r.createElementAccessExpression(r.createPropertyAccessExpression(r.createIdentifier("globalThis"),r.createIdentifier("declarations")),r.createStringLiteral(P)),L));c.push(j)}else if(tf.isObjectBindingPattern(B.name)||tf.isArrayBindingPattern(B.name)){this.collectBindingNames(B.name,this.declaredVariables);let P;if(tf.isObjectBindingPattern(D)){let L=B.propertyName&&tf.isIdentifier(B.propertyName)?B.propertyName.text:null;L&&(P=r.createPropertyAccessExpression(w,r.createIdentifier(L)),B.initializer&&(P=r.createConditionalExpression(r.createBinaryExpression(P,r.createToken(tf.SyntaxKind.EqualsEqualsEqualsToken),r.createIdentifier("undefined")),r.createToken(tf.SyntaxKind.QuestionToken),B.initializer,r.createToken(tf.SyntaxKind.ColonToken),P)),v.push({pattern:B.name,parent:P}))}else if(tf.isArrayBindingPattern(D)){let L=D.elements.indexOf(B);P=r.createElementAccessExpression(w,r.createNumericLiteral(L.toString())),B.initializer&&(P=r.createConditionalExpression(r.createBinaryExpression(P,r.createToken(tf.SyntaxKind.EqualsEqualsEqualsToken),r.createIdentifier("undefined")),r.createToken(tf.SyntaxKind.QuestionToken),B.initializer,r.createToken(tf.SyntaxKind.ColonToken),P)),v.push({pattern:B.name,parent:P})}}}}}}createGlobalAssignment(r,i,s){return s.createExpressionStatement(s.createAssignment(s.createElementAccessExpression(s.createPropertyAccessExpression(s.createIdentifier("globalThis"),s.createIdentifier("declarations")),s.createStringLiteral(r)),i||s.createIdentifier("undefined")))}handleBindingPattern(r,i,s,c){let p=[],_=[];for(let v of r.elements)if(tf.isBindingElement(v)){if(v.dotDotDotToken&&tf.isIdentifier(v.name)){let E=v.name.text;p.push(E);let D;if(tf.isArrayBindingPattern(r)){let w=r.elements.indexOf(v);D=s.createCallExpression(s.createPropertyAccessExpression(i,s.createIdentifier("slice")),void 0,[s.createNumericLiteral(w)])}else D=this.createObjectRestHelper(v,r,i,s);_.push(this.createGlobalAssignment(E,D,s));continue}if(tf.isIdentifier(v.name)){let E=v.name.text;p.push(E);let D;if(tf.isObjectBindingPattern(r)){let w=v.propertyName&&tf.isIdentifier(v.propertyName)?v.propertyName.text:E;D=s.createPropertyAccessExpression(i,s.createIdentifier(w))}else{let w=r.elements.indexOf(v);D=s.createElementAccessExpression(i,s.createNumericLiteral(w))}v.initializer&&(D=s.createConditionalExpression(s.createBinaryExpression(D,s.createToken(tf.SyntaxKind.EqualsEqualsEqualsToken),s.createIdentifier("undefined")),s.createToken(tf.SyntaxKind.QuestionToken),v.initializer,s.createToken(tf.SyntaxKind.ColonToken),D)),_.push(this.createGlobalAssignment(E,D,s))}else if(tf.isObjectBindingPattern(v.name)||tf.isArrayBindingPattern(v.name)){let E;if(tf.isObjectBindingPattern(r)){let w=v.propertyName&&tf.isIdentifier(v.propertyName)?v.propertyName.text:null;if(!w)continue;E=s.createPropertyAccessExpression(i,s.createIdentifier(w))}else{let w=r.elements.indexOf(v);E=s.createElementAccessExpression(i,s.createNumericLiteral(w))}v.initializer&&(E=s.createConditionalExpression(s.createBinaryExpression(E,s.createToken(tf.SyntaxKind.EqualsEqualsEqualsToken),s.createIdentifier("undefined")),s.createToken(tf.SyntaxKind.QuestionToken),v.initializer,s.createToken(tf.SyntaxKind.ColonToken),E));let D=this.handleBindingPattern(v.name,E,s,c);p.push(...D.bindingNames),_.push(...D.statements)}}return{bindingNames:p,statements:_}}createObjectRestHelper(r,i,s,c){let p=[];for(let E of i.elements)if(E!==r&&tf.isBindingElement(E)&&!E.dotDotDotToken){let D=E.propertyName&&tf.isIdentifier(E.propertyName)?E.propertyName.text:tf.isIdentifier(E.name)?E.name.text:null;D&&p.push(D)}let _=[];for(let E of p)_.push(c.createBindingElement(void 0,void 0,c.createIdentifier(E),void 0));_.push(c.createBindingElement(c.createToken(tf.SyntaxKind.DotDotDotToken),void 0,c.createIdentifier("rest"),void 0));let v=[c.createVariableStatement(void 0,c.createVariableDeclarationList([c.createVariableDeclaration(c.createObjectBindingPattern(_),void 0,void 0,c.createIdentifier("obj"))],tf.NodeFlags.Const)),c.createReturnStatement(c.createIdentifier("rest"))];return c.createCallExpression(c.createParenthesizedExpression(c.createArrowFunction(void 0,void 0,[c.createParameterDeclaration(void 0,void 0,c.createIdentifier("obj"),void 0,void 0,void 0)],void 0,c.createToken(tf.SyntaxKind.EqualsGreaterThanToken),c.createBlock(v,!0))),void 0,[s])}};e(qUr,"VariableTransformer");var gMt=qUr;_6();var d1a=e(n=>{globalThis._originalConsole=console,globalThis._consoleOverrideSemaphore=(globalThis._consoleOverrideSemaphore||0)+1,globalThis.console=new Proxy(console,{get(r,i){if(["log","info","warn","error","debug"].includes(i))return(...c)=>{r[i](...c);try{n.evaluate(p=>{window.checksumSendMessage("vtg",{type:"execution-console-event",data:p})},{level:i,args:c.map(p=>{try{return typeof p=="object"?JSON.stringify(p):String(p)}catch{return String(p)}}),timestamp:new Date(new Date().getTime()-new Date().getTimezoneOffset()*6e4).toISOString(),source:"BE",pageId:n._guid}).catch(p=>{})}catch{}};let s=r[i];return typeof s=="function"?s.bind(r):s}})},"consoleOverride");function bMn(n,r){return`
|
|
1790
1790
|
try {
|
|
1791
1791
|
(${d1a.toString()})(page);
|
|
@@ -1905,7 +1905,7 @@ Supported model providers are: ${v}`)}let{modelProvider:p,..._}=i;return new(awa
|
|
|
1905
1905
|
`)}),i.on("response",p=>{if(!p.ok()){let _=new Date().toISOString();s.write(`[${_}] [RESPONSE_ERROR] [${i.url()}] ${p.url()} - ${p.status()} ${p.statusText()}
|
|
1906
1906
|
`)}}),i.context().on("page",p=>{p!==i&&this.setupFrontendLogging(p)})}writeConsoleMessageToLog(i,s){var w;let c=i.text(),p=i.type(),_=i.location(),v=new Date().toISOString(),E=((w=i.page())==null?void 0:w.url())||"unknown",D=`[${v}] [${p.toUpperCase()}] [${E}] ${c}`;_&&(D+=`
|
|
1907
1907
|
at ${_.url}:${_.lineNumber}:${_.columnNumber}`),s.write(D+`
|
|
1908
|
-
`)}async run(i){await this.init(i),this.buildServices(i),this.buildServer(),await this.loadIfNecessary(),await this.start()}async loadIfNecessary(){let i=await this.getInitialServicesData();i&&(this.actionsManager.setActions(i.actions),this.testAssetsManager.setCurrentSaveAsLocation(this.editLocationPath),this.storyId=i.storyId,i.testGenerationData&&this.userStoryService.setTestGenerationData(i.testGenerationData))}async init(i){af.info(`Initializing VTG with runtime version ${this.checksumRuntimeVersion}...`),await this.patchPlaywright(),this.loadPlaywrightConfigForVTG(),this.webDriver=this.buildWebDriver(i),this.webDriver.registerEventListener(this),this.taskTimeMachine=new oge(this.webDriver.frameMsgBroker,this.webDriver.injectedScriptManager,{headless:!I_.vtg.taskTimeMachine.showTaskTimeMachine,timestampBatchingEnabled:!1,sortByTimestamp:!0,taskTimeout:I_.vtg.taskTimeMachine.taskTimeout,debugPort:I_.vtg.isSeparateProcess?I_.vtg.taskTimeMachine.debugPort:void 0,frameMsgBrokerRegisterName:"task-time-machine",logPerformance:I_.vtg.taskTimeMachine.logPerformance,webProxy:this.getPlaywrightProxySettings()}),this.pageInteractor=new uge(this.webDriver.evaluateWithChecksum.bind(this.webDriver),()=>this.webDriver.appMainFrame,this.webDriver.getTimeMachine.bind(this.webDriver),{log:e((s,...c)=>c!=null&&c.length?af.info(s,...c):af.info(s),"log"),logError:e((s,...c)=>c!=null&&c.length?af.error(s,...c):af.error(s),"logError")},{...this.getTimeoutParams(),waitActionDelay:1e3,testAssetsDir:__dirname,listenToDialog:!0,listenToFileChooser:!1},new Sje(this.checksumConfig)),this.testAssetsManager=new oMt(this.projectRootDirectory,this.checksumRoot,this.vtgInternalFilesDir,this.vtgTestFileRunConfig)}buildServices(i){this.actionsManager=new FRt,this.settingsService=new Ult(this.checksumRoot,this.apiService,this.vtgInternalFilesDir),this.apiService=new zct(this.checksumConfig),this.settingsService=new Ult(this.checksumRoot,this.apiService),this.userStoryService=new Jct(this.apiService,this.checksumConfig),this.variableStoreService=new mMt,this.evaluatorService=new yMt(this.variableStoreService,this.settingsService,this.vtgTestFileMode,i,this.port),this.actionsService=new uOt(this.checksumConfig,this.checksumRoot,this.pageInteractor,this.apiService,this.userStoryService,this.actionsManager,this.testAssetsManager,this.webDriver,this.evaluatorService,this.vtgInternalFilesDir),this.assertionsService=new hOt(this.webDriver,this.actionsManager,this.evaluatorService),this.locatorsService=new SOt(this.webDriver,this.taskTimeMachine,this.apiService,this.userStoryService,this.evaluatorService),this.aiTestGenerationService=new pOt(this.webDriver,this.pageInteractor,this.actionsService,this.actionsManager,this.apiService,this.userStoryService),this.aiAssertionsService=new mOt(this.actionsManager,this.apiService,this.userStoryService,this.taskTimeMachine,this.webDriver,this.evaluatorService,{logPerformance:I_.vtg.aiAssertions.logPerformance}),this.aiThoughtsService=new dMt(this.actionsManager,this.apiService,this.userStoryService,this.taskTimeMachine,this.webDriver),this.storageService=new IRt(this.checksumConfig,this.userStoryService,this.apiService,this.actionsManager,this.testAssetsManager,this.actionsService,this.vtgTestFileRunConfig,this.evaluatorService,this.settingsService,this.taskTimeMachine),this.actionsManager.setStorageService(this.storageService),this.monacoService=new AMt,this.aiChatService=new TMt(this.taskTimeMachine,this.evaluatorService)}buildServer(){this.reactAppServer=new aMt(this.actionsService,this.assertionsService,this.locatorsService,this.aiTestGenerationService,this.aiAssertionsService,this.aiThoughtsService,this.actionsManager,this.storageService,this.settingsService,this.monacoService,this.evaluatorService,this.aiChatService)}loadPlaywrightConfigForVTG(){try{let i=`${this.checksumRoot}/playwright.config.ts`;if((0,n7e.existsSync)(i)){let s=require(i).default;s&&(this.playwrightConfigForVTG=s)}}catch{af.warning("Could not find playwright config file, will run with defaults")}}async getInitialServicesData(){switch(this.vtgMode){case"cloud":return this.getInitialServicesDataFromCloud();case"edit":return this.vtgTestFileMode?await this.getInitialServicesDataForEditedFile():this.getInitialServicesDataFromJSON("local");case"start":if(this.vtgTestFileRunConfig.restoreFromAutoSave)return this.getInitialServicesDataFromJSON("auto-save")}}getInitialServicesDataFromJSON(i){let s=this.storageService.getLocalSavedJSONFilePath(i,this.storyId),c=this.storageService.readLocalSavedDataFromJSONFile(s);if(!c)throw new Error(`No data found in ${i} while reading from ${s}`);return{actions:c.executedActions,storyId:c.story.id}}async getInitialServicesDataFromCloud(){let s=await(await this.apiService.post(`test-generation/${this.cloudTestGenerationId}/info`)).json(),{actionsDownloadSignedURL:c}=s,p=await fetch(c,{mode:"cors",credentials:"same-origin",headers:{"Content-Type":"application/json"}});if(!p.ok)throw new Error(`HTTP error! Status: ${p.status}`);let _=await p.json();return{actions:this.initializeTestStepsWithIds(_),storyId:s.story.id}}initializeTestStepsWithIds(i){return i.map((s,c)=>({...s,id:(0,ZUr.randomUUID)(),assertions:(s.assertions??[]).map(p=>({...p,id:(0,ZUr.randomUUID)()}))}))}async getInitialServicesDataForEditedFile(){var s,c,p,_,v,E,D;if(((s=this.vtgTestFileRunConfig)==null?void 0:s.mode)!=="edit")return;let i=[];if(!this.vtgTestFileRunConfig.restoreFromAutoSave){let w=(c=this.vtgTestFileRunConfig)==null?void 0:c.actionsJsonFilePath;i=this.storageService.readJsonFile(w),(0,n7e.rmSync)(w,{force:!0}),i=this.initializeTestStepsWithIds(i)}if((p=this.vtgTestFileRunConfig)!=null&&p.internalTestId)try{let w=await this.apiService.post(`test-generation-by-internal-test-id/${(_=this.vtgTestFileRunConfig)==null?void 0:_.internalTestId}/info`);if(!w.ok){let P=w.statusText;try{let L=await w.text();try{P=JSON.parse(L).message||L||w.statusText}catch{P=L||w.statusText}}catch{P="Test id not found or invalid"}throw new Error(`Error fetching test generation data: ${P}`)}let B=await w.json();if(this.vtgTestFileRunConfig.restoreFromAutoSave){let P=this.storageService.getLocalSavedJSONFilePath("auto-save"),L=this.storageService.readLocalSavedDataFromJSONFile(P);if(!L)throw new Error(`No data found in auto-save while reading from ${P}`);i=L==null?void 0:L.executedActions}return{actions:i,storyId:B.story.id,testGenerationData:B.testGenerationData}}catch{af.warning(`Could not find data matching internal test id: ${(v=this.vtgTestFileRunConfig)==null?void 0:v.internalTestId}`)}if((E=this.vtgTestFileRunConfig)!=null&&E.storyId)return{actions:i,storyId:(D=this.vtgTestFileRunConfig)==null?void 0:D.storyId};throw new Error("Cannot edit file without either valid internal test id or story id")}async start({createAssetsFolder:i=!0}={}){var c,p;await this.userStoryService.fetchStory(this.storyId),i&&this.testAssetsManager.createTestAssetsFolders(),this.testAssetsManager.createTestGenerationLocalAutoSaveFolder(),await this.reactAppServer.start();let{environment:s}=this.userStoryService.getEnvInfo();await this.webDriver.prepare({baseURL:s.baseURL,shutdown:!this.vtgTestFileMode},{serverPort:await this.reactAppServer.getPort()}),I_.vtg.writeLogFile&&this.setupFrontendLogging(this.webDriver.page),await this.webDriver.page.evaluate(()=>{"checksumRRWeb"in window&&console.log(`Using forked rrweb. ${JSON.stringify(window.checksumRRWeb)}`)}),await this.webDriver.addHARMockAPIRecordings(this.testAssetsManager.getHarFilePath()),await this.initTimeMachine(),this.pageInteractor.init(),this.assertionsService.setPage(this.webDriver.appMainFrame.page()),this.actionsService.setPage(this.webDriver.appMainFrame.page()),this.evaluatorService.setPage(this.webDriver.appMainFrame.page()),this.aiChatService.setPage(this.webDriver.appMainFrame.page()),await this.taskTimeMachine.prepare(this.webDriver.appMainFrame,void 0,_=>this.webDriver.registerTimeMachineFrame(_)),await this.reactAppServer.evaluateServerPort(this.webDriver.page),await this.webDriver.appMainFrame.goto("about:blank",{waitUntil:"domcontentloaded",timeout:0}),await this.webDriver.getTimeMachine().toggleTimeMachineHandleEvents(!1),this.vtgMode==="start"&&!this.vtgTestFileRunConfig.restoreFromAutoSave&&(await this.actionsService.addInitialLoginAction(),await this.actionsService.addStartURLNavigationAction(),this.vtgTestFileMode&&await this.storageService.saveTestFile()),af.info("VTG is ready with story:",{goal:(c=this.userStoryService.getStory())==null?void 0:c.goal}),await this.webDriver.page.evaluate(({localSaveFolderPath:_,stepsData:v,appViewport:E,userStoryGoal:D,isLoadedFromFile:w})=>{window.vtg.initClient(_,v,E,this.checksumRuntimeVersion,D,w)},{localSaveFolderPath:this.editLocationPath,stepsData:await this.actionsManager.buildStepDataWithCode(this.actionsManager.actions,{loadingFromFile:["edit","cloud"].includes(this.vtgMode)}),appViewport:this.webDriver.getApplicationViewport(),userStoryGoal:(p=this.userStoryService.getStory())==null?void 0:p.goal,isLoadedFromFile:this.vtgTestFileMode}),this.vtgTestFileMode||await new Promise(()=>{})}getTimeoutParams(){var c,p,_,v;let i=((p=(c=this.playwrightConfigForVTG)==null?void 0:c.use)==null?void 0:p.navigationTimeout)||3e4,s=((v=(_=this.playwrightConfigForVTG)==null?void 0:_.use)==null?void 0:v.actionTimeout)||5e3;return{navigationTimeout:i,actionTimeout:s}}getPlaywrightProxySettings(){var _,v;let i=(v=(_=this.playwrightConfigForVTG)==null?void 0:_.use)==null?void 0:v.proxy,{server:s,username:c,password:p}=i||{};if(c&&p&&s)return{username:c,password:p,server:s}}getPlaywrightViewportSettings(){var c,p;let{width:i=1280,height:s=720}=((p=(c=this.playwrightConfigForVTG)==null?void 0:c.use)==null?void 0:p.viewport)||{};return{width:i,height:s}}buildWebDriver(i){var p,_,v,E,D,w;let s=this.getPlaywrightProxySettings(),c=this.getPlaywrightViewportSettings();return new lMt({scriptSource:I_.checksumScript.source,scriptURL:I_.checksumScript.url,scriptFile:I_.checksumScript.path,isScriptFileAbsolute:!0,fullScreenResolution:!1,hostWindowViewport:!0,baseURL:(p=this.checksumConfig.environments.find(B=>B.default))==null?void 0:p.baseURL,useProxy:!!s,webProxy:s,disableWebSecurity:!0,allowFileAccess:!0,remoteDebugging:I_.vtg.remoteDebugging,remoteDebuggingPort:I_.vtg.vtgRemoteDebuggingPort},{devtools:!1,headless:I_.CI},{frontendAppSpecificRules:{},frontendTestGenerationConfig:{logPrefix:"$checksum"},viewport:c,completeOriginHeaderOnLivePage:!I_.vtg.isSeparateProcess&&!((E=(v=(_=this.checksumConfig.options)==null?void 0:_.modelConfig)==null?void 0:v.browserArgs)!=null&&E.skipDisableWebSecurity)&&!((w=(D=this.checksumConfig.options)==null?void 0:D.modelConfig)!=null&&w.skipCompleteOriginHeaderOnDisableWebSecurity)},i)}async onWebDriverContextClose(){var i,s,c;this.evaluatorService.stopListening(),(i=this.vtgTestFileRunConfig)!=null&&i.evalFilePath&&(0,n7e.rmSync)((s=this.vtgTestFileRunConfig)==null?void 0:s.evalFilePath,{force:!0}),this.vtgTestFileRunConfig.mode==="edit"&&(0,n7e.rmSync)((c=this.vtgTestFileRunConfig)==null?void 0:c.actionsJsonFilePath,{force:!0})}initializeAccordingToVTGMode(i){var p;let s=i.indexOf("--edit"),c=i.indexOf("--cloud");if(i.indexOf("--test-file")!==-1){this.vtgTestFileMode=!0,this.vtgTestFileRunConfig=JSON.parse(process.env.CHECKSUM_VTG_TEST_FILE_RUN_CONFIG),this.vtgMode=this.vtgTestFileRunConfig.mode,this.storyId=((p=this.vtgTestFileRunConfig)==null?void 0:p.mode)==="start"?this.vtgTestFileRunConfig.storyId:void 0;return}s!==-1&&(this.vtgMode="edit",this.editLocationPath=i[s+1]),c!==-1&&(this.vtgMode="cloud",this.cloudTestGenerationId=i[c+1]),this.vtgMode==="start"&&(this.storyId=i[0])}getWebDriver(){return this.webDriver}async eval(i){return this.evaluatorService.listenForExecution(i)}};e(eQr,"VisualTestGenerator");var kMt=eQr;cT();WS();var QMn=nd(NBr());yre();var tQr=e(async(n,r,i,s,c={})=>{let{preventDialogFromAutoDismissing:p=!1,retry:_=!0,maxRetries:v=void 0,numberOfRetries:E=0}=c;try{console.log(`${n} attempting to connect to ${r} on port ${i}...`);let w=(await QMn.chromium.connectOverCDP("http://127.0.0.1:"+i)).contexts()[0],B=s(w.pages());for(;!B;)await Mb(1e3),B=s(w.pages());return console.log(`${n} is connected to ${r} on port ${i}`,B.url()),p&&rOt(B),B}catch(D){if(!_||v&&E>=v)throw console.error(`${n} failed to connect to ${r}, retries were exhausted or disabled`,D),D;return console.log(`${n} is waiting and retrying connection to ${r} on port ${i}...`),await Mb(1e3),tQr(n,r,i,s,{...c,numberOfRetries:E+1})}},"connectToPage");_6();(async()=>{af.info("[VTG PW Bridge Runner] Started.");let n=new kMt(["--test-file"],!1,JSON.parse(process.env.CHECKSUM_CONFIG),parseInt(process.env.CHECKSUM_PORT)),r=I_.vtg.appRemoteDebuggingPort,i=await tQr("VTG via Bridge","Live App Page",r,s=>s[0],{preventDialogFromAutoDismissing:!0});af.info("[VTG PW Bridge Runner] Running VTG..."),await n.run(i)})();
|
|
1908
|
+
`)}async run(i){await this.init(i),this.buildServices(i),this.buildServer(),await this.loadIfNecessary(),await this.start()}async loadIfNecessary(){let i=await this.getInitialServicesData();i&&(this.actionsManager.setActions(i.actions),this.testAssetsManager.setCurrentSaveAsLocation(this.editLocationPath),this.storyId=i.storyId,i.testGenerationData&&this.userStoryService.setTestGenerationData(i.testGenerationData))}async init(i){af.info(`Initializing VTG with runtime version ${this.checksumRuntimeVersion}...`),await this.patchPlaywright(),this.loadPlaywrightConfigForVTG(),this.webDriver=this.buildWebDriver(i),this.webDriver.registerEventListener(this),this.taskTimeMachine=new oge(this.webDriver.frameMsgBroker,this.webDriver.injectedScriptManager,{headless:!I_.vtg.taskTimeMachine.showTaskTimeMachine,timestampBatchingEnabled:!1,sortByTimestamp:!0,taskTimeout:I_.vtg.taskTimeMachine.taskTimeout,debugPort:I_.vtg.isSeparateProcess?I_.vtg.taskTimeMachine.debugPort:void 0,frameMsgBrokerRegisterName:"task-time-machine",logPerformance:I_.vtg.taskTimeMachine.logPerformance,webProxy:this.getPlaywrightProxySettings()}),this.pageInteractor=new uge(this.webDriver.evaluateWithChecksum.bind(this.webDriver),()=>this.webDriver.appMainFrame,this.webDriver.getTimeMachine.bind(this.webDriver),{log:e((s,...c)=>c!=null&&c.length?af.info(s,...c):af.info(s),"log"),logError:e((s,...c)=>c!=null&&c.length?af.error(s,...c):af.error(s),"logError")},{...this.getTimeoutParams(),waitActionDelay:1e3,testAssetsDir:__dirname,listenToDialog:!0,listenToFileChooser:!1},new Sje(this.checksumConfig)),this.testAssetsManager=new oMt(this.projectRootDirectory,this.checksumRoot,this.vtgInternalFilesDir,this.vtgTestFileRunConfig)}buildServices(i){this.actionsManager=new FRt,this.settingsService=new Ult(this.checksumRoot,this.apiService,this.vtgInternalFilesDir),this.apiService=new zct(this.checksumConfig),this.settingsService=new Ult(this.checksumRoot,this.apiService),this.userStoryService=new Jct(this.apiService,this.checksumConfig),this.variableStoreService=new mMt,this.evaluatorService=new yMt(this.variableStoreService,this.settingsService,this.vtgTestFileMode,i,this.port),this.actionsService=new uOt(this.checksumConfig,this.checksumRoot,this.pageInteractor,this.apiService,this.userStoryService,this.actionsManager,this.testAssetsManager,this.webDriver,this.evaluatorService,this.vtgInternalFilesDir),this.assertionsService=new hOt(this.webDriver,this.actionsManager,this.evaluatorService),this.locatorsService=new SOt(this.webDriver,this.taskTimeMachine,this.apiService,this.userStoryService,this.evaluatorService),this.aiTestGenerationService=new pOt(this.webDriver,this.pageInteractor,this.actionsService,this.actionsManager,this.apiService,this.userStoryService),this.aiAssertionsService=new mOt(this.actionsManager,this.apiService,this.userStoryService,this.taskTimeMachine,this.webDriver,this.evaluatorService,{logPerformance:I_.vtg.aiAssertions.logPerformance}),this.aiThoughtsService=new dMt(this.actionsManager,this.apiService,this.userStoryService,this.taskTimeMachine,this.webDriver),this.storageService=new IRt(this.checksumConfig,this.userStoryService,this.apiService,this.actionsManager,this.testAssetsManager,this.actionsService,this.vtgTestFileRunConfig,this.evaluatorService,this.settingsService,this.taskTimeMachine),this.actionsManager.setStorageService(this.storageService),this.monacoService=new AMt,this.aiChatService=new TMt(this.taskTimeMachine,this.evaluatorService)}buildServer(){this.reactAppServer=new aMt(this.actionsService,this.assertionsService,this.locatorsService,this.aiTestGenerationService,this.aiAssertionsService,this.aiThoughtsService,this.actionsManager,this.storageService,this.settingsService,this.monacoService,this.evaluatorService,this.aiChatService)}loadPlaywrightConfigForVTG(){try{let i=`${this.checksumRoot}/playwright.config.ts`;if((0,n7e.existsSync)(i)){let s=require(i).default;s&&(this.playwrightConfigForVTG=s)}}catch{af.warning("Could not find playwright config file, will run with defaults")}}async getInitialServicesData(){switch(this.vtgMode){case"cloud":return this.getInitialServicesDataFromCloud();case"edit":return this.vtgTestFileMode?await this.getInitialServicesDataForEditedFile():this.getInitialServicesDataFromJSON("local");case"start":if(this.vtgTestFileRunConfig.restoreFromAutoSave)return this.getInitialServicesDataFromJSON("auto-save")}}getInitialServicesDataFromJSON(i){let s=this.storageService.getLocalSavedJSONFilePath(i,this.storyId),c=this.storageService.readLocalSavedDataFromJSONFile(s);if(!c)throw new Error(`No data found in ${i} while reading from ${s}`);return{actions:c.executedActions,storyId:c.story.id}}async getInitialServicesDataFromCloud(){let s=await(await this.apiService.post(`test-generation/${this.cloudTestGenerationId}/info`)).json(),{actionsDownloadSignedURL:c}=s,p=await fetch(c,{mode:"cors",credentials:"same-origin",headers:{"Content-Type":"application/json"}});if(!p.ok)throw new Error(`HTTP error! Status: ${p.status}`);let _=await p.json();return{actions:this.initializeTestStepsWithIds(_),storyId:s.story.id}}initializeTestStepsWithIds(i){return i.map((s,c)=>({...s,id:(0,ZUr.randomUUID)(),assertions:(s.assertions??[]).map(p=>({...p,id:(0,ZUr.randomUUID)()}))}))}async getInitialServicesDataForEditedFile(){var s,c,p,_,v,E,D;if(((s=this.vtgTestFileRunConfig)==null?void 0:s.mode)!=="edit")return;let i=[];if(!this.vtgTestFileRunConfig.restoreFromAutoSave){let w=(c=this.vtgTestFileRunConfig)==null?void 0:c.actionsJsonFilePath;i=this.storageService.readJsonFile(w),(0,n7e.rmSync)(w,{force:!0}),i=this.initializeTestStepsWithIds(i)}if((p=this.vtgTestFileRunConfig)!=null&&p.internalTestId)try{let w=await this.apiService.post(`test-generation-by-internal-test-id/${(_=this.vtgTestFileRunConfig)==null?void 0:_.internalTestId}/info`);if(!w.ok){let P=w.statusText;try{let L=await w.text();try{P=JSON.parse(L).message||L||w.statusText}catch{P=L||w.statusText}}catch{P="Test id not found or invalid"}throw new Error(`Error fetching test generation data: ${P}`)}let B=await w.json();if(this.vtgTestFileRunConfig.restoreFromAutoSave){let P=this.storageService.getLocalSavedJSONFilePath("auto-save"),L=this.storageService.readLocalSavedDataFromJSONFile(P);if(!L)throw new Error(`No data found in auto-save while reading from ${P}`);i=L==null?void 0:L.executedActions}return{actions:i,storyId:B.story.id,testGenerationData:B.testGenerationData}}catch{af.warning(`Could not find data matching internal test id: ${(v=this.vtgTestFileRunConfig)==null?void 0:v.internalTestId}`)}if((E=this.vtgTestFileRunConfig)!=null&&E.storyId)return{actions:i,storyId:(D=this.vtgTestFileRunConfig)==null?void 0:D.storyId};throw new Error("Cannot edit file without either valid internal test id or story id")}async start({createAssetsFolder:i=!0}={}){var c,p;await this.userStoryService.fetchStory(this.storyId),i&&this.testAssetsManager.createTestAssetsFolders(),this.testAssetsManager.createTestGenerationLocalAutoSaveFolder(),await this.reactAppServer.start();let{environment:s}=this.userStoryService.getEnvInfo();await this.webDriver.prepare({baseURL:s.baseURL,shutdown:!this.vtgTestFileMode},{serverPort:await this.reactAppServer.getPort()}),I_.vtg.writeLogFile&&this.setupFrontendLogging(this.webDriver.page),await this.webDriver.page.evaluate(()=>{"checksumRRWeb"in window&&console.log(`Using forked rrweb. ${JSON.stringify(window.checksumRRWeb)}`)}),await this.webDriver.addHARMockAPIRecordings(this.testAssetsManager.getHarFilePath()),await this.initTimeMachine(),this.pageInteractor.init(),this.assertionsService.setPage(this.webDriver.appMainFrame.page()),this.actionsService.setPage(this.webDriver.appMainFrame.page()),this.evaluatorService.setPage(this.webDriver.appMainFrame.page()),this.aiChatService.setPage(this.webDriver.appMainFrame.page()),await this.taskTimeMachine.prepare(this.webDriver.appMainFrame,void 0,_=>this.webDriver.registerTimeMachineFrame(_)),await this.reactAppServer.evaluateServerPort(this.webDriver.page),await this.webDriver.appMainFrame.goto("about:blank",{waitUntil:"domcontentloaded",timeout:0}),await this.webDriver.getTimeMachine().toggleTimeMachineHandleEvents(!1),this.vtgMode==="start"&&!this.vtgTestFileRunConfig.restoreFromAutoSave&&(await this.actionsService.addInitialLoginAction(),await this.actionsService.addStartURLNavigationAction(),this.vtgTestFileMode&&await this.storageService.saveTestFile()),af.info("VTG is ready with story:",{goal:(c=this.userStoryService.getStory())==null?void 0:c.goal}),await this.webDriver.page.evaluate(({localSaveFolderPath:_,stepsData:v,appViewport:E,userStoryGoal:D,isLoadedFromFile:w})=>{window.vtg.initClient(_,v,E,this.checksumRuntimeVersion,D,w)},{localSaveFolderPath:this.editLocationPath,stepsData:await this.actionsManager.buildStepDataWithCode(this.actionsManager.actions,{loadingFromFile:["edit","cloud"].includes(this.vtgMode)}),appViewport:this.webDriver.getApplicationViewport(),userStoryGoal:(p=this.userStoryService.getStory())==null?void 0:p.goal,isLoadedFromFile:this.vtgTestFileMode}),this.vtgTestFileMode||await new Promise(()=>{})}getTimeoutParams(){var c,p,_,v;let i=((p=(c=this.playwrightConfigForVTG)==null?void 0:c.use)==null?void 0:p.navigationTimeout)||3e4,s=((v=(_=this.playwrightConfigForVTG)==null?void 0:_.use)==null?void 0:v.actionTimeout)||5e3;return{navigationTimeout:i,actionTimeout:s}}getPlaywrightProxySettings(){var _,v;let i=(v=(_=this.playwrightConfigForVTG)==null?void 0:_.use)==null?void 0:v.proxy,{server:s,username:c,password:p}=i||{};if(c&&p&&s)return{username:c,password:p,server:s}}getPlaywrightViewportSettings(){var c,p;let{width:i=1280,height:s=720}=((p=(c=this.playwrightConfigForVTG)==null?void 0:c.use)==null?void 0:p.viewport)||{};return{width:i,height:s}}buildWebDriver(i){var p,_,v,E,D,w;let s=this.getPlaywrightProxySettings(),c=this.getPlaywrightViewportSettings();return new lMt({scriptSource:I_.checksumScript.source,scriptURL:I_.checksumScript.url,scriptFile:I_.checksumScript.path,isScriptFileAbsolute:!0,fullScreenResolution:!1,hostWindowViewport:!0,baseURL:(p=this.checksumConfig.environments.find(B=>B.default))==null?void 0:p.baseURL,useProxy:!!s,webProxy:s,disableWebSecurity:!0,allowFileAccess:!0,remoteDebugging:I_.vtg.remoteDebugging,remoteDebuggingPort:I_.vtg.vtgRemoteDebuggingPort},{headless:I_.CI},{frontendAppSpecificRules:{},frontendTestGenerationConfig:{logPrefix:"$checksum"},viewport:c,completeOriginHeaderOnLivePage:!I_.vtg.isSeparateProcess&&!((E=(v=(_=this.checksumConfig.options)==null?void 0:_.modelConfig)==null?void 0:v.browserArgs)!=null&&E.skipDisableWebSecurity)&&!((w=(D=this.checksumConfig.options)==null?void 0:D.modelConfig)!=null&&w.skipCompleteOriginHeaderOnDisableWebSecurity)},i)}async onWebDriverContextClose(){var i,s,c;this.evaluatorService.stopListening(),(i=this.vtgTestFileRunConfig)!=null&&i.evalFilePath&&(0,n7e.rmSync)((s=this.vtgTestFileRunConfig)==null?void 0:s.evalFilePath,{force:!0}),this.vtgTestFileRunConfig.mode==="edit"&&(0,n7e.rmSync)((c=this.vtgTestFileRunConfig)==null?void 0:c.actionsJsonFilePath,{force:!0})}initializeAccordingToVTGMode(i){var p;let s=i.indexOf("--edit"),c=i.indexOf("--cloud");if(i.indexOf("--test-file")!==-1){this.vtgTestFileMode=!0,this.vtgTestFileRunConfig=JSON.parse(process.env.CHECKSUM_VTG_TEST_FILE_RUN_CONFIG),this.vtgMode=this.vtgTestFileRunConfig.mode,this.storyId=((p=this.vtgTestFileRunConfig)==null?void 0:p.mode)==="start"?this.vtgTestFileRunConfig.storyId:void 0;return}s!==-1&&(this.vtgMode="edit",this.editLocationPath=i[s+1]),c!==-1&&(this.vtgMode="cloud",this.cloudTestGenerationId=i[c+1]),this.vtgMode==="start"&&(this.storyId=i[0])}getWebDriver(){return this.webDriver}async eval(i){return this.evaluatorService.listenForExecution(i)}};e(eQr,"VisualTestGenerator");var kMt=eQr;cT();WS();var QMn=nd(NBr());yre();var tQr=e(async(n,r,i,s,c={})=>{let{preventDialogFromAutoDismissing:p=!1,retry:_=!0,maxRetries:v=void 0,numberOfRetries:E=0}=c;try{console.log(`${n} attempting to connect to ${r} on port ${i}...`);let w=(await QMn.chromium.connectOverCDP("http://127.0.0.1:"+i)).contexts()[0],B=s(w.pages());for(;!B;)await Mb(1e3),B=s(w.pages());return console.log(`${n} is connected to ${r} on port ${i}`,B.url()),p&&rOt(B),B}catch(D){if(!_||v&&E>=v)throw console.error(`${n} failed to connect to ${r}, retries were exhausted or disabled`,D),D;return console.log(`${n} is waiting and retrying connection to ${r} on port ${i}...`),await Mb(1e3),tQr(n,r,i,s,{...c,numberOfRetries:E+1})}},"connectToPage");_6();(async()=>{af.info("[VTG PW Bridge Runner] Started.");let n=new kMt(["--test-file"],!1,JSON.parse(process.env.CHECKSUM_CONFIG),parseInt(process.env.CHECKSUM_PORT)),r=I_.vtg.appRemoteDebuggingPort,i=await tQr("VTG via Bridge","Live App Page",r,s=>s[0],{preventDialogFromAutoDismissing:!0});af.info("[VTG PW Bridge Runner] Running VTG..."),await n.run(i)})();
|
|
1909
1909
|
/*! Bundled license information:
|
|
1910
1910
|
|
|
1911
1911
|
undici/lib/web/fetch/body.js:
|