@checksum-ai/runtime 1.1.14 → 1.1.15
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/checksumlib.js +1 -1
- package/cli.js +1 -1
- package/index.js +4 -4
- package/package.json +1 -1
package/checksumlib.js
CHANGED
|
@@ -23738,7 +23738,7 @@
|
|
|
23738
23738
|
tag: se.element.tagName.toLowerCase(),
|
|
23739
23739
|
innerText: this.innerTextExtractor.extract(se.element),
|
|
23740
23740
|
innerFeatures: this.innerFeaturesExtractor.extract(se.element),
|
|
23741
|
-
classes: se.element.
|
|
23741
|
+
classes: Array.from(se.element.classList) || [],
|
|
23742
23742
|
attributes: Array.from(se.element.attributes).reduce((acc, attr) => {
|
|
23743
23743
|
if (!["class", "style", "id"].includes(attr.name)) {
|
|
23744
23744
|
acc[attr.name] = attr.value;
|
package/cli.js
CHANGED
|
@@ -89,7 +89,7 @@ If your bundler has issues with dynamic imports take a look at '.plugins.setDepe
|
|
|
89
89
|
`&&(n+=VC(s)))}return n},"exec");ZC.exports=(e,r,t)=>String(e).normalize().replace(/\r\n/g,`
|
|
90
90
|
`).split(`
|
|
91
91
|
`).map(i=>KA(i,r,t)).join(`
|
|
92
|
-
`)});var JC=g((_Z,XC)=>{var QA=require("stream"),Ds,qt,pl,dl,Rm=class Rm extends QA{constructor(t={}){super(t);_(this,qt);_(this,Ds,null);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=t.replace,this._prompt=t.prompt||null,this._hadControl=!1}get isTTY(){return f(this,Ds)!==null?f(this,Ds):k(this,qt,pl).call(this,"isTTY",!1)}set isTTY(t){S(this,Ds,t)}get rows(){return k(this,qt,pl).call(this,"rows")}get columns(){return k(this,qt,pl).call(this,"columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(t){this._src=t}pipe(t,i){return this._dest=t,super.pipe(t,i)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(t){if(this.muted){if(!this.replace)return!0;if(t.match(/^\u001b/))return t.indexOf(this._prompt)===0&&(t=t.slice(this._prompt.length),t=t.replace(/./g,this.replace),t=this._prompt+t),this._hadControl=!0,this.emit("data",t);this._prompt&&this._hadControl&&t.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),t=t.slice(this._prompt.length)),t=t.toString().replace(/./g,this.replace)}this.emit("data",t)}end(t){this.muted&&(t&&this.replace?t=t.toString().replace(/./g,this.replace):t=null),t&&this.emit("data",t),this.emit("end")}destroy(...t){return k(this,qt,dl).call(this,"destroy",...t)}destroySoon(...t){return k(this,qt,dl).call(this,"destroySoon",...t)}close(...t){return k(this,qt,dl).call(this,"close",...t)}};Ds=new WeakMap,qt=new WeakSet,pl=o(function(t,i){return this._dest?this._dest[t]:this._src?this._src[t]:i},"#destSrc"),dl=o(function(t,...i){var n,s;typeof((n=this._dest)==null?void 0:n[t])=="function"&&this._dest[t](...i),typeof((s=this._src)==null?void 0:s[t])=="function"&&this._src[t](...i)},"#proxy"),o(Rm,"MuteStream");var Im=Rm;XC.exports=Im});var ak=require("@playwright/test");var ma="checksum";var _s=w(require("path"));var W=o(e=>new Promise(r=>setTimeout(r,e)),"awaitSleep"),Se=o(async(e,r=1e3,t="guardReturnTimedOut")=>{if(r===null)return e;let i="guard-timed-out",n=o(async()=>(await W(r+1e3),i),"guard"),s=await Promise.race([e,n()]);if(typeof s=="string"&&s===i)throw new Error(t);return s},"guardReturn");function Ll(e){return!!e&&!["navigation","keystroke","wait","get_more_items","custom_code"].includes(e)}o(Ll,"isActionOnElement");function lg(e){return{click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",upload_files:"upload_files",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",reset:void 0,save:void 0,fail:void 0,wait:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,get_more_items:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0}[e]}o(lg,"getActionEventCode");var hg=o((e,r,t)=>{if(!r)return e;if(!t||!t.length)return e.locator(r);let i=e.frameLocator(t[0]);for(let n of t.slice(1))i=i.frameLocator(n);return i.locator(r)},"makeLocator");function Bl(){return process.env.CHECKSUM_ROOT_FOLDER?process.env.CHECKSUM_ROOT_FOLDER:_s.join(__dirname,"..","..","..","checksum")}o(Bl,"checksumFolder");function fg({isInit:e,excludeLogin:r}){return[...e?["example.checksum.spec.ts","github-actions.example.yml"]:[],...r?[]:["login.ts"],"checksum.config.ts","playwright.config.ts","README.md",".gitignore.example"]}o(fg,"getRuntimeFiles");var vP={generateSelectionData:!1,navigationTimeout:30*1e3,actionTimeout:5*1e3};var D8=require("jsdom");var ck=w(hc());var rk=250,_h=class _h{constructor(r,t){this.timeMachineable=r;this.initMethod=t;this.numberOfReceivedRrwebEventsIndex=0;this.syncTimeMachine=o(async()=>{try{let r;try{r=await this.timeMachineable.getRRwebEvents(this.numberOfReceivedRrwebEventsIndex)}catch{return}if(!r||r.length===0)return;try{await this.timeMachineable.getTimeMachinePage().evaluate(({events:t,len:i})=>window.checksum.timeMachine.handleEvents(t,i),{events:r,len:this.numberOfReceivedRrwebEventsIndex})}catch{return}this.numberOfReceivedRrwebEventsIndex+=r.length}finally{this.syncTimeout=setTimeout(this.syncTimeMachine,rk)}},"syncTimeMachine")}async start(r=!1){var t;await((t=this.initMethod)==null?void 0:t.call(this,r)),this.syncTimeMachine()}async stop(){clearTimeout(this.syncTimeout)}async disableEventsHandling(){await this.setShouldHandleEvents(!1)}async enableEventsHandling(){await this.setShouldHandleEvents(!0)}async setShouldHandleEvents(r){try{await this.timeMachineable.getTimeMachinePage().evaluate(t=>window.checksum.timeMachine.setShouldHandleEvents(t),r)}catch{}}};o(_h,"TimeMachineSync");var ao=_h;var _y=require("path"),Fy=require("fs");var nk=!0,Fh=class Fh{constructor(r,t,i,n,s,a){this.evaluateWithChecksum=r;this.getPage=t;this.getTimeMachinePage=i;this.logger=n;this.options=s;this.loginFunction=a;this.newPagesIds=[];this.performFileUploadAction=o(async(r,t)=>{if(!await r.evaluate(n=>n.tagName==="INPUT"&&n.getAttribute("type")==="file"))throw new Error("File upload action performed on non-file input element");let i=t.files.map(n=>(0,_y.join)(this.options.testAssetsDir,n)).filter(n=>(0,Fy.existsSync)(n)?!0:(this.logger.log(`Upload file not found: ${n}. Filtering out.`),!1));if(!i.length)throw new Error("No files to upload");await this.actionGuardReturn(r.setInputFiles(i),"Set input files timeout")},"performFileUploadAction");this.getSelectionDataForAction=o(async(r,t)=>r.checksumid?this.getSelectionDataForChecksumId(r.checksumid,t):r.position?await this.evaluateWithChecksum(async([i,n])=>window.checksum.testGenerator.getSelectorByPosition(i,n),[r.position.x,r.position.y]):r.selector?{selector:r.selector,locator:`locator("${r.selector}")`}:{selector:"",locator:""},"getSelectionDataForAction")}init(){let r=this.getPage();r.on("filechooser",async t=>{this.logger.log("File chooser event detected"),this.fileChooser=t}),r.context().on("page",t=>{this.newPagesIds.push(t._guid)})}getOpenedFileChooser(){if(this.fileChooser){let r=this.fileChooser;return this.fileChooser=void 0,r}return null}async handleFileChooserEvent(r=[]){let t=this.getOpenedFileChooser();if(!t)return{};let i="fc_"+Math.random().toString(36).slice(2,4);return await this.evaluateWithChecksum(async([n,s])=>{window.checksum.testGenerator.addForceIncludeElement(s,n)},[i,t.element()]),{interruptionEvent:"fileUploadOpenedEvent",payload:{checksumid:i,customFiles:r}}}async addMoreItemsToDom(r,t){let i=r.querySelector(`[checksum-get-more-items='${t}']`);if(!i)throw new Error("Get more items root not found");let{items:n,hasMoreItems:s}=await this.getMoreItemsForTemplate(t);i.innerHTML=i.innerHTML+n,s||i.removeAttribute("checksum-get-more-items")}async getPageInfo(r){return{id:r._guid,url:r.url(),title:await r.title(),new:this.newPagesIds.includes(r._guid),active:r._guid===this.getPage()._guid}}async getTabsInfo(){let r=(await Promise.all(this.getPage().context().pages().map(t=>this.getPageInfo(t)))).filter(t=>{var i;return t.id!==((i=this.getTimeMachinePage())==null?void 0:i._guid)});return this.newPagesIds=[],r}async getSelectionDataFromSelectorGenerator(r,t,i={}){if(i={useCompoundSelector:!1,useCSSExtraction:!0,useVariables:!0,...i},!r||!Ll(lg(t.action.type))||!t.action.checksumid)return{};let n=await r.generateSelectionForAction(t,i);return n?{locator:`locator("${n.selector}")`,...n}:{}}async translateActionResponseToAgentPotentialAction(r,t=void 0,{pageId:i,makeStaticMetadataForESRA:n}={}){let s=structuredClone(r.actionHiddenOverride??r.action),{selector:a,selectorWithVars:c,locator:u,locatorWithVars:l,clickOffset:h,selectOptionValue:p,compoundSelector:d,parentFramesSelectors:m}={...await this.getSelectionDataForAction(s,r.actionHiddenOverride),...await this.getSelectionDataFromSelectorGenerator(t,r)},E=await this.getESRAForSelector(a,m,n);if(!E&&a&&this.logger.logError("Error getting ESRA metadata"),(E==null?void 0:E.tag)==="select")switch(this.getActionEventCode(s.type)){case"input":s.type="selectoption";break;case"click":p&&(s.type="selectoption",s.value=p);break}let y={eventCode:this.getActionEventCode(s.type),selector:a,selectorWithVars:c,parentFramesSelectors:m,locator:u,locatorWithVars:l,clickOffset:h,pageId:i,compoundSelector:d,fillValue:s.value,fillValueName:s.valueName?`variablesStore.${s.valueName}`:"",variables:r.variables,getMoreItemsId:s.getMoreItemsId,esraMetadata:E,description:r.thought,userRole:s.userRole};switch(y.eventCode){case"drag_and_drop":{let{selector:v,selectorWithVars:D,locator:x,locatorWithVars:b,parentFramesSelectors:C}={...await this.getSelectionDataForAction({type:r.action.type,checksumid:r.action.dropTargetChecksumid}),...await this.getSelectionDataFromSelectorGenerator(t,{...r,action:{type:r.action.type,checksumid:r.action.dropTargetChecksumid}},{useCompoundSelector:!1})};y.dropTarget={selector:v,selectorWithVars:D,locator:x,locatorWithVars:b,parentFramesSelectors:C,esraMetadata:await this.getESRAForSelector(v,C,n)}}break;case"upload_files":y.files=this.mapFileMIMETypeToFilename(s.files);break;case"switch_tab":y.switchToTab={id:s.tabId,index:this.getPage().context().pages().findIndex(v=>v._guid===s.tabId)};break;case"keystroke":y.fillValue=s.value}return y}async reauthenticate(r){this.loginFunction&&(await Promise.all([this.getPage().context().clearCookies(),this.getPage().evaluate(()=>localStorage.clear())]),await this.loginFunction(this.getPage(),{role:r}))}mapFileMIMETypeToFilename(r){return r.map(t=>{if(t.fileName)return t.fileName;switch(t.mimeType){case"image/png":return"image_200x200.png";case"image/jpeg":return"image_200x200.jpg";case"application/pdf":return"document.pdf";case"text/csv":return"data.csv";default:return"file.txt"}})}async performAction(r,{handleActionFailed:t,monitorFlashingHTML:i=!0}={}){try{if(r.executed){this.logger.log("[performAction] Action marked as executed, skipping...");return}if(Ll(r.eventCode)&&!r.selector)throw new Error("No selector provided for action. Try changing app rules preMapReducedHTMLSelectors to true");i&&(this.logger.log("starting flashing elements detection"),await this.evaluateWithChecksum(async()=>window.checksum.testGenerator.startFlashingElementsDetection())),this.logger.log(`Performing action: ${r.eventCode}. Selector: ${r.selector}, Position: ${r.clickOffset}, Parent frame: ${r.parentFramesSelectors}`);let n=o(()=>this.makeLocator(r.selector,r.parentFramesSelectors),"getLocator");switch(r.eventCode){case"click":try{await this.actionGuardReturn(n().click({position:r.clickOffset}),"Click timeout")}catch(c){this.logger.log("Error performing click, will attempt a force click",c),r.force=!0,await this.actionGuardReturn(n().click({position:r.clickOffset,force:!0}),"Click timeout")}break;case"double_click":try{await this.actionGuardReturn(n().dblclick({position:r.clickOffset}),"DoubleClick timeout")}catch(c){this.logger.log("Error performing double click, will attempt a force double click",c),r.force=!0,await this.actionGuardReturn(n().dblclick({position:r.clickOffset,force:!0}),"Click timeout")}break;case"check":await this.actionGuardReturn(n().check(),"Check timeout");break;case"uncheck":await this.actionGuardReturn(n().uncheck(),"UnCheck timeout");break;case"drag_and_drop":await this.actionGuardReturn(n().dragTo(this.makeLocator(r.dropTarget.selector,r.dropTarget.parentFramesSelectors)),"DragAndDrop timeout");break;case"input":await this.actionGuardReturn(n().fill(this.getActionFillValue(r)),"Fill timeout");break;case"click_and_type":await Se(n().click({position:r.clickOffset}),1e4,"Click before type timeout"),await Se(n().pressSequentially(this.getActionFillValue(r)),1e4,"pressSequentially timeout");break;case"clear_and_type":await Se(n().clear(),1e4,"Clear before type timeout"),await Se(n().pressSequentially(this.getActionFillValue(r)),1e4,"pressSequentially timeout");break;case"selectoption":await this.actionGuardReturn(n().selectOption(this.getActionFillValue(r)),"SelectOption timeout");break;case"hover":await this.actionGuardReturn(n().hover(),"Hover timeout");break;case"navigation":await this.actionGuardReturn(this.getPage().goto(r.fillValue),"Navigation timeout",!0);break;case"keystroke":await this.actionGuardReturn(this.getPage().keyboard.press(r.fillValue),"Keystroke timeout");break;case"upload_files":await this.performFileUploadAction(n(),r);break;case"wait":await W(this.options.waitActionDelay??1e3);break;case"custom_code":let s=`async (page) => {${r.fillValue}}`;await(0,eval)(s)(this.getPage());break;case"logout_and_login":await this.reauthenticate(r.userRole);break}}catch(n){throw this.logger.log(`Error performing action: ${r.eventCode}, will attempt a correction template`,n),await(t==null?void 0:t()),new Error("Failed performing action")}this.logger.log(`Successfully performed action ${r.eventCode} with description "${r.description}"`)}getActionFillValue(r,t=!0){let i=r.fillValue;if(!i){let n=r.selector.match(/(?<=value.*)('|").*/);n&&(i=n[0].slice(1,-1))}return typeof i!="string"&&(i="X"),t&&(r.fillValue=i),i}actionGuardReturn(r,t,i=!1){return Se(r,i?this.options.navigationTimeout:this.options.actionTimeout,t)}makeLocator(r,t){return hg(this.getPage(),r,t)}getCurrentURL(){return this.getPage().url()}async getSelectionDataForChecksumId(r,t){if(t!=null&&t.selector)return{...t,selector:t.selector,clickOffset:t.position};if(!r)return this.logger.log(`[getSelectionDataForChecksumId] checksumid not provided (${r})`),{...t,selector:r};let i=await this.evaluateWithChecksum(async n=>{let{selector:s,locator:a,clickOffset:c,parentFramesSelectors:u,invalid:l,rrwebId:h}=await window.checksum.testGenerator.getSelectorForChecksumId(n),p=await window.checksum.testGenerator.getElementForChecksumId(n),d=p instanceof HTMLOptionElement&&p.value?p.value:void 0;return{selector:s,locator:a,clickOffset:c,selectOptionValue:d,parentFramesSelectors:u,invalid:l,rrwebId:h}},r);if(nk&&i.invalid&&i.rrwebId){this.logger.log(`[getSelectionDataForChecksumId] Could not get selector for checksumid: ${r}. Trying to use time machine...`);try{let n=await this.getSelectionDataForRRwebIdAtReduceHTMLTime(i.rrwebId);i={...i,...n}}catch{this.logger.log(`[getSelectionDataForChecksumId] error using time machine to get selector for checksumid: ${r}`)}this.logger.log(`[getSelectionDataForChecksumId] got selector: ${i.selector} for checksumid: ${r} from time machine`)}return i!=null&&i.selector||this.logger.log(`[getSelectionDataForChecksumId] Could not get selector for checksumid: ${r}. If checksumid is correct, try to change app rules preMapReducedHTMLSelectors to true`),i}async getSelectionDataForRRwebIdAtReduceHTMLTime(r){if(!this.rrwebEventAtLastReducedHTML)return;let t=this.getTimeMachinePage();if(t)return t.evaluate(async({rrwebId:i,timestamp:n})=>{await window.checksum.timeMachine.goBack(n);let s=await window.checksum.testGenerator.getInspectedElementSelectionResultByRRwebId(i,{fromTimeMachine:!0});return await window.checksum.timeMachine.goLive(),s},{rrwebId:r,timestamp:this.rrwebEventAtLastReducedHTML.timestamp})}async getESRAForSelector(r,t,i){let n=await this.evaluateWithChecksum(async({selector:s,parentFramesSelectors:a})=>window.checksum.testGenerator.getSelectionDataForSelector(s,a),{selector:r,parentFramesSelectors:t});return n!=null&&n.esraMetadata&&i&&(n.esraMetadata.staticMetadata=await i(n.esraMetadata,r)),n==null?void 0:n.esraMetadata}async getMoreItemsForTemplate(r){return await this.evaluateWithChecksum(async t=>window.checksum.testGenerator.getMoreItemsForTemplate(t,{}),r)??{items:"",hasMoreItems:!1}}async getCurrentReducedHTML({retriesLeft:r=3,retryWaitMS:t=2e3,initialChecksumId:i="0",extractESRAForInterpretationRequiredElements:n=!1,stopFlashingElementsDetection:s=!1,assignChecksumIdsToAllElements:a}={}){let c=new Date;this.logger.log("[getCurrentReducedHTML] Fetching reduced HTML...");try{let{reducedHTML:u,currentChecksumId:l,flashingHTML:h,elementsForNodeInterpretation:p,lastRRwebEvent:d}=await this.evaluateWithChecksum(async E=>window.checksum.testGenerator.reduceHTML({},E),{initialChecksumId:i,extractESRAForInterpretationRequiredElements:n,stopFlashingElementsDetection:s,assignChecksumIdsToAllElements:a}),m=new Date;return this.logger.log(`[getCurrentReducedHTML] Fetched reduced HTML in ${m.getTime()-c.getTime()}ms`),this.rrwebEventAtLastReducedHTML=d,{reducedHTML:u,flashingHTML:h,elementsForNodeInterpretation:p,currentChecksumId:l}}catch(u){if(r>0)return this.logger.logError(`[getCurrentReducedHTML] Error: ${u.message}`),this.logger.logError(`Failed do obtain reduced HTML, trying again in ${t/1e3} seconds, ${r-1} to go.`),await W(t),this.getCurrentReducedHTML({retriesLeft:r-1,retryWaitMS:t});throw u}}getActionEventCode(r){return{click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",upload_files:"upload_files",wait:"wait",get_more_items:"get_more_items",reset:void 0,save:void 0,fail:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0,logout_and_login:"logout_and_login"}[r]}exampleCustomCode(){function r(i){return new Promise(n=>setTimeout(n,i))}o(r,"sleep");async function t(){let i={foo:o(()=>{console.log("fooed")},"foo")};await(0,eval)('async (page) => {console.log("before foo"); await sleep(1000); page.foo();}')(i)}o(t,"doit"),(async()=>t())()}};o(Fh,"TestGenerationPageInteractor");var ri=Fh;var hL=__dirname+"/checksumlib.js",fL=1e3*30;var ky=!1;function kh(e){ky=e}o(kh,"setLogToConsole");function ce(...e){ky&&console.log(...e)}o(ce,"log");function uk(e,{role:r,environment:t}={},i=!1){var c,u;let n;t&&(n=(c=e.environments)==null?void 0:c.find(({name:l})=>t===l)),n||(n=(u=e.environments)==null?void 0:u.find(({default:l})=>l)),n||(n={baseURL:e.baseURL,default:!0,name:void 0});let s=(n==null?void 0:n.users)??e.users,a;if(s&&(r&&(a=s.find(l=>l.role===r)),a||(a=s.find(l=>l.default))),a||(a={role:void 0,username:e.username,password:e.password,default:!0}),t&&n.name!==t){if(i)throw new Error(`Could not find environment with name "${t}" in config file`);console.warn(`Could not find environment with name "${t}" in config file, trying to use default environment`)}if(r&&a.role!==r){if(i)throw new Error(`Could not find user with role "${r}" for environment "${t}" in config file`);console.warn(`Could not find user with role "${r}" for environment "${t}" in config file, trying to login with environment's default user`)}return{environment:n,user:a}}o(uk,"resolveEnvironment");function Sh(e){let{config:r,folder:t,throwIfAuthFailed:i}=e;try{let n=require(`${t??Bl()}/login.ts`).default;return async(s,{role:a,environment:c}={})=>{let u={username:r.username,password:r.password},{environment:l,user:h}=uk(r,{role:a,environment:c});if(i&&!h)throw new Error("Could not find user credentials matching the provided role and/or environment");h&&(u.username=h.username,u.password=h.password);let p=o(()=>n(s,{...r,...u},{environment:l,user:h}),"performLogin");"checksumAI"in s?await s.checksumAI(`Log in${h!=null&&h.role?` using ${h.role} role`:""}${l!=null&&l.name?` in ${l.name} environment`:""}`,p):await p()}}catch(n){throw console.warn("Could not find checksum login file. Please create a login.ts file in your checksum folder"),n}}o(Sh,"makeUnboundLogin");var Xy=require("path"),fo=require("@playwright/test"),$h=w(Yy());var Hh=class Hh{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=o(async(r,t,i)=>{let n=[],s=o(a=>{if(a)switch(a.type){case"abort":return r.abort(a.errorCode);case"fulfill":return r.fulfill(a.fulfillOptions);default:case"continue":n.push(a)}},"processResult");for(let[a,c]of Object.entries(this.interceptors))if(this.options[a]){let u=s(await c(r,t,i));if(u)return u}return this.applyContinueResults(r,n)},"intercept")}setOptions(r){this.options=r}mergeOptions(r){this.options={...this.options,...r}}applyContinueResults(r,t){let i=t.filter(s=>!!s),n={};return i.forEach(s=>{s.options&&(s.options.headers&&(n.headers={...n.headers,...s.options.headers}),s.options.method&&(n.method=s.options.method),s.options.postData&&(n.postData=s.options.postData),s.options.url&&(n.url=s.options.url))}),r.continue(n)}async harInterceptor(r){let t=r.request().headers(),i=r.request().method();return t["Checksum-Id"]=(++this.harData.methodIndex[i]).toString(),{options:{headers:t}}}async completeOriginHeaderInterceptor(r,t,{page:i}){let n=r.request().headers();if(!n.Origin){try{let s=new URL(i.url()).origin;n.Origin=s}catch{}return{options:{headers:n}}}}};o(Hh,"RouteInterceptors");var mc=Hh;var zh=class zh{constructor(r={},t={}){this.browserConfig={devtools:!1,executablePath:process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH??void 0};this.options={fullScreenResolution:!1,defaultTimeout:3e4,defaultNavigationTimeout:3e4,disableWebSecurity:!0};this.navigationPromise={};this.contextClosePromise=void 0;this.eventListeners=[];this.lastSnapshot={selector:void 0,eventCode:void 0};this.snapshotTimeout=3e4;this.cacheScript=!1;this.pagesCounter=0;this.pagesIndexToGuid={};this.onRequestFinished=o(async r=>{try{let t=await r.response();if(!t.ok())return;let i=r.resourceType(),n=r.url(),s=o(async()=>{try{return await t.text()}catch{try{return await(await fetch(n)).text()}catch{return}}},"getBody");if(["document","script","stylesheet"].includes(i))try{let a=await s();if(!a)return;let c={url:n,source:a,type:i};await this.forEachEventListener(u=>{var l;return(l=u.onWebDriverResourceLoaded)==null?void 0:l.call(u,c)})}catch(a){console.error("[WebDriver] requestfinished event handler error",i,n,a)}}catch(t){console.error("[WebDriver] requestfinished event handler error",t)}},"onRequestFinished");this.onPage=o(async r=>{try{await(r==null?void 0:r.route("**/*",async(t,i)=>this.routeInterceptor.intercept(t,i,{page:r})))}catch(t){console.error("[WebDriver] onPage error",t)}},"onPage");this.onFrameNavigated=o(async r=>{let t=r.page();if(t.mainFrame()!==r)return;let i=o(async n=>{await this.forEachEventListener(s=>{var a;return(a=s.onWebDriverPageNavigated)==null?void 0:a.call(s,t,t.url(),n)})},"notifyFrameNavigated");await i(!1),this.navigationPromise[this.getGuid(t)]=new Promise(async n=>{await this.loadScript(t),await i(!0),n()})},"onFrameNavigated");this.navigatingPages={};this.tracing=!1;this.tracingChunk=!1;this.chunkIndex=0;var i;if(this.options={...this.options,...r},this.browserConfig={...this.browserConfig,...t},this.browserConfig.args||(this.browserConfig.args=[]),this.options.disableWebSecurity&&this.browserConfig.args.push("--disable-web-security"),this.browserConfig.args.push("--disable-site-isolation-trials"),this.browserConfig.args.push("--allow-running-insecure-content"),this.options.forceHeadless&&(this.browserConfig.headless=!0,this.browserConfig.devtools=!1),this.options.useProxy)if((i=this.options.webProxy)!=null&&i.server){console.log("[WebDriver] using proxy");let{server:n,username:s,password:a}=this.options.webProxy;this.browserConfig.proxy={server:n,username:s,password:a},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 mc({completeOriginHeader:this.options.completeOriginHeader,recordHar:this.options.recordHAR})}setOnScriptLoad(r){this.onScriptLoad=r}async prepare({storageState:r}={}){if(await this.shutdown(),this.options.useStealth){let i=require("puppeteer-extra-plugin-stealth");$h.chromium.use(i()),this.browser=await $h.chromium.launch(this.browserConfig)}else this.browser=await fo.chromium.launch(this.browserConfig);let t={};return t.bypassCSP=!0,t.ignoreHTTPSErrors=!0,t.baseURL=this.options.baseURL,this.options.timezoneId&&(t.timezoneId=this.options.timezoneId),this.options.fullScreenResolution&&(t.viewport={width:1280,height:720}),r&&(t.storageState=r),this.context=await this.browser.newContext(t),this.options.defaultTimeout&&this.context.setDefaultTimeout(this.options.defaultTimeout),this.options.defaultNavigationTimeout&&this.context.setDefaultNavigationTimeout(this.options.defaultNavigationTimeout),this.pageInjectedScriptOptions=this.getPageInjectedScriptOptions(),this.context.on("page",i=>{this.onPage(i),this.onFrameNavigated(i.mainFrame()),i.on("framenavigated",this.onFrameNavigated)}),this.context.on("close",async()=>{this.contextClosePromise=this.forEachEventListener(i=>{var n;return(n=i.onWebDriverContextClose)==null?void 0:n.call(i)})}),this.activePage=await this.context.newPage(),this.originalPage=this.activePage,this.options.trackLoadedResources&&this.page.on("requestfinished",this.onRequestFinished),this.options.useCDPSession&&(this.cdpSession=await this.context.newCDPSession(this.page)),!0}getGuid(r){return r._guid}switchActivePage(r){let t=this.context.pages().find(i=>this.getGuid(i)===r);return!t||t.isClosed()?(console.error(`[WebDriver] Page with guid ${r} not found or has been closed.`),!1):(this.previousPage=this.activePage,this.activePage=t,!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 t=>{try{await r(t)}catch(i){console.log("WebDriver/forEachEventListener exception",i)}}))}getPageInjectedScriptOptions(){switch(this.options.scriptSource){case"file":return this.options.scriptFile?{path:(0,Xy.join)(process.cwd(),this.options.scriptFile)}:void 0;case"url":return this.options.scriptURL?{url:this.options.scriptURL}:void 0;default:return}}registerEventListener(r){this.eventListeners.push(r)}async loadScript(r,{retriesLeft:t=3,retryWaitMS:i=2e3}={}){var a;if(!this.pageInjectedScriptOptions){console.warn("[WebDriver] Script options not set, skipping script load");return}if(r.isClosed())return;try{if(await r.waitForFunction(()=>!!window.checksum,void 0,{timeout:1e3}))return}catch{}if(r.isClosed())return;try{await r.addScriptTag(this.pageInjectedScriptOptions)}catch(c){if(t>0)return console.warn(`[WebDriver] Failed to add script, trying again in ${i/1e3} seconds, ${t-1} retries left.`,c),await W(i),this.loadScript(r,{retriesLeft:t-1,retryWaitMS:i});throw c}let n=this.getGuid(r),s=Date.now().toString(36)+Math.random().toString(36).substr(2);if(this.navigatingPages[n]=s,this.options.scriptInitWait&&(console.log(`Waiting ${this.options.scriptInitWait}[ms] before onScriptLoad...`),await W(this.options.scriptInitWait),console.log("Done waiting before onScriptLoad")),!r.isClosed()){if(this.navigatingPages[n]&&this.navigatingPages[n]!==s)return console.log("Page navigated again, waiting on new promise..."),this.navigationPromise[n];try{await((a=this.onScriptLoad)==null?void 0:a.call(this,r))}catch(c){console.error("[WebDriver] onScriptLoad error",c)}}}async getScript(){async function r(t){let{exec:i}=require("child_process");return new Promise((n,s)=>{i(t,a=>{a?(console.log("error executing cmd, ",a),s(a)):n()})})}switch(o(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(t){console.log("[web-driver] Failed fetching frontend script",t)}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,t){return this.page.setViewportSize({width:r,height:t})}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:t=!1,onErrorOnly:i=!1}={}){if(t)return r();let n=[],s=o(u=>{n.push(u.text())},"log");this.page.on("console",s);let a,c;try{c=await r()}catch(u){a=u}if(this.page.off("console",s),(!i||a)&&console.log("browser console messages:",n),a)throw a;return c}async takeElementSnapshot(r,t,i={},n={}){if(r===this.lastSnapshot.selector&&t===this.lastSnapshot.eventCode)return{};if(!r)return{};try{let{snapshot:s,elementLocator:a}=await this.takeSnapshot(r,n,{frameLocatorSelector:i.frameLocatorSelector});return this.lastSnapshot={selector:r,eventCode:t},{snapshot:s,elementLocator:a}}catch(s){return console.error("takeElementSnapshot error",s),{}}}getScreenshotTimeout(r=!1){return r?this.snapshotTimeout:this.snapshotTimeout+5e3}async takePageSnapshot(r){let t=this.page.screenshot({...r,timeout:this.getScreenshotTimeout()});return await Promise.race([t,W(this.getScreenshotTimeout(!0))])}async takeSnapshot(r,t,{frameLocatorSelector:i}={}){let n=i?this.page.frameLocator(i).locator(r):this.page.locator(r),s=n.screenshot({...t,timeout:this.getScreenshotTimeout()});return{snapshot:await Promise.race([s,W(this.getScreenshotTimeout(!0))]),elementLocator:n}}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 W(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}};o(zh,"WebDriver");var gc=zh;var Nk={useCDPSession:!0,trackLoadedResources:!0},Kh=class Kh extends gc{constructor(t={},i={devtools:!0},n={}){super({...Nk,...t},i);this.settings={frontendAppSpecificRules:void 0,initTestGenerator:!0,frontendTestGenerationConfig:void 0,useTimeMachine:!1};this.initTestGenerator=o(async t=>{let i={assertionGenerator:!0,sessionRecorder:!0};t===this.timeMachinePage&&(i.assertionGenerator=!1,i.sessionRecorder=!1);try{return await t.waitForFunction(()=>{var n;return!!((n=window.checksum)!=null&&n.testGenerator)}),t.evaluate(async({appSpecificRules:n,config:s,initModules:a})=>{window.checksum.testGenerator.init(n,s,a),n.hasGoals&&await window.checksum.goalTracker.init()},{appSpecificRules:this.settings.frontendAppSpecificRules,config:this.getFrontendTestGenerationConfig(),initModules:i})}catch(n){console.log("initTestGenerator exception",n)}},"initTestGenerator");this.settings={...this.settings,...n},this.settings.initTestGenerator&&this.setOnScriptLoad(this.initTestGenerator)}async prepare(t={}){let i=await super.prepare(t);return this.settings.loadScriptOnPrepare&&await this.loadScript(this.page),await this.page.addInitScript(()=>{window.sessionStorage.setItem("checksumai:disable","true")}),this.settings.useTimeMachine&&(this.timeMachinePage=await this.context.newPage(),await this.page.bringToFront(),await this.loadScript(this.timeMachinePage),await this.timeMachinePage.evaluate(()=>window.checksum.timeMachine.start({firstEventTimestamp:Date.now()}))),i}getTimeMachinePage(){return this.timeMachinePage}getFrontendTestGenerationConfig(){return this.settings.frontendTestGenerationConfig}async getBestMatchingElementSimilarityScore(t){return this.evaluateWithChecksum(async i=>await window.checksum.testGenerator.getBestMatchingElementSimilarityScore(i),t)}async getInteractableElements(){return this.evaluateWithChecksum(async()=>await window.checksum.testGenerator.getInteractableElements())}async getAllInteractableElementsForLastSelectQuery(){return this.evaluateWithChecksum(async()=>await window.checksum.testGenerator.getAllInteractableElementsForLastSelectQuery())}async evaluateWithChecksum(t,i){this.navigationPromise[this.getGuid(this.page)]&&await this.navigationPromise[this.getGuid(this.page)];try{return this.page.evaluate(t,i)}catch(n){throw console.error("evaluateWithChecksum error",n,t.toString()),n}}async overlayInteractableElementsWithChecksumId(t){return this.page.evaluate(i=>window.checksum.testGenerator.overlayInteractableElementsWithChecksumId(i),t)}async postRRwebEvents(t){return this.page.evaluate(i=>window.checksum.testGenerator.postRRwebEvents(i),t)}async getRRwebEvents(t=0){return this.evaluateWithChecksum(async({index:i})=>window.checksum.testGenerator.getRRwebEvents(i),{index:t})}async getGoals(){return await this.evaluateWithChecksum(async()=>window.checksum.goalTracker.getGoals())}async takeElementSnapshot(t,i,n={},s={}){try{let{snapshot:a,elementLocator:c}=await super.takeElementSnapshot(t,i,n);if(!a||!n.takeBodyScreenshot)return a?{snapshot:a}:{};await this.highlightElementByLocator(c,n.mousePosition);let u=await this.takePageSnapshot(s);return await this.clearHighlights(),{snapshot:a,bodySnapshot:u}}catch(a){return console.error("[ChecksumWebDriver] takeElementSnapshot error",a),{}}}async highlightElementByLocator(t,i,n="20px solid rgba(255,0,0,1)"){return this.evaluateWithChecksum(async([s,a,c])=>{window.checksum.testGenerator.highlightElement(s,{highlightStyle:{outline:a},mousePosition:c})},[await t.elementHandle(),n,i])}async clearHighlights(){return this.evaluateWithChecksum(async()=>window.checksum.testGenerator.clearHighlights())}async getInspectedElementSelectionResultByRRwebId(t,i={fromTimeMachine:!1}){return await(i.fromTimeMachine?this.getTimeMachinePage().evaluate.bind(this.getTimeMachinePage()):this.evaluateWithChecksum.bind(this))(([s,a])=>window.checksum.testGenerator.getInspectedElementSelectionResultByRRwebId(s,a),[parseInt(t,10),i])}};o(Kh,"ChecksumWebDriver");var fn=Kh;var Vh=class Vh{constructor(r,t={},i=!0){this.requests=[];this.watcherConfig={minimumWaitTime:250,maximumWaitTime:1e4,followingRequestsWaitTime:250};this.resolved=!0;this.hasMinimumWaitTimePassed=!1;this.useLog=!1;this.logStack=[];this.resolve=o(()=>{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,...t},this.initListeners(r),this.useLog=i}initListeners(r){r.on("request",t=>{var i;this.hasMinimumWaitTimePassed||(i=this.watcherConfig.whitelist)!=null&&i.length&&!this.watcherConfig.whitelist.some(n=>n.test(t.url()))||(this.useLog&&this.logStack.push(`${t.method()} ${t.url().substring(0,60)}`),this.requests.push(t),this.observedRequestsCount+=1)}),r.on("response",t=>{this.requests=this.requests.filter(i=>i!==t.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=[])}};o(Vh,"NetworkWatcher");var pn=Vh;var yc=o(e=>e.name==="up"||e.name==="k"||e.ctrl&&e.name==="p","isUpKey"),Zh=o(e=>e.name==="down"||e.name==="j"||e.ctrl&&e.name==="n","isDownKey"),Jy=o(e=>e.name==="space","isSpaceKey");var Qy=o(e=>"123456789".includes(e.name),"isNumberKey"),eb=o(e=>e.name==="enter"||e.name==="return","isEnterKey");var uf=w(M(),1),Rb=w(Ct(),1);var Fc=require("async_hooks");var Pb=new Fc.AsyncLocalStorage;function uS(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}o(uS,"createStore");function Tb(e,r){let t=uS(e);return Pb.run(t,()=>{r(t)})}o(Tb,"withHooks");function yn(){let e=Pb.getStore();if(!e)throw new Error("[Inquirer] Hook functions can only be called from within a prompt");return e}o(yn,"getStore");function of(){return yn().rl}o(of,"readline");function af(e){let r=o((...t)=>{let i=yn(),n=!1,s=i.handleChange;i.handleChange=()=>{n=!0};let a=e(...t);return n&&s(),i.handleChange=s,a},"wrapped");return Fc.AsyncResource.bind(r)}o(af,"withUpdates");function bn(e){let r=yn(),{index:t}=r,i={get(){return r.hooks[t]},set(s){r.hooks[t]=s},initialized:t in r.hooks},n=e(i);return r.index++,n}o(bn,"withPointer");function Ib(){yn().handleChange()}o(Ib,"handleChange");var kc={queue(e){let r=yn(),{index:t}=r;r.hooksEffect.push(()=>{var n,s;(s=(n=r.hooksCleanup)[t])==null||s.call(n);let i=e(of());if(i!=null&&typeof i!="function")throw new Error("useEffect return value must be a cleanup function or nothing.");r.hooksCleanup[t]=i})},run(){let e=yn();af(()=>{e.hooksEffect.forEach(r=>{r()}),e.hooksEffect.length=0})()}};function ft(e){return bn(r=>{let t=o(n=>{r.get()!==n&&(r.set(n),Ib())},"setFn");if(r.initialized)return[r.get(),t];let i=typeof e=="function"?e():e;return r.set(i),[i,t]})}o(ft,"useState");function mo(e,r){bn(t=>{let i=t.get();(!Array.isArray(i)||r.some((s,a)=>!Object.is(s,i[a])))&&kc.queue(e),t.set(r)})}o(mo,"useEffect");var cf=Rb.default.dots;function lf(e=!1){let[r,t]=ft(0);if(mo(()=>{if(e){let i=setTimeout(()=>{t(r+1)},cf.interval);return()=>clearTimeout(i)}},[e,r]),e){let i=r%cf.frames.length;return uf.default.yellow(cf.frames[i])}return uf.default.green("?")}o(lf,"usePrefix");function hf(e,r){return bn(t=>{let i=t.get();if(!i||i.dependencies.length!==r.length||i.dependencies.some((n,s)=>n!==r[s])){let n=e();return t.set({value:n,dependencies:r}),n}return i.value})}o(hf,"useMemo");function go(e){return ft({current:e})[0]}o(go,"useRef");function ff(e){let r=go(e);r.current=e,mo(t=>{let i=af((n,s)=>{r.current(s,t)});return t.input.on("keypress",i),()=>{t.input.removeListener("keypress",i)}},[])}o(ff,"useKeypress");var Jb=w(M(),1);var Kb=w(Bb(),1),Vb=w(zb(),1);function bo(e,r){return e.split(`
|
|
92
|
+
`)});var JC=g((_Z,XC)=>{var QA=require("stream"),Ds,qt,pl,dl,Rm=class Rm extends QA{constructor(t={}){super(t);_(this,qt);_(this,Ds,null);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=t.replace,this._prompt=t.prompt||null,this._hadControl=!1}get isTTY(){return f(this,Ds)!==null?f(this,Ds):k(this,qt,pl).call(this,"isTTY",!1)}set isTTY(t){S(this,Ds,t)}get rows(){return k(this,qt,pl).call(this,"rows")}get columns(){return k(this,qt,pl).call(this,"columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(t){this._src=t}pipe(t,i){return this._dest=t,super.pipe(t,i)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(t){if(this.muted){if(!this.replace)return!0;if(t.match(/^\u001b/))return t.indexOf(this._prompt)===0&&(t=t.slice(this._prompt.length),t=t.replace(/./g,this.replace),t=this._prompt+t),this._hadControl=!0,this.emit("data",t);this._prompt&&this._hadControl&&t.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),t=t.slice(this._prompt.length)),t=t.toString().replace(/./g,this.replace)}this.emit("data",t)}end(t){this.muted&&(t&&this.replace?t=t.toString().replace(/./g,this.replace):t=null),t&&this.emit("data",t),this.emit("end")}destroy(...t){return k(this,qt,dl).call(this,"destroy",...t)}destroySoon(...t){return k(this,qt,dl).call(this,"destroySoon",...t)}close(...t){return k(this,qt,dl).call(this,"close",...t)}};Ds=new WeakMap,qt=new WeakSet,pl=o(function(t,i){return this._dest?this._dest[t]:this._src?this._src[t]:i},"#destSrc"),dl=o(function(t,...i){var n,s;typeof((n=this._dest)==null?void 0:n[t])=="function"&&this._dest[t](...i),typeof((s=this._src)==null?void 0:s[t])=="function"&&this._src[t](...i)},"#proxy"),o(Rm,"MuteStream");var Im=Rm;XC.exports=Im});var ak=require("@playwright/test");var ma="checksum";var _s=w(require("path"));var W=o(e=>new Promise(r=>setTimeout(r,e)),"awaitSleep"),Se=o(async(e,r=1e3,t="guardReturnTimedOut")=>{if(r===null)return e;let i="guard-timed-out",n=o(async()=>(await W(r+1e3),i),"guard"),s=await Promise.race([e,n()]);if(typeof s=="string"&&s===i)throw new Error(t);return s},"guardReturn");function Ll(e){return!!e&&!["navigation","keystroke","wait","get_more_items","custom_code"].includes(e)}o(Ll,"isActionOnElement");function lg(e){return{click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",upload_files:"upload_files",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",reset:void 0,save:void 0,fail:void 0,wait:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,get_more_items:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0}[e]}o(lg,"getActionEventCode");var hg=o((e,r,t)=>{if(!r)return e;if(!t||!t.length)return e.locator(r);let i=e.frameLocator(t[0]);for(let n of t.slice(1))i=i.frameLocator(n);return i.locator(r)},"makeLocator");function Bl(){return process.env.CHECKSUM_ROOT_FOLDER?process.env.CHECKSUM_ROOT_FOLDER:_s.join(__dirname,"..","..","..","checksum")}o(Bl,"checksumFolder");function fg({isInit:e,excludeLogin:r}){return[...e?["example.checksum.spec.ts","github-actions.example.yml"]:[],...r?[]:["login.ts"],"checksum.config.ts","playwright.config.ts","README.md",".gitignore.example"]}o(fg,"getRuntimeFiles");var vP={generateSelectionData:!1,navigationTimeout:30*1e3,actionTimeout:5*1e3};var D8=require("jsdom");var ck=w(hc());var rk=250,_h=class _h{constructor(r,t){this.timeMachineable=r;this.initMethod=t;this.numberOfReceivedRrwebEventsIndex=0;this.syncTimeMachine=o(async()=>{try{let r;try{r=await this.timeMachineable.getRRwebEvents(this.numberOfReceivedRrwebEventsIndex)}catch{return}if(!r||r.length===0)return;try{await this.timeMachineable.getTimeMachinePage().evaluate(({events:t,len:i})=>window.checksum.timeMachine.handleEvents(t,i),{events:r,len:this.numberOfReceivedRrwebEventsIndex})}catch{return}this.numberOfReceivedRrwebEventsIndex+=r.length}finally{this.syncTimeout=setTimeout(this.syncTimeMachine,rk)}},"syncTimeMachine")}async start(r=!1){var t;await((t=this.initMethod)==null?void 0:t.call(this,r)),this.syncTimeMachine()}async stop(){clearTimeout(this.syncTimeout)}async disableEventsHandling(){await this.setShouldHandleEvents(!1)}async enableEventsHandling(){await this.setShouldHandleEvents(!0)}async setShouldHandleEvents(r){try{await this.timeMachineable.getTimeMachinePage().evaluate(t=>window.checksum.timeMachine.setShouldHandleEvents(t),r)}catch{}}};o(_h,"TimeMachineSync");var ao=_h;var _y=require("path"),Fy=require("fs");var nk=!0,Fh=class Fh{constructor(r,t,i,n,s,a){this.evaluateWithChecksum=r;this.getPage=t;this.getTimeMachinePage=i;this.logger=n;this.options=s;this.loginFunction=a;this.newPagesIds=[];this.performFileUploadAction=o(async(r,t)=>{if(!await r.evaluate(n=>n.tagName==="INPUT"&&n.getAttribute("type")==="file"))throw new Error("File upload action performed on non-file input element");let i=t.files.map(n=>(0,_y.join)(this.options.testAssetsDir,n)).filter(n=>(0,Fy.existsSync)(n)?!0:(this.logger.log(`Upload file not found: ${n}. Filtering out.`),!1));if(!i.length)throw new Error("No files to upload");await this.actionGuardReturn(r.setInputFiles(i),"Set input files timeout")},"performFileUploadAction");this.getSelectionDataForAction=o(async(r,t)=>r.checksumid?this.getSelectionDataForChecksumId(r.checksumid,t):r.position?await this.evaluateWithChecksum(async([i,n])=>window.checksum.testGenerator.getSelectorByPosition(i,n),[r.position.x,r.position.y]):r.selector?{selector:r.selector,locator:`locator("${r.selector}")`}:{selector:"",locator:""},"getSelectionDataForAction")}init(){let r=this.getPage();r.on("filechooser",async t=>{this.logger.log("File chooser event detected"),this.fileChooser=t}),r.context().on("page",t=>{this.newPagesIds.push(t._guid)})}getOpenedFileChooser(){if(this.fileChooser){let r=this.fileChooser;return this.fileChooser=void 0,r}return null}async handleFileChooserEvent(r=[]){let t=this.getOpenedFileChooser();if(!t)return{};let i="fc_"+Math.random().toString(36).slice(2,4);return await this.evaluateWithChecksum(async([n,s])=>{window.checksum.testGenerator.addForceIncludeElement(s,n)},[i,t.element()]),{interruptionEvent:"fileUploadOpenedEvent",payload:{checksumid:i,customFiles:r}}}async addMoreItemsToDom(r,t){let i=r.querySelector(`[checksum-get-more-items='${t}']`);if(!i)throw new Error("Get more items root not found");let{items:n,hasMoreItems:s}=await this.getMoreItemsForTemplate(t);i.innerHTML=i.innerHTML+n,s||i.removeAttribute("checksum-get-more-items")}async getPageInfo(r){return{id:r._guid,url:r.url(),title:await r.title(),new:this.newPagesIds.includes(r._guid),active:r._guid===this.getPage()._guid}}async getTabsInfo(){let r=(await Promise.all(this.getPage().context().pages().map(t=>this.getPageInfo(t)))).filter(t=>{var i;return t.id!==((i=this.getTimeMachinePage())==null?void 0:i._guid)});return this.newPagesIds=[],r}async getSelectionDataFromSelectorGenerator(r,t,i={}){if(i={useCompoundSelector:!0,useCSSExtraction:!0,useVariables:!0,...i},!r||!Ll(lg(t.action.type))||!t.action.checksumid)return{};let n=await r.generateSelectionForAction(t,i);return n?{locator:`locator("${n.selector}")`,...n}:{}}async translateActionResponseToAgentPotentialAction(r,t=void 0,{pageId:i,makeStaticMetadataForESRA:n}={}){let s=structuredClone(r.actionHiddenOverride??r.action),{selector:a,selectorWithVars:c,locator:u,locatorWithVars:l,clickOffset:h,selectOptionValue:p,compoundSelector:d,parentFramesSelectors:m}={...await this.getSelectionDataForAction(s,r.actionHiddenOverride),...await this.getSelectionDataFromSelectorGenerator(t,r)},E=await this.getESRAForSelector(a,m,n);if(!E&&a&&this.logger.logError("Error getting ESRA metadata"),(E==null?void 0:E.tag)==="select")switch(this.getActionEventCode(s.type)){case"input":s.type="selectoption";break;case"click":p&&(s.type="selectoption",s.value=p);break}let y={eventCode:this.getActionEventCode(s.type),selector:a,selectorWithVars:c,parentFramesSelectors:m,locator:u,locatorWithVars:l,clickOffset:h,pageId:i,compoundSelector:d,fillValue:s.value,fillValueName:s.valueName?`variablesStore.${s.valueName}`:"",variables:r.variables,getMoreItemsId:s.getMoreItemsId,esraMetadata:E,description:r.thought,userRole:s.userRole};switch(y.eventCode){case"drag_and_drop":{let{selector:v,selectorWithVars:D,locator:x,locatorWithVars:b,parentFramesSelectors:C}={...await this.getSelectionDataForAction({type:r.action.type,checksumid:r.action.dropTargetChecksumid}),...await this.getSelectionDataFromSelectorGenerator(t,{...r,action:{type:r.action.type,checksumid:r.action.dropTargetChecksumid}},{useCompoundSelector:!1})};y.dropTarget={selector:v,selectorWithVars:D,locator:x,locatorWithVars:b,parentFramesSelectors:C,esraMetadata:await this.getESRAForSelector(v,C,n)}}break;case"upload_files":y.files=this.mapFileMIMETypeToFilename(s.files);break;case"switch_tab":y.switchToTab={id:s.tabId,index:this.getPage().context().pages().findIndex(v=>v._guid===s.tabId)};break;case"keystroke":y.fillValue=s.value}return y}async reauthenticate(r){this.loginFunction&&(await Promise.all([this.getPage().context().clearCookies(),this.getPage().evaluate(()=>localStorage.clear())]),await this.loginFunction(this.getPage(),{role:r}))}mapFileMIMETypeToFilename(r){return r.map(t=>{if(t.fileName)return t.fileName;switch(t.mimeType){case"image/png":return"image_200x200.png";case"image/jpeg":return"image_200x200.jpg";case"application/pdf":return"document.pdf";case"text/csv":return"data.csv";default:return"file.txt"}})}async performAction(r,{handleActionFailed:t,monitorFlashingHTML:i=!0}={}){try{if(r.executed){this.logger.log("[performAction] Action marked as executed, skipping...");return}if(Ll(r.eventCode)&&!r.selector)throw new Error("No selector provided for action. Try changing app rules preMapReducedHTMLSelectors to true");i&&(this.logger.log("starting flashing elements detection"),await this.evaluateWithChecksum(async()=>window.checksum.testGenerator.startFlashingElementsDetection())),this.logger.log(`Performing action: ${r.eventCode}. Selector: ${r.selector}, Position: ${r.clickOffset}, Parent frame: ${r.parentFramesSelectors}`);let n=o(()=>this.makeLocator(r.selector,r.parentFramesSelectors),"getLocator");switch(r.eventCode){case"click":try{await this.actionGuardReturn(n().click({position:r.clickOffset}),"Click timeout")}catch(c){this.logger.log("Error performing click, will attempt a force click",c),r.force=!0,await this.actionGuardReturn(n().click({position:r.clickOffset,force:!0}),"Click timeout")}break;case"double_click":try{await this.actionGuardReturn(n().dblclick({position:r.clickOffset}),"DoubleClick timeout")}catch(c){this.logger.log("Error performing double click, will attempt a force double click",c),r.force=!0,await this.actionGuardReturn(n().dblclick({position:r.clickOffset,force:!0}),"Click timeout")}break;case"check":await this.actionGuardReturn(n().check(),"Check timeout");break;case"uncheck":await this.actionGuardReturn(n().uncheck(),"UnCheck timeout");break;case"drag_and_drop":await this.actionGuardReturn(n().dragTo(this.makeLocator(r.dropTarget.selector,r.dropTarget.parentFramesSelectors)),"DragAndDrop timeout");break;case"input":await this.actionGuardReturn(n().fill(this.getActionFillValue(r)),"Fill timeout");break;case"click_and_type":await Se(n().click({position:r.clickOffset}),1e4,"Click before type timeout"),await Se(n().pressSequentially(this.getActionFillValue(r)),1e4,"pressSequentially timeout");break;case"clear_and_type":await Se(n().clear(),1e4,"Clear before type timeout"),await Se(n().pressSequentially(this.getActionFillValue(r)),1e4,"pressSequentially timeout");break;case"selectoption":await this.actionGuardReturn(n().selectOption(this.getActionFillValue(r)),"SelectOption timeout");break;case"hover":await this.actionGuardReturn(n().hover(),"Hover timeout");break;case"navigation":await this.actionGuardReturn(this.getPage().goto(r.fillValue),"Navigation timeout",!0);break;case"keystroke":await this.actionGuardReturn(this.getPage().keyboard.press(r.fillValue),"Keystroke timeout");break;case"upload_files":await this.performFileUploadAction(n(),r);break;case"wait":await W(this.options.waitActionDelay??1e3);break;case"custom_code":let s=`async (page) => {${r.fillValue}}`;await(0,eval)(s)(this.getPage());break;case"logout_and_login":await this.reauthenticate(r.userRole);break}}catch(n){throw this.logger.log(`Error performing action: ${r.eventCode}, will attempt a correction template`,n),await(t==null?void 0:t()),new Error("Failed performing action")}this.logger.log(`Successfully performed action ${r.eventCode} with description "${r.description}"`)}getActionFillValue(r,t=!0){let i=r.fillValue;if(!i){let n=r.selector.match(/(?<=value.*)('|").*/);n&&(i=n[0].slice(1,-1))}return typeof i!="string"&&(i="X"),t&&(r.fillValue=i),i}actionGuardReturn(r,t,i=!1){return Se(r,i?this.options.navigationTimeout:this.options.actionTimeout,t)}makeLocator(r,t){return hg(this.getPage(),r,t)}getCurrentURL(){return this.getPage().url()}async getSelectionDataForChecksumId(r,t){if(t!=null&&t.selector)return{...t,selector:t.selector,clickOffset:t.position};if(!r)return this.logger.log(`[getSelectionDataForChecksumId] checksumid not provided (${r})`),{...t,selector:r};let i=await this.evaluateWithChecksum(async n=>{let{selector:s,locator:a,clickOffset:c,parentFramesSelectors:u,invalid:l,rrwebId:h}=await window.checksum.testGenerator.getSelectorForChecksumId(n),p=await window.checksum.testGenerator.getElementForChecksumId(n),d=p instanceof HTMLOptionElement&&p.value?p.value:void 0;return{selector:s,locator:a,clickOffset:c,selectOptionValue:d,parentFramesSelectors:u,invalid:l,rrwebId:h}},r);if(nk&&i.invalid&&i.rrwebId){this.logger.log(`[getSelectionDataForChecksumId] Could not get selector for checksumid: ${r}. Trying to use time machine...`);try{let n=await this.getSelectionDataForRRwebIdAtReduceHTMLTime(i.rrwebId);i={...i,...n}}catch{this.logger.log(`[getSelectionDataForChecksumId] error using time machine to get selector for checksumid: ${r}`)}this.logger.log(`[getSelectionDataForChecksumId] got selector: ${i.selector} for checksumid: ${r} from time machine`)}return i!=null&&i.selector||this.logger.log(`[getSelectionDataForChecksumId] Could not get selector for checksumid: ${r}. If checksumid is correct, try to change app rules preMapReducedHTMLSelectors to true`),i}async getSelectionDataForRRwebIdAtReduceHTMLTime(r){if(!this.rrwebEventAtLastReducedHTML)return;let t=this.getTimeMachinePage();if(t)return t.evaluate(async({rrwebId:i,timestamp:n})=>{await window.checksum.timeMachine.goBack(n);let s=await window.checksum.testGenerator.getInspectedElementSelectionResultByRRwebId(i,{fromTimeMachine:!0});return await window.checksum.timeMachine.goLive(),s},{rrwebId:r,timestamp:this.rrwebEventAtLastReducedHTML.timestamp})}async getESRAForSelector(r,t,i){let n=await this.evaluateWithChecksum(async({selector:s,parentFramesSelectors:a})=>window.checksum.testGenerator.getSelectionDataForSelector(s,a),{selector:r,parentFramesSelectors:t});return n!=null&&n.esraMetadata&&i&&(n.esraMetadata.staticMetadata=await i(n.esraMetadata,r)),n==null?void 0:n.esraMetadata}async getMoreItemsForTemplate(r){return await this.evaluateWithChecksum(async t=>window.checksum.testGenerator.getMoreItemsForTemplate(t,{}),r)??{items:"",hasMoreItems:!1}}async getCurrentReducedHTML({retriesLeft:r=3,retryWaitMS:t=2e3,initialChecksumId:i="0",extractESRAForInterpretationRequiredElements:n=!1,stopFlashingElementsDetection:s=!1,assignChecksumIdsToAllElements:a}={}){let c=new Date;this.logger.log("[getCurrentReducedHTML] Fetching reduced HTML...");try{let{reducedHTML:u,currentChecksumId:l,flashingHTML:h,elementsForNodeInterpretation:p,lastRRwebEvent:d}=await this.evaluateWithChecksum(async E=>window.checksum.testGenerator.reduceHTML({},E),{initialChecksumId:i,extractESRAForInterpretationRequiredElements:n,stopFlashingElementsDetection:s,assignChecksumIdsToAllElements:a}),m=new Date;return this.logger.log(`[getCurrentReducedHTML] Fetched reduced HTML in ${m.getTime()-c.getTime()}ms`),this.rrwebEventAtLastReducedHTML=d,{reducedHTML:u,flashingHTML:h,elementsForNodeInterpretation:p,currentChecksumId:l}}catch(u){if(r>0)return this.logger.logError(`[getCurrentReducedHTML] Error: ${u.message}`),this.logger.logError(`Failed do obtain reduced HTML, trying again in ${t/1e3} seconds, ${r-1} to go.`),await W(t),this.getCurrentReducedHTML({retriesLeft:r-1,retryWaitMS:t});throw u}}getActionEventCode(r){return{click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",upload_files:"upload_files",wait:"wait",get_more_items:"get_more_items",reset:void 0,save:void 0,fail:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0,logout_and_login:"logout_and_login"}[r]}exampleCustomCode(){function r(i){return new Promise(n=>setTimeout(n,i))}o(r,"sleep");async function t(){let i={foo:o(()=>{console.log("fooed")},"foo")};await(0,eval)('async (page) => {console.log("before foo"); await sleep(1000); page.foo();}')(i)}o(t,"doit"),(async()=>t())()}};o(Fh,"TestGenerationPageInteractor");var ri=Fh;var hL=__dirname+"/checksumlib.js",fL=1e3*30;var ky=!1;function kh(e){ky=e}o(kh,"setLogToConsole");function ce(...e){ky&&console.log(...e)}o(ce,"log");function uk(e,{role:r,environment:t}={},i=!1){var c,u;let n;t&&(n=(c=e.environments)==null?void 0:c.find(({name:l})=>t===l)),n||(n=(u=e.environments)==null?void 0:u.find(({default:l})=>l)),n||(n={baseURL:e.baseURL,default:!0,name:void 0});let s=(n==null?void 0:n.users)??e.users,a;if(s&&(r&&(a=s.find(l=>l.role===r)),a||(a=s.find(l=>l.default))),a||(a={role:void 0,username:e.username,password:e.password,default:!0}),t&&n.name!==t){if(i)throw new Error(`Could not find environment with name "${t}" in config file`);console.warn(`Could not find environment with name "${t}" in config file, trying to use default environment`)}if(r&&a.role!==r){if(i)throw new Error(`Could not find user with role "${r}" for environment "${t}" in config file`);console.warn(`Could not find user with role "${r}" for environment "${t}" in config file, trying to login with environment's default user`)}return{environment:n,user:a}}o(uk,"resolveEnvironment");function Sh(e){let{config:r,folder:t,throwIfAuthFailed:i}=e;try{let n=require(`${t??Bl()}/login.ts`).default;return async(s,{role:a,environment:c}={})=>{let u={username:r.username,password:r.password},{environment:l,user:h}=uk(r,{role:a,environment:c});if(i&&!h)throw new Error("Could not find user credentials matching the provided role and/or environment");h&&(u.username=h.username,u.password=h.password);let p=o(()=>n(s,{...r,...u},{environment:l,user:h}),"performLogin");"checksumAI"in s?await s.checksumAI(`Log in${h!=null&&h.role?` using ${h.role} role`:""}${l!=null&&l.name?` in ${l.name} environment`:""}`,p):await p()}}catch(n){throw console.warn("Could not find checksum login file. Please create a login.ts file in your checksum folder"),n}}o(Sh,"makeUnboundLogin");var Xy=require("path"),fo=require("@playwright/test"),$h=w(Yy());var Hh=class Hh{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=o(async(r,t,i)=>{let n=[],s=o(a=>{if(a)switch(a.type){case"abort":return r.abort(a.errorCode);case"fulfill":return r.fulfill(a.fulfillOptions);default:case"continue":n.push(a)}},"processResult");for(let[a,c]of Object.entries(this.interceptors))if(this.options[a]){let u=s(await c(r,t,i));if(u)return u}return this.applyContinueResults(r,n)},"intercept")}setOptions(r){this.options=r}mergeOptions(r){this.options={...this.options,...r}}applyContinueResults(r,t){let i=t.filter(s=>!!s),n={};return i.forEach(s=>{s.options&&(s.options.headers&&(n.headers={...n.headers,...s.options.headers}),s.options.method&&(n.method=s.options.method),s.options.postData&&(n.postData=s.options.postData),s.options.url&&(n.url=s.options.url))}),r.continue(n)}async harInterceptor(r){let t=r.request().headers(),i=r.request().method();return t["Checksum-Id"]=(++this.harData.methodIndex[i]).toString(),{options:{headers:t}}}async completeOriginHeaderInterceptor(r,t,{page:i}){let n=r.request().headers();if(!n.Origin){try{let s=new URL(i.url()).origin;n.Origin=s}catch{}return{options:{headers:n}}}}};o(Hh,"RouteInterceptors");var mc=Hh;var zh=class zh{constructor(r={},t={}){this.browserConfig={devtools:!1,executablePath:process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH??void 0};this.options={fullScreenResolution:!1,defaultTimeout:3e4,defaultNavigationTimeout:3e4,disableWebSecurity:!0};this.navigationPromise={};this.contextClosePromise=void 0;this.eventListeners=[];this.lastSnapshot={selector:void 0,eventCode:void 0};this.snapshotTimeout=3e4;this.cacheScript=!1;this.pagesCounter=0;this.pagesIndexToGuid={};this.onRequestFinished=o(async r=>{try{let t=await r.response();if(!t.ok())return;let i=r.resourceType(),n=r.url(),s=o(async()=>{try{return await t.text()}catch{try{return await(await fetch(n)).text()}catch{return}}},"getBody");if(["document","script","stylesheet"].includes(i))try{let a=await s();if(!a)return;let c={url:n,source:a,type:i};await this.forEachEventListener(u=>{var l;return(l=u.onWebDriverResourceLoaded)==null?void 0:l.call(u,c)})}catch(a){console.error("[WebDriver] requestfinished event handler error",i,n,a)}}catch(t){console.error("[WebDriver] requestfinished event handler error",t)}},"onRequestFinished");this.onPage=o(async r=>{try{await(r==null?void 0:r.route("**/*",async(t,i)=>this.routeInterceptor.intercept(t,i,{page:r})))}catch(t){console.error("[WebDriver] onPage error",t)}},"onPage");this.onFrameNavigated=o(async r=>{let t=r.page();if(t.mainFrame()!==r)return;let i=o(async n=>{await this.forEachEventListener(s=>{var a;return(a=s.onWebDriverPageNavigated)==null?void 0:a.call(s,t,t.url(),n)})},"notifyFrameNavigated");await i(!1),this.navigationPromise[this.getGuid(t)]=new Promise(async n=>{await this.loadScript(t),await i(!0),n()})},"onFrameNavigated");this.navigatingPages={};this.tracing=!1;this.tracingChunk=!1;this.chunkIndex=0;var i;if(this.options={...this.options,...r},this.browserConfig={...this.browserConfig,...t},this.browserConfig.args||(this.browserConfig.args=[]),this.options.disableWebSecurity&&this.browserConfig.args.push("--disable-web-security"),this.browserConfig.args.push("--disable-site-isolation-trials"),this.browserConfig.args.push("--allow-running-insecure-content"),this.options.forceHeadless&&(this.browserConfig.headless=!0,this.browserConfig.devtools=!1),this.options.useProxy)if((i=this.options.webProxy)!=null&&i.server){console.log("[WebDriver] using proxy");let{server:n,username:s,password:a}=this.options.webProxy;this.browserConfig.proxy={server:n,username:s,password:a},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 mc({completeOriginHeader:this.options.completeOriginHeader,recordHar:this.options.recordHAR})}setOnScriptLoad(r){this.onScriptLoad=r}async prepare({storageState:r}={}){if(await this.shutdown(),this.options.useStealth){let i=require("puppeteer-extra-plugin-stealth");$h.chromium.use(i()),this.browser=await $h.chromium.launch(this.browserConfig)}else this.browser=await fo.chromium.launch(this.browserConfig);let t={};return t.bypassCSP=!0,t.ignoreHTTPSErrors=!0,t.baseURL=this.options.baseURL,this.options.timezoneId&&(t.timezoneId=this.options.timezoneId),this.options.fullScreenResolution&&(t.viewport={width:1280,height:720}),r&&(t.storageState=r),this.context=await this.browser.newContext(t),this.options.defaultTimeout&&this.context.setDefaultTimeout(this.options.defaultTimeout),this.options.defaultNavigationTimeout&&this.context.setDefaultNavigationTimeout(this.options.defaultNavigationTimeout),this.pageInjectedScriptOptions=this.getPageInjectedScriptOptions(),this.context.on("page",i=>{this.onPage(i),this.onFrameNavigated(i.mainFrame()),i.on("framenavigated",this.onFrameNavigated)}),this.context.on("close",async()=>{this.contextClosePromise=this.forEachEventListener(i=>{var n;return(n=i.onWebDriverContextClose)==null?void 0:n.call(i)})}),this.activePage=await this.context.newPage(),this.originalPage=this.activePage,this.options.trackLoadedResources&&this.page.on("requestfinished",this.onRequestFinished),this.options.useCDPSession&&(this.cdpSession=await this.context.newCDPSession(this.page)),!0}getGuid(r){return r._guid}switchActivePage(r){let t=this.context.pages().find(i=>this.getGuid(i)===r);return!t||t.isClosed()?(console.error(`[WebDriver] Page with guid ${r} not found or has been closed.`),!1):(this.previousPage=this.activePage,this.activePage=t,!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 t=>{try{await r(t)}catch(i){console.log("WebDriver/forEachEventListener exception",i)}}))}getPageInjectedScriptOptions(){switch(this.options.scriptSource){case"file":return this.options.scriptFile?{path:(0,Xy.join)(process.cwd(),this.options.scriptFile)}:void 0;case"url":return this.options.scriptURL?{url:this.options.scriptURL}:void 0;default:return}}registerEventListener(r){this.eventListeners.push(r)}async loadScript(r,{retriesLeft:t=3,retryWaitMS:i=2e3}={}){var a;if(!this.pageInjectedScriptOptions){console.warn("[WebDriver] Script options not set, skipping script load");return}if(r.isClosed())return;try{if(await r.waitForFunction(()=>!!window.checksum,void 0,{timeout:1e3}))return}catch{}if(r.isClosed())return;try{await r.addScriptTag(this.pageInjectedScriptOptions)}catch(c){if(t>0)return console.warn(`[WebDriver] Failed to add script, trying again in ${i/1e3} seconds, ${t-1} retries left.`,c),await W(i),this.loadScript(r,{retriesLeft:t-1,retryWaitMS:i});throw c}let n=this.getGuid(r),s=Date.now().toString(36)+Math.random().toString(36).substr(2);if(this.navigatingPages[n]=s,this.options.scriptInitWait&&(console.log(`Waiting ${this.options.scriptInitWait}[ms] before onScriptLoad...`),await W(this.options.scriptInitWait),console.log("Done waiting before onScriptLoad")),!r.isClosed()){if(this.navigatingPages[n]&&this.navigatingPages[n]!==s)return console.log("Page navigated again, waiting on new promise..."),this.navigationPromise[n];try{await((a=this.onScriptLoad)==null?void 0:a.call(this,r))}catch(c){console.error("[WebDriver] onScriptLoad error",c)}}}async getScript(){async function r(t){let{exec:i}=require("child_process");return new Promise((n,s)=>{i(t,a=>{a?(console.log("error executing cmd, ",a),s(a)):n()})})}switch(o(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(t){console.log("[web-driver] Failed fetching frontend script",t)}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,t){return this.page.setViewportSize({width:r,height:t})}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:t=!1,onErrorOnly:i=!1}={}){if(t)return r();let n=[],s=o(u=>{n.push(u.text())},"log");this.page.on("console",s);let a,c;try{c=await r()}catch(u){a=u}if(this.page.off("console",s),(!i||a)&&console.log("browser console messages:",n),a)throw a;return c}async takeElementSnapshot(r,t,i={},n={}){if(r===this.lastSnapshot.selector&&t===this.lastSnapshot.eventCode)return{};if(!r)return{};try{let{snapshot:s,elementLocator:a}=await this.takeSnapshot(r,n,{frameLocatorSelector:i.frameLocatorSelector});return this.lastSnapshot={selector:r,eventCode:t},{snapshot:s,elementLocator:a}}catch(s){return console.error("takeElementSnapshot error",s),{}}}getScreenshotTimeout(r=!1){return r?this.snapshotTimeout:this.snapshotTimeout+5e3}async takePageSnapshot(r){let t=this.page.screenshot({...r,timeout:this.getScreenshotTimeout()});return await Promise.race([t,W(this.getScreenshotTimeout(!0))])}async takeSnapshot(r,t,{frameLocatorSelector:i}={}){let n=i?this.page.frameLocator(i).locator(r):this.page.locator(r),s=n.screenshot({...t,timeout:this.getScreenshotTimeout()});return{snapshot:await Promise.race([s,W(this.getScreenshotTimeout(!0))]),elementLocator:n}}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 W(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}};o(zh,"WebDriver");var gc=zh;var Nk={useCDPSession:!0,trackLoadedResources:!0},Kh=class Kh extends gc{constructor(t={},i={devtools:!0},n={}){super({...Nk,...t},i);this.settings={frontendAppSpecificRules:void 0,initTestGenerator:!0,frontendTestGenerationConfig:void 0,useTimeMachine:!1};this.initTestGenerator=o(async t=>{let i={assertionGenerator:!0,sessionRecorder:!0};t===this.timeMachinePage&&(i.assertionGenerator=!1,i.sessionRecorder=!1);try{return await t.waitForFunction(()=>{var n;return!!((n=window.checksum)!=null&&n.testGenerator)}),t.evaluate(async({appSpecificRules:n,config:s,initModules:a})=>{window.checksum.testGenerator.init(n,s,a),n.hasGoals&&await window.checksum.goalTracker.init()},{appSpecificRules:this.settings.frontendAppSpecificRules,config:this.getFrontendTestGenerationConfig(),initModules:i})}catch(n){console.log("initTestGenerator exception",n)}},"initTestGenerator");this.settings={...this.settings,...n},this.settings.initTestGenerator&&this.setOnScriptLoad(this.initTestGenerator)}async prepare(t={}){let i=await super.prepare(t);return this.settings.loadScriptOnPrepare&&await this.loadScript(this.page),await this.page.addInitScript(()=>{window.sessionStorage.setItem("checksumai:disable","true")}),this.settings.useTimeMachine&&(this.timeMachinePage=await this.context.newPage(),await this.page.bringToFront(),await this.loadScript(this.timeMachinePage),await this.timeMachinePage.evaluate(()=>window.checksum.timeMachine.start({firstEventTimestamp:Date.now()}))),i}getTimeMachinePage(){return this.timeMachinePage}getFrontendTestGenerationConfig(){return this.settings.frontendTestGenerationConfig}async getBestMatchingElementSimilarityScore(t){return this.evaluateWithChecksum(async i=>await window.checksum.testGenerator.getBestMatchingElementSimilarityScore(i),t)}async getInteractableElements(){return this.evaluateWithChecksum(async()=>await window.checksum.testGenerator.getInteractableElements())}async getAllInteractableElementsForLastSelectQuery(){return this.evaluateWithChecksum(async()=>await window.checksum.testGenerator.getAllInteractableElementsForLastSelectQuery())}async evaluateWithChecksum(t,i){this.navigationPromise[this.getGuid(this.page)]&&await this.navigationPromise[this.getGuid(this.page)];try{return this.page.evaluate(t,i)}catch(n){throw console.error("evaluateWithChecksum error",n,t.toString()),n}}async overlayInteractableElementsWithChecksumId(t){return this.page.evaluate(i=>window.checksum.testGenerator.overlayInteractableElementsWithChecksumId(i),t)}async postRRwebEvents(t){return this.page.evaluate(i=>window.checksum.testGenerator.postRRwebEvents(i),t)}async getRRwebEvents(t=0){return this.evaluateWithChecksum(async({index:i})=>window.checksum.testGenerator.getRRwebEvents(i),{index:t})}async getGoals(){return await this.evaluateWithChecksum(async()=>window.checksum.goalTracker.getGoals())}async takeElementSnapshot(t,i,n={},s={}){try{let{snapshot:a,elementLocator:c}=await super.takeElementSnapshot(t,i,n);if(!a||!n.takeBodyScreenshot)return a?{snapshot:a}:{};await this.highlightElementByLocator(c,n.mousePosition);let u=await this.takePageSnapshot(s);return await this.clearHighlights(),{snapshot:a,bodySnapshot:u}}catch(a){return console.error("[ChecksumWebDriver] takeElementSnapshot error",a),{}}}async highlightElementByLocator(t,i,n="20px solid rgba(255,0,0,1)"){return this.evaluateWithChecksum(async([s,a,c])=>{window.checksum.testGenerator.highlightElement(s,{highlightStyle:{outline:a},mousePosition:c})},[await t.elementHandle(),n,i])}async clearHighlights(){return this.evaluateWithChecksum(async()=>window.checksum.testGenerator.clearHighlights())}async getInspectedElementSelectionResultByRRwebId(t,i={fromTimeMachine:!1}){return await(i.fromTimeMachine?this.getTimeMachinePage().evaluate.bind(this.getTimeMachinePage()):this.evaluateWithChecksum.bind(this))(([s,a])=>window.checksum.testGenerator.getInspectedElementSelectionResultByRRwebId(s,a),[parseInt(t,10),i])}};o(Kh,"ChecksumWebDriver");var fn=Kh;var Vh=class Vh{constructor(r,t={},i=!0){this.requests=[];this.watcherConfig={minimumWaitTime:250,maximumWaitTime:1e4,followingRequestsWaitTime:250};this.resolved=!0;this.hasMinimumWaitTimePassed=!1;this.useLog=!1;this.logStack=[];this.resolve=o(()=>{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,...t},this.initListeners(r),this.useLog=i}initListeners(r){r.on("request",t=>{var i;this.hasMinimumWaitTimePassed||(i=this.watcherConfig.whitelist)!=null&&i.length&&!this.watcherConfig.whitelist.some(n=>n.test(t.url()))||(this.useLog&&this.logStack.push(`${t.method()} ${t.url().substring(0,60)}`),this.requests.push(t),this.observedRequestsCount+=1)}),r.on("response",t=>{this.requests=this.requests.filter(i=>i!==t.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=[])}};o(Vh,"NetworkWatcher");var pn=Vh;var yc=o(e=>e.name==="up"||e.name==="k"||e.ctrl&&e.name==="p","isUpKey"),Zh=o(e=>e.name==="down"||e.name==="j"||e.ctrl&&e.name==="n","isDownKey"),Jy=o(e=>e.name==="space","isSpaceKey");var Qy=o(e=>"123456789".includes(e.name),"isNumberKey"),eb=o(e=>e.name==="enter"||e.name==="return","isEnterKey");var uf=w(M(),1),Rb=w(Ct(),1);var Fc=require("async_hooks");var Pb=new Fc.AsyncLocalStorage;function uS(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}o(uS,"createStore");function Tb(e,r){let t=uS(e);return Pb.run(t,()=>{r(t)})}o(Tb,"withHooks");function yn(){let e=Pb.getStore();if(!e)throw new Error("[Inquirer] Hook functions can only be called from within a prompt");return e}o(yn,"getStore");function of(){return yn().rl}o(of,"readline");function af(e){let r=o((...t)=>{let i=yn(),n=!1,s=i.handleChange;i.handleChange=()=>{n=!0};let a=e(...t);return n&&s(),i.handleChange=s,a},"wrapped");return Fc.AsyncResource.bind(r)}o(af,"withUpdates");function bn(e){let r=yn(),{index:t}=r,i={get(){return r.hooks[t]},set(s){r.hooks[t]=s},initialized:t in r.hooks},n=e(i);return r.index++,n}o(bn,"withPointer");function Ib(){yn().handleChange()}o(Ib,"handleChange");var kc={queue(e){let r=yn(),{index:t}=r;r.hooksEffect.push(()=>{var n,s;(s=(n=r.hooksCleanup)[t])==null||s.call(n);let i=e(of());if(i!=null&&typeof i!="function")throw new Error("useEffect return value must be a cleanup function or nothing.");r.hooksCleanup[t]=i})},run(){let e=yn();af(()=>{e.hooksEffect.forEach(r=>{r()}),e.hooksEffect.length=0})()}};function ft(e){return bn(r=>{let t=o(n=>{r.get()!==n&&(r.set(n),Ib())},"setFn");if(r.initialized)return[r.get(),t];let i=typeof e=="function"?e():e;return r.set(i),[i,t]})}o(ft,"useState");function mo(e,r){bn(t=>{let i=t.get();(!Array.isArray(i)||r.some((s,a)=>!Object.is(s,i[a])))&&kc.queue(e),t.set(r)})}o(mo,"useEffect");var cf=Rb.default.dots;function lf(e=!1){let[r,t]=ft(0);if(mo(()=>{if(e){let i=setTimeout(()=>{t(r+1)},cf.interval);return()=>clearTimeout(i)}},[e,r]),e){let i=r%cf.frames.length;return uf.default.yellow(cf.frames[i])}return uf.default.green("?")}o(lf,"usePrefix");function hf(e,r){return bn(t=>{let i=t.get();if(!i||i.dependencies.length!==r.length||i.dependencies.some((n,s)=>n!==r[s])){let n=e();return t.set({value:n,dependencies:r}),n}return i.value})}o(hf,"useMemo");function go(e){return ft({current:e})[0]}o(go,"useRef");function ff(e){let r=go(e);r.current=e,mo(t=>{let i=af((n,s)=>{r.current(s,t)});return t.input.on("keypress",i),()=>{t.input.removeListener("keypress",i)}},[])}o(ff,"useKeypress");var Jb=w(M(),1);var Kb=w(Bb(),1),Vb=w(zb(),1);function bo(e,r){return e.split(`
|
|
93
93
|
`).flatMap(t=>(0,Vb.default)(t,r,{trim:!1,hard:!0}).split(`
|
|
94
94
|
`).map(i=>i.trimEnd())).join(`
|
|
95
95
|
`)}o(bo,"breakLines");function Sc(){return(0,Kb.default)({defaultWidth:80,output:of().output})}o(Sc,"readlineWidth");function wS(e,r){return bo(e,r).split(`
|
package/index.js
CHANGED
|
@@ -269,8 +269,8 @@ m2: `).concat(this.mapper2.__debugToString().split(`
|
|
|
269
269
|
`}return w+=k.finalLexState,w},F}(O),ne=function(N){Th(F,N);function F(v,S,x){var k=N.call(this,v)||this;return k.logger=S,k.host=x,k.logPerformance=!1,k}return r(F,"CoreServicesShimObject"),F.prototype.forwardJSONCall=function(v,S){return b(this.logger,v,S,this.logPerformance)},F.prototype.resolveModuleName=function(v,S,x){var k=this;return this.forwardJSONCall("resolveModuleName('".concat(v,"')"),function(){var w=JSON.parse(x),P=e.resolveModuleName(S,e.normalizeSlashes(v),w,k.host),ge=P.resolvedModule?P.resolvedModule.resolvedFileName:void 0;return P.resolvedModule&&P.resolvedModule.extension!==".ts"&&P.resolvedModule.extension!==".tsx"&&P.resolvedModule.extension!==".d.ts"&&(ge=void 0),{resolvedFileName:ge,failedLookupLocations:P.failedLookupLocations,affectingLocations:P.affectingLocations}})},F.prototype.resolveTypeReferenceDirective=function(v,S,x){var k=this;return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(v,")"),function(){var w=JSON.parse(x),P=e.resolveTypeReferenceDirective(S,e.normalizeSlashes(v),w,k.host);return{resolvedFileName:P.resolvedTypeReferenceDirective?P.resolvedTypeReferenceDirective.resolvedFileName:void 0,primary:P.resolvedTypeReferenceDirective?P.resolvedTypeReferenceDirective.primary:!0,failedLookupLocations:P.failedLookupLocations}})},F.prototype.getPreProcessedFileInfo=function(v,S){var x=this;return this.forwardJSONCall("getPreProcessedFileInfo('".concat(v,"')"),function(){var k=e.preProcessFile(e.getSnapshotText(S),!0,!0);return{referencedFiles:x.convertFileReferences(k.referencedFiles),importedFiles:x.convertFileReferences(k.importedFiles),ambientExternalModules:k.ambientExternalModules,isLibFile:k.isLibFile,typeReferenceDirectives:x.convertFileReferences(k.typeReferenceDirectives),libReferenceDirectives:x.convertFileReferences(k.libReferenceDirectives)}})},F.prototype.getAutomaticTypeDirectiveNames=function(v){var S=this;return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(v,"')"),function(){var x=JSON.parse(v);return e.getAutomaticTypeDirectiveNames(x,S.host)})},F.prototype.convertFileReferences=function(v){if(v){for(var S=[],x=0,k=v;x<k.length;x++){var w=k[x];S.push({path:e.normalizeSlashes(w.fileName),position:w.pos,length:w.end-w.pos})}return S}},F.prototype.getTSConfigFileInfo=function(v,S){var x=this;return this.forwardJSONCall("getTSConfigFileInfo('".concat(v,"')"),function(){var k=e.parseJsonText(v,e.getSnapshotText(S)),w=e.normalizeSlashes(v),P=e.parseJsonSourceFileConfigFileContent(k,x.host,e.getDirectoryPath(w),{},w);return{options:P.options,typeAcquisition:P.typeAcquisition,files:P.fileNames,raw:P.raw,errors:m(Hn(Hn([],k.parseDiagnostics,!0),P.errors,!0),`\r
|
|
270
270
|
`)}})},F.prototype.getDefaultCompilationSettings=function(){return this.forwardJSONCall("getDefaultCompilationSettings()",function(){return e.getDefaultCompilerOptions()})},F.prototype.discoverTypings=function(v){var S=this,x=e.createGetCanonicalFileName(!1);return this.forwardJSONCall("discoverTypings()",function(){var k=JSON.parse(v);return S.safeList===void 0&&(S.safeList=e.JsTyping.loadSafeList(S.host,e.toPath(k.safeListPath,k.safeListPath,x))),e.JsTyping.discoverTypings(S.host,function(w){return S.logger.log(w)},k.fileNames,e.toPath(k.projectRootPath,k.projectRootPath,x),S.safeList,k.packageNameToTypingLocation,k.typeAcquisition,k.unresolvedImports,k.typesRegistry,e.emptyOptions)})},F}(O),se=function(){function N(){this._shims=[]}return r(N,"TypeScriptServicesFactory"),N.prototype.getServicesVersion=function(){return e.servicesVersion},N.prototype.createLanguageServiceShim=function(F){try{this.documentRegistry===void 0&&(this.documentRegistry=e.createDocumentRegistry(F.useCaseSensitiveFileNames&&F.useCaseSensitiveFileNames(),F.getCurrentDirectory()));var v=new u(F),S=e.createLanguageService(v,this.documentRegistry,!1);return new le(this,F,S)}catch(x){throw t(F,x),x}},N.prototype.createClassifierShim=function(F){try{return new X(this,F)}catch(v){throw t(F,v),v}},N.prototype.createCoreServicesShim=function(F){try{var v=new g(F);return new ne(this,F,v)}catch(S){throw t(F,S),S}},N.prototype.close=function(){e.clear(this._shims),this.documentRegistry=void 0},N.prototype.registerShim=function(F){this._shims.push(F)},N.prototype.unregisterShim=function(F){for(var v=0;v<this._shims.length;v++)if(this._shims[v]===F){delete this._shims[v];return}throw new Error("Invalid operation")},N}();e.TypeScriptServicesFactory=se})(_r||(_r={}));(function(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:r(function(){return this},"get"),configurable:!0}),__magic__.globalThis=__magic__,typeof globalThis>"u"&&(window.globalThis=window),delete Object.prototype.__magic__}catch{window.globalThis=window}})();(typeof process>"u"||process.browser)&&(globalThis.TypeScript=globalThis.TypeScript||{},globalThis.TypeScript.Services=globalThis.TypeScript.Services||{},globalThis.TypeScript.Services.TypeScriptServicesFactory=_r.TypeScriptServicesFactory,globalThis.toolsVersion=_r.versionMajorMinor);typeof l2<"u"&&l2.exports&&(l2.exports=_r);var _r;(function(e){function t(g,d,b,J){if(Object.defineProperty(X,"name",Ri(Ri({},Object.getOwnPropertyDescriptor(X,"name")),{value:g})),J)for(var O=0,m=Object.keys(J);O<m.length;O++){var h=m[O],le=+h;!isNaN(le)&&e.hasProperty(d,"".concat(le))&&(d[le]=e.Debug.deprecate(d[le],Ri(Ri({},J[le]),{name:g})))}var ae=c(d,b);return X;function X(){for(var ne=[],se=0;se<arguments.length;se++)ne[se]=arguments[se];var N=ae(ne),F=N!==void 0?d[N]:void 0;if(typeof F=="function")return F.apply(void 0,ne);throw new TypeError("Invalid arguments")}}r(t,"createOverload"),e.createOverload=t;function c(g,d){return function(b){for(var J=0;e.hasProperty(g,"".concat(J))&&e.hasProperty(d,"".concat(J));J++){var O=d[J];if(O(b))return J}}}r(c,"createBinder");function u(g){return{overload:r(function(d){return{bind:r(function(b){return{finish:r(function(){return t(g,d,b)},"finish"),deprecate:r(function(J){return{finish:r(function(){return t(g,d,b,J)},"finish")}},"deprecate")}},"bind")}},"overload")}}r(u,"buildOverload"),e.buildOverload=u})(_r||(_r={}));var _r;(function(e){var t={since:"4.0",warnAfter:"4.1",message:"Use the appropriate method on 'ts.factory' or the 'factory' supplied by your transformation context instead."};e.createNodeArray=e.Debug.deprecate(e.factory.createNodeArray,t),e.createNumericLiteral=e.Debug.deprecate(e.factory.createNumericLiteral,t),e.createBigIntLiteral=e.Debug.deprecate(e.factory.createBigIntLiteral,t),e.createStringLiteral=e.Debug.deprecate(e.factory.createStringLiteral,t),e.createStringLiteralFromNode=e.Debug.deprecate(e.factory.createStringLiteralFromNode,t),e.createRegularExpressionLiteral=e.Debug.deprecate(e.factory.createRegularExpressionLiteral,t),e.createLoopVariable=e.Debug.deprecate(e.factory.createLoopVariable,t),e.createUniqueName=e.Debug.deprecate(e.factory.createUniqueName,t),e.createPrivateIdentifier=e.Debug.deprecate(e.factory.createPrivateIdentifier,t),e.createSuper=e.Debug.deprecate(e.factory.createSuper,t),e.createThis=e.Debug.deprecate(e.factory.createThis,t),e.createNull=e.Debug.deprecate(e.factory.createNull,t),e.createTrue=e.Debug.deprecate(e.factory.createTrue,t),e.createFalse=e.Debug.deprecate(e.factory.createFalse,t),e.createModifier=e.Debug.deprecate(e.factory.createModifier,t),e.createModifiersFromModifierFlags=e.Debug.deprecate(e.factory.createModifiersFromModifierFlags,t),e.createQualifiedName=e.Debug.deprecate(e.factory.createQualifiedName,t),e.updateQualifiedName=e.Debug.deprecate(e.factory.updateQualifiedName,t),e.createComputedPropertyName=e.Debug.deprecate(e.factory.createComputedPropertyName,t),e.updateComputedPropertyName=e.Debug.deprecate(e.factory.updateComputedPropertyName,t),e.createTypeParameterDeclaration=e.Debug.deprecate(e.factory.createTypeParameterDeclaration,t),e.updateTypeParameterDeclaration=e.Debug.deprecate(e.factory.updateTypeParameterDeclaration,t),e.createParameter=e.Debug.deprecate(e.factory.createParameterDeclaration,t),e.updateParameter=e.Debug.deprecate(e.factory.updateParameterDeclaration,t),e.createDecorator=e.Debug.deprecate(e.factory.createDecorator,t),e.updateDecorator=e.Debug.deprecate(e.factory.updateDecorator,t),e.createProperty=e.Debug.deprecate(e.factory.createPropertyDeclaration,t),e.updateProperty=e.Debug.deprecate(e.factory.updatePropertyDeclaration,t),e.createMethod=e.Debug.deprecate(e.factory.createMethodDeclaration,t),e.updateMethod=e.Debug.deprecate(e.factory.updateMethodDeclaration,t),e.createConstructor=e.Debug.deprecate(e.factory.createConstructorDeclaration,t),e.updateConstructor=e.Debug.deprecate(e.factory.updateConstructorDeclaration,t),e.createGetAccessor=e.Debug.deprecate(e.factory.createGetAccessorDeclaration,t),e.updateGetAccessor=e.Debug.deprecate(e.factory.updateGetAccessorDeclaration,t),e.createSetAccessor=e.Debug.deprecate(e.factory.createSetAccessorDeclaration,t),e.updateSetAccessor=e.Debug.deprecate(e.factory.updateSetAccessorDeclaration,t),e.createCallSignature=e.Debug.deprecate(e.factory.createCallSignature,t),e.updateCallSignature=e.Debug.deprecate(e.factory.updateCallSignature,t),e.createConstructSignature=e.Debug.deprecate(e.factory.createConstructSignature,t),e.updateConstructSignature=e.Debug.deprecate(e.factory.updateConstructSignature,t),e.updateIndexSignature=e.Debug.deprecate(e.factory.updateIndexSignature,t),e.createKeywordTypeNode=e.Debug.deprecate(e.factory.createKeywordTypeNode,t),e.createTypePredicateNodeWithModifier=e.Debug.deprecate(e.factory.createTypePredicateNode,t),e.updateTypePredicateNodeWithModifier=e.Debug.deprecate(e.factory.updateTypePredicateNode,t),e.createTypeReferenceNode=e.Debug.deprecate(e.factory.createTypeReferenceNode,t),e.updateTypeReferenceNode=e.Debug.deprecate(e.factory.updateTypeReferenceNode,t),e.createFunctionTypeNode=e.Debug.deprecate(e.factory.createFunctionTypeNode,t),e.updateFunctionTypeNode=e.Debug.deprecate(e.factory.updateFunctionTypeNode,t),e.createConstructorTypeNode=e.Debug.deprecate(function(c,u,g){return e.factory.createConstructorTypeNode(void 0,c,u,g)},t),e.updateConstructorTypeNode=e.Debug.deprecate(function(c,u,g,d){return e.factory.updateConstructorTypeNode(c,c.modifiers,u,g,d)},t),e.createTypeQueryNode=e.Debug.deprecate(e.factory.createTypeQueryNode,t),e.updateTypeQueryNode=e.Debug.deprecate(e.factory.updateTypeQueryNode,t),e.createTypeLiteralNode=e.Debug.deprecate(e.factory.createTypeLiteralNode,t),e.updateTypeLiteralNode=e.Debug.deprecate(e.factory.updateTypeLiteralNode,t),e.createArrayTypeNode=e.Debug.deprecate(e.factory.createArrayTypeNode,t),e.updateArrayTypeNode=e.Debug.deprecate(e.factory.updateArrayTypeNode,t),e.createTupleTypeNode=e.Debug.deprecate(e.factory.createTupleTypeNode,t),e.updateTupleTypeNode=e.Debug.deprecate(e.factory.updateTupleTypeNode,t),e.createOptionalTypeNode=e.Debug.deprecate(e.factory.createOptionalTypeNode,t),e.updateOptionalTypeNode=e.Debug.deprecate(e.factory.updateOptionalTypeNode,t),e.createRestTypeNode=e.Debug.deprecate(e.factory.createRestTypeNode,t),e.updateRestTypeNode=e.Debug.deprecate(e.factory.updateRestTypeNode,t),e.createUnionTypeNode=e.Debug.deprecate(e.factory.createUnionTypeNode,t),e.updateUnionTypeNode=e.Debug.deprecate(e.factory.updateUnionTypeNode,t),e.createIntersectionTypeNode=e.Debug.deprecate(e.factory.createIntersectionTypeNode,t),e.updateIntersectionTypeNode=e.Debug.deprecate(e.factory.updateIntersectionTypeNode,t),e.createConditionalTypeNode=e.Debug.deprecate(e.factory.createConditionalTypeNode,t),e.updateConditionalTypeNode=e.Debug.deprecate(e.factory.updateConditionalTypeNode,t),e.createInferTypeNode=e.Debug.deprecate(e.factory.createInferTypeNode,t),e.updateInferTypeNode=e.Debug.deprecate(e.factory.updateInferTypeNode,t),e.createImportTypeNode=e.Debug.deprecate(e.factory.createImportTypeNode,t),e.updateImportTypeNode=e.Debug.deprecate(e.factory.updateImportTypeNode,t),e.createParenthesizedType=e.Debug.deprecate(e.factory.createParenthesizedType,t),e.updateParenthesizedType=e.Debug.deprecate(e.factory.updateParenthesizedType,t),e.createThisTypeNode=e.Debug.deprecate(e.factory.createThisTypeNode,t),e.updateTypeOperatorNode=e.Debug.deprecate(e.factory.updateTypeOperatorNode,t),e.createIndexedAccessTypeNode=e.Debug.deprecate(e.factory.createIndexedAccessTypeNode,t),e.updateIndexedAccessTypeNode=e.Debug.deprecate(e.factory.updateIndexedAccessTypeNode,t),e.createMappedTypeNode=e.Debug.deprecate(e.factory.createMappedTypeNode,t),e.updateMappedTypeNode=e.Debug.deprecate(e.factory.updateMappedTypeNode,t),e.createLiteralTypeNode=e.Debug.deprecate(e.factory.createLiteralTypeNode,t),e.updateLiteralTypeNode=e.Debug.deprecate(e.factory.updateLiteralTypeNode,t),e.createObjectBindingPattern=e.Debug.deprecate(e.factory.createObjectBindingPattern,t),e.updateObjectBindingPattern=e.Debug.deprecate(e.factory.updateObjectBindingPattern,t),e.createArrayBindingPattern=e.Debug.deprecate(e.factory.createArrayBindingPattern,t),e.updateArrayBindingPattern=e.Debug.deprecate(e.factory.updateArrayBindingPattern,t),e.createBindingElement=e.Debug.deprecate(e.factory.createBindingElement,t),e.updateBindingElement=e.Debug.deprecate(e.factory.updateBindingElement,t),e.createArrayLiteral=e.Debug.deprecate(e.factory.createArrayLiteralExpression,t),e.updateArrayLiteral=e.Debug.deprecate(e.factory.updateArrayLiteralExpression,t),e.createObjectLiteral=e.Debug.deprecate(e.factory.createObjectLiteralExpression,t),e.updateObjectLiteral=e.Debug.deprecate(e.factory.updateObjectLiteralExpression,t),e.createPropertyAccess=e.Debug.deprecate(e.factory.createPropertyAccessExpression,t),e.updatePropertyAccess=e.Debug.deprecate(e.factory.updatePropertyAccessExpression,t),e.createPropertyAccessChain=e.Debug.deprecate(e.factory.createPropertyAccessChain,t),e.updatePropertyAccessChain=e.Debug.deprecate(e.factory.updatePropertyAccessChain,t),e.createElementAccess=e.Debug.deprecate(e.factory.createElementAccessExpression,t),e.updateElementAccess=e.Debug.deprecate(e.factory.updateElementAccessExpression,t),e.createElementAccessChain=e.Debug.deprecate(e.factory.createElementAccessChain,t),e.updateElementAccessChain=e.Debug.deprecate(e.factory.updateElementAccessChain,t),e.createCall=e.Debug.deprecate(e.factory.createCallExpression,t),e.updateCall=e.Debug.deprecate(e.factory.updateCallExpression,t),e.createCallChain=e.Debug.deprecate(e.factory.createCallChain,t),e.updateCallChain=e.Debug.deprecate(e.factory.updateCallChain,t),e.createNew=e.Debug.deprecate(e.factory.createNewExpression,t),e.updateNew=e.Debug.deprecate(e.factory.updateNewExpression,t),e.createTypeAssertion=e.Debug.deprecate(e.factory.createTypeAssertion,t),e.updateTypeAssertion=e.Debug.deprecate(e.factory.updateTypeAssertion,t),e.createParen=e.Debug.deprecate(e.factory.createParenthesizedExpression,t),e.updateParen=e.Debug.deprecate(e.factory.updateParenthesizedExpression,t),e.createFunctionExpression=e.Debug.deprecate(e.factory.createFunctionExpression,t),e.updateFunctionExpression=e.Debug.deprecate(e.factory.updateFunctionExpression,t),e.createDelete=e.Debug.deprecate(e.factory.createDeleteExpression,t),e.updateDelete=e.Debug.deprecate(e.factory.updateDeleteExpression,t),e.createTypeOf=e.Debug.deprecate(e.factory.createTypeOfExpression,t),e.updateTypeOf=e.Debug.deprecate(e.factory.updateTypeOfExpression,t),e.createVoid=e.Debug.deprecate(e.factory.createVoidExpression,t),e.updateVoid=e.Debug.deprecate(e.factory.updateVoidExpression,t),e.createAwait=e.Debug.deprecate(e.factory.createAwaitExpression,t),e.updateAwait=e.Debug.deprecate(e.factory.updateAwaitExpression,t),e.createPrefix=e.Debug.deprecate(e.factory.createPrefixUnaryExpression,t),e.updatePrefix=e.Debug.deprecate(e.factory.updatePrefixUnaryExpression,t),e.createPostfix=e.Debug.deprecate(e.factory.createPostfixUnaryExpression,t),e.updatePostfix=e.Debug.deprecate(e.factory.updatePostfixUnaryExpression,t),e.createBinary=e.Debug.deprecate(e.factory.createBinaryExpression,t),e.updateConditional=e.Debug.deprecate(e.factory.updateConditionalExpression,t),e.createTemplateExpression=e.Debug.deprecate(e.factory.createTemplateExpression,t),e.updateTemplateExpression=e.Debug.deprecate(e.factory.updateTemplateExpression,t),e.createTemplateHead=e.Debug.deprecate(e.factory.createTemplateHead,t),e.createTemplateMiddle=e.Debug.deprecate(e.factory.createTemplateMiddle,t),e.createTemplateTail=e.Debug.deprecate(e.factory.createTemplateTail,t),e.createNoSubstitutionTemplateLiteral=e.Debug.deprecate(e.factory.createNoSubstitutionTemplateLiteral,t),e.updateYield=e.Debug.deprecate(e.factory.updateYieldExpression,t),e.createSpread=e.Debug.deprecate(e.factory.createSpreadElement,t),e.updateSpread=e.Debug.deprecate(e.factory.updateSpreadElement,t),e.createOmittedExpression=e.Debug.deprecate(e.factory.createOmittedExpression,t),e.createAsExpression=e.Debug.deprecate(e.factory.createAsExpression,t),e.updateAsExpression=e.Debug.deprecate(e.factory.updateAsExpression,t),e.createNonNullExpression=e.Debug.deprecate(e.factory.createNonNullExpression,t),e.updateNonNullExpression=e.Debug.deprecate(e.factory.updateNonNullExpression,t),e.createNonNullChain=e.Debug.deprecate(e.factory.createNonNullChain,t),e.updateNonNullChain=e.Debug.deprecate(e.factory.updateNonNullChain,t),e.createMetaProperty=e.Debug.deprecate(e.factory.createMetaProperty,t),e.updateMetaProperty=e.Debug.deprecate(e.factory.updateMetaProperty,t),e.createTemplateSpan=e.Debug.deprecate(e.factory.createTemplateSpan,t),e.updateTemplateSpan=e.Debug.deprecate(e.factory.updateTemplateSpan,t),e.createSemicolonClassElement=e.Debug.deprecate(e.factory.createSemicolonClassElement,t),e.createBlock=e.Debug.deprecate(e.factory.createBlock,t),e.updateBlock=e.Debug.deprecate(e.factory.updateBlock,t),e.createVariableStatement=e.Debug.deprecate(e.factory.createVariableStatement,t),e.updateVariableStatement=e.Debug.deprecate(e.factory.updateVariableStatement,t),e.createEmptyStatement=e.Debug.deprecate(e.factory.createEmptyStatement,t),e.createExpressionStatement=e.Debug.deprecate(e.factory.createExpressionStatement,t),e.updateExpressionStatement=e.Debug.deprecate(e.factory.updateExpressionStatement,t),e.createStatement=e.Debug.deprecate(e.factory.createExpressionStatement,t),e.updateStatement=e.Debug.deprecate(e.factory.updateExpressionStatement,t),e.createIf=e.Debug.deprecate(e.factory.createIfStatement,t),e.updateIf=e.Debug.deprecate(e.factory.updateIfStatement,t),e.createDo=e.Debug.deprecate(e.factory.createDoStatement,t),e.updateDo=e.Debug.deprecate(e.factory.updateDoStatement,t),e.createWhile=e.Debug.deprecate(e.factory.createWhileStatement,t),e.updateWhile=e.Debug.deprecate(e.factory.updateWhileStatement,t),e.createFor=e.Debug.deprecate(e.factory.createForStatement,t),e.updateFor=e.Debug.deprecate(e.factory.updateForStatement,t),e.createForIn=e.Debug.deprecate(e.factory.createForInStatement,t),e.updateForIn=e.Debug.deprecate(e.factory.updateForInStatement,t),e.createForOf=e.Debug.deprecate(e.factory.createForOfStatement,t),e.updateForOf=e.Debug.deprecate(e.factory.updateForOfStatement,t),e.createContinue=e.Debug.deprecate(e.factory.createContinueStatement,t),e.updateContinue=e.Debug.deprecate(e.factory.updateContinueStatement,t),e.createBreak=e.Debug.deprecate(e.factory.createBreakStatement,t),e.updateBreak=e.Debug.deprecate(e.factory.updateBreakStatement,t),e.createReturn=e.Debug.deprecate(e.factory.createReturnStatement,t),e.updateReturn=e.Debug.deprecate(e.factory.updateReturnStatement,t),e.createWith=e.Debug.deprecate(e.factory.createWithStatement,t),e.updateWith=e.Debug.deprecate(e.factory.updateWithStatement,t),e.createSwitch=e.Debug.deprecate(e.factory.createSwitchStatement,t),e.updateSwitch=e.Debug.deprecate(e.factory.updateSwitchStatement,t),e.createLabel=e.Debug.deprecate(e.factory.createLabeledStatement,t),e.updateLabel=e.Debug.deprecate(e.factory.updateLabeledStatement,t),e.createThrow=e.Debug.deprecate(e.factory.createThrowStatement,t),e.updateThrow=e.Debug.deprecate(e.factory.updateThrowStatement,t),e.createTry=e.Debug.deprecate(e.factory.createTryStatement,t),e.updateTry=e.Debug.deprecate(e.factory.updateTryStatement,t),e.createDebuggerStatement=e.Debug.deprecate(e.factory.createDebuggerStatement,t),e.createVariableDeclarationList=e.Debug.deprecate(e.factory.createVariableDeclarationList,t),e.updateVariableDeclarationList=e.Debug.deprecate(e.factory.updateVariableDeclarationList,t),e.createFunctionDeclaration=e.Debug.deprecate(e.factory.createFunctionDeclaration,t),e.updateFunctionDeclaration=e.Debug.deprecate(e.factory.updateFunctionDeclaration,t),e.createClassDeclaration=e.Debug.deprecate(e.factory.createClassDeclaration,t),e.updateClassDeclaration=e.Debug.deprecate(e.factory.updateClassDeclaration,t),e.createInterfaceDeclaration=e.Debug.deprecate(e.factory.createInterfaceDeclaration,t),e.updateInterfaceDeclaration=e.Debug.deprecate(e.factory.updateInterfaceDeclaration,t),e.createTypeAliasDeclaration=e.Debug.deprecate(e.factory.createTypeAliasDeclaration,t),e.updateTypeAliasDeclaration=e.Debug.deprecate(e.factory.updateTypeAliasDeclaration,t),e.createEnumDeclaration=e.Debug.deprecate(e.factory.createEnumDeclaration,t),e.updateEnumDeclaration=e.Debug.deprecate(e.factory.updateEnumDeclaration,t),e.createModuleDeclaration=e.Debug.deprecate(e.factory.createModuleDeclaration,t),e.updateModuleDeclaration=e.Debug.deprecate(e.factory.updateModuleDeclaration,t),e.createModuleBlock=e.Debug.deprecate(e.factory.createModuleBlock,t),e.updateModuleBlock=e.Debug.deprecate(e.factory.updateModuleBlock,t),e.createCaseBlock=e.Debug.deprecate(e.factory.createCaseBlock,t),e.updateCaseBlock=e.Debug.deprecate(e.factory.updateCaseBlock,t),e.createNamespaceExportDeclaration=e.Debug.deprecate(e.factory.createNamespaceExportDeclaration,t),e.updateNamespaceExportDeclaration=e.Debug.deprecate(e.factory.updateNamespaceExportDeclaration,t),e.createImportEqualsDeclaration=e.Debug.deprecate(e.factory.createImportEqualsDeclaration,t),e.updateImportEqualsDeclaration=e.Debug.deprecate(e.factory.updateImportEqualsDeclaration,t),e.createImportDeclaration=e.Debug.deprecate(e.factory.createImportDeclaration,t),e.updateImportDeclaration=e.Debug.deprecate(e.factory.updateImportDeclaration,t),e.createNamespaceImport=e.Debug.deprecate(e.factory.createNamespaceImport,t),e.updateNamespaceImport=e.Debug.deprecate(e.factory.updateNamespaceImport,t),e.createNamedImports=e.Debug.deprecate(e.factory.createNamedImports,t),e.updateNamedImports=e.Debug.deprecate(e.factory.updateNamedImports,t),e.createImportSpecifier=e.Debug.deprecate(e.factory.createImportSpecifier,t),e.updateImportSpecifier=e.Debug.deprecate(e.factory.updateImportSpecifier,t),e.createExportAssignment=e.Debug.deprecate(e.factory.createExportAssignment,t),e.updateExportAssignment=e.Debug.deprecate(e.factory.updateExportAssignment,t),e.createNamedExports=e.Debug.deprecate(e.factory.createNamedExports,t),e.updateNamedExports=e.Debug.deprecate(e.factory.updateNamedExports,t),e.createExportSpecifier=e.Debug.deprecate(e.factory.createExportSpecifier,t),e.updateExportSpecifier=e.Debug.deprecate(e.factory.updateExportSpecifier,t),e.createExternalModuleReference=e.Debug.deprecate(e.factory.createExternalModuleReference,t),e.updateExternalModuleReference=e.Debug.deprecate(e.factory.updateExternalModuleReference,t),e.createJSDocTypeExpression=e.Debug.deprecate(e.factory.createJSDocTypeExpression,t),e.createJSDocTypeTag=e.Debug.deprecate(e.factory.createJSDocTypeTag,t),e.createJSDocReturnTag=e.Debug.deprecate(e.factory.createJSDocReturnTag,t),e.createJSDocThisTag=e.Debug.deprecate(e.factory.createJSDocThisTag,t),e.createJSDocComment=e.Debug.deprecate(e.factory.createJSDocComment,t),e.createJSDocParameterTag=e.Debug.deprecate(e.factory.createJSDocParameterTag,t),e.createJSDocClassTag=e.Debug.deprecate(e.factory.createJSDocClassTag,t),e.createJSDocAugmentsTag=e.Debug.deprecate(e.factory.createJSDocAugmentsTag,t),e.createJSDocEnumTag=e.Debug.deprecate(e.factory.createJSDocEnumTag,t),e.createJSDocTemplateTag=e.Debug.deprecate(e.factory.createJSDocTemplateTag,t),e.createJSDocTypedefTag=e.Debug.deprecate(e.factory.createJSDocTypedefTag,t),e.createJSDocCallbackTag=e.Debug.deprecate(e.factory.createJSDocCallbackTag,t),e.createJSDocSignature=e.Debug.deprecate(e.factory.createJSDocSignature,t),e.createJSDocPropertyTag=e.Debug.deprecate(e.factory.createJSDocPropertyTag,t),e.createJSDocTypeLiteral=e.Debug.deprecate(e.factory.createJSDocTypeLiteral,t),e.createJSDocImplementsTag=e.Debug.deprecate(e.factory.createJSDocImplementsTag,t),e.createJSDocAuthorTag=e.Debug.deprecate(e.factory.createJSDocAuthorTag,t),e.createJSDocPublicTag=e.Debug.deprecate(e.factory.createJSDocPublicTag,t),e.createJSDocPrivateTag=e.Debug.deprecate(e.factory.createJSDocPrivateTag,t),e.createJSDocProtectedTag=e.Debug.deprecate(e.factory.createJSDocProtectedTag,t),e.createJSDocReadonlyTag=e.Debug.deprecate(e.factory.createJSDocReadonlyTag,t),e.createJSDocTag=e.Debug.deprecate(e.factory.createJSDocUnknownTag,t),e.createJsxElement=e.Debug.deprecate(e.factory.createJsxElement,t),e.updateJsxElement=e.Debug.deprecate(e.factory.updateJsxElement,t),e.createJsxSelfClosingElement=e.Debug.deprecate(e.factory.createJsxSelfClosingElement,t),e.updateJsxSelfClosingElement=e.Debug.deprecate(e.factory.updateJsxSelfClosingElement,t),e.createJsxOpeningElement=e.Debug.deprecate(e.factory.createJsxOpeningElement,t),e.updateJsxOpeningElement=e.Debug.deprecate(e.factory.updateJsxOpeningElement,t),e.createJsxClosingElement=e.Debug.deprecate(e.factory.createJsxClosingElement,t),e.updateJsxClosingElement=e.Debug.deprecate(e.factory.updateJsxClosingElement,t),e.createJsxFragment=e.Debug.deprecate(e.factory.createJsxFragment,t),e.createJsxText=e.Debug.deprecate(e.factory.createJsxText,t),e.updateJsxText=e.Debug.deprecate(e.factory.updateJsxText,t),e.createJsxOpeningFragment=e.Debug.deprecate(e.factory.createJsxOpeningFragment,t),e.createJsxJsxClosingFragment=e.Debug.deprecate(e.factory.createJsxJsxClosingFragment,t),e.updateJsxFragment=e.Debug.deprecate(e.factory.updateJsxFragment,t),e.createJsxAttribute=e.Debug.deprecate(e.factory.createJsxAttribute,t),e.updateJsxAttribute=e.Debug.deprecate(e.factory.updateJsxAttribute,t),e.createJsxAttributes=e.Debug.deprecate(e.factory.createJsxAttributes,t),e.updateJsxAttributes=e.Debug.deprecate(e.factory.updateJsxAttributes,t),e.createJsxSpreadAttribute=e.Debug.deprecate(e.factory.createJsxSpreadAttribute,t),e.updateJsxSpreadAttribute=e.Debug.deprecate(e.factory.updateJsxSpreadAttribute,t),e.createJsxExpression=e.Debug.deprecate(e.factory.createJsxExpression,t),e.updateJsxExpression=e.Debug.deprecate(e.factory.updateJsxExpression,t),e.createCaseClause=e.Debug.deprecate(e.factory.createCaseClause,t),e.updateCaseClause=e.Debug.deprecate(e.factory.updateCaseClause,t),e.createDefaultClause=e.Debug.deprecate(e.factory.createDefaultClause,t),e.updateDefaultClause=e.Debug.deprecate(e.factory.updateDefaultClause,t),e.createHeritageClause=e.Debug.deprecate(e.factory.createHeritageClause,t),e.updateHeritageClause=e.Debug.deprecate(e.factory.updateHeritageClause,t),e.createCatchClause=e.Debug.deprecate(e.factory.createCatchClause,t),e.updateCatchClause=e.Debug.deprecate(e.factory.updateCatchClause,t),e.createPropertyAssignment=e.Debug.deprecate(e.factory.createPropertyAssignment,t),e.updatePropertyAssignment=e.Debug.deprecate(e.factory.updatePropertyAssignment,t),e.createShorthandPropertyAssignment=e.Debug.deprecate(e.factory.createShorthandPropertyAssignment,t),e.updateShorthandPropertyAssignment=e.Debug.deprecate(e.factory.updateShorthandPropertyAssignment,t),e.createSpreadAssignment=e.Debug.deprecate(e.factory.createSpreadAssignment,t),e.updateSpreadAssignment=e.Debug.deprecate(e.factory.updateSpreadAssignment,t),e.createEnumMember=e.Debug.deprecate(e.factory.createEnumMember,t),e.updateEnumMember=e.Debug.deprecate(e.factory.updateEnumMember,t),e.updateSourceFileNode=e.Debug.deprecate(e.factory.updateSourceFile,t),e.createNotEmittedStatement=e.Debug.deprecate(e.factory.createNotEmittedStatement,t),e.createPartiallyEmittedExpression=e.Debug.deprecate(e.factory.createPartiallyEmittedExpression,t),e.updatePartiallyEmittedExpression=e.Debug.deprecate(e.factory.updatePartiallyEmittedExpression,t),e.createCommaList=e.Debug.deprecate(e.factory.createCommaListExpression,t),e.updateCommaList=e.Debug.deprecate(e.factory.updateCommaListExpression,t),e.createBundle=e.Debug.deprecate(e.factory.createBundle,t),e.updateBundle=e.Debug.deprecate(e.factory.updateBundle,t),e.createImmediatelyInvokedFunctionExpression=e.Debug.deprecate(e.factory.createImmediatelyInvokedFunctionExpression,t),e.createImmediatelyInvokedArrowFunction=e.Debug.deprecate(e.factory.createImmediatelyInvokedArrowFunction,t),e.createVoidZero=e.Debug.deprecate(e.factory.createVoidZero,t),e.createExportDefault=e.Debug.deprecate(e.factory.createExportDefault,t),e.createExternalModuleExport=e.Debug.deprecate(e.factory.createExternalModuleExport,t),e.createNamespaceExport=e.Debug.deprecate(e.factory.createNamespaceExport,t),e.updateNamespaceExport=e.Debug.deprecate(e.factory.updateNamespaceExport,t),e.createToken=e.Debug.deprecate(r(function(u){return e.factory.createToken(u)},"createToken"),t),e.createIdentifier=e.Debug.deprecate(r(function(u){return e.factory.createIdentifier(u,void 0,void 0)},"createIdentifier"),t),e.createTempVariable=e.Debug.deprecate(r(function(u){return e.factory.createTempVariable(u,void 0)},"createTempVariable"),t),e.getGeneratedNameForNode=e.Debug.deprecate(r(function(u){return e.factory.getGeneratedNameForNode(u,void 0)},"getGeneratedNameForNode"),t),e.createOptimisticUniqueName=e.Debug.deprecate(r(function(u){return e.factory.createUniqueName(u,16)},"createOptimisticUniqueName"),t),e.createFileLevelUniqueName=e.Debug.deprecate(r(function(u){return e.factory.createUniqueName(u,48)},"createFileLevelUniqueName"),t),e.createIndexSignature=e.Debug.deprecate(r(function(u,g,d,b){return e.factory.createIndexSignature(u,g,d,b)},"createIndexSignature"),t),e.createTypePredicateNode=e.Debug.deprecate(r(function(u,g){return e.factory.createTypePredicateNode(void 0,u,g)},"createTypePredicateNode"),t),e.updateTypePredicateNode=e.Debug.deprecate(r(function(u,g,d){return e.factory.updateTypePredicateNode(u,void 0,g,d)},"updateTypePredicateNode"),t),e.createLiteral=e.Debug.deprecate(r(function(u){return typeof u=="number"?e.factory.createNumericLiteral(u):typeof u=="object"&&"base10Value"in u?e.factory.createBigIntLiteral(u):typeof u=="boolean"?u?e.factory.createTrue():e.factory.createFalse():typeof u=="string"?e.factory.createStringLiteral(u,void 0):e.factory.createStringLiteralFromNode(u)},"createLiteral"),{since:"4.0",warnAfter:"4.1",message:"Use `factory.createStringLiteral`, `factory.createStringLiteralFromNode`, `factory.createNumericLiteral`, `factory.createBigIntLiteral`, `factory.createTrue`, `factory.createFalse`, or the factory supplied by your transformation context instead."}),e.createMethodSignature=e.Debug.deprecate(r(function(u,g,d,b,J){return e.factory.createMethodSignature(void 0,b,J,u,g,d)},"createMethodSignature"),t),e.updateMethodSignature=e.Debug.deprecate(r(function(u,g,d,b,J,O){return e.factory.updateMethodSignature(u,u.modifiers,J,O,g,d,b)},"updateMethodSignature"),t),e.createTypeOperatorNode=e.Debug.deprecate(r(function(u,g){var d;return g?d=u:(g=u,d=141),e.factory.createTypeOperatorNode(d,g)},"createTypeOperatorNode"),t),e.createTaggedTemplate=e.Debug.deprecate(r(function(u,g,d){var b;return d?b=g:d=g,e.factory.createTaggedTemplateExpression(u,b,d)},"createTaggedTemplate"),t),e.updateTaggedTemplate=e.Debug.deprecate(r(function(u,g,d,b){var J;return b?J=d:b=d,e.factory.updateTaggedTemplateExpression(u,g,J,b)},"updateTaggedTemplate"),t),e.updateBinary=e.Debug.deprecate(r(function(u,g,d,b){return b===void 0&&(b=u.operatorToken),typeof b=="number"&&(b=b===u.operatorToken.kind?u.operatorToken:e.factory.createToken(b)),e.factory.updateBinaryExpression(u,g,b,d)},"updateBinary"),t),e.createConditional=e.Debug.deprecate(r(function(u,g,d,b,J){return arguments.length===5?e.factory.createConditionalExpression(u,g,d,b,J):arguments.length===3?e.factory.createConditionalExpression(u,e.factory.createToken(57),g,e.factory.createToken(58),d):e.Debug.fail("Argument count mismatch")},"createConditional"),t),e.createYield=e.Debug.deprecate(r(function(u,g){var d;return g?d=u:g=u,e.factory.createYieldExpression(d,g)},"createYield"),t),e.createClassExpression=e.Debug.deprecate(r(function(u,g,d,b,J){return e.factory.createClassExpression(void 0,u,g,d,b,J)},"createClassExpression"),t),e.updateClassExpression=e.Debug.deprecate(r(function(u,g,d,b,J,O){return e.factory.updateClassExpression(u,void 0,g,d,b,J,O)},"updateClassExpression"),t),e.createPropertySignature=e.Debug.deprecate(r(function(u,g,d,b,J){var O=e.factory.createPropertySignature(u,g,d,b);return O.initializer=J,O},"createPropertySignature"),t),e.updatePropertySignature=e.Debug.deprecate(r(function(u,g,d,b,J,O){var m=e.factory.updatePropertySignature(u,g,d,b,J);return u.initializer!==O&&(m===u&&(m=e.factory.cloneNode(u)),m.initializer=O),m},"updatePropertySignature"),t),e.createExpressionWithTypeArguments=e.Debug.deprecate(r(function(u,g){return e.factory.createExpressionWithTypeArguments(g,u)},"createExpressionWithTypeArguments"),t),e.updateExpressionWithTypeArguments=e.Debug.deprecate(r(function(u,g,d){return e.factory.updateExpressionWithTypeArguments(u,d,g)},"updateExpressionWithTypeArguments"),t),e.createArrowFunction=e.Debug.deprecate(r(function(u,g,d,b,J,O){return arguments.length===6?e.factory.createArrowFunction(u,g,d,b,J,O):arguments.length===5?e.factory.createArrowFunction(u,g,d,b,void 0,J):e.Debug.fail("Argument count mismatch")},"createArrowFunction"),t),e.updateArrowFunction=e.Debug.deprecate(r(function(u,g,d,b,J,O,m){return arguments.length===7?e.factory.updateArrowFunction(u,g,d,b,J,O,m):arguments.length===6?e.factory.updateArrowFunction(u,g,d,b,J,u.equalsGreaterThanToken,O):e.Debug.fail("Argument count mismatch")},"updateArrowFunction"),t),e.createVariableDeclaration=e.Debug.deprecate(r(function(u,g,d,b){return arguments.length===4?e.factory.createVariableDeclaration(u,g,d,b):arguments.length>=1&&arguments.length<=3?e.factory.createVariableDeclaration(u,void 0,g,d):e.Debug.fail("Argument count mismatch")},"createVariableDeclaration"),t),e.updateVariableDeclaration=e.Debug.deprecate(r(function(u,g,d,b,J){return arguments.length===5?e.factory.updateVariableDeclaration(u,g,d,b,J):arguments.length===4?e.factory.updateVariableDeclaration(u,g,u.exclamationToken,d,b):e.Debug.fail("Argument count mismatch")},"updateVariableDeclaration"),t),e.createImportClause=e.Debug.deprecate(r(function(u,g,d){return d===void 0&&(d=!1),e.factory.createImportClause(d,u,g)},"createImportClause"),t),e.updateImportClause=e.Debug.deprecate(r(function(u,g,d,b){return e.factory.updateImportClause(u,b,g,d)},"updateImportClause"),t),e.createExportDeclaration=e.Debug.deprecate(r(function(u,g,d,b,J){return J===void 0&&(J=!1),e.factory.createExportDeclaration(u,g,J,d,b)},"createExportDeclaration"),t),e.updateExportDeclaration=e.Debug.deprecate(r(function(u,g,d,b,J,O){return e.factory.updateExportDeclaration(u,g,d,O,b,J,u.assertClause)},"updateExportDeclaration"),t),e.createJSDocParamTag=e.Debug.deprecate(r(function(u,g,d,b){return e.factory.createJSDocParameterTag(void 0,u,g,d,!1,b?e.factory.createNodeArray([e.factory.createJSDocText(b)]):void 0)},"createJSDocParamTag"),t),e.createComma=e.Debug.deprecate(r(function(u,g){return e.factory.createComma(u,g)},"createComma"),t),e.createLessThan=e.Debug.deprecate(r(function(u,g){return e.factory.createLessThan(u,g)},"createLessThan"),t),e.createAssignment=e.Debug.deprecate(r(function(u,g){return e.factory.createAssignment(u,g)},"createAssignment"),t),e.createStrictEquality=e.Debug.deprecate(r(function(u,g){return e.factory.createStrictEquality(u,g)},"createStrictEquality"),t),e.createStrictInequality=e.Debug.deprecate(r(function(u,g){return e.factory.createStrictInequality(u,g)},"createStrictInequality"),t),e.createAdd=e.Debug.deprecate(r(function(u,g){return e.factory.createAdd(u,g)},"createAdd"),t),e.createSubtract=e.Debug.deprecate(r(function(u,g){return e.factory.createSubtract(u,g)},"createSubtract"),t),e.createLogicalAnd=e.Debug.deprecate(r(function(u,g){return e.factory.createLogicalAnd(u,g)},"createLogicalAnd"),t),e.createLogicalOr=e.Debug.deprecate(r(function(u,g){return e.factory.createLogicalOr(u,g)},"createLogicalOr"),t),e.createPostfixIncrement=e.Debug.deprecate(r(function(u){return e.factory.createPostfixIncrement(u)},"createPostfixIncrement"),t),e.createLogicalNot=e.Debug.deprecate(r(function(u){return e.factory.createLogicalNot(u)},"createLogicalNot"),t),e.createNode=e.Debug.deprecate(r(function(u,g,d){return g===void 0&&(g=0),d===void 0&&(d=0),e.setTextRangePosEnd(u===308?e.parseBaseNodeFactory.createBaseSourceFileNode(u):u===79?e.parseBaseNodeFactory.createBaseIdentifierNode(u):u===80?e.parseBaseNodeFactory.createBasePrivateIdentifierNode(u):e.isNodeKind(u)?e.parseBaseNodeFactory.createBaseNode(u):e.parseBaseNodeFactory.createBaseTokenNode(u),g,d)},"createNode"),{since:"4.0",warnAfter:"4.1",message:"Use an appropriate `factory` method instead."}),e.getMutableClone=e.Debug.deprecate(r(function(u){var g=e.factory.cloneNode(u);return e.setTextRange(g,u),e.setParent(g,u.parent),g},"getMutableClone"),{since:"4.0",warnAfter:"4.1",message:"Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`."})})(_r||(_r={}));var _r;(function(e){e.isTypeAssertion=e.Debug.deprecate(r(function(c){return c.kind===213},"isTypeAssertion"),{since:"4.0",warnAfter:"4.1",message:"Use `isTypeAssertionExpression` instead."})})(_r||(_r={}));var _r;(function(e){e.isIdentifierOrPrivateIdentifier=e.Debug.deprecate(r(function(c){return e.isMemberName(c)},"isIdentifierOrPrivateIdentifier"),{since:"4.2",warnAfter:"4.3",message:"Use `isMemberName` instead."})})(_r||(_r={}));var _r;(function(e){function t(u){var g=u.createConstructorTypeNode,d=u.updateConstructorTypeNode;u.createConstructorTypeNode=e.buildOverload("createConstructorTypeNode").overload({0:function(b,J,O,m){return g(b,J,O,m)},1:function(b,J,O){return g(void 0,b,J,O)}}).bind({0:function(b){return b.length===4},1:function(b){return b.length===3}}).deprecate({1:{since:"4.2",warnAfter:"4.3",message:"Use the overload that accepts 'modifiers'"}}).finish(),u.updateConstructorTypeNode=e.buildOverload("updateConstructorTypeNode").overload({0:function(b,J,O,m,h){return d(b,J,O,m,h)},1:function(b,J,O,m){return d(b,b.modifiers,J,O,m)}}).bind({0:function(b){return b.length===5},1:function(b){return b.length===4}}).deprecate({1:{since:"4.2",warnAfter:"4.3",message:"Use the overload that accepts 'modifiers'"}}).finish()}r(t,"patchNodeFactory");var c=e.createNodeFactory;e.createNodeFactory=function(u,g){var d=c(u,g);return t(d),d},t(e.factory)})(_r||(_r={}));var _r;(function(e){function t(u){var g=u.createImportTypeNode,d=u.updateImportTypeNode;u.createImportTypeNode=e.buildOverload("createImportTypeNode").overload({0:function(b,J,O,m,h){return g(b,J,O,m,h)},1:function(b,J,O,m){return g(b,void 0,J,O,m)}}).bind({0:function(b){var J=b[1],O=b[2],m=b[3],h=b[4];return(J===void 0||e.isImportTypeAssertionContainer(J))&&(O===void 0||!e.isArray(O))&&(m===void 0||e.isArray(m))&&(h===void 0||typeof h=="boolean")},1:function(b){var J=b[1],O=b[2],m=b[3],h=b[4];return h===void 0&&(J===void 0||e.isEntityName(J))&&(O===void 0||e.isArray(O))&&(m===void 0||typeof m=="boolean")}}).deprecate({1:{since:"4.6",warnAfter:"4.7",message:"Use the overload that accepts 'assertions'"}}).finish(),u.updateImportTypeNode=e.buildOverload("updateImportTypeNode").overload({0:function(b,J,O,m,h,le){return d(b,J,O,m,h,le)},1:function(b,J,O,m,h){return d(b,J,b.assertions,O,m,h)}}).bind({0:function(b){var J=b[2],O=b[3],m=b[4],h=b[5];return(J===void 0||e.isImportTypeAssertionContainer(J))&&(O===void 0||!e.isArray(O))&&(m===void 0||e.isArray(m))&&(h===void 0||typeof h=="boolean")},1:function(b){var J=b[2],O=b[3],m=b[4],h=b[5];return h===void 0&&(J===void 0||e.isEntityName(J))&&(O===void 0||e.isArray(O))&&(m===void 0||typeof m=="boolean")}}).deprecate({1:{since:"4.6",warnAfter:"4.7",message:"Use the overload that accepts 'assertions'"}}).finish()}r(t,"patchNodeFactory");var c=e.createNodeFactory;e.createNodeFactory=function(u,g){var d=c(u,g);return t(d),d},t(e.factory)})(_r||(_r={}));var _r;(function(e){function t(u){var g=u.createTypeParameterDeclaration,d=u.updateTypeParameterDeclaration;u.createTypeParameterDeclaration=e.buildOverload("createTypeParameterDeclaration").overload({0:function(b,J,O,m){return g(b,J,O,m)},1:function(b,J,O){return g(void 0,b,J,O)}}).bind({0:function(b){var J=b[0];return J===void 0||e.isArray(J)},1:function(b){var J=b[0];return J!==void 0&&!e.isArray(J)}}).deprecate({1:{since:"4.7",warnAfter:"4.8",message:"Use the overload that accepts 'modifiers'"}}).finish(),u.updateTypeParameterDeclaration=e.buildOverload("updateTypeParameterDeclaration").overload({0:function(b,J,O,m,h){return d(b,J,O,m,h)},1:function(b,J,O,m){return d(b,b.modifiers,J,O,m)}}).bind({0:function(b){var J=b[1];return J===void 0||e.isArray(J)},1:function(b){var J=b[1];return J!==void 0&&!e.isArray(J)}}).deprecate({1:{since:"4.7",warnAfter:"4.8",message:"Use the overload that accepts 'modifiers'"}}).finish()}r(t,"patchNodeFactory");var c=e.createNodeFactory;e.createNodeFactory=function(u,g){var d=c(u,g);return t(d),d},t(e.factory)})(_r||(_r={}));var _r;(function(e){var t={since:"4.8",warnAfter:"4.9.0-0",message:"Decorators have been combined with modifiers. Callers should switch to an overload that does not accept a 'decorators' parameter."},c={since:"4.8",warnAfter:"4.9.0-0",message:"Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter."},u={since:"4.8",warnAfter:"4.9.0-0",message:"Decorators and modifiers are no longer supported for this function. Callers should switch to an overload that does not accept the 'decorators' and 'modifiers' parameters."};function g(b){var J=b.createParameterDeclaration,O=b.updateParameterDeclaration,m=b.createPropertyDeclaration,h=b.updatePropertyDeclaration,le=b.createMethodDeclaration,ae=b.updateMethodDeclaration,X=b.createConstructorDeclaration,ne=b.updateConstructorDeclaration,se=b.createGetAccessorDeclaration,N=b.updateGetAccessorDeclaration,F=b.createSetAccessorDeclaration,v=b.updateSetAccessorDeclaration,S=b.createIndexSignature,x=b.updateIndexSignature,k=b.createClassStaticBlockDeclaration,w=b.updateClassStaticBlockDeclaration,P=b.createClassExpression,ge=b.updateClassExpression,De=b.createFunctionDeclaration,re=b.updateFunctionDeclaration,j=b.createClassDeclaration,Y=b.updateClassDeclaration,$=b.createInterfaceDeclaration,E=b.updateInterfaceDeclaration,z=b.createTypeAliasDeclaration,ue=b.updateTypeAliasDeclaration,W=b.createEnumDeclaration,B=b.updateEnumDeclaration,R=b.createModuleDeclaration,G=b.updateModuleDeclaration,ee=b.createImportEqualsDeclaration,ie=b.updateImportEqualsDeclaration,be=b.createImportDeclaration,A=b.updateImportDeclaration,I=b.createExportAssignment,M=b.updateExportAssignment,oe=b.createExportDeclaration,q=b.updateExportDeclaration;b.createParameterDeclaration=e.buildOverload("createParameterDeclaration").overload({0:function(_,L,U,Q,K,ve){return J(_,L,U,Q,K,ve)},1:function(_,L,U,Q,K,ve,me){return J(e.concatenate(_,L),U,Q,K,ve,me)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6];return me===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||typeof U=="string"||e.isBindingName(U))&&(Q===void 0||typeof Q=="object"&&e.isQuestionToken(Q))&&(K===void 0||e.isTypeNode(K))&&(ve===void 0||e.isExpression(ve))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6];return(L===void 0||e.isArray(L))&&(U===void 0||typeof U=="object"&&e.isDotDotDotToken(U))&&(Q===void 0||typeof Q=="string"||e.isBindingName(Q))&&(K===void 0||e.isQuestionToken(K))&&(ve===void 0||e.isTypeNode(ve))&&(me===void 0||e.isExpression(me))}}).deprecate({1:t}).finish(),b.updateParameterDeclaration=e.buildOverload("updateParameterDeclaration").overload({0:function(_,L,U,Q,K,ve,me){return O(_,L,U,Q,K,ve,me)},1:function(_,L,U,Q,K,ve,me,Ke){return O(_,e.concatenate(L,U),Q,K,ve,me,Ke)}}).bind({0:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6],me=_[7];return me===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||typeof U=="string"||e.isBindingName(U))&&(Q===void 0||typeof Q=="object"&&e.isQuestionToken(Q))&&(K===void 0||e.isTypeNode(K))&&(ve===void 0||e.isExpression(ve))},1:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6],me=_[7];return(L===void 0||e.isArray(L))&&(U===void 0||typeof U=="object"&&e.isDotDotDotToken(U))&&(Q===void 0||typeof Q=="string"||e.isBindingName(Q))&&(K===void 0||e.isQuestionToken(K))&&(ve===void 0||e.isTypeNode(ve))&&(me===void 0||e.isExpression(me))}}).deprecate({1:t}).finish(),b.createPropertyDeclaration=e.buildOverload("createPropertyDeclaration").overload({0:function(_,L,U,Q,K){return m(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return m(e.concatenate(_,L),U,Q,K,ve)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return ve===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||typeof U=="object"&&e.isQuestionOrExclamationToken(U))&&(Q===void 0||e.isTypeNode(Q))&&(K===void 0||e.isExpression(K))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return(L===void 0||e.isArray(L))&&(U===void 0||typeof U=="string"||e.isPropertyName(U))&&(Q===void 0||e.isQuestionOrExclamationToken(Q))&&(K===void 0||e.isTypeNode(K))&&(ve===void 0||e.isExpression(ve))}}).deprecate({1:t}).finish(),b.updatePropertyDeclaration=e.buildOverload("updatePropertyDeclaration").overload({0:function(_,L,U,Q,K,ve){return h(_,L,U,Q,K,ve)},1:function(_,L,U,Q,K,ve,me){return h(_,e.concatenate(L,U),Q,K,ve,me)}}).bind({0:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6];return ve===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||typeof U=="object"&&e.isQuestionOrExclamationToken(U))&&(Q===void 0||e.isTypeNode(Q))&&(K===void 0||e.isExpression(K))},1:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6];return(L===void 0||e.isArray(L))&&(U===void 0||typeof U=="string"||e.isPropertyName(U))&&(Q===void 0||e.isQuestionOrExclamationToken(Q))&&(K===void 0||e.isTypeNode(K))&&(ve===void 0||e.isExpression(ve))}}).deprecate({1:t}).finish(),b.createMethodDeclaration=e.buildOverload("createMethodDeclaration").overload({0:function(_,L,U,Q,K,ve,me,Ke){return le(_,L,U,Q,K,ve,me,Ke)},1:function(_,L,U,Q,K,ve,me,Ke,je){return le(e.concatenate(_,L),U,Q,K,ve,me,Ke,je)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6],Ke=_[7],je=_[8];return je===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||typeof U=="string"||e.isPropertyName(U))&&(Q===void 0||typeof Q=="object"&&e.isQuestionToken(Q))&&(K===void 0||e.isArray(K))&&(ve===void 0||!e.some(ve,e.isTypeParameterDeclaration))&&(me===void 0||!e.isArray(me))&&(Ke===void 0||e.isBlock(Ke))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6],Ke=_[7],je=_[8];return(L===void 0||e.isArray(L))&&(U===void 0||typeof U=="object"&&e.isAsteriskToken(U))&&(Q===void 0||typeof Q=="string"||e.isPropertyName(Q))&&(K===void 0||!e.isArray(K))&&(ve===void 0||!e.some(ve,e.isParameter))&&(me===void 0||e.isArray(me))&&(Ke===void 0||e.isTypeNode(Ke))&&(je===void 0||e.isBlock(je))}}).deprecate({1:t}).finish(),b.updateMethodDeclaration=e.buildOverload("updateMethodDeclaration").overload({0:function(_,L,U,Q,K,ve,me,Ke,je){return ae(_,L,U,Q,K,ve,me,Ke,je)},1:function(_,L,U,Q,K,ve,me,Ke,je,Le){return ae(_,e.concatenate(L,U),Q,K,ve,me,Ke,je,Le)}}).bind({0:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6],me=_[7],Ke=_[8],je=_[9];return je===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||typeof U=="string"||e.isPropertyName(U))&&(Q===void 0||typeof Q=="object"&&e.isQuestionToken(Q))&&(K===void 0||e.isArray(K))&&(ve===void 0||!e.some(ve,e.isTypeParameterDeclaration))&&(me===void 0||!e.isArray(me))&&(Ke===void 0||e.isBlock(Ke))},1:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6],me=_[7],Ke=_[8],je=_[9];return(L===void 0||e.isArray(L))&&(U===void 0||typeof U=="object"&&e.isAsteriskToken(U))&&(Q===void 0||typeof Q=="string"||e.isPropertyName(Q))&&(K===void 0||!e.isArray(K))&&(ve===void 0||!e.some(ve,e.isParameter))&&(me===void 0||e.isArray(me))&&(Ke===void 0||e.isTypeNode(Ke))&&(je===void 0||e.isBlock(je))}}).deprecate({1:t}).finish(),b.createConstructorDeclaration=e.buildOverload("createConstructorDeclaration").overload({0:function(_,L,U){return X(_,L,U)},1:function(_,L,U,Q){return X(L,U,Q)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3];return K===void 0&&(L===void 0||!e.some(L,e.isDecorator))&&(U===void 0||!e.some(U,e.isModifier))&&(Q===void 0||!e.isArray(Q))},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3];return(L===void 0||!e.some(L,e.isModifier))&&(U===void 0||!e.some(U,e.isParameter))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.isBlock(K))}}).deprecate({1:c}).finish(),b.updateConstructorDeclaration=e.buildOverload("updateConstructorDeclaration").overload({0:function(_,L,U,Q){return ne(_,L,U,Q)},1:function(_,L,U,Q,K){return ne(_,U,Q,K)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return K===void 0&&(L===void 0||!e.some(L,e.isDecorator))&&(U===void 0||!e.some(U,e.isModifier))&&(Q===void 0||!e.isArray(Q))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return(L===void 0||!e.some(L,e.isModifier))&&(U===void 0||!e.some(U,e.isParameter))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.isBlock(K))}}).deprecate({1:c}).finish(),b.createGetAccessorDeclaration=e.buildOverload("createGetAccessorDeclaration").overload({0:function(_,L,U,Q,K){return se(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return se(e.concatenate(_,L),U,Q,K,ve)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return ve===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.isBlock(K))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return(L===void 0||e.isArray(L))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.isTypeNode(K))&&(ve===void 0||e.isBlock(ve))}}).deprecate({1:t}).finish(),b.updateGetAccessorDeclaration=e.buildOverload("updateGetAccessorDeclaration").overload({0:function(_,L,U,Q,K,ve){return N(_,L,U,Q,K,ve)},1:function(_,L,U,Q,K,ve,me){return N(_,e.concatenate(L,U),Q,K,ve,me)}}).bind({0:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6];return ve===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.isBlock(K))},1:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6];return(L===void 0||e.isArray(L))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.isTypeNode(K))&&(ve===void 0||e.isBlock(ve))}}).deprecate({1:t}).finish(),b.createSetAccessorDeclaration=e.buildOverload("createSetAccessorDeclaration").overload({0:function(_,L,U,Q){return F(_,L,U,Q)},1:function(_,L,U,Q,K){return F(e.concatenate(_,L),U,Q,K)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return K===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return(L===void 0||e.isArray(L))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.isBlock(K))}}).deprecate({1:t}).finish(),b.updateSetAccessorDeclaration=e.buildOverload("updateSetAccessorDeclaration").overload({0:function(_,L,U,Q,K){return v(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return v(_,e.concatenate(L,U),Q,K,ve)}}).bind({0:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5];return K===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))},1:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5];return(L===void 0||e.isArray(L))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.isBlock(K))}}).deprecate({1:t}).finish(),b.createIndexSignature=e.buildOverload("createIndexSignature").overload({0:function(_,L,U){return S(_,L,U)},1:function(_,L,U,Q){return S(L,U,Q)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3];return K===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||e.every(U,e.isParameter))&&(Q===void 0||!e.isArray(Q))},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.every(U,e.isModifier))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.isTypeNode(K))}}).deprecate({1:c}).finish(),b.updateIndexSignature=e.buildOverload("updateIndexSignature").overload({0:function(_,L,U,Q){return x(_,L,U,Q)},1:function(_,L,U,Q,K){return x(_,U,Q,K)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return K===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||e.every(U,e.isParameter))&&(Q===void 0||!e.isArray(Q))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.every(U,e.isModifier))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.isTypeNode(K))}}).deprecate({1:c}).finish(),b.createClassStaticBlockDeclaration=e.buildOverload("createClassStaticBlockDeclaration").overload({0:function(_){return k(_)},1:function(_,L,U){return k(U)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2];return U===void 0&&Q===void 0&&(L===void 0||!e.isArray(L))},1:function(_){var L=_[0],U=_[1],Q=_[2];return(L===void 0||e.isArray(L))&&(U===void 0||e.isArray(L))&&(Q===void 0||e.isBlock(Q))}}).deprecate({1:u}).finish(),b.updateClassStaticBlockDeclaration=e.buildOverload("updateClassStaticBlockDeclaration").overload({0:function(_,L){return w(_,L)},1:function(_,L,U,Q){return w(_,Q)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3];return U===void 0&&Q===void 0&&(L===void 0||!e.isArray(L))},1:function(_){var L=_[1],U=_[2],Q=_[3];return(L===void 0||e.isArray(L))&&(U===void 0||e.isArray(L))&&(Q===void 0||e.isBlock(Q))}}).deprecate({1:u}).finish(),b.createClassExpression=e.buildOverload("createClassExpression").overload({0:function(_,L,U,Q,K){return P(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return P(e.concatenate(_,L),U,Q,K,ve)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return ve===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isArray(U))&&(Q===void 0||e.every(Q,e.isHeritageClause))&&(K===void 0||e.every(K,e.isClassElement))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return(L===void 0||e.isArray(L))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.every(Q,e.isTypeParameterDeclaration))&&(K===void 0||e.every(K,e.isHeritageClause))&&(ve===void 0||e.isArray(ve))}}).deprecate({1:c}).finish(),b.updateClassExpression=e.buildOverload("updateClassExpression").overload({0:function(_,L,U,Q,K,ve){return ge(_,L,U,Q,K,ve)},1:function(_,L,U,Q,K,ve,me){return ge(_,e.concatenate(L,U),Q,K,ve,me)}}).bind({0:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6];return ve===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isArray(U))&&(Q===void 0||e.every(Q,e.isHeritageClause))&&(K===void 0||e.every(K,e.isClassElement))},1:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6];return(L===void 0||e.isArray(L))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.every(Q,e.isTypeParameterDeclaration))&&(K===void 0||e.every(K,e.isHeritageClause))&&(ve===void 0||e.isArray(ve))}}).deprecate({1:c}).finish(),b.createFunctionDeclaration=e.buildOverload("createFunctionDeclaration").overload({0:function(_,L,U,Q,K,ve,me){return De(_,L,U,Q,K,ve,me)},1:function(_,L,U,Q,K,ve,me,Ke){return De(L,U,Q,K,ve,me,Ke)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6],Ke=_[7];return Ke===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||typeof U=="string"||e.isIdentifier(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.every(K,e.isParameter))&&(ve===void 0||!e.isArray(ve))&&(me===void 0||e.isBlock(me))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6],Ke=_[7];return(L===void 0||e.isArray(L))&&(U===void 0||typeof U!="string"&&e.isAsteriskToken(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.every(K,e.isTypeParameterDeclaration))&&(ve===void 0||e.isArray(ve))&&(me===void 0||e.isTypeNode(me))&&(Ke===void 0||e.isBlock(Ke))}}).deprecate({1:c}).finish(),b.updateFunctionDeclaration=e.buildOverload("updateFunctionDeclaration").overload({0:function(_,L,U,Q,K,ve,me,Ke){return re(_,L,U,Q,K,ve,me,Ke)},1:function(_,L,U,Q,K,ve,me,Ke,je){return re(_,U,Q,K,ve,me,Ke,je)}}).bind({0:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6],me=_[7],Ke=_[8];return Ke===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isIdentifier(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.every(K,e.isParameter))&&(ve===void 0||!e.isArray(ve))&&(me===void 0||e.isBlock(me))},1:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6],me=_[7],Ke=_[8];return(L===void 0||e.isArray(L))&&(U===void 0||typeof U!="string"&&e.isAsteriskToken(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.every(K,e.isTypeParameterDeclaration))&&(ve===void 0||e.isArray(ve))&&(me===void 0||e.isTypeNode(me))&&(Ke===void 0||e.isBlock(Ke))}}).deprecate({1:c}).finish(),b.createClassDeclaration=e.buildOverload("createClassDeclaration").overload({0:function(_,L,U,Q,K){return j(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return j(e.concatenate(_,L),U,Q,K,ve)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return ve===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isArray(U))&&(Q===void 0||e.every(Q,e.isHeritageClause))&&(K===void 0||e.every(K,e.isClassElement))},1:function(){return!0}}).deprecate({1:t}).finish(),b.updateClassDeclaration=e.buildOverload("updateClassDeclaration").overload({0:function(_,L,U,Q,K,ve){return Y(_,L,U,Q,K,ve)},1:function(_,L,U,Q,K,ve,me){return Y(_,e.concatenate(L,U),Q,K,ve,me)}}).bind({0:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6];return ve===void 0&&(L===void 0||!e.isArray(L))&&(U===void 0||e.isArray(U))&&(Q===void 0||e.every(Q,e.isHeritageClause))&&(K===void 0||e.every(K,e.isClassElement))},1:function(_){var L=_[2],U=_[3],Q=_[4],K=_[5],ve=_[6];return(L===void 0||e.isArray(L))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.every(Q,e.isTypeParameterDeclaration))&&(K===void 0||e.every(K,e.isHeritageClause))&&(ve===void 0||e.isArray(ve))}}).deprecate({1:t}).finish(),b.createInterfaceDeclaration=e.buildOverload("createInterfaceDeclaration").overload({0:function(_,L,U,Q,K){return $(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return $(L,U,Q,K,ve)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4],me=_[5];return me===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.every(K,e.isHeritageClause))&&(ve===void 0||e.every(ve,e.isTypeElement))},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4],me=_[5];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.every(K,e.isTypeParameterDeclaration))&&(ve===void 0||e.every(ve,e.isHeritageClause))&&(me===void 0||e.every(me,e.isTypeElement))}}).deprecate({1:c}).finish(),b.updateInterfaceDeclaration=e.buildOverload("updateInterfaceDeclaration").overload({0:function(_,L,U,Q,K,ve){return E(_,L,U,Q,K,ve)},1:function(_,L,U,Q,K,ve,me){return E(_,U,Q,K,ve,me)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6];return me===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||e.every(K,e.isHeritageClause))&&(ve===void 0||e.every(ve,e.isTypeElement))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.every(K,e.isTypeParameterDeclaration))&&(ve===void 0||e.every(ve,e.isHeritageClause))&&(me===void 0||e.every(me,e.isTypeElement))}}).deprecate({1:c}).finish(),b.createTypeAliasDeclaration=e.buildOverload("createTypeAliasDeclaration").overload({0:function(_,L,U,Q){return z(_,L,U,Q)},1:function(_,L,U,Q,K){return z(L,U,Q,K)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4];return ve===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||!e.isArray(K))},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.isArray(K))&&(ve===void 0||e.isTypeNode(ve))}}).deprecate({1:c}).finish(),b.updateTypeAliasDeclaration=e.buildOverload("updateTypeAliasDeclaration").overload({0:function(_,L,U,Q,K){return ue(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return ue(_,U,Q,K,ve)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return ve===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))&&(K===void 0||!e.isArray(K))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.isArray(K))&&(ve===void 0||e.isTypeNode(ve))}}).deprecate({1:c}).finish(),b.createEnumDeclaration=e.buildOverload("createEnumDeclaration").overload({0:function(_,L,U){return W(_,L,U)},1:function(_,L,U,Q){return W(L,U,Q)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3];return K===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.isArray(K))}}).deprecate({1:c}).finish(),b.updateEnumDeclaration=e.buildOverload("updateEnumDeclaration").overload({0:function(_,L,U,Q){return B(_,L,U,Q)},1:function(_,L,U,Q,K){return B(_,U,Q,K)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return K===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isArray(Q))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||!e.isArray(Q))&&(K===void 0||e.isArray(K))}}).deprecate({1:c}).finish(),b.createModuleDeclaration=e.buildOverload("createModuleDeclaration").overload({0:function(_,L,U,Q){return R(_,L,U,Q)},1:function(_,L,U,Q,K){return R(L,U,Q,K)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4];return ve===void 0&&(L===void 0||e.every(L,e.isModifier))&&U!==void 0&&!e.isArray(U)&&(Q===void 0||e.isModuleBody(Q))&&(K===void 0||typeof K=="number")},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&Q!==void 0&&e.isModuleName(Q)&&(K===void 0||typeof K=="object")&&(ve===void 0||typeof ve=="number")}}).deprecate({1:c}).finish(),b.updateModuleDeclaration=e.buildOverload("updateModuleDeclaration").overload({0:function(_,L,U,Q){return G(_,L,U,Q)},1:function(_,L,U,Q,K){return G(_,U,Q,K)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return K===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isModuleBody(Q))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&Q!==void 0&&e.isModuleName(Q)&&(K===void 0||e.isModuleBody(K))}}).deprecate({1:c}).finish(),b.createImportEqualsDeclaration=e.buildOverload("createImportEqualsDeclaration").overload({0:function(_,L,U,Q){return ee(_,L,U,Q)},1:function(_,L,U,Q,K){return ee(L,U,Q,K)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4];return ve===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||typeof U=="boolean")&&typeof Q!="boolean"&&typeof K!="string"},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||typeof Q=="boolean")&&(typeof K=="string"||e.isIdentifier(K))&&ve!==void 0&&e.isModuleReference(ve)}}).deprecate({1:c}).finish(),b.updateImportEqualsDeclaration=e.buildOverload("updateImportEqualsDeclaration").overload({0:function(_,L,U,Q,K){return ie(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return ie(_,U,Q,K,ve)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return ve===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||typeof U=="boolean")&&typeof Q!="boolean"&&typeof K!="string"},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||typeof Q=="boolean")&&(typeof K=="string"||e.isIdentifier(K))&&ve!==void 0&&e.isModuleReference(ve)}}).deprecate({1:c}).finish(),b.createImportDeclaration=e.buildOverload("createImportDeclaration").overload({0:function(_,L,U,Q){return be(_,L,U,Q)},1:function(_,L,U,Q,K){return be(L,U,Q,K)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4];return ve===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&Q!==void 0&&e.isExpression(Q)&&(K===void 0||e.isAssertClause(K))},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||e.isImportClause(Q))&&K!==void 0&&e.isExpression(K)&&(ve===void 0||e.isAssertClause(ve))}}).deprecate({1:c}).finish(),b.updateImportDeclaration=e.buildOverload("updateImportDeclaration").overload({0:function(_,L,U,Q,K){return A(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return A(_,U,Q,K,ve)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return ve===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||!e.isArray(U))&&(Q===void 0||e.isExpression(Q))&&(K===void 0||e.isAssertClause(K))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||e.isImportClause(Q))&&K!==void 0&&e.isExpression(K)&&(ve===void 0||e.isAssertClause(ve))}}).deprecate({1:c}).finish(),b.createExportAssignment=e.buildOverload("createExportAssignment").overload({0:function(_,L,U){return I(_,L,U)},1:function(_,L,U,Q){return I(L,U,Q)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3];return K===void 0&&(L===void 0||e.every(L,e.isModifier))&&(U===void 0||typeof U=="boolean")&&typeof Q=="object"},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&(Q===void 0||typeof Q=="boolean")&&K!==void 0&&e.isExpression(K)}}).deprecate({1:c}).finish(),b.updateExportAssignment=e.buildOverload("updateExportAssignment").overload({0:function(_,L,U){return M(_,L,U)},1:function(_,L,U,Q){return M(_,U,Q)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3];return Q===void 0&&(L===void 0||e.every(L,e.isModifier))&&U!==void 0&&!e.isArray(U)},1:function(_){var L=_[1],U=_[2],Q=_[3];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&Q!==void 0&&e.isExpression(Q)}}).deprecate({1:c}).finish(),b.createExportDeclaration=e.buildOverload("createExportDeclaration").overload({0:function(_,L,U,Q,K){return oe(_,L,U,Q,K)},1:function(_,L,U,Q,K,ve){return oe(L,U,Q,K,ve)}}).bind({0:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4],me=_[5];return me===void 0&&(L===void 0||e.every(L,e.isModifier))&&typeof U=="boolean"&&typeof Q!="boolean"&&(K===void 0||e.isExpression(K))&&(ve===void 0||e.isAssertClause(ve))},1:function(_){var L=_[0],U=_[1],Q=_[2],K=_[3],ve=_[4],me=_[5];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&typeof Q=="boolean"&&(K===void 0||e.isNamedExportBindings(K))&&(ve===void 0||e.isExpression(ve))&&(me===void 0||e.isAssertClause(me))}}).deprecate({1:c}).finish(),b.updateExportDeclaration=e.buildOverload("updateExportDeclaration").overload({0:function(_,L,U,Q,K,ve){return q(_,L,U,Q,K,ve)},1:function(_,L,U,Q,K,ve,me){return q(_,U,Q,K,ve,me)}}).bind({0:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6];return me===void 0&&(L===void 0||e.every(L,e.isModifier))&&typeof U=="boolean"&&typeof Q!="boolean"&&(K===void 0||e.isExpression(K))&&(ve===void 0||e.isAssertClause(ve))},1:function(_){var L=_[1],U=_[2],Q=_[3],K=_[4],ve=_[5],me=_[6];return(L===void 0||e.every(L,e.isDecorator))&&(U===void 0||e.isArray(U))&&typeof Q=="boolean"&&(K===void 0||e.isNamedExportBindings(K))&&(ve===void 0||e.isExpression(ve))&&(me===void 0||e.isAssertClause(me))}}).deprecate({1:c}).finish()}r(g,"patchNodeFactory");var d=e.createNodeFactory;e.createNodeFactory=function(b,J){var O=d(b,J);return g(O),O},g(e.factory)})(_r||(_r={}));var _r;(function(e){typeof console<"u"&&(e.Debug.loggingHost={log:r(function(t,c){switch(t){case e.LogLevel.Error:return console.error(c);case e.LogLevel.Warning:return console.warn(c);case e.LogLevel.Info:return console.log(c);case e.LogLevel.Verbose:return console.log(c)}},"log")})})(_r||(_r={}))});var WK={};dW(WK,{RunMode:()=>py,getChecksumConfig:()=>nE,getLogin:()=>hy,init:()=>UK});module.exports=pW(WK);var iA=require("@playwright/test");var bm=h1(require("path"));var py=(u=>(u.Normal="normal",u.Heal="heal",u.Refactor="refactor",u))(py||{});var gy=(m=>(m.Locator="locator",m.GetByRole="getByRole",m.GetByText="getByText",m.GetByLabel="getByLabel",m.GetByPlaceholder="getByPlaceholder",m.GetByAltText="getByAltText",m.GetByTitle="getByTitle",m.GetByTestId="getByTestId",m.FrameLocator="frameLocator",m))(gy||{}),GT=(F=>(F.Click="click",F.DblClick="dblclick",F.Hover="hover",F.Focus="focus",F.Type="type",F.SelectOption="selectOption",F.Check="check",F.Uncheck="uncheck",F.Press="press",F.Fill="fill",F.Clear="clear",F.Blur="blur",F.DragTo="dragTo",F.PressSequentially="pressSequentially",F.SetInputFiles="setInputFiles",F.SelectText="selectText",F.SetChecked="setChecked",F))(GT||{}),ub=(d=>(d.First="first",d.Last="last",d.Nth="nth",d.Filter="filter",d.Or="or",d))(ub||{});var Vc=h1(require("path")),cm=require("fs");var B_=r(e=>new Promise(t=>setTimeout(t,e)),"awaitSleep"),c_=r(async(e,t=1e3,c="guardReturnTimedOut")=>{if(t===null)return e;let u="guard-timed-out",g=r(async()=>(await B_(t+1e3),u),"guard"),d=await Promise.race([e,g()]);if(typeof d=="string"&&d===u)throw new Error(c);return d},"guardReturn");function y1(e=5,t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"){let c="";for(let u=e;u>0;--u)c+=t[Math.floor(Math.random()*t.length)];return c}r(y1,"randomString");function KT(e){return!!e&&!["navigation","keystroke","wait","get_more_items","custom_code"].includes(e)}r(KT,"isActionOnElement");function s3(e){return{click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",upload_files:"upload_files",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",reset:void 0,save:void 0,fail:void 0,wait:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,get_more_items:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0}[e]}r(s3,"getActionEventCode");async function fb(e,t){let u=r(()=>{let O=QT(e,t);if((0,cm.existsSync)(O)||O.endsWith(".data")&&(O=O.replace(".data",".esra"),(0,cm.existsSync)(O)))return O;throw new Error(`Could not find metadata file for test ${t}`)},"getFilePath")(),{ungzip:g}=lb(),d=await g((0,cm.readFileSync)(u)),b=JSON.parse(d),J=Object.keys(b);return J.length>0&&!b[J[0]].esraMetadata?J.reduce((O,m)=>({...O,[m]:{esraMetadata:b[m]}}),{}):b}r(fb,"getMetadataForTestId");function my(e){return Vc.join(Vc.dirname(e),"..")}r(my,"getTestBaseDir");function QT(e,t){return Vc.join(gW(e),`${t}.checksum.data`)}r(QT,"getMetadataFilePath");function gW(e){return Vc.join(vy(e),"esra")}r(gW,"getMetadataFolderPath");function XT(e){return Vc.join(vy(e),"bin")}r(XT,"getBinFolderPath");function ZT(e){return Vc.join(vy(e),"har")}r(ZT,"getHARFolderPath");function f3(e,t){return Vc.join(ZT(e),`${t}.har.zip`)}r(f3,"getHARFilePath");function _3(e,t){return Vc.join(vy(e),"trace",`${t}.playwright-trace.zip`)}r(_3,"getTraceFilePath");function vy(e){return Vc.join(e,"test-data")}r(vy,"getTestDataPath");function d3(){return{uploadAgentHOST:"localhost",uploadAgentPort:3e3}}r(d3,"getUploadAgentDefaultConfig");var l3=r(async e=>{try{await c_(e,5e3)}catch{}},"guardAwait"),$T=r(e=>{let t=/\/\/.*/,c=/\/\*[\s\S]*?\*\//g;return e.replace(t,"").replace(c,"")},"stripJavascriptComments"),YT=r(e=>{console.log("\x1B[31m%s\x1B[0m",e)},"printError"),eE=r((e,t,c)=>{if(!t)return e;if(!c||!c.length)return e.locator(t);let u=e.frameLocator(c[0]);for(let g of c.slice(1))u=u.frameLocator(g);return u.locator(t)},"makeLocator");async function p3(e,t,c){let g=r(async()=>e.evaluate(async({selector:b,parentFramesSelectors:J})=>await window.checksum.testGenerator.getSelectionDataForSelector(b,J),{selector:t,parentFramesSelectors:c}),"getSelectionDataForSelector"),d=await g();if(d||(await l3(e.waitForLoadState("networkidle")),d=await g(),d)||(await l3(eE(e,t,c).waitFor({state:"visible"})),d=await g(),d)||(await B_(5e3),d=await g(),d))return d}r(p3,"selectionDataForSelector");function um(){return process.env.CHECKSUM_ROOT_FOLDER?process.env.CHECKSUM_ROOT_FOLDER:Vc.join(__dirname,"..","..","..","checksum")}r(um,"checksumFolder");function _b(e,t){try{let c=e.filter(u=>u.endsWith("checksum.config.ts")&&Vc.dirname(u).endsWith("checksum"));return c.find(u=>u==="checksum/checksum.config.ts")?"checksum":c.length===1?Vc.dirname(c[0]):t?Vc.dirname(mW(c,t)):Vc.dirname(c.sort((u,g)=>g.length-u.length)[0])}catch{return"checksum"}}r(_b,"findChecksumRootFolder");function mW(e,t){let c=r(J=>J.split(Vc.sep).filter(O=>O.length>0),"splitPath"),u=r((J,O)=>{let m=c(J),h=c(O),le=Math.min(m.length,h.length),ae=Math.abs(m.length-h.length);for(let X=0;X<le;X++)if(m[X]!==h[X]){ae+=2*(le-X);break}return ae},"directoryDistance"),g=null,d=1/0,b=Vc.dirname(t);return e.forEach(J=>{let O=u(b,J);O<d&&(d=O,g=J)}),g}r(mW,"getClosestPath");function db(e,t=2){let c=[],u=[],g=r(b=>{if(c.includes(b))return;c.push(b);let J=(0,cm.readdirSync)(b);for(let O of J){let m=Vc.join(b,O),h=(0,cm.statSync)(m);if(!(h.isSymbolicLink()||m.includes("node_modules"))){if(h.isDirectory())g(m);else if(O==="checksum.config.ts"){u.push(m);return}}}},"searchDirectory"),d=Vc.dirname(e);try{for(let b=0;b<t&&(g(d),d=Vc.join(d,".."),b===t-1&&b<9&&!u.length&&(t+=2),!(Vc.resolve(d)==="/"||!d||Vc.resolve(d)===Vc.resolve(process.cwd())));b++);return u}catch{return u}}r(db,"findChecksumRootQualifyingPathsForTestFile");var g3=require("fs");var m3=!1;function v3(e){m3=e}r(v3,"setLogToConsole");function ks(...e){m3&&console.log(...e)}r(ks,"log");async function pb(e,t,c,u=6e4){if(!(t in e))return e;let g=r(()=>e[t](...c),"executor");return u===null?g():c_(g(),u,"Execution timeout")}r(pb,"executePlaywrightMethodWithTimeout");function rE(e,{role:t,environment:c}={},u=!1){var J,O;let g;c&&(g=(J=e.environments)==null?void 0:J.find(({name:m})=>c===m)),g||(g=(O=e.environments)==null?void 0:O.find(({default:m})=>m)),g||(g={baseURL:e.baseURL,default:!0,name:void 0});let d=(g==null?void 0:g.users)??e.users,b;if(d&&(t&&(b=d.find(m=>m.role===t)),b||(b=d.find(m=>m.default))),b||(b={role:void 0,username:e.username,password:e.password,default:!0}),c&&g.name!==c){if(u)throw new Error(`Could not find environment with name "${c}" in config file`);console.warn(`Could not find environment with name "${c}" in config file, trying to use default environment`)}if(t&&b.role!==t){if(u)throw new Error(`Could not find user with role "${t}" for environment "${c}" in config file`);console.warn(`Could not find user with role "${t}" for environment "${c}" in config file, trying to login with environment's default user`)}return{environment:g,user:b}}r(rE,"resolveEnvironment");function h3(e,{environment:t,user:c}){try{let u=require(`${um()}/login.ts`).default;return async g=>{let d={username:c.username,password:c.password},b=r(()=>u(g,{...e,...d},{environment:t,user:c}),"performLogin");"checksumAI"in g?await g.checksumAI(`Log in${c!=null&&c.role?` using ${c.role} role`:""}${t!=null&&t.name?` in ${t.name} environment`:""}`,b):await b()}}catch(u){throw console.warn("Could not find checksum login file. Please set login.ts file in your checksum folder"),u}}r(h3,"makeBoundLogin");function hy(e){let{config:t,folder:c,throwIfAuthFailed:u}=e;try{let g=require(`${c??um()}/login.ts`).default;return async(d,{role:b,environment:J}={})=>{let O={username:t.username,password:t.password},{environment:m,user:h}=rE(t,{role:b,environment:J});if(u&&!h)throw new Error("Could not find user credentials matching the provided role and/or environment");h&&(O.username=h.username,O.password=h.password);let le=r(()=>g(d,{...t,...O},{environment:m,user:h}),"performLogin");"checksumAI"in d?await d.checksumAI(`Log in${h!=null&&h.role?` using ${h.role} role`:""}${m!=null&&m.name?` in ${m.name} environment`:""}`,le):await le()}}catch(g){throw console.warn("Could not find checksum login file. Please create a login.ts file in your checksum folder"),g}}r(hy,"makeUnboundLogin");var lm;function y3(){if(lm)return lm;let e;try{let t=(0,g3.existsSync)(`${um()}/checksum.config.tmp.ts`)?"checksum.config.tmp.ts":"checksum.config.ts";e=require(`${um()}/${t}`).default}catch{console.warn("Could not find checksum config file, will run with defaults"),e=nE()}return e}r(y3,"loadChecksumConfig");function nE(e={}){var d,b,J;lm={...{apiKey:void 0,runMode:"normal",baseURL:void 0,apiURL:void 0,username:void 0,password:void 0,options:{useChecksumSelectors:!0,useChecksumAI:{actions:!0,assertions:!1},newAssertionsEnabled:!0,useMockData:!1,printLogs:!1},...d3()},...e};let c=lm.username||lm.password,u=((d=lm.users)==null?void 0:d.length)>0,g=((b=lm.environments)==null?void 0:b.length)>0&&((J=lm.environments)==null?void 0:J.some(O=>{var m;return((m=O.users)==null?void 0:m.length)>0}));return!c&&!u&&!g&&console.warn("Testing user credentials are not set in the config file"),lm}r(nE,"getChecksumConfig");var cv="Checksum failed connecting to the server";var gb=(u=>(u[u.Element=0]="Element",u[u.VisibleElement=1]="VisibleElement",u[u.AtPointElement=2]="AtPointElement",u))(gb||{});var vW={generateSelectionData:!1,navigationTimeout:30*1e3,actionTimeout:5*1e3},iE=class iE{constructor(t,c,u,g,d,b){this.page=t;this.evaluateWithChecksum=c;this.checksumPage=u;this.timeMachinePage=g;this.pageInteractor=d;this.options=b;this.API_BASE_DOMAIN="https://api.checksum.ai";this.didCancel=!1;this.timeout=15*60*1e3;this.canResolveAssertion=!1;this.page=t,this.options={...vW,...b},this.pageInteractor.init()}canResolve(t){return!(t.type==="assertion"&&!this.canResolveAssertion)}addMetadata(t){}cancel(){this.didCancel=!0}async execute(t,c,u){return pb(t,c,u)}log(...t){ks(...t)}setThought(t){this.thought=t}setVariables(t){this.variablesString=t}};r(iE,"AbstractFallback");var uv=iE;var tE=class tE extends uv{constructor(){super(...arguments);this.API_BASE_ROUTE="/client-api/runtime/esra-fallback"}init(c){let{apiKey:u,testId:g,apiURL:d,checksumId:b,fileName:J,timeout:O}=c;return this.data={...this.data,testId:g,checksumId:b,fileName:J},this.apiKey=u,d&&(this.API_BASE_DOMAIN=d.replace(/\/$/,"")),O&&(this.timeout=O),this.checksumRootFolder=process.env.CHECKSUM_ROOT_FOLDER??_b(db(this.data.fileName),this.data.fileName),this}getRecoveryAttemptTitle(c){return`Checksum auto-heal: trying to locate the element using checksumSelector("${this.data.checksumId}")...`}async sendLog(c){let u=process.env.CHECKSUM_TEST_SUITE_ID??"",{selector:g}=c,{checksumId:d,testId:b}=this.data,J={testSuiteId:u,testId:b,selector:g,checksumId:d,thought:this.thought};try{fetch(`${this.getAPIBaseURL()}/log`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify(J)}).catch(O=>this.log("[ESRAFallback] Error sending log"))}catch(O){this.log("[ESRAFallback] Error sending log",O)}}async getMetadataForTestId(){return fb(this.checksumRootFolder,this.data.testId)}getAPIBaseURL(){return this.API_BASE_DOMAIN+this.API_BASE_ROUTE}};r(tE,"MetadataBaseFallback");var yy=tE;var aE=class aE extends yy{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(c){return super.init(c),this.data.minSelectionScore=.7,this}async resolve(c){try{let{method:u,args:g}=c,{checksumId:d}=this.data,b=await this.getActionIdToESRAMap();if(!(d in b)){let h=`No ESRA metadata found for id ${d}`;throw new Error(h)}let J=await this.getTestIdsForLocator(b[d].esraMetadata),{elementDataMap:O}=await this.getSelectors(J);if(this.didCancel)return;let m=await this.executeWithSelectors(Object.values(O),u,g);return m?(this.sendLog(m),this.checksumPage.addErrorMessage(c.error,`${this.thought?`"${this.thought}" auto-healed`:"Auto-healed"} using alternative selector "${m.selector}"`),{steps:[{type:"action",...m}]}):void 0}catch(u){this.log(u.message);return}}async getActionIdToESRAMap(){try{this.actionIdToESRAMap||(this.actionIdToESRAMap=await this.getMetadataForTestId())}catch(c){return super.log("Could not read ESRA metadata file, ",c),{}}return this.actionIdToESRAMap}async getSelectors(c){let u=[],g={};if(!c)return{selectors:u,elementDataMap:g};for(let d in Object.keys(gb)){let b=c.testIds[this.locatorTypeEnumToFieldMap[d]];if(!b)continue;let J=`[data-checksum-testid="${b}"]`;u.push(J),g[J]={...c.elementData[this.locatorTypeEnumToFieldMap[d]],selector:c.selectors[this.locatorTypeEnumToFieldMap[d]],parentFramesSelectors:c.parentFramesSelectors[this.locatorTypeEnumToFieldMap[d]]}}for(let d in Object.keys(gb)){let b=c.selectors[this.locatorTypeEnumToFieldMap[d]];b&&(u.push(b),g[b]={...c.elementData[this.locatorTypeEnumToFieldMap[d]],selector:b})}return this.log("Selectors for ESRA metadata:",u),{selectors:u,elementDataMap:g}}async getTestIdsForLocator(c,u={}){let{cachedSelector:g=void 0,retriesLeft:d=3,retryMaxTimeout:b=3e3,staticMetadata:J}=u,O=await this.evaluateWithChecksum(async({esraMetadata:m,cachedSelector:h,staticMetadata:le,minSelectionScore:ae})=>await window.checksum.testGenerator.getMatchingElementSelectionData(m,{minSelectionScore:ae,cachedSelector:h,staticMetadata:le}),{esraMetadata:c,cachedSelector:g,staticMetadata:J,minSelectionScore:this.data.minSelectionScore});if(!O){if(d>0)return this.log("[getTestIdsForLocator] no match found, waiting and retrying..."),await B_(b/d),this.getTestIdsForLocator(c,{...u,retriesLeft:d-1});this.log("[getTestIdsForLocator] failed to locate")}return O}async executeWithSelectors(c,u,g){for(let{selector:d,tag:b,parentFramesSelectors:J}of c){let O=this.pageInteractor.makeLocator(d,J);this.log(`Running with selector=${d};${J!=null&&J.length?` parentFramesSelectors=${J};`:""}`);let m=!1;["check","uncheck"].includes(u)&&b!=="input"&&(m=!0);let h=this.generateSelectionDataForSelector(d,J);if(await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(O,m?"click":u,g))===!1){this.log("Fallback selector timeout");continue}return h}}async generateSelectionDataForSelector(c,u){let{generateSelectionData:g}=this.options;if(!g)return{selector:c,generatedLocator:void 0,esraMetadata:void 0,parentFramesSelectors:void 0};try{let d=await p3(this.page,c,u);if(!d)throw new Error(`[generateSelectionDataForSelector] Failed to generate selection data for selector ${c}`);return d}catch(d){throw this.log(d.message),d}}toString(){return`Checksum selector (${this.data.checksumId})`}};r(aE,"ESRAfallback");var D1=aE;var oE=class oE extends uv{init(){return this}canResolve(t){return["check","uncheck"].includes(t.method)}getRecoveryAttemptTitle(t){return"Checksum auto-heal: Trying force click for check/uncheck action..."}async resolve(t){try{let{locator:c,method:u}=t;if(!c)return;let{args:g}=t;if(!["check","uncheck"].includes(u))return;let d=!1;for(let J of Array.from(g))if(typeof J=="object"){J.force=!0,d=!0;break}if(d||(g=Array.from(g),g.push({force:!0})),await this.execute(c,u,g)!==!1)return{steps:[{type:"action",selector:c._selector,generatedLocator:void 0,esraMetadata:void 0}]};this.log("Locator timed out, ")}catch(c){this.log("initiateFallbackSequence exception, ",c);return}}toString(){return"Force click check/uncheck"}};r(oE,"ForceFallback");var S1=oE;var D3=require("jsdom");var sE=class sE extends uv{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.currentChecksumId="0";this.hasPreviousActionFailed=!1;this.canResolveAssertion=!0;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"}}init(c){let{goal:u,apiKey:g,testId:d,apiURL:b,thoughts:J}=c;return this.goal=u,this.apiKey=g,this.testId=d,this.testSuiteId=process.env.CHECKSUM_TEST_SUITE_ID??"",this.thoughts=J,this.withChecksumAI=!1,b&&(this.API_BASE_DOMAIN=b.replace(/\/$/,"")),this}getRecoveryAttemptTitle(c){switch(c.type){case"action":return`Checksum auto-heal: trying to achieve action "${this.getFailedThought()}"...`;case"assertion":return`Checksum auto-heal: trying to verify assertion "${this.getFailedThought()}"...`}}async resolve(c){this.fallbackData=c,this.withChecksumAI=c.withChecksumAI;let u=this.getFailedThought();if(u!=="_fail_")try{if(await this.initSession(),!await this.iterate()){this.log("[AIFallback] AIFallback failed");return}return this.addAutoHealErrorToReport(c,u),{steps:this.executedSteps.map(d=>{switch(d.type){case"action":return this.translateExecutedActionToFallbackAction(d);case"assertion":return d}})}}catch(g){if(this.withChecksumAI&&g.message==="fetch failed")throw g;this.log("[AIFallback] Error",g);return}}addAutoHealErrorToReport(c,u){this.withChecksumAI||this.checksumPage.addErrorMessage(c.error,`"${u}" auto-healed:
|
|
271
271
|
${this.executedSteps.map(g=>{switch(g.type){case"action":return g.description;case"assertion":return g.feedback}}).join(`,
|
|
272
|
-
`)}`)}async getReductionComponents(c){var u,g;return c.interruptionEvent==="didRequestMoreItemsEvent"?{reducedHTML:(g=(u=c.payload)==null?void 0:u.promptData)==null?void 0:g.reducedHTML,reducedDomHTMLElement:this.lastReducedDOM,flashingHTML:[],elementsForNodeInterpretation:[],currentChecksumId:this.currentChecksumId}:this.pageInteractor.getCurrentReducedHTML({stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:this.currentChecksumId})}async iterate(){var u,g;this.hasPreviousActionFailed=!1;let c=this.CLIENT_MAX_ITERATIONS;do{if(this.didCancel)return!1;let d=await this.getPreviousActionOverview(),{reducedHTML:b,flashingHTML:J,elementsForNodeInterpretation:O,currentChecksumId:m}=await this.getReductionComponents(d);this.lastReducedDOM=new D3.JSDOM(b),this.currentChecksumId=m;let h=await this.getNextAction({reducedHTML:b,flashingHTML:J,elementsForNodeInterpretation:O,previousActionOverview:d});if(this.didCancel)return!1;if(["failed","fail"].includes(h.thought)||["failed","fail"].includes((u=h.action)==null?void 0:u.type))return this.log("[AIFallback] Received failed signal, will quit"),!1;if((h.changedVariables??[]).forEach(({name:X,value:ne})=>{this.checksumPage.variablesStore.setVariable(X,ne)}),this.fallbackData.type==="assertion"){let X=h.thought;this.log(`[AIFallback] for assertion returned with value: ${h.action.value}, feedback: ${X}`);let ne=["irrelevant","pass","soft_reject"].includes(h.action.value);return this.checksumPage.step(`AI: ${X}`,async()=>{}),this.executedSteps.push({type:"assertion",feedback:X}),ne}if(h.thought==="finish"||((g=h.action)==null?void 0:g.type)==="finish")return this.log("[AIFallback] Received finish step"),this.executedSteps.length>0;let ae=await this.pageInteractor.translateActionResponseToAgentPotentialAction(h);try{try{this.checksumPage.step(`AI: ${ae.description}`,async()=>{await this.pageInteractor.performAction(ae)})}catch{throw new Error("Action failed")}this.hasPreviousActionFailed=!1,this.executedSteps.push({type:"action",...ae}),await B_(1e3)}catch(X){this.log("[AIFallback] Error while executing selector",X.message),this.hasPreviousActionFailed=!0;continue}if(--c<=0){this.log("[AIFallback] Maximum repetition reached");break}}while(!0);return!1}async getNextAction({reducedHTML:c,flashingHTML:u,elementsForNodeInterpretation:g,previousActionOverview:d}){let{apiKey:b}=this;if(this.mockServer)return this.finish?{thought:"finish"}:(--this.actionsCounter===0&&(this.finish=!0),{thought:"mock-thought",action:{type:"click",checksumid:"10"}});let J={reduction:{reducedHTML:c,flashingHTML:u,elementsForNodeInterpretation:g},currentURL:this.page.url(),previousActionOverview:d,resolvesSmartAssertion:this.withChecksumAI,variablesString:this.variablesString};try{let m=await(await fetch(`${this.getAPIBaseURL()}/iterate`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:b,sessionId:this.sessionId,iterationData:J})})).json();return this.log("[AIFallback] Received next action",m),m}catch(O){throw this.log("[AIFallback] Error calling iterate",O),O}}async getPreviousActionOverview(){let c=await this.pageInteractor.handleFileChooserEvent();return{success:!this.hasPreviousActionFailed,...this.hasPreviousActionFailed?{failureEvent:"generalExecutionFailureError"}:{},...this.getPreviousWaitActionOverview(),...c,...await this.getPreviousGetMoreItemsActionOverview()}}getExecutedActions(){return this.executedSteps.filter(c=>c.type==="action")}async getPreviousGetMoreItemsActionOverview(){let c=this.getExecutedActions(),u=c[c.length-1];if((u==null?void 0:u.eventCode)!=="get_more_items"||!this.lastReducedDOM)return{};try{return await this.pageInteractor.addMoreItemsToDom(this.lastReducedDOM.window.document.body,u.getMoreItemsId),{interruptionEvent:"didRequestMoreItemsEvent",payload:{promptData:{reducedHTML:this.lastReducedDOM.serialize()},getMoreItemsId:u.getMoreItemsId}}}catch{return{}}}getPreviousWaitActionOverview(){var g;let c=this.getExecutedActions();if(((g=c[c.length-1])==null?void 0:g.eventCode)!=="wait")return{};let u=0;return c.slice().reverse().every(d=>d.eventCode==="wait"?(u++,!0):!1,0),{payload:{waitCount:u}}}async initSession(){let{apiKey:c,goal:u,thoughts:g}=this;if(this.log("[AIFallback] Calling init session...",{appName:c,goal:u,thoughts:g}),!c){let b="Missing Checksum API key, will not run AI fallback";throw YT(b),new Error(b)}if(this.mockServer){this.sessionId="mock-session-id";return}let d={type:this.fallbackData.type,resolveSmartAssertion:this.withChecksumAI,storyTitle:u,testSuiteId:this.testSuiteId,testId:this.testId,thoughtsAndActions:{previous:g.slice(0,Math.max(g.length-1,0)).map(b=>({thought:b})),failing:{thought:g[g.length-1]},next:[]}};try{let b=await fetch(`${this.getAPIBaseURL()}/init`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:c,data:d})});this.sessionId=await b.text(),this.log("[AIFallback] Session ID",this.sessionId)}catch(b){throw this.withChecksumAI&&b.message==="fetch failed"&&(this.checksumPage.step(cv,async()=>{throw new Error(cv)}),YT(cv)),this.log("[AIFallback] Error calling init session",b),b}}translateExecutedActionToFallbackAction(c){return{type:"action",esraMetadata:c.esraMetadata,generatedLocator:c.locator,selector:c.selector,parentFramesSelectors:c.parentFramesSelectors,method:this.getMethodForPotentialAction(c),thought:c.description}}getMethodForPotentialAction(c){return{name:this.actionEventCodeToMethodName[c.eventCode],args:r(()=>{switch(c.eventCode){case"click":case"double_click":return[{position:c.clickOffset}];case"drag_and_drop":return[this.pageInteractor.makeLocator(c.dropTarget.selector,c.dropTarget.parentFramesSelectors)];case"input":case"click_and_type":case"clear_and_type":case"selectoption":case"keystroke":case"navigation":return[this.pageInteractor.getActionFillValue(c,!1)];case"upload_files":return c.files;default:return}},"makeArgs")()}}getAPIBaseURL(){return this.API_BASE_DOMAIN+this.API_BASE_ROUTE}getFailedThought(){return this.thoughts[this.thoughts.length-1]}toString(){return`Checksum AI ("${this.getFailedThought()}")`}};r(sE,"AIFallback");var ah=sE;var f_=require("fs");var R7=h1(I7());var ZG=250,Zk=class Zk{constructor(t,c){this.timeMachineable=t;this.initMethod=c;this.numberOfReceivedRrwebEventsIndex=0;this.syncTimeMachine=r(async()=>{try{let t;try{t=await this.timeMachineable.getRRwebEvents(this.numberOfReceivedRrwebEventsIndex)}catch{return}if(!t||t.length===0)return;try{await this.timeMachineable.getTimeMachinePage().evaluate(({events:c,len:u})=>window.checksum.timeMachine.handleEvents(c,u),{events:t,len:this.numberOfReceivedRrwebEventsIndex})}catch{return}this.numberOfReceivedRrwebEventsIndex+=t.length}finally{this.syncTimeout=setTimeout(this.syncTimeMachine,ZG)}},"syncTimeMachine")}async start(t=!1){var c;await((c=this.initMethod)==null?void 0:c.call(this,t)),this.syncTimeMachine()}async stop(){clearTimeout(this.syncTimeout)}async disableEventsHandling(){await this.setShouldHandleEvents(!1)}async enableEventsHandling(){await this.setShouldHandleEvents(!0)}async setShouldHandleEvents(t){try{await this.timeMachineable.getTimeMachinePage().evaluate(c=>window.checksum.timeMachine.setShouldHandleEvents(c),t)}catch{}}};r(Zk,"TimeMachineSync");var cS=Zk;var Yk=class Yk{constructor(t,c,u,g,d){this.page=t;this.evaluateWithChecksum=c;this.executeLocatorAction=u;this.initiateFallbackSequence=g;this.locators=d;this.LOCATORS_TIMEOUT=5e3;this.HANDLES_INTERVAL=300}init(){return new Proxy(this,{get:r((t,c)=>this.handleTargetLocator(t,c),"get")})}setTargetLocator(t,c){this.targetLocator=this.page[t](...c)}getLocatorSelector(t){return t._selector}handleTargetLocator(t,c){if(!Object.values(gy).includes(c))throw new Error(`Invalid locator method: ${c}. Compound selector must be followed by a locator method pointing at the target element`);return function(...u){return t.setTargetLocator(c,u),new Proxy(t,{get:r((g,d)=>r(async function(...J){return g.handleAction(d,J)},"Locator"),"get")})}.bind(t)}async handleAction(t,c){var u;try{if(typeof t=="symbol")return;if(!Object.values(GT).includes(t))throw new Error(`Invalid action method: ${t.toString()}. Target locator method must be followed by an action method`);if(!((u=this.locators)!=null&&u.length)||!this.targetLocator)throw new Error("Missing locators or target locator");ks("Waiting for locators..");try{await Promise.all(this.locators.map(b=>c_(b.first().first().waitFor({bypassChecksum:!0}),this.LOCATORS_TIMEOUT)))}catch{throw new Error("Waiting for compound selector locators timeout")}let g=await c_(this.getElementHandles(),5e3);ks(`Resolved to ${$k(g)} elements from ${this.locators.length} locators`);let d=this.getLocatorSelector(this.targetLocator);try{let b=await this.evaluateWithChecksum(async({handles:O,targetSelector:m})=>window.checksum.testGenerator.getCompoundSelector().select(O,m),{handles:g,targetSelector:d});ks(`Resolved compound selector: ${b}`);let J=this.page.locator(b);await this.executeLocatorAction(J,t,c,["elementHandles","waitFor"])}catch(b){throw new Error(`Failed to resolve compound selector: ${b}`)}}catch(g){ks(`Failed to execute compound selection action: ${g}`),await this.initiateFallbackSequence({type:"action",method:t,error:new Error("Compound selection error"),args:c})}}async getElementHandles(){ks("Resolving compound selector elements");let t,c,u,g,d,b=r(()=>{d=2},"resetSameHandlesCount");do t=c,c=[],await Promise.all(this.locators.map(async J=>{let O=await J.elementHandles({bypassChecksum:!0});if(O.length===0)throw new Error(`No elements found for locator: ${this.getLocatorSelector(J)}`);c.push(O)})),u=$k(c),g=t?$k(t):0,ks(`Handles itteration, previous: ${t?g:"-"}, current: ${u}`),g!==u&&b(),await B_(this.HANDLES_INTERVAL);while(!t||g!==u||--d>0);return c}};r(Yk,"CompoundSelectorLocator");var uS=Yk,$k=r(e=>e.reduce((t,c)=>t+c.length,0),"countHandleElements");var eA=class eA extends yy{constructor(){super(...arguments);this.timeout=5*1e3}init(c){return super.init(c),this}async resolve(c){try{let{method:u,args:g}=c,{checksumId:d}=this.data,b;try{let le=await this.getMetadataForTestId();if(!(d in le)||!le[d].compoundSelector)throw new Error(`No compound selection metadata found for id ${d}`);b=le[d].compoundSelector}catch(le){super.log("Could not read compound selector metadata file, ",le)}let J=await this.generateCompoundSelector(b),O=this.pageInteractor.makeLocator(J.selector),m=b.targetSelection.featuresMetadata.tag,h=["check","uncheck"].includes(u)&&m!=="input"?"click":u;try{await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(O,h,g));let le={selector:J.selector,generatedLocator:J.locator,esraMetadata:void 0};return this.sendLog(le),this.checksumPage.addErrorMessage(c.error,`${this.thought?`"${this.thought}" auto-healed`:"Auto-healed"} using alternative selector "${J.selector}"`),{steps:[{type:"action",...le}]}}catch(le){throw new Error(`Failed to execute compound selection fallback action: ${le.message}`)}}catch(u){this.log(u.message);return}}async generateCompoundSelector(c){let u=await this.evaluateWithChecksum(async g=>{var b;return await((b=window.checksum)==null?void 0:b.testGenerator.getCompoundSelector().selectFromMetadata(g))},c);return super.log("Resolved compound selector to",u),u}toString(){return`Checksum compound selector (${this.data.checksumId})`}};r(eA,"CompoundSelectorFallback");var t2=eA;var O7=require("path"),F7=require("fs");var $G=!0,rA=class rA{constructor(t,c,u,g,d,b){this.evaluateWithChecksum=t;this.getPage=c;this.getTimeMachinePage=u;this.logger=g;this.options=d;this.loginFunction=b;this.newPagesIds=[];this.performFileUploadAction=r(async(t,c)=>{if(!await t.evaluate(g=>g.tagName==="INPUT"&&g.getAttribute("type")==="file"))throw new Error("File upload action performed on non-file input element");let u=c.files.map(g=>(0,O7.join)(this.options.testAssetsDir,g)).filter(g=>(0,F7.existsSync)(g)?!0:(this.logger.log(`Upload file not found: ${g}. Filtering out.`),!1));if(!u.length)throw new Error("No files to upload");await this.actionGuardReturn(t.setInputFiles(u),"Set input files timeout")},"performFileUploadAction");this.getSelectionDataForAction=r(async(t,c)=>t.checksumid?this.getSelectionDataForChecksumId(t.checksumid,c):t.position?await this.evaluateWithChecksum(async([u,g])=>window.checksum.testGenerator.getSelectorByPosition(u,g),[t.position.x,t.position.y]):t.selector?{selector:t.selector,locator:`locator("${t.selector}")`}:{selector:"",locator:""},"getSelectionDataForAction")}init(){let t=this.getPage();t.on("filechooser",async c=>{this.logger.log("File chooser event detected"),this.fileChooser=c}),t.context().on("page",c=>{this.newPagesIds.push(c._guid)})}getOpenedFileChooser(){if(this.fileChooser){let t=this.fileChooser;return this.fileChooser=void 0,t}return null}async handleFileChooserEvent(t=[]){let c=this.getOpenedFileChooser();if(!c)return{};let u="fc_"+Math.random().toString(36).slice(2,4);return await this.evaluateWithChecksum(async([g,d])=>{window.checksum.testGenerator.addForceIncludeElement(d,g)},[u,c.element()]),{interruptionEvent:"fileUploadOpenedEvent",payload:{checksumid:u,customFiles:t}}}async addMoreItemsToDom(t,c){let u=t.querySelector(`[checksum-get-more-items='${c}']`);if(!u)throw new Error("Get more items root not found");let{items:g,hasMoreItems:d}=await this.getMoreItemsForTemplate(c);u.innerHTML=u.innerHTML+g,d||u.removeAttribute("checksum-get-more-items")}async getPageInfo(t){return{id:t._guid,url:t.url(),title:await t.title(),new:this.newPagesIds.includes(t._guid),active:t._guid===this.getPage()._guid}}async getTabsInfo(){let t=(await Promise.all(this.getPage().context().pages().map(c=>this.getPageInfo(c)))).filter(c=>{var u;return c.id!==((u=this.getTimeMachinePage())==null?void 0:u._guid)});return this.newPagesIds=[],t}async getSelectionDataFromSelectorGenerator(t,c,u={}){if(u={useCompoundSelector:!1,useCSSExtraction:!0,useVariables:!0,...u},!t||!KT(s3(c.action.type))||!c.action.checksumid)return{};let g=await t.generateSelectionForAction(c,u);return g?{locator:`locator("${g.selector}")`,...g}:{}}async translateActionResponseToAgentPotentialAction(t,c=void 0,{pageId:u,makeStaticMetadataForESRA:g}={}){let d=structuredClone(t.actionHiddenOverride??t.action),{selector:b,selectorWithVars:J,locator:O,locatorWithVars:m,clickOffset:h,selectOptionValue:le,compoundSelector:ae,parentFramesSelectors:X}={...await this.getSelectionDataForAction(d,t.actionHiddenOverride),...await this.getSelectionDataFromSelectorGenerator(c,t)},ne=await this.getESRAForSelector(b,X,g);if(!ne&&b&&this.logger.logError("Error getting ESRA metadata"),(ne==null?void 0:ne.tag)==="select")switch(this.getActionEventCode(d.type)){case"input":d.type="selectoption";break;case"click":le&&(d.type="selectoption",d.value=le);break}let se={eventCode:this.getActionEventCode(d.type),selector:b,selectorWithVars:J,parentFramesSelectors:X,locator:O,locatorWithVars:m,clickOffset:h,pageId:u,compoundSelector:ae,fillValue:d.value,fillValueName:d.valueName?`variablesStore.${d.valueName}`:"",variables:t.variables,getMoreItemsId:d.getMoreItemsId,esraMetadata:ne,description:t.thought,userRole:d.userRole};switch(se.eventCode){case"drag_and_drop":{let{selector:N,selectorWithVars:F,locator:v,locatorWithVars:S,parentFramesSelectors:x}={...await this.getSelectionDataForAction({type:t.action.type,checksumid:t.action.dropTargetChecksumid}),...await this.getSelectionDataFromSelectorGenerator(c,{...t,action:{type:t.action.type,checksumid:t.action.dropTargetChecksumid}},{useCompoundSelector:!1})};se.dropTarget={selector:N,selectorWithVars:F,locator:v,locatorWithVars:S,parentFramesSelectors:x,esraMetadata:await this.getESRAForSelector(N,x,g)}}break;case"upload_files":se.files=this.mapFileMIMETypeToFilename(d.files);break;case"switch_tab":se.switchToTab={id:d.tabId,index:this.getPage().context().pages().findIndex(N=>N._guid===d.tabId)};break;case"keystroke":se.fillValue=d.value}return se}async reauthenticate(t){this.loginFunction&&(await Promise.all([this.getPage().context().clearCookies(),this.getPage().evaluate(()=>localStorage.clear())]),await this.loginFunction(this.getPage(),{role:t}))}mapFileMIMETypeToFilename(t){return t.map(c=>{if(c.fileName)return c.fileName;switch(c.mimeType){case"image/png":return"image_200x200.png";case"image/jpeg":return"image_200x200.jpg";case"application/pdf":return"document.pdf";case"text/csv":return"data.csv";default:return"file.txt"}})}async performAction(t,{handleActionFailed:c,monitorFlashingHTML:u=!0}={}){try{if(t.executed){this.logger.log("[performAction] Action marked as executed, skipping...");return}if(KT(t.eventCode)&&!t.selector)throw new Error("No selector provided for action. Try changing app rules preMapReducedHTMLSelectors to true");u&&(this.logger.log("starting flashing elements detection"),await this.evaluateWithChecksum(async()=>window.checksum.testGenerator.startFlashingElementsDetection())),this.logger.log(`Performing action: ${t.eventCode}. Selector: ${t.selector}, Position: ${t.clickOffset}, Parent frame: ${t.parentFramesSelectors}`);let g=r(()=>this.makeLocator(t.selector,t.parentFramesSelectors),"getLocator");switch(t.eventCode){case"click":try{await this.actionGuardReturn(g().click({position:t.clickOffset}),"Click timeout")}catch(J){this.logger.log("Error performing click, will attempt a force click",J),t.force=!0,await this.actionGuardReturn(g().click({position:t.clickOffset,force:!0}),"Click timeout")}break;case"double_click":try{await this.actionGuardReturn(g().dblclick({position:t.clickOffset}),"DoubleClick timeout")}catch(J){this.logger.log("Error performing double click, will attempt a force double click",J),t.force=!0,await this.actionGuardReturn(g().dblclick({position:t.clickOffset,force:!0}),"Click timeout")}break;case"check":await this.actionGuardReturn(g().check(),"Check timeout");break;case"uncheck":await this.actionGuardReturn(g().uncheck(),"UnCheck timeout");break;case"drag_and_drop":await this.actionGuardReturn(g().dragTo(this.makeLocator(t.dropTarget.selector,t.dropTarget.parentFramesSelectors)),"DragAndDrop timeout");break;case"input":await this.actionGuardReturn(g().fill(this.getActionFillValue(t)),"Fill timeout");break;case"click_and_type":await c_(g().click({position:t.clickOffset}),1e4,"Click before type timeout"),await c_(g().pressSequentially(this.getActionFillValue(t)),1e4,"pressSequentially timeout");break;case"clear_and_type":await c_(g().clear(),1e4,"Clear before type timeout"),await c_(g().pressSequentially(this.getActionFillValue(t)),1e4,"pressSequentially timeout");break;case"selectoption":await this.actionGuardReturn(g().selectOption(this.getActionFillValue(t)),"SelectOption timeout");break;case"hover":await this.actionGuardReturn(g().hover(),"Hover timeout");break;case"navigation":await this.actionGuardReturn(this.getPage().goto(t.fillValue),"Navigation timeout",!0);break;case"keystroke":await this.actionGuardReturn(this.getPage().keyboard.press(t.fillValue),"Keystroke timeout");break;case"upload_files":await this.performFileUploadAction(g(),t);break;case"wait":await B_(this.options.waitActionDelay??1e3);break;case"custom_code":let d=`async (page) => {${t.fillValue}}`;await(0,eval)(d)(this.getPage());break;case"logout_and_login":await this.reauthenticate(t.userRole);break}}catch(g){throw this.logger.log(`Error performing action: ${t.eventCode}, will attempt a correction template`,g),await(c==null?void 0:c()),new Error("Failed performing action")}this.logger.log(`Successfully performed action ${t.eventCode} with description "${t.description}"`)}getActionFillValue(t,c=!0){let u=t.fillValue;if(!u){let g=t.selector.match(/(?<=value.*)('|").*/);g&&(u=g[0].slice(1,-1))}return typeof u!="string"&&(u="X"),c&&(t.fillValue=u),u}actionGuardReturn(t,c,u=!1){return c_(t,u?this.options.navigationTimeout:this.options.actionTimeout,c)}makeLocator(t,c){return eE(this.getPage(),t,c)}getCurrentURL(){return this.getPage().url()}async getSelectionDataForChecksumId(t,c){if(c!=null&&c.selector)return{...c,selector:c.selector,clickOffset:c.position};if(!t)return this.logger.log(`[getSelectionDataForChecksumId] checksumid not provided (${t})`),{...c,selector:t};let u=await this.evaluateWithChecksum(async g=>{let{selector:d,locator:b,clickOffset:J,parentFramesSelectors:O,invalid:m,rrwebId:h}=await window.checksum.testGenerator.getSelectorForChecksumId(g),le=await window.checksum.testGenerator.getElementForChecksumId(g),ae=le instanceof HTMLOptionElement&&le.value?le.value:void 0;return{selector:d,locator:b,clickOffset:J,selectOptionValue:ae,parentFramesSelectors:O,invalid:m,rrwebId:h}},t);if($G&&u.invalid&&u.rrwebId){this.logger.log(`[getSelectionDataForChecksumId] Could not get selector for checksumid: ${t}. Trying to use time machine...`);try{let g=await this.getSelectionDataForRRwebIdAtReduceHTMLTime(u.rrwebId);u={...u,...g}}catch{this.logger.log(`[getSelectionDataForChecksumId] error using time machine to get selector for checksumid: ${t}`)}this.logger.log(`[getSelectionDataForChecksumId] got selector: ${u.selector} for checksumid: ${t} from time machine`)}return u!=null&&u.selector||this.logger.log(`[getSelectionDataForChecksumId] Could not get selector for checksumid: ${t}. If checksumid is correct, try to change app rules preMapReducedHTMLSelectors to true`),u}async getSelectionDataForRRwebIdAtReduceHTMLTime(t){if(!this.rrwebEventAtLastReducedHTML)return;let c=this.getTimeMachinePage();if(c)return c.evaluate(async({rrwebId:u,timestamp:g})=>{await window.checksum.timeMachine.goBack(g);let d=await window.checksum.testGenerator.getInspectedElementSelectionResultByRRwebId(u,{fromTimeMachine:!0});return await window.checksum.timeMachine.goLive(),d},{rrwebId:t,timestamp:this.rrwebEventAtLastReducedHTML.timestamp})}async getESRAForSelector(t,c,u){let g=await this.evaluateWithChecksum(async({selector:d,parentFramesSelectors:b})=>window.checksum.testGenerator.getSelectionDataForSelector(d,b),{selector:t,parentFramesSelectors:c});return g!=null&&g.esraMetadata&&u&&(g.esraMetadata.staticMetadata=await u(g.esraMetadata,t)),g==null?void 0:g.esraMetadata}async getMoreItemsForTemplate(t){return await this.evaluateWithChecksum(async c=>window.checksum.testGenerator.getMoreItemsForTemplate(c,{}),t)??{items:"",hasMoreItems:!1}}async getCurrentReducedHTML({retriesLeft:t=3,retryWaitMS:c=2e3,initialChecksumId:u="0",extractESRAForInterpretationRequiredElements:g=!1,stopFlashingElementsDetection:d=!1,assignChecksumIdsToAllElements:b}={}){let J=new Date;this.logger.log("[getCurrentReducedHTML] Fetching reduced HTML...");try{let{reducedHTML:O,currentChecksumId:m,flashingHTML:h,elementsForNodeInterpretation:le,lastRRwebEvent:ae}=await this.evaluateWithChecksum(async ne=>window.checksum.testGenerator.reduceHTML({},ne),{initialChecksumId:u,extractESRAForInterpretationRequiredElements:g,stopFlashingElementsDetection:d,assignChecksumIdsToAllElements:b}),X=new Date;return this.logger.log(`[getCurrentReducedHTML] Fetched reduced HTML in ${X.getTime()-J.getTime()}ms`),this.rrwebEventAtLastReducedHTML=ae,{reducedHTML:O,flashingHTML:h,elementsForNodeInterpretation:le,currentChecksumId:m}}catch(O){if(t>0)return this.logger.logError(`[getCurrentReducedHTML] Error: ${O.message}`),this.logger.logError(`Failed do obtain reduced HTML, trying again in ${c/1e3} seconds, ${t-1} to go.`),await B_(c),this.getCurrentReducedHTML({retriesLeft:t-1,retryWaitMS:c});throw O}}getActionEventCode(t){return{click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",upload_files:"upload_files",wait:"wait",get_more_items:"get_more_items",reset:void 0,save:void 0,fail:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0,logout_and_login:"logout_and_login"}[t]}exampleCustomCode(){function t(u){return new Promise(g=>setTimeout(g,u))}r(t,"sleep");async function c(){let u={foo:r(()=>{console.log("fooed")},"foo")};await(0,eval)('async (page) => {console.log("before foo"); await sleep(1000); page.foo();}')(u)}r(c,"doit"),(async()=>c())()}};r(rA,"TestGenerationPageInteractor");var lS=rA;var YG=__dirname+"/checksumlib.js",nA=1e3*30,M7=!0;var Dh=class Dh{constructor(t,c="normal",u,g,d,b,J,O,m,h,le,ae,X){this.page=t;this.runMode=c;this.codeMirror=u;this.monitorBridge=g;this.testInfo=d;this.checksumTestId=b;this.test=J;this.options=O;this.apiKey=m;this.apiURL=h;this.isReplMode=le;this.config=ae;this.locatorStack=[];this.isTracingActive=!1;this.hasRuntimeStartedTrace=!1;this.unzippedHarData=[];this.fallbacks=[];this.hasHealed=!1;this.thoughtsCounter=0;this.highLevelThoughts=[];this.pages={};var N,F;v3(O.printLogs);let ne=hy({config:this.config,throwIfAuthFailed:!0}),se=this.getPlaywrightProjectConfig();this.pageInteractor=new lS(this.evaluateWithChecksum.bind(this),()=>this.page,()=>this.timeMachinePage,{log:ks,logError:ks},{navigationTimeout:(N=se.use)==null?void 0:N.navigationTimeout,actionTimeout:(F=se.use)==null?void 0:F.actionTimeout,testAssetsDir:XT(um()),waitActionDelay:1e3},ne),this.setPageProxy(),this.registerPageEvents(),this.checkForActiveTracing(),this.resetFallbacks(),X&&(this.highLevelThoughts=X.highLevelThoughts??[],this.pages=X.pages??{},this.timeMachineBrowserContext=X.timeMachineBrowserContext,this.variablesStore=X.variablesStore),this.pages[this.getPageGuid(t)]=this.proxy}static async init(t,c,u,g,d,b,J,O,m=!1){let{apiKey:h,apiURL:le,runMode:ae,options:X}=O;b||(b=y1(5),console.warn(`Checksum test id was not defined for test "${d.title}" and was auto-generated. Please replace - "${d.title}" with -
|
|
273
|
-
test(defineChecksumTest("${d.title}", "${b}"), async ({ page }) => {...`)),u.addTestInfo(b,d.testId),X.useChecksumAI!==void 0&&typeof X.useChecksumAI=="boolean"&&(X.useChecksumAI={actions:X.useChecksumAI,assertions:!1});let ne=new Dh(t,ae,c,u,d,b,J,{useChecksumSelectors:!0,useChecksumAI:{actions:!0,assertions:!1},newAssertionsEnabled:ae!=="normal",useMockData:!1,printLogs:!1,...X},h,le,m,O,{variablesStore:g});return J._checksum.expect.setPage(ne),J._checksum.checksumAI.page=ne,g.clearAll(),await ne.asyncInit(),ne.proxy}async asyncInit(t=!1){if(await this.loadAppSpecificRules(),await this.wrapInternalSteps(async()=>{await this.page.addInitScript(()=>{window.sessionStorage.setItem("checksumai:disable","true")})}),M7){if(!this.timeMachineBrowserContext){iA.chromium._checksumInternal=!0;let c=await iA.chromium.launch({devtools:!1,headless:!0});c._checksumInternal=!0,this.timeMachineBrowserContext=await c.newContext({bypassCSP:!0}),this.timeMachineBrowserContext._checksumInternal=!0,this.timeMachineBrowserContext.tracing.stop(),this.timeMachineBrowserContext.tracing.stop=async()=>{},this.timeMachineBrowserContext.tracing.stopChunk=async()=>{}}this.timeMachinePage=await this.timeMachineBrowserContext.newPage(),this.timeMachinePage._checksumInternal=!0,this.timeMachinePage.mainFrame()._checksumInternal=!0,await this.loadScript(this.timeMachinePage,!0),await this.timeMachinePage.evaluate(()=>window.checksum.timeMachine.start({firstEventTimestamp:Date.now()})),this.timeMachineSync=new cS({getTimeMachinePage:r(()=>this.timeMachinePage,"getTimeMachinePage"),getRRwebEvents:r(async c=>this.evaluateWithChecksum(async({index:u})=>window.checksum.testGenerator.getRRwebEvents(u),{index:c},!1),"getRRwebEvents")}),this.timeMachineSync.start()}t||await this.prepareForTestArtifacts()}async getPage(t){let c=this.page.context().pages()[t];if(!c)throw new Error(`Page with index ${t} not found`);let u=this.getPageGuid(c);if(this.pages[u])return this.pages[u];let g=new Dh(c,this.runMode,this.codeMirror,this.monitorBridge,this.testInfo,this.checksumTestId,this.test,this.options,this.apiKey,this.apiURL,this.isReplMode,this.config,{highLevelThoughts:this.highLevelThoughts,pages:this.pages,timeMachineBrowserContext:this.timeMachineBrowserContext,variablesStore:this.variablesStore});return await g.asyncInit(!0),g.proxy}async reauthenticate(t){try{await this.pageInteractor.reauthenticate(t)}catch(c){throw new Error(`Failed to reauthenticate: ${c}`)}}getPageGuid(t){return t._guid}getPlaywrightProjectConfig(){return this.testInfo.project}checkForActiveTracing(){var g;let c=(g=this.getPlaywrightProjectConfig().use)==null?void 0:g.trace;!c||c==="off"||(this.isTracingActive=!0)}registerPageEvents(){let t=r(async()=>{this.navigationPromise=new Promise((c,u)=>{this.loadScript().then(()=>c()).catch(u)})},"initiateLoadScript");t(),this.page.on("framenavigated",async c=>{this.page.mainFrame()===c&&t()}),this.page.on("filechooser",async c=>{ks("File chooser event detected"),c.setFiles([])})}setPageProxy(){this.proxy=new Proxy(this,{get:r(function(c,u){return c.getPageMethod(u)},"get")})}getPageMethod(t){return typeof this[t]=="function"?this[t].bind(this):!Object.values(gy).includes(t)||!this.testInfo?this.page[t]:(this.locatorStack.length===0&&(this.pageInitialCallInTestFile=this.getFirstStackTraceFromTestFile()),this.pushToLocatorStack([{type:t,base:this.page,line:this.pageInitialCallInTestFile.line}]),r(function(u,g){try{return this.executeLocator(u,g)}catch(d){throw this.popLocatorChain(),d}},"Page").bind(this))}checksumSelector(t){return this.checksumStepId=t,this.options.useChecksumSelectors&&this.setSelectorFallback(t),this.proxy}checksumAI(t,c){let u=this.addNewThought(t,"action",!!c);return c?this.test.step(t,async()=>{var g;try{return await c()}catch(d){if(u.children=[],!this.options.useChecksumAI.actions)throw d;return this.setAIFallback(t),await this.initiateFallbackSequence({type:"action",error:d,method:void 0,args:[]},{fallbackTypes:[ah]})}finally{this.currentThought=(g=this.currentThought)==null?void 0:g.parent}}):(this.options.useChecksumAI.actions&&this.setAIFallback(t),this.proxy)}resolveAssetsFolder(t){return t.map(c=>bm.join(XT(um()),c))}compoundSelection(t){try{let c=new uS(this.page,this.evaluateWithChecksum.bind(this),this.executeLocatorAction.bind(this),this.initiateFallbackSequence.bind(this),t);return this.checksumStepId&&this.options.useChecksumSelectors&&this.setCompoundSelectorFallback(this.checksumStepId),c.init()}catch{throw new Error("Failed generating compound selector")}}getRuntimeOptions(){return this.options}async onTestComplete(t){await this.sendTestArtifacts(),this.cleanupMockData()}async wrapInternalSteps(t,c=this.page){try{return c.mainFrame()._checksumInternal=!0,c._checksumInternal=!0,await t()}finally{c.mainFrame()._checksumInternal=!1,c._checksumInternal=!1}}async conditionallyWrapInternalSteps(t,c){return t?this.wrapInternalSteps(c):c()}async wrapNoLocationSteps(t){try{return this.testInfo._checksumNoLocation=!0,await t()}finally{this.testInfo._checksumNoLocation=!1}}async step(t,c,u=!0,{obtainStep:g=void 0,box:d=!1}={}){try{return this.testInfo._checksumInternal=u===!0,await this.test.step(t,c||(()=>{}),{obtainStep:g,box:d})}finally{this.testInfo._checksumInternal=!1}}addErrorMessage(t,c){this.testInfo.addError(t,c)}async evaluateWithChecksum(t,c,u=!0){return this.navigationPromise&&await this.navigationPromise,this.conditionallyWrapInternalSteps(u,()=>this.page.evaluate(t,c))}addNewThought(t,c,u=!1){let g={id:void 0,thought:t,type:c,children:u?[]:void 0,parent:void 0};if(!this.currentThought)this.highLevelThoughts.push(g);else if(this.currentThought.children)this.currentThought.children.push(g),g.parent=this.currentThought;else{let d=this.currentThought.parent;d?(d.children.push(g),g.parent=d):this.highLevelThoughts.push(g)}return g.parent?g.id=`${g.parent.id}.${g.parent.children.length}`:g.id=`${++this.thoughtsCounter}`,this.currentThought=g,g}buildThoughtsChainForFallback(t=this.highLevelThoughts){let c=[];return t.forEach(u=>{c.push(u.thought),u.children&&c.push(...this.buildThoughtsChainForFallback(u.children))}),c}async loadScript(t=this.page,c=!1){try{return!c&&this.navigationPromise&&await this.navigationPromise,await this.wrapInternalSteps(async()=>{ks("[loadScript] evaluate"),await t.evaluate(()=>!!window.checksum)?ks("checksum already exists in window, no need to load"):(ks("[loadScript] addScriptTag"),await t.addScriptTag({path:YG})),await t.evaluate(async({appSpecificRules:g,esraTimeout:d,sessionRecorder:b})=>{var J;(J=window.checksum)==null||J.testGenerator.init(g,{esraTimeout:d},{assertionGenerator:!1,sessionRecorder:b},{skipElementHighlighting:!0})},{appSpecificRules:this.appSpecificRules,esraTimeout:nA,sessionRecorder:c?!1:M7}),ks(`[init] init script loaded for ${t.url()}`)},t),!0}catch{return!1}}pushToLocatorStack(t){this.locatorStack.push(t)}getCurrentLocatorChain(){if(this.locatorStack.length)return this.locatorStack[this.locatorStack.length-1]}popLocatorChain(){return this.locatorStack.pop()}getCurrentLocatorInChain(){let t=this.getCurrentLocatorChain();return t==null?void 0:t[t.length-1]}getLocator(t,c){let u=this.getCurrentLocatorInChain();return u.base[u.type](t,c)}getFirstStackTraceFromTestFile(){let t=this.getTestFileStackTrace()[0];if(!t)throw new Error(`Could not find test file location from stack trace ${Dh.getStackTrace()}`);let u=[/\((.*):(\d+):(\d+)\)$/,/.*at (.*):(\d+):(\d+)$/].map(J=>J.exec(t)).find(J=>J!==null);if(!u)throw new Error(`Could not find test file location from stack trace ${t}`);let[,g,d,b]=u;return{file:g,line:parseInt(d),column:parseInt(b)}}getTestFileStackTrace(){return Dh.getStackTrace().filter(c=>c.includes(this.testInfo.file))}static getStackTrace(){return new Error().stack.split(`
|
|
272
|
+
`)}`)}async getReductionComponents(c){var u,g;return c.interruptionEvent==="didRequestMoreItemsEvent"?{reducedHTML:(g=(u=c.payload)==null?void 0:u.promptData)==null?void 0:g.reducedHTML,reducedDomHTMLElement:this.lastReducedDOM,flashingHTML:[],elementsForNodeInterpretation:[],currentChecksumId:this.currentChecksumId}:this.pageInteractor.getCurrentReducedHTML({stopFlashingElementsDetection:!0,assignChecksumIdsToAllElements:!0,initialChecksumId:this.currentChecksumId})}async iterate(){var u,g;this.hasPreviousActionFailed=!1;let c=this.CLIENT_MAX_ITERATIONS;do{if(this.didCancel)return!1;let d=await this.getPreviousActionOverview(),{reducedHTML:b,flashingHTML:J,elementsForNodeInterpretation:O,currentChecksumId:m}=await this.getReductionComponents(d);this.lastReducedDOM=new D3.JSDOM(b),this.currentChecksumId=m;let h=await this.getNextAction({reducedHTML:b,flashingHTML:J,elementsForNodeInterpretation:O,previousActionOverview:d});if(this.didCancel)return!1;if(["failed","fail"].includes(h.thought)||["failed","fail"].includes((u=h.action)==null?void 0:u.type))return this.log("[AIFallback] Received failed signal, will quit"),!1;if((h.changedVariables??[]).forEach(({name:X,value:ne})=>{this.checksumPage.variablesStore.setVariable(X,ne)}),this.fallbackData.type==="assertion"){let X=h.thought;this.log(`[AIFallback] for assertion returned with value: ${h.action.value}, feedback: ${X}`);let ne=["irrelevant","pass","soft_reject"].includes(h.action.value);return this.checksumPage.step(`AI: ${X}`,async()=>{}),this.executedSteps.push({type:"assertion",feedback:X}),ne}if(h.thought==="finish"||((g=h.action)==null?void 0:g.type)==="finish")return this.log("[AIFallback] Received finish step"),this.executedSteps.length>0;let ae=await this.pageInteractor.translateActionResponseToAgentPotentialAction(h);try{try{this.checksumPage.step(`AI: ${ae.description}`,async()=>{await this.pageInteractor.performAction(ae)})}catch{throw new Error("Action failed")}this.hasPreviousActionFailed=!1,this.executedSteps.push({type:"action",...ae}),await B_(1e3)}catch(X){this.log("[AIFallback] Error while executing selector",X.message),this.hasPreviousActionFailed=!0;continue}if(--c<=0){this.log("[AIFallback] Maximum repetition reached");break}}while(!0);return!1}async getNextAction({reducedHTML:c,flashingHTML:u,elementsForNodeInterpretation:g,previousActionOverview:d}){let{apiKey:b}=this;if(this.mockServer)return this.finish?{thought:"finish"}:(--this.actionsCounter===0&&(this.finish=!0),{thought:"mock-thought",action:{type:"click",checksumid:"10"}});let J={reduction:{reducedHTML:c,flashingHTML:u,elementsForNodeInterpretation:g},currentURL:this.page.url(),previousActionOverview:d,resolvesSmartAssertion:this.withChecksumAI,variablesString:this.variablesString};try{let m=await(await fetch(`${this.getAPIBaseURL()}/iterate`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:b,sessionId:this.sessionId,iterationData:J})})).json();return this.log("[AIFallback] Received next action",m),m}catch(O){throw this.log("[AIFallback] Error calling iterate",O),O}}async getPreviousActionOverview(){let c=await this.pageInteractor.handleFileChooserEvent();return{success:!this.hasPreviousActionFailed,...this.hasPreviousActionFailed?{failureEvent:"generalExecutionFailureError"}:{},...this.getPreviousWaitActionOverview(),...c,...await this.getPreviousGetMoreItemsActionOverview()}}getExecutedActions(){return this.executedSteps.filter(c=>c.type==="action")}async getPreviousGetMoreItemsActionOverview(){let c=this.getExecutedActions(),u=c[c.length-1];if((u==null?void 0:u.eventCode)!=="get_more_items"||!this.lastReducedDOM)return{};try{return await this.pageInteractor.addMoreItemsToDom(this.lastReducedDOM.window.document.body,u.getMoreItemsId),{interruptionEvent:"didRequestMoreItemsEvent",payload:{promptData:{reducedHTML:this.lastReducedDOM.serialize()},getMoreItemsId:u.getMoreItemsId}}}catch{return{}}}getPreviousWaitActionOverview(){var g;let c=this.getExecutedActions();if(((g=c[c.length-1])==null?void 0:g.eventCode)!=="wait")return{};let u=0;return c.slice().reverse().every(d=>d.eventCode==="wait"?(u++,!0):!1,0),{payload:{waitCount:u}}}async initSession(){let{apiKey:c,goal:u,thoughts:g}=this;if(this.log("[AIFallback] Calling init session...",{appName:c,goal:u,thoughts:g}),!c){let b="Missing Checksum API key, will not run AI fallback";throw YT(b),new Error(b)}if(this.mockServer){this.sessionId="mock-session-id";return}let d={type:this.fallbackData.type,resolveSmartAssertion:this.withChecksumAI,storyTitle:u,testSuiteId:this.testSuiteId,testId:this.testId,thoughtsAndActions:{previous:g.slice(0,Math.max(g.length-1,0)).map(b=>({thought:b})),failing:{thought:g[g.length-1]},next:[]}};try{let b=await fetch(`${this.getAPIBaseURL()}/init`,{method:"POST",headers:{"Content-Type":"application/json",ChecksumAppCode:this.apiKey},body:JSON.stringify({appName:c,data:d})});this.sessionId=await b.text(),this.log("[AIFallback] Session ID",this.sessionId)}catch(b){throw this.withChecksumAI&&b.message==="fetch failed"&&(this.checksumPage.step(cv,async()=>{throw new Error(cv)}),YT(cv)),this.log("[AIFallback] Error calling init session",b),b}}translateExecutedActionToFallbackAction(c){return{type:"action",esraMetadata:c.esraMetadata,generatedLocator:c.locator,selector:c.selector,parentFramesSelectors:c.parentFramesSelectors,method:this.getMethodForPotentialAction(c),thought:c.description}}getMethodForPotentialAction(c){return{name:this.actionEventCodeToMethodName[c.eventCode],args:r(()=>{switch(c.eventCode){case"click":case"double_click":return[{position:c.clickOffset}];case"drag_and_drop":return[this.pageInteractor.makeLocator(c.dropTarget.selector,c.dropTarget.parentFramesSelectors)];case"input":case"click_and_type":case"clear_and_type":case"selectoption":case"keystroke":case"navigation":return[this.pageInteractor.getActionFillValue(c,!1)];case"upload_files":return c.files;default:return}},"makeArgs")()}}getAPIBaseURL(){return this.API_BASE_DOMAIN+this.API_BASE_ROUTE}getFailedThought(){return this.thoughts[this.thoughts.length-1]}toString(){return`Checksum AI ("${this.getFailedThought()}")`}};r(sE,"AIFallback");var ah=sE;var f_=require("fs");var R7=h1(I7());var ZG=250,Zk=class Zk{constructor(t,c){this.timeMachineable=t;this.initMethod=c;this.numberOfReceivedRrwebEventsIndex=0;this.syncTimeMachine=r(async()=>{try{let t;try{t=await this.timeMachineable.getRRwebEvents(this.numberOfReceivedRrwebEventsIndex)}catch{return}if(!t||t.length===0)return;try{await this.timeMachineable.getTimeMachinePage().evaluate(({events:c,len:u})=>window.checksum.timeMachine.handleEvents(c,u),{events:t,len:this.numberOfReceivedRrwebEventsIndex})}catch{return}this.numberOfReceivedRrwebEventsIndex+=t.length}finally{this.syncTimeout=setTimeout(this.syncTimeMachine,ZG)}},"syncTimeMachine")}async start(t=!1){var c;await((c=this.initMethod)==null?void 0:c.call(this,t)),this.syncTimeMachine()}async stop(){clearTimeout(this.syncTimeout)}async disableEventsHandling(){await this.setShouldHandleEvents(!1)}async enableEventsHandling(){await this.setShouldHandleEvents(!0)}async setShouldHandleEvents(t){try{await this.timeMachineable.getTimeMachinePage().evaluate(c=>window.checksum.timeMachine.setShouldHandleEvents(c),t)}catch{}}};r(Zk,"TimeMachineSync");var cS=Zk;var Yk=class Yk{constructor(t,c,u,g,d){this.page=t;this.evaluateWithChecksum=c;this.executeLocatorAction=u;this.initiateFallbackSequence=g;this.locators=d;this.LOCATORS_TIMEOUT=5e3;this.HANDLES_INTERVAL=300}init(){return new Proxy(this,{get:r((t,c)=>this.handleTargetLocator(t,c),"get")})}setTargetLocator(t,c){this.targetLocator=this.page[t](...c)}getLocatorSelector(t){return t._selector}handleTargetLocator(t,c){if(!Object.values(gy).includes(c))throw new Error(`Invalid locator method: ${c}. Compound selector must be followed by a locator method pointing at the target element`);return function(...u){return t.setTargetLocator(c,u),new Proxy(t,{get:r((g,d)=>r(async function(...J){return g.handleAction(d,J)},"Locator"),"get")})}.bind(t)}async handleAction(t,c){var u;try{if(typeof t=="symbol")return;if(!Object.values(GT).includes(t))throw new Error(`Invalid action method: ${t.toString()}. Target locator method must be followed by an action method`);if(!((u=this.locators)!=null&&u.length)||!this.targetLocator)throw new Error("Missing locators or target locator");ks("Waiting for locators..");try{await Promise.all(this.locators.map(b=>c_(b.first().first().waitFor({bypassChecksum:!0}),this.LOCATORS_TIMEOUT)))}catch{throw new Error("Waiting for compound selector locators timeout")}let g=await c_(this.getElementHandles(),5e3);ks(`Resolved to ${$k(g)} elements from ${this.locators.length} locators`);let d=this.getLocatorSelector(this.targetLocator);try{let b=await this.evaluateWithChecksum(async({handles:O,targetSelector:m})=>window.checksum.testGenerator.getCompoundSelector().select(O,m),{handles:g,targetSelector:d});ks(`Resolved compound selector: ${b}`);let J=this.page.locator(b);await this.executeLocatorAction(J,t,c,["elementHandles","waitFor"])}catch(b){throw new Error(`Failed to resolve compound selector: ${b}`)}}catch(g){ks(`Failed to execute compound selection action: ${g}`),await this.initiateFallbackSequence({type:"action",method:t,error:new Error("Compound selection error"),args:c})}}async getElementHandles(){ks("Resolving compound selector elements");let t,c,u,g,d,b=r(()=>{d=2},"resetSameHandlesCount");do t=c,c=[],await Promise.all(this.locators.map(async J=>{let O=await J.elementHandles({bypassChecksum:!0});if(O.length===0)throw new Error(`No elements found for locator: ${this.getLocatorSelector(J)}`);c.push(O)})),u=$k(c),g=t?$k(t):0,ks(`Handles itteration, previous: ${t?g:"-"}, current: ${u}`),g!==u&&b(),await B_(this.HANDLES_INTERVAL);while(!t||g!==u||--d>0);return c}};r(Yk,"CompoundSelectorLocator");var uS=Yk,$k=r(e=>e.reduce((t,c)=>t+c.length,0),"countHandleElements");var eA=class eA extends yy{constructor(){super(...arguments);this.timeout=5*1e3}init(c){return super.init(c),this}async resolve(c){try{let{method:u,args:g}=c,{checksumId:d}=this.data,b;try{let le=await this.getMetadataForTestId();if(!(d in le)||!le[d].compoundSelector)throw new Error(`No compound selection metadata found for id ${d}`);b=le[d].compoundSelector}catch(le){super.log("Could not read compound selector metadata file, ",le)}let J=await this.generateCompoundSelector(b),O=this.pageInteractor.makeLocator(J.selector),m=b.targetSelection.featuresMetadata.tag,h=["check","uncheck"].includes(u)&&m!=="input"?"click":u;try{await this.checksumPage.wrapNoLocationSteps(async()=>this.execute(O,h,g));let le={selector:J.selector,generatedLocator:J.locator,esraMetadata:void 0};return this.sendLog(le),this.checksumPage.addErrorMessage(c.error,`${this.thought?`"${this.thought}" auto-healed`:"Auto-healed"} using alternative selector "${J.selector}"`),{steps:[{type:"action",...le}]}}catch(le){throw new Error(`Failed to execute compound selection fallback action: ${le.message}`)}}catch(u){this.log(u.message);return}}async generateCompoundSelector(c){let u=await this.evaluateWithChecksum(async g=>{var b;return await((b=window.checksum)==null?void 0:b.testGenerator.getCompoundSelector().selectFromMetadata(g))},c);return super.log("Resolved compound selector to",u),u}toString(){return`Checksum compound selector (${this.data.checksumId})`}};r(eA,"CompoundSelectorFallback");var t2=eA;var O7=require("path"),F7=require("fs");var $G=!0,rA=class rA{constructor(t,c,u,g,d,b){this.evaluateWithChecksum=t;this.getPage=c;this.getTimeMachinePage=u;this.logger=g;this.options=d;this.loginFunction=b;this.newPagesIds=[];this.performFileUploadAction=r(async(t,c)=>{if(!await t.evaluate(g=>g.tagName==="INPUT"&&g.getAttribute("type")==="file"))throw new Error("File upload action performed on non-file input element");let u=c.files.map(g=>(0,O7.join)(this.options.testAssetsDir,g)).filter(g=>(0,F7.existsSync)(g)?!0:(this.logger.log(`Upload file not found: ${g}. Filtering out.`),!1));if(!u.length)throw new Error("No files to upload");await this.actionGuardReturn(t.setInputFiles(u),"Set input files timeout")},"performFileUploadAction");this.getSelectionDataForAction=r(async(t,c)=>t.checksumid?this.getSelectionDataForChecksumId(t.checksumid,c):t.position?await this.evaluateWithChecksum(async([u,g])=>window.checksum.testGenerator.getSelectorByPosition(u,g),[t.position.x,t.position.y]):t.selector?{selector:t.selector,locator:`locator("${t.selector}")`}:{selector:"",locator:""},"getSelectionDataForAction")}init(){let t=this.getPage();t.on("filechooser",async c=>{this.logger.log("File chooser event detected"),this.fileChooser=c}),t.context().on("page",c=>{this.newPagesIds.push(c._guid)})}getOpenedFileChooser(){if(this.fileChooser){let t=this.fileChooser;return this.fileChooser=void 0,t}return null}async handleFileChooserEvent(t=[]){let c=this.getOpenedFileChooser();if(!c)return{};let u="fc_"+Math.random().toString(36).slice(2,4);return await this.evaluateWithChecksum(async([g,d])=>{window.checksum.testGenerator.addForceIncludeElement(d,g)},[u,c.element()]),{interruptionEvent:"fileUploadOpenedEvent",payload:{checksumid:u,customFiles:t}}}async addMoreItemsToDom(t,c){let u=t.querySelector(`[checksum-get-more-items='${c}']`);if(!u)throw new Error("Get more items root not found");let{items:g,hasMoreItems:d}=await this.getMoreItemsForTemplate(c);u.innerHTML=u.innerHTML+g,d||u.removeAttribute("checksum-get-more-items")}async getPageInfo(t){return{id:t._guid,url:t.url(),title:await t.title(),new:this.newPagesIds.includes(t._guid),active:t._guid===this.getPage()._guid}}async getTabsInfo(){let t=(await Promise.all(this.getPage().context().pages().map(c=>this.getPageInfo(c)))).filter(c=>{var u;return c.id!==((u=this.getTimeMachinePage())==null?void 0:u._guid)});return this.newPagesIds=[],t}async getSelectionDataFromSelectorGenerator(t,c,u={}){if(u={useCompoundSelector:!0,useCSSExtraction:!0,useVariables:!0,...u},!t||!KT(s3(c.action.type))||!c.action.checksumid)return{};let g=await t.generateSelectionForAction(c,u);return g?{locator:`locator("${g.selector}")`,...g}:{}}async translateActionResponseToAgentPotentialAction(t,c=void 0,{pageId:u,makeStaticMetadataForESRA:g}={}){let d=structuredClone(t.actionHiddenOverride??t.action),{selector:b,selectorWithVars:J,locator:O,locatorWithVars:m,clickOffset:h,selectOptionValue:le,compoundSelector:ae,parentFramesSelectors:X}={...await this.getSelectionDataForAction(d,t.actionHiddenOverride),...await this.getSelectionDataFromSelectorGenerator(c,t)},ne=await this.getESRAForSelector(b,X,g);if(!ne&&b&&this.logger.logError("Error getting ESRA metadata"),(ne==null?void 0:ne.tag)==="select")switch(this.getActionEventCode(d.type)){case"input":d.type="selectoption";break;case"click":le&&(d.type="selectoption",d.value=le);break}let se={eventCode:this.getActionEventCode(d.type),selector:b,selectorWithVars:J,parentFramesSelectors:X,locator:O,locatorWithVars:m,clickOffset:h,pageId:u,compoundSelector:ae,fillValue:d.value,fillValueName:d.valueName?`variablesStore.${d.valueName}`:"",variables:t.variables,getMoreItemsId:d.getMoreItemsId,esraMetadata:ne,description:t.thought,userRole:d.userRole};switch(se.eventCode){case"drag_and_drop":{let{selector:N,selectorWithVars:F,locator:v,locatorWithVars:S,parentFramesSelectors:x}={...await this.getSelectionDataForAction({type:t.action.type,checksumid:t.action.dropTargetChecksumid}),...await this.getSelectionDataFromSelectorGenerator(c,{...t,action:{type:t.action.type,checksumid:t.action.dropTargetChecksumid}},{useCompoundSelector:!1})};se.dropTarget={selector:N,selectorWithVars:F,locator:v,locatorWithVars:S,parentFramesSelectors:x,esraMetadata:await this.getESRAForSelector(N,x,g)}}break;case"upload_files":se.files=this.mapFileMIMETypeToFilename(d.files);break;case"switch_tab":se.switchToTab={id:d.tabId,index:this.getPage().context().pages().findIndex(N=>N._guid===d.tabId)};break;case"keystroke":se.fillValue=d.value}return se}async reauthenticate(t){this.loginFunction&&(await Promise.all([this.getPage().context().clearCookies(),this.getPage().evaluate(()=>localStorage.clear())]),await this.loginFunction(this.getPage(),{role:t}))}mapFileMIMETypeToFilename(t){return t.map(c=>{if(c.fileName)return c.fileName;switch(c.mimeType){case"image/png":return"image_200x200.png";case"image/jpeg":return"image_200x200.jpg";case"application/pdf":return"document.pdf";case"text/csv":return"data.csv";default:return"file.txt"}})}async performAction(t,{handleActionFailed:c,monitorFlashingHTML:u=!0}={}){try{if(t.executed){this.logger.log("[performAction] Action marked as executed, skipping...");return}if(KT(t.eventCode)&&!t.selector)throw new Error("No selector provided for action. Try changing app rules preMapReducedHTMLSelectors to true");u&&(this.logger.log("starting flashing elements detection"),await this.evaluateWithChecksum(async()=>window.checksum.testGenerator.startFlashingElementsDetection())),this.logger.log(`Performing action: ${t.eventCode}. Selector: ${t.selector}, Position: ${t.clickOffset}, Parent frame: ${t.parentFramesSelectors}`);let g=r(()=>this.makeLocator(t.selector,t.parentFramesSelectors),"getLocator");switch(t.eventCode){case"click":try{await this.actionGuardReturn(g().click({position:t.clickOffset}),"Click timeout")}catch(J){this.logger.log("Error performing click, will attempt a force click",J),t.force=!0,await this.actionGuardReturn(g().click({position:t.clickOffset,force:!0}),"Click timeout")}break;case"double_click":try{await this.actionGuardReturn(g().dblclick({position:t.clickOffset}),"DoubleClick timeout")}catch(J){this.logger.log("Error performing double click, will attempt a force double click",J),t.force=!0,await this.actionGuardReturn(g().dblclick({position:t.clickOffset,force:!0}),"Click timeout")}break;case"check":await this.actionGuardReturn(g().check(),"Check timeout");break;case"uncheck":await this.actionGuardReturn(g().uncheck(),"UnCheck timeout");break;case"drag_and_drop":await this.actionGuardReturn(g().dragTo(this.makeLocator(t.dropTarget.selector,t.dropTarget.parentFramesSelectors)),"DragAndDrop timeout");break;case"input":await this.actionGuardReturn(g().fill(this.getActionFillValue(t)),"Fill timeout");break;case"click_and_type":await c_(g().click({position:t.clickOffset}),1e4,"Click before type timeout"),await c_(g().pressSequentially(this.getActionFillValue(t)),1e4,"pressSequentially timeout");break;case"clear_and_type":await c_(g().clear(),1e4,"Clear before type timeout"),await c_(g().pressSequentially(this.getActionFillValue(t)),1e4,"pressSequentially timeout");break;case"selectoption":await this.actionGuardReturn(g().selectOption(this.getActionFillValue(t)),"SelectOption timeout");break;case"hover":await this.actionGuardReturn(g().hover(),"Hover timeout");break;case"navigation":await this.actionGuardReturn(this.getPage().goto(t.fillValue),"Navigation timeout",!0);break;case"keystroke":await this.actionGuardReturn(this.getPage().keyboard.press(t.fillValue),"Keystroke timeout");break;case"upload_files":await this.performFileUploadAction(g(),t);break;case"wait":await B_(this.options.waitActionDelay??1e3);break;case"custom_code":let d=`async (page) => {${t.fillValue}}`;await(0,eval)(d)(this.getPage());break;case"logout_and_login":await this.reauthenticate(t.userRole);break}}catch(g){throw this.logger.log(`Error performing action: ${t.eventCode}, will attempt a correction template`,g),await(c==null?void 0:c()),new Error("Failed performing action")}this.logger.log(`Successfully performed action ${t.eventCode} with description "${t.description}"`)}getActionFillValue(t,c=!0){let u=t.fillValue;if(!u){let g=t.selector.match(/(?<=value.*)('|").*/);g&&(u=g[0].slice(1,-1))}return typeof u!="string"&&(u="X"),c&&(t.fillValue=u),u}actionGuardReturn(t,c,u=!1){return c_(t,u?this.options.navigationTimeout:this.options.actionTimeout,c)}makeLocator(t,c){return eE(this.getPage(),t,c)}getCurrentURL(){return this.getPage().url()}async getSelectionDataForChecksumId(t,c){if(c!=null&&c.selector)return{...c,selector:c.selector,clickOffset:c.position};if(!t)return this.logger.log(`[getSelectionDataForChecksumId] checksumid not provided (${t})`),{...c,selector:t};let u=await this.evaluateWithChecksum(async g=>{let{selector:d,locator:b,clickOffset:J,parentFramesSelectors:O,invalid:m,rrwebId:h}=await window.checksum.testGenerator.getSelectorForChecksumId(g),le=await window.checksum.testGenerator.getElementForChecksumId(g),ae=le instanceof HTMLOptionElement&&le.value?le.value:void 0;return{selector:d,locator:b,clickOffset:J,selectOptionValue:ae,parentFramesSelectors:O,invalid:m,rrwebId:h}},t);if($G&&u.invalid&&u.rrwebId){this.logger.log(`[getSelectionDataForChecksumId] Could not get selector for checksumid: ${t}. Trying to use time machine...`);try{let g=await this.getSelectionDataForRRwebIdAtReduceHTMLTime(u.rrwebId);u={...u,...g}}catch{this.logger.log(`[getSelectionDataForChecksumId] error using time machine to get selector for checksumid: ${t}`)}this.logger.log(`[getSelectionDataForChecksumId] got selector: ${u.selector} for checksumid: ${t} from time machine`)}return u!=null&&u.selector||this.logger.log(`[getSelectionDataForChecksumId] Could not get selector for checksumid: ${t}. If checksumid is correct, try to change app rules preMapReducedHTMLSelectors to true`),u}async getSelectionDataForRRwebIdAtReduceHTMLTime(t){if(!this.rrwebEventAtLastReducedHTML)return;let c=this.getTimeMachinePage();if(c)return c.evaluate(async({rrwebId:u,timestamp:g})=>{await window.checksum.timeMachine.goBack(g);let d=await window.checksum.testGenerator.getInspectedElementSelectionResultByRRwebId(u,{fromTimeMachine:!0});return await window.checksum.timeMachine.goLive(),d},{rrwebId:t,timestamp:this.rrwebEventAtLastReducedHTML.timestamp})}async getESRAForSelector(t,c,u){let g=await this.evaluateWithChecksum(async({selector:d,parentFramesSelectors:b})=>window.checksum.testGenerator.getSelectionDataForSelector(d,b),{selector:t,parentFramesSelectors:c});return g!=null&&g.esraMetadata&&u&&(g.esraMetadata.staticMetadata=await u(g.esraMetadata,t)),g==null?void 0:g.esraMetadata}async getMoreItemsForTemplate(t){return await this.evaluateWithChecksum(async c=>window.checksum.testGenerator.getMoreItemsForTemplate(c,{}),t)??{items:"",hasMoreItems:!1}}async getCurrentReducedHTML({retriesLeft:t=3,retryWaitMS:c=2e3,initialChecksumId:u="0",extractESRAForInterpretationRequiredElements:g=!1,stopFlashingElementsDetection:d=!1,assignChecksumIdsToAllElements:b}={}){let J=new Date;this.logger.log("[getCurrentReducedHTML] Fetching reduced HTML...");try{let{reducedHTML:O,currentChecksumId:m,flashingHTML:h,elementsForNodeInterpretation:le,lastRRwebEvent:ae}=await this.evaluateWithChecksum(async ne=>window.checksum.testGenerator.reduceHTML({},ne),{initialChecksumId:u,extractESRAForInterpretationRequiredElements:g,stopFlashingElementsDetection:d,assignChecksumIdsToAllElements:b}),X=new Date;return this.logger.log(`[getCurrentReducedHTML] Fetched reduced HTML in ${X.getTime()-J.getTime()}ms`),this.rrwebEventAtLastReducedHTML=ae,{reducedHTML:O,flashingHTML:h,elementsForNodeInterpretation:le,currentChecksumId:m}}catch(O){if(t>0)return this.logger.logError(`[getCurrentReducedHTML] Error: ${O.message}`),this.logger.logError(`Failed do obtain reduced HTML, trying again in ${c/1e3} seconds, ${t-1} to go.`),await B_(c),this.getCurrentReducedHTML({retriesLeft:t-1,retryWaitMS:c});throw O}}getActionEventCode(t){return{click:"click",fill:"input",click_and_type:"click_and_type",clear_and_type:"clear_and_type",double_click:"double_click",drag_and_drop:"drag_and_drop",hover:"hover",navigate:"navigation",keystroke:"keystroke",selectoption:"selectoption",upload_files:"upload_files",wait:"wait",get_more_items:"get_more_items",reset:void 0,save:void 0,fail:void 0,finish:void 0,dismiss_modal:void 0,vision_help:void 0,switch_tab:"switch_tab",expand_interactable_elements:void 0,approve_release:void 0,logout_and_login:"logout_and_login"}[t]}exampleCustomCode(){function t(u){return new Promise(g=>setTimeout(g,u))}r(t,"sleep");async function c(){let u={foo:r(()=>{console.log("fooed")},"foo")};await(0,eval)('async (page) => {console.log("before foo"); await sleep(1000); page.foo();}')(u)}r(c,"doit"),(async()=>c())()}};r(rA,"TestGenerationPageInteractor");var lS=rA;var YG=__dirname+"/checksumlib.js",nA=1e3*30,M7=!0;var Dh=class Dh{constructor(t,c="normal",u,g,d,b,J,O,m,h,le,ae,X){this.page=t;this.runMode=c;this.codeMirror=u;this.monitorBridge=g;this.testInfo=d;this.checksumTestId=b;this.test=J;this.options=O;this.apiKey=m;this.apiURL=h;this.isReplMode=le;this.config=ae;this.locatorStack=[];this.isTracingActive=!1;this.hasRuntimeStartedTrace=!1;this.unzippedHarData=[];this.fallbacks=[];this.hasHealed=!1;this.thoughtsCounter=0;this.highLevelThoughts=[];this.pages={};var N,F;v3(O.printLogs);let ne=hy({config:this.config,throwIfAuthFailed:!0}),se=this.getPlaywrightProjectConfig();this.pageInteractor=new lS(this.evaluateWithChecksum.bind(this),()=>this.page,()=>this.timeMachinePage,{log:ks,logError:ks},{navigationTimeout:(N=se.use)==null?void 0:N.navigationTimeout,actionTimeout:(F=se.use)==null?void 0:F.actionTimeout,testAssetsDir:XT(um()),waitActionDelay:1e3},ne),this.setPageProxy(),this.registerPageEvents(),this.checkForActiveTracing(),this.resetFallbacks(),X&&(this.highLevelThoughts=X.highLevelThoughts??[],this.pages=X.pages??{},this.timeMachineBrowserContext=X.timeMachineBrowserContext,this.variablesStore=X.variablesStore),this.pages[this.getPageGuid(t)]=this.proxy}static async init(t,c,u,g,d,b,J,O,m=!1){let{apiKey:h,apiURL:le,runMode:ae,options:X}=O;b||(b=y1(5),console.warn(`Checksum test id was not defined for test "${d.title}" and was auto-generated. Please replace - "${d.title}" with -
|
|
273
|
+
test(defineChecksumTest("${d.title}", "${b}"), async ({ page }) => {...`)),u.addTestInfo(b,d.testId),X.useChecksumAI!==void 0&&typeof X.useChecksumAI=="boolean"&&(X.useChecksumAI={actions:X.useChecksumAI,assertions:!1});let ne=new Dh(t,ae,c,u,d,b,J,{useChecksumSelectors:!0,useChecksumAI:{actions:!0,assertions:!1},newAssertionsEnabled:ae!=="normal",useMockData:!1,printLogs:!1,...X},h,le,m,O,{variablesStore:g});return J._checksum.expect.setPage(ne),J._checksum.checksumAI.page=ne,g.clearAll(),await ne.asyncInit(),ne.proxy}async asyncInit(t=!1){if(await this.loadAppSpecificRules(),await this.wrapInternalSteps(async()=>{await this.page.addInitScript(()=>{window.sessionStorage.setItem("checksumai:disable","true")})}),M7){if(!this.timeMachineBrowserContext){iA.chromium._checksumInternal=!0;let c=await iA.chromium.launch({devtools:!1,headless:!0});c._checksumInternal=!0,this.timeMachineBrowserContext=await c.newContext({bypassCSP:!0}),this.timeMachineBrowserContext._checksumInternal=!0,this.timeMachineBrowserContext.tracing.stop(),this.timeMachineBrowserContext.tracing.stop=async()=>{},this.timeMachineBrowserContext.tracing.stopChunk=async()=>{}}this.timeMachinePage=await this.timeMachineBrowserContext.newPage(),this.timeMachinePage._checksumInternal=!0,this.timeMachinePage.mainFrame()._checksumInternal=!0,await this.loadScript(this.timeMachinePage,!0),await this.timeMachinePage.evaluate(()=>window.checksum.timeMachine.start({firstEventTimestamp:Date.now()})),this.timeMachineSync=new cS({getTimeMachinePage:r(()=>this.timeMachinePage,"getTimeMachinePage"),getRRwebEvents:r(async c=>this.evaluateWithChecksum(async({index:u})=>window.checksum.testGenerator.getRRwebEvents(u),{index:c},!1),"getRRwebEvents")}),this.timeMachineSync.start()}t||await this.prepareForTestArtifacts()}async getPage(t){let c=this.page.context().pages()[t];if(!c)throw new Error(`Page with index ${t} not found`);let u=this.getPageGuid(c);if(this.pages[u])return this.pages[u];let g=new Dh(c,this.runMode,this.codeMirror,this.monitorBridge,this.testInfo,this.checksumTestId,this.test,this.options,this.apiKey,this.apiURL,this.isReplMode,this.config,{highLevelThoughts:this.highLevelThoughts,pages:this.pages,timeMachineBrowserContext:this.timeMachineBrowserContext,variablesStore:this.variablesStore});return await g.asyncInit(!0),g.proxy}async reauthenticate(t){try{await this.pageInteractor.reauthenticate(t)}catch(c){throw new Error(`Failed to reauthenticate: ${c}`)}}getPageGuid(t){return t._guid}getPlaywrightProjectConfig(){return this.testInfo.project}checkForActiveTracing(){var g;let c=(g=this.getPlaywrightProjectConfig().use)==null?void 0:g.trace;!c||c==="off"||(this.isTracingActive=!0)}registerPageEvents(){let t=r(async()=>{this.navigationPromise=new Promise((c,u)=>{this.loadScript().then(()=>c()).catch(u)})},"initiateLoadScript");t(),this.page.on("framenavigated",async c=>{this.page.mainFrame()===c&&t()}),this.page.on("filechooser",async c=>{ks("File chooser event detected"),c.setFiles([])})}setPageProxy(){this.proxy=new Proxy(this,{get:r(function(c,u){return c.getPageMethod(u)},"get")})}getPageMethod(t){return typeof this[t]=="function"?t==="constructor"?this[t]:this[t].bind(this):!Object.values(gy).includes(t)||!this.testInfo?this.page[t]:(this.locatorStack.length===0&&(this.pageInitialCallInTestFile=this.getFirstStackTraceFromTestFile()),this.pushToLocatorStack([{type:t,base:this.page,line:this.pageInitialCallInTestFile.line}]),r(function(u,g){try{return this.executeLocator(u,g)}catch(d){throw this.popLocatorChain(),d}},"Page").bind(this))}checksumSelector(t){return this.checksumStepId=t,this.options.useChecksumSelectors&&this.setSelectorFallback(t),this.proxy}checksumAI(t,c){let u=this.addNewThought(t,"action",!!c);return c?this.test.step(t,async()=>{var g;try{return await c()}catch(d){if(u.children=[],!this.options.useChecksumAI.actions)throw d;return this.setAIFallback(t),await this.initiateFallbackSequence({type:"action",error:d,method:void 0,args:[]},{fallbackTypes:[ah]})}finally{this.currentThought=(g=this.currentThought)==null?void 0:g.parent}}):(this.options.useChecksumAI.actions&&this.setAIFallback(t),this.proxy)}resolveAssetsFolder(t){return t.map(c=>bm.join(XT(um()),c))}compoundSelection(t){try{let c=new uS(this.page,this.evaluateWithChecksum.bind(this),this.executeLocatorAction.bind(this),this.initiateFallbackSequence.bind(this),t);return this.checksumStepId&&this.options.useChecksumSelectors&&this.setCompoundSelectorFallback(this.checksumStepId),c.init()}catch{throw new Error("Failed generating compound selector")}}getRuntimeOptions(){return this.options}async onTestComplete(t){await this.sendTestArtifacts(),this.cleanupMockData()}async wrapInternalSteps(t,c=this.page){try{return c.mainFrame()._checksumInternal=!0,c._checksumInternal=!0,await t()}finally{c.mainFrame()._checksumInternal=!1,c._checksumInternal=!1}}async conditionallyWrapInternalSteps(t,c){return t?this.wrapInternalSteps(c):c()}async wrapNoLocationSteps(t){try{return this.testInfo._checksumNoLocation=!0,await t()}finally{this.testInfo._checksumNoLocation=!1}}async step(t,c,u=!0,{obtainStep:g=void 0,box:d=!1}={}){try{return this.testInfo._checksumInternal=u===!0,await this.test.step(t,c||(()=>{}),{obtainStep:g,box:d})}finally{this.testInfo._checksumInternal=!1}}addErrorMessage(t,c){this.testInfo.addError(t,c)}async evaluateWithChecksum(t,c,u=!0){return this.navigationPromise&&await this.navigationPromise,this.conditionallyWrapInternalSteps(u,()=>this.page.evaluate(t,c))}addNewThought(t,c,u=!1){let g={id:void 0,thought:t,type:c,children:u?[]:void 0,parent:void 0};if(!this.currentThought)this.highLevelThoughts.push(g);else if(this.currentThought.children)this.currentThought.children.push(g),g.parent=this.currentThought;else{let d=this.currentThought.parent;d?(d.children.push(g),g.parent=d):this.highLevelThoughts.push(g)}return g.parent?g.id=`${g.parent.id}.${g.parent.children.length}`:g.id=`${++this.thoughtsCounter}`,this.currentThought=g,g}buildThoughtsChainForFallback(t=this.highLevelThoughts){let c=[];return t.forEach(u=>{c.push(u.thought),u.children&&c.push(...this.buildThoughtsChainForFallback(u.children))}),c}async loadScript(t=this.page,c=!1){try{return!c&&this.navigationPromise&&await this.navigationPromise,await this.wrapInternalSteps(async()=>{ks("[loadScript] evaluate"),await t.evaluate(()=>!!window.checksum)?ks("checksum already exists in window, no need to load"):(ks("[loadScript] addScriptTag"),await t.addScriptTag({path:YG})),await t.evaluate(async({appSpecificRules:g,esraTimeout:d,sessionRecorder:b})=>{var J;(J=window.checksum)==null||J.testGenerator.init(g,{esraTimeout:d},{assertionGenerator:!1,sessionRecorder:b},{skipElementHighlighting:!0})},{appSpecificRules:this.appSpecificRules,esraTimeout:nA,sessionRecorder:c?!1:M7}),ks(`[init] init script loaded for ${t.url()}`)},t),!0}catch{return!1}}pushToLocatorStack(t){this.locatorStack.push(t)}getCurrentLocatorChain(){if(this.locatorStack.length)return this.locatorStack[this.locatorStack.length-1]}popLocatorChain(){return this.locatorStack.pop()}getCurrentLocatorInChain(){let t=this.getCurrentLocatorChain();return t==null?void 0:t[t.length-1]}getLocator(t,c){let u=this.getCurrentLocatorInChain();return u.base[u.type](t,c)}getFirstStackTraceFromTestFile(){let t=this.getTestFileStackTrace()[0];if(!t)throw new Error(`Could not find test file location from stack trace ${Dh.getStackTrace()}`);let u=[/\((.*):(\d+):(\d+)\)$/,/.*at (.*):(\d+):(\d+)$/].map(J=>J.exec(t)).find(J=>J!==null);if(!u)throw new Error(`Could not find test file location from stack trace ${t}`);let[,g,d,b]=u;return{file:g,line:parseInt(d),column:parseInt(b)}}getTestFileStackTrace(){return Dh.getStackTrace().filter(c=>c.includes(this.testInfo.file))}static getStackTrace(){return new Error().stack.split(`
|
|
274
274
|
`)}executeLocator(t,c){try{ks(`
|
|
275
275
|
Executing locator ${this.getCurrentLocatorInChain().type} with ${typeof t=="string"?`selector ${t}`:"locator"}`);let u=this.getLocator(t,c);return new Proxy(u,{get:r((g,d)=>this.getLocatorMethod(u,g,d),"get")})}catch(u){ks("Failed to locate",u)}}getLocatorMethod(t,c,u){return u==="constructor"?r(function(...d){return this.popLocatorChain(),c.constructor(...d)},"Locator"):u in c&&typeof c[u]!="function"||u===Symbol.toPrimitive||u in Object?(this.popLocatorChain(),c[u]):[...Object.values(gy),...Object.values(ub)].includes(u)?u==="or"?(ks("'Or' locator not supported, will execute normally"),this.popLocatorChain(),c[u]):(this.getCurrentLocatorChain().push({type:u,base:t}),r(function(...d){return this.executeLocator(d[0],d[1])},"Locator").bind(this)):r(async function(...d){let b=await this.executeLocatorAction(t,u,d);return this.popLocatorChain(),b},"Locator").bind(this)}async executeLocatorAction(t,c,u){if(u&&Array.from(u).some(O=>(O==null?void 0:O.bypassChecksum)===!0))return t[c](...u);let g=t._selector,d=this.consumeChecksumStepId();ks("Executing",c,g);let b=c==="_expect"?"assertion":"action";b==="action"&&this.lastLocatorActionType==="action"&&(ks("Adding minimal wait between consecutive actions..."),await new Promise(O=>setTimeout(O,100))),this.lastLocatorActionType=b,ks("Running initial locator...");let J;try{this.navigationPromise&&await this.navigationPromise,await this.wrapInternalSteps(async()=>{try{ks("[executeLocatorAction] waitForFunction"),await this.page.waitForFunction(()=>!!window.checksum,{timeout:5e3})}catch{ks("[executeLocatorAction] checksum libs not loaded")}});let O=await pb(t,c,u,this.getLocatorActionTimeout(b,c,u));if(b==="action"){if(O!==!1)return this.resetFallbacks(),O}else if(b==="assertion")return O;J=new Error("Locator action error")}catch(O){ks("Failed initial execution. Exception:",O.message),J=O}switch(b){case"action":return this.initiateFallbackSequence({type:"action",locator:t,method:c,args:u,error:J});case"assertion":throw J}}consumeChecksumStepId(){let t=this.checksumStepId;return this.checksumStepId=void 0,t}setExpectConfiguration(t=void 0){this.expectConfiguration=t}getLocatorActionTimeout(t,c,u){if(this.isReplMode)return null;if(t==="assertion"){let b=this.getAssertionTimeout();return ks(`Assertion timeout set to ${b}`),b}let g=["fill","dragTo"].includes(c)?1:0;return(u[g]??{}).timeout??3e4}getAssertionTimeout(){var c,u,g,d;if(((c=this.expectConfiguration)==null?void 0:c.timeout)!==void 0)return(u=this.expectConfiguration)==null?void 0:u.timeout;let t=(d=(g=this.testInfo._projectInternal)==null?void 0:g.expect)==null?void 0:d.timeout;return t!==void 0?t:3e4}setSelectorFallback(t){let{apiKey:c,apiURL:u}=this;this.pushFallback(this.constructFallback(D1).init({checksumId:t,fileName:this.testInfo.file,testId:this.checksumTestId,apiKey:c,apiURL:u,timeout:nA}))}setCompoundSelectorFallback(t){let{apiKey:c,apiURL:u}=this;this.pushFallback(this.constructFallback(t2).init({checksumId:t,fileName:this.testInfo.file,testId:this.checksumTestId,apiKey:c,apiURL:u,timeout:nA}))}setAIFallback(t){let{apiKey:c,apiURL:u}=this;return this.pushFallback(this.constructFallback(ah).init({goal:this.testInfo.title,apiKey:c,apiURL:u,testId:this.checksumTestId,thoughts:this.buildThoughtsChainForFallback()})),this.proxy}pushFallback(t){this.fallbacks.push(t),this.sortFallbacks()}async runFallback(t,c){let u=t.resolve(c),g=await c_(u,t.timeout);if(!g)throw new Error("Fallback failed");if(this.hasHealed=!0,g.steps.length===1){let d=g.steps[0];d.thought&&(this.currentThought.thought=d.thought)}else this.currentThought.children=g.steps.map((d,b)=>({id:`${this.currentThought.id}.${b+1}`,thought:d.thought,type:d.type,children:void 0,parent:this.currentThought}))}async runConditionallyWithinStep(t,c,u){return t?await this.step(c,u):await u()}async initiateFallbackSequence(t,{fallbackTypes:c=void 0}={}){ks(`[initiateFallbackSequence] with type: ${t.type}...`);let u=this.fallbacks.find(d=>d instanceof ah);if(u){let d=u.getFailedThought(),b=this.variablesStore.getActiveVariablesString();this.fallbacks.forEach(J=>{J.setThought(d),J.setVariables(b)})}let g=this.fallbacks;c&&(g=g.filter(d=>c.reduce((b,J)=>b||d instanceof J,!1))),g=g.filter(d=>d.canResolve(t));try{for(let d of g){let b=d==null?void 0:d.toString();b&&console.log(`Using ${b}`);try{await this.runConditionallyWithinStep(t.type!=="assertion"||!t.withChecksumAI,d.getRecoveryAttemptTitle(t),async()=>{await this.runFallback(d,t)})}catch(J){if(t.withChecksumAI&&J.message==="fetch failed")throw new Error(cv);b&&console.log(`Failed to use ${b}`),d.cancel();continue}return!0}throw t.error}finally{this.resetFallbacks()}}resetFallbacks(){this.fallbacks=[this.constructFallback(S1).init()]}sortFallbacks(){let t=[S1,t2,D1,ah];this.fallbacks.sort((c,u)=>t.indexOf(c.constructor)-t.indexOf(u.constructor))}constructFallback(t){return new t(this.page,this.evaluateWithChecksum.bind(this),this,this.timeMachinePage,this.pageInteractor,{generateSelectionData:this.runMode!=="normal"})}async prepareForTestArtifacts(){if((this.options.useMockData||this.runMode==="refactor")&&await this.prepareAPIMock(),this.isTracingActive){let c=await this.getTraceFilePath();c&&this.monitorBridge.addAsset({type:"trace",path:c,testId:this.checksumTestId})}if(!1){let c=f3(my(this.testInfo.file),this.checksumTestId);this.monitorBridge.addAsset({type:"har",path:c,testId:this.checksumTestId})}}async sendTestArtifacts(){this.runMode!=="normal"&&(await this.codeMirror.write()).forEach(t=>this.monitorBridge.addAsset(t))}async getTraceFilePath(){if(this.isTracingActive)return this.hasRuntimeStartedTrace?_3(my(this.testInfo.file),this.checksumTestId).replace(".zip",".original.zip"):this.testInfo.outputPath("trace.zip")}async prepareMockData(){let t=ZT(my(this.testInfo.file)),c=bm.join(t,`${this.checksumTestId}.har.zip`);if(!(0,f_.existsSync)(c))throw new Error("Could not find har file or zip file");let u=bm.join(t,"tmp");(0,f_.existsSync)(u)||(0,f_.mkdirSync)(u);let g=(0,f_.readFileSync)(c),d=await(0,R7.loadAsync)(g);for(let J of Object.keys(d.files)){let O=await d.file(J).async("string"),m=bm.join(u,J);(0,f_.writeFileSync)(m,O),this.unzippedHarData.push(m)}let b=bm.join(u,"test.har");if(!(0,f_.existsSync)(b))throw this.cleanupMockData(),new Error(`Could not find har file ${b} after unzipping ${c}`);return b}cleanupMockData(){this.unzippedHarData.forEach(t=>{(0,f_.rmSync)(t)}),this.unzippedHarData.length>0&&(0,f_.rmSync)(bm.dirname(this.unzippedHarData[0]),{recursive:!0,force:!0})}async prepareAPIMock(){let t={GET:0,POST:0,PUT:0,DELETE:0};try{let c=await this.prepareMockData();await this.page.routeFromHAR(c,{url:"*/**",notFound:"fallback",update:!1});let u=this.page._routes[0].handler;await this.page.route("**/*",g=>{let d=g.request().headers(),b=g.request().method();d["Checksum-Id"]=(++t[b]).toString(),g.request()._applyFallbackOverrides({headers:d}),u(g)})}catch(c){ks("Error setting up mock data",c.message)}}async loadAppSpecificRules(){this.appSpecificRules={};let t=bm.join(vy(um()),"settings.asr");if(!(0,f_.existsSync)(t)){ks("Could not find ASR file");return}let{ungzip:c}=lb();try{let u=await c((0,f_.readFileSync)(t));this.appSpecificRules=JSON.parse(u)||{}}catch(u){ks("Could not read ASR file",u.message)}}};r(Dh,"ChecksumPage");var fS=Dh;var Eh=h1(yO()),DO=h1(require("path")),xm=require("fs");var f2=class f2{constructor(t,c){this.runMode=t;this.assertionCodeGenerator=c;this.lines=[];this.linesOffsetFromOriginalFile=0;let u={getPageRegexMatchingUrl:r(()=>null,"getPageRegexMatchingUrl"),resolvePageIdFromUrl:r(()=>null,"resolvePageIdFromUrl")}}static init(t,c){return new f2(t,c)}static initWithContent(t,c){let u=new f2("normal",c);return u.lines=[t],u}async load(t,c){if(this.filename)return;this.filename=t,this.testId=c;let u=this.getProcessedFilename(this.filename);(0,xm.existsSync)(u)&&(0,xm.unlinkSync)(u),this.lines=["",...(0,xm.readFileSync)(this.filename,"utf-8").split(`
|
|
276
276
|
`)];try{this.esraMetadataMap=await fb(my(u),c)}catch{console.log("[CodeMirror] Failed loading ESRA metadata for test file, creating new ESRA map"),this.esraMetadataMap={}}}addTestToCode(t,c){let u=Eh.createSourceFile("",this.lines.join(""),Eh.ScriptTarget.ES2015),g=this.findTitleInParentNode(this.getSourceFileChildren(u),u,t.description);if(g){let J=u.text.substring(0,g.pos)+c.generateSingleTestCode(t)+u.text.substring(g.end);return c.styleCode(J)}let d=this.getLastDescribeNode(this.getSourceFileChildren(u),u);if(d){let J=u.text.substring(0,u.text.substring(0,d.end).lastIndexOf("}")-1)+c.generateSingleTestCode(t)+"});";return c.styleCode(J)}let b=u.text+`
|
|
@@ -302,8 +302,8 @@ ${g}`,c(d,g))return u}return u}addESRA(t,c){if(!this.esraMetadataMap)return"";if
|
|
|
302
302
|
\\s]*,\\s*({[\\s\\S]*?}))?[\r
|
|
303
303
|
\\s]*\\)`)}}};r(f2,"CodeMirror");var hS=f2;var AA=class AA{constructor(t,c){this.config=t;this.workerInfo=c;this.hasMonitor=!1;this.monitorAgentHost="http://localhost",this.monitorAgentPort=process.env.CHECKSUM_UPLOAD_AGENT_PORT,this.monitorAgentPort?this.hasMonitor=!0:ks("CHECKSUM_UPLOAD_AGENT_PORT is not defined"),this.sendPlaywrightConfig()}addAsset(t){this.signalUpload(t,["trace","har"].includes(t.type))}addTestInfo(t,c){this.sendMessage({type:"testInfo",payload:{checksumTestId:t,pwTestId:c}})}addSingleTestStats(t,c){this.sendMessage({type:"testStats",payload:{passed:t,healed:c}})}sendPlaywrightConfig(){this.sendMessage({type:"playwrightConfig",payload:{reporter:this.workerInfo.config.reporter}})}sendMessage(t){if(this.hasMonitor)return fetch(`${this.monitorAgentHost}:${this.monitorAgentPort}`,{method:"POST",body:JSON.stringify(t)}).catch(c=>{ks("Failed to send message to test run monitor",t,c)})}signalUpload(t,c=!1){return this.sendMessage({type:"asset",payload:t,watch:c})}};r(AA,"TestRunMonitorBridge");var yS=AA;var BK=r(()=>{let t=new Error().stack.split(`
|
|
304
304
|
`).find(c=>c.includes(".checksum.spec.ts"));if(t)return{lineNumber:parseInt(t.split(":")[1]),columnNumber:parseInt(t.split(":")[2])}},"findCodeLocationFromStackTrace"),NA=class NA{constructor(){this.store={};this.activeVariablesSet=new Set;return new Proxy(this,this)}clearAll(){for(let t in this.store)this.store.hasOwnProperty(t)&&delete this.store[t];this.activeVariablesSet.clear()}getActiveVariables(){let t={};for(let c of this.activeVariablesSet)t[c]=this.store[c];return t}getActiveVariablesString(){return Object.entries(this.getActiveVariables()).map(([t,c])=>`const ${t} = "${c.value}";`).join(`
|
|
305
|
-
`)}setVariable(t,c){this.store[t]={value:c}}set(t,c,u){if(typeof c!="string")return!1;let g=BK();return t.store[c]={value:u,...g,line:""},!0}get(t,c){var u;if(c in t)return t[c];if(!(c in t.store))throw new Error(`Variable ${c} is not defined`);return t.activeVariablesSet.add(c),(u=t.store[c])==null?void 0:u.value}};r(NA,"VariablesStore");var DS=NA;var PA={},bO=r((e,t,c={},u=!1)=>{let{baseURL:g,runMode:d,apiKey:b,apiURL:J}=t,O=e.extend({codeMirror:[async({},m)=>{let h=await hS.init(d,{generateAssertionCode:r(()=>"","generateAssertionCode")});await m(h)},{scope:"worker"}],monitorBridge:[async({},m,h)=>{let le=new yS(t,h);await m(le)},{scope:"worker"}],variablesStore:r(async({},m)=>{let h=new DS;await m(h)},"variablesStore"),page:r(async({page:m,codeMirror:h,monitorBridge:le,variablesStore:ae},X,ne)=>{let se=await fS.init(m,h,le,ae,ne,jK(ne),O,t,u);await X(se),await se.onTestComplete(ne.status==="passed")},"page")});return O.use({launchOptions:{args:["--remote-debugging-port=9222",...c!=null&&c.useMockData?["--disable-web-security"]:[]]},baseURL:g,bypassCSP:!0}),{test:O,defineChecksumTest:JK}},"createChecksumTestExtension"),JK=r((e,t)=>{let u=new Error().stack.split(`
|
|
306
|
-
`).filter(g=>g.includes(".checksum.spec.ts"))[0];if(!u)throw new Error("Could not locate test location. Make sure test is run from valid checksum test file");return PA[u]=t,e},"defineChecksumTest");function jK(e){let{file:t,line:c}=e,u=Object.keys(PA).filter(d=>d.trim().includes(t.trim()));if(!u.length)return;let g=4;for(let d=0;d<g;d++)for(let b of u){let J;try{J=parseInt(b.split(":").reverse()[1])}catch{continue}if(J-d===parseInt(c))return PA[b]}}r(jK,"getCurrentTestIdFromMapping");var wA=class wA{constructor(t,c,u=!1,g={}){this.page=t;this.soft=u;this.configuration=g;this.fallbackEnabled=!1;this.withChecksumAI=!1;this.withChecksumAIMatcher=r(async()=>{throw this.withChecksumAI=!0,new Error},"withChecksumAIMatcher");this.setThought(c)}setThought(t){var c,u;t&&(this.checksumAIThought=this.page.addNewThought(t,"assertion"),(u=(c=this.page.getRuntimeOptions())==null?void 0:c.useChecksumAI)!=null&&u.assertions&&(this.page.setAIFallback(t),this.fallbackEnabled=!0))}get(t,c,u){if(typeof c!="string")return t[c];if(c==="checksumAI")return g=>(this.setThought(g),u);if(c==="withChecksumAI"||typeof t[c]=="function"){let g=c==="withChecksumAI"?this.withChecksumAIMatcher:t[c];return(...d)=>this.checksumAIThought?this.executeMatcherWithinStep(g,t,...d):this.executeMatcher(g,t,...d)}else{let g=t[c];return new Proxy(g,this)}}findNestedErrors(t,c){t.error&&t.infectParentStepsWithError&&c.push(t.error);for(let u of t.steps)this.findNestedErrors(u,c)}async callMatcher(t,c,...u){this.beforeMatcherCall();let g=t.call(c,...u),d=g instanceof Promise?await g:g
|
|
305
|
+
`)}setVariable(t,c){this.store[t]={value:c}}set(t,c,u){if(typeof c!="string")return!1;let g=BK();return t.store[c]={value:u,...g,line:""},!0}get(t,c){var u;if(c in t)return t[c];if(!(c in t.store))throw new Error(`Variable ${c} is not defined`);return t.activeVariablesSet.add(c),(u=t.store[c])==null?void 0:u.value}};r(NA,"VariablesStore");var DS=NA;var PA={},bO=r((e,t,c={},u=!1)=>{let{baseURL:g,runMode:d,apiKey:b,apiURL:J}=t,O=e.extend({codeMirror:[async({},m)=>{let h=await hS.init(d,{generateAssertionCode:r(()=>"","generateAssertionCode")});await m(h)},{scope:"worker"}],monitorBridge:[async({},m,h)=>{let le=new yS(t,h);await m(le)},{scope:"worker"}],variablesStore:r(async({},m)=>{let h=new DS;await m(h)},"variablesStore"),page:r(async({page:m,codeMirror:h,monitorBridge:le,variablesStore:ae},X,ne)=>{let se=await fS.init(m,h,le,ae,ne,jK(ne),O,t,u);Object.defineProperty(se.constructor,"name",{value:"Page"}),await X(se),await se.onTestComplete(ne.status==="passed")},"page")});return O.use({launchOptions:{args:["--remote-debugging-port=9222",...c!=null&&c.useMockData?["--disable-web-security"]:[]]},baseURL:g,bypassCSP:!0}),{test:O,defineChecksumTest:JK}},"createChecksumTestExtension"),JK=r((e,t)=>{let u=new Error().stack.split(`
|
|
306
|
+
`).filter(g=>g.includes(".checksum.spec.ts"))[0];if(!u)throw new Error("Could not locate test location. Make sure test is run from valid checksum test file");return PA[u]=t,e},"defineChecksumTest");function jK(e){let{file:t,line:c}=e,u=Object.keys(PA).filter(d=>d.trim().includes(t.trim()));if(!u.length)return;let g=4;for(let d=0;d<g;d++)for(let b of u){let J;try{J=parseInt(b.split(":").reverse()[1])}catch{continue}if(J-d===parseInt(c))return PA[b]}}r(jK,"getCurrentTestIdFromMapping");var wA=class wA{constructor(t,c,u=!1,g={}){this.page=t;this.soft=u;this.configuration=g;this.fallbackEnabled=!1;this.withChecksumAI=!1;this.withChecksumAIMatcher=r(async()=>{throw this.withChecksumAI=!0,new Error},"withChecksumAIMatcher");this.setThought(c)}setThought(t){var c,u;t&&(this.checksumAIThought=this.page.addNewThought(t,"assertion"),(u=(c=this.page.getRuntimeOptions())==null?void 0:c.useChecksumAI)!=null&&u.assertions&&(this.page.setAIFallback(t),this.fallbackEnabled=!0))}get(t,c,u){if(typeof c!="string")return t[c];if(c==="checksumAI")return g=>(this.setThought(g),u);if(c==="withChecksumAI"||typeof t[c]=="function"){let g=c==="withChecksumAI"?this.withChecksumAIMatcher:t[c];return(...d)=>this.checksumAIThought?this.executeMatcherWithinStep(g,t,...d):this.executeMatcher(g,t,...d)}else{let g=t[c];return new Proxy(g,this)}}findNestedErrors(t,c){t.error&&t.infectParentStepsWithError&&c.push(t.error);for(let u of t.steps)this.findNestedErrors(u,c)}async callMatcher(t,c,...u){this.beforeMatcherCall();let g=t.call(c,...u),d=g instanceof Promise?await g:g;if(this.step){let b=[];if(this.step.error?b.push(this.step.error):this.findNestedErrors(this.step,b),b.length)throw b[0]}return d}executeMatcherWithinStep(t,c,...u){return this.page.step(this.checksumAIThought.thought,()=>this.callMatcher(t,c,...u).catch(this.onMatcherFailure.bind(this)),!1,{obtainStep:r(g=>this.step=g,"obtainStep")}).catch(g=>{if(!this.soft&&!(this.withChecksumAI&&g.message===cv))throw g}).finally(this.afterMatcherExecute.bind(this))}async executeMatcher(t,c,...u){try{return await this.callMatcher(t,c,...u)}catch(g){await this.onMatcherFailure(g)}finally{this.afterMatcherExecute()}}beforeMatcherCall(){this.page.setExpectConfiguration(this.configuration)}afterMatcherExecute(){this.checksumAIThought=void 0,this.fallbackEnabled=!1,this.withChecksumAI=!1,this.page.resetFallbacks(),this.page.setExpectConfiguration(void 0)}async onMatcherFailure(t){if(!this.fallbackEnabled)throw ks("[onMatcherFailure] fallback disabled, continuing with error."),t;ks("[onMatcherFailure] initiating fallback sequence with thought:",this.checksumAIThought.thought);try{await this.page.initiateFallbackSequence({type:"assertion",error:t,withChecksumAI:this.withChecksumAI})}catch(c){if(this.soft)return;throw c}throw this.soft=!0,this.page.testInfo.status="failed",t}};r(wA,"ExpectCallProxyHandler");var bS=wA;var xS=class xS{constructor(t=void 0,c={}){this.page=t;this.configuration=c}get(t,c){return c==="setPage"?u=>{this.page=u}:c==="extend"?(...u)=>{let g=t.extend(...u);return new Proxy(g,this)}:c==="configure"?u=>{let g=t.configure(u);return new Proxy(g,new xS(this.page,{...this.configuration,...u}))}:c==="soft"?(...u)=>{let g=this.manipulateArgsAndExtractThought(u),d=t.soft(...u);return new Proxy(d,this.makeExpectCallProxyHandler(g,!0))}:c==="poll"?(...u)=>{let g=this.manipulateArgsAndExtractThought(u),d=t.poll(...u);return new Proxy(d,this.makeExpectCallProxyHandler(g))}:t[c]instanceof Function?t[c].bind(t):t[c]}apply(t,c,u){let g=this.manipulateArgsAndExtractThought(u),d=t.apply(c,u);return new Proxy(d,this.makeExpectCallProxyHandler(g))}makeExpectCallProxyHandler(t,c){var u;return new bS(this.page,t,c===!0?!0:(u=this.configuration)==null?void 0:u.soft,this.configuration)}manipulateArgsAndExtractThought(t){let c,u=t[1];if(typeof u=="string")c=u,t[1]=void 0;else if(typeof u=="object"){if(u.checksumAI===!1){t[1].checksumAI=void 0;return}u.checksumAI&&typeof u.checksumAI=="string"?(c=u.checksumAI,t[1].checksumAI=void 0):u.message&&(c=u.message,t[1].message=void 0)}return c}};r(xS,"ExpectProxyHandler");var SS=xS;var TS=class TS{constructor(t){this.expect=t;this.proxy=new Proxy(this.expect,new SS)}static init(t){return new TS(t).proxy}};r(TS,"ChecksumExpect");var CS=TS;function UK(e){let t=y3(),{baseURL:c,runMode:u,options:g,apiKey:d,apiURL:b}=t;if(!c)throw new Error("A default baseURL is required - please set it in the config file");if(!d)throw new Error("apiKey is required - please set it in the config file - checksum.config.ts");let J=process.env.CHECKSUM_REPL==="true",{test:O,defineChecksumTest:m}=bO(e,t,g,J),h=CS.init(O.expect),le=zK();O._checksum={expect:h,checksumAI:le},J&&(console.log("Detected REPL mode"),O.beforeEach(async()=>{O.setTimeout(0)}),O.afterEach(async()=>{for(;;)await B_(1e3)}));let ae=r(({name:X,userRole:ne})=>{let{environment:se,user:N}=rE(t,{environment:X,role:ne},!0),F=h3(t,{environment:se,user:N});return{environment:se,user:N,login:F}},"getEnvironment");return{test:O,expect:h,login:hy({config:t}),defineChecksumTest:m,getEnvironment:ae,checksumAI:le}}r(UK,"init");var zK=r(()=>{let e=r(function(){},"func");return e.page=void 0,new Proxy(e,{apply:r(function(c,u,g){return c.page.checksumAI(g[0],g[1])},"apply"),set:r(function(c,u,g){if(u==="page")return c[u]=g},"set")})},"makeChecksumAI");0&&(module.exports={RunMode,getChecksumConfig,getLogin,init});
|
|
307
307
|
/*! Bundled license information:
|
|
308
308
|
|
|
309
309
|
typescript/lib/typescript.js:
|