var test=function(i,h,d,k){"use strict";function m(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var f=m(d);const r=async t=>{await t.goto("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/welcome"),await t.locator("text=Get Started").click(),await t.waitForURL("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/select-action"),await t.locator("text=Import wallet").click(),await t.waitForURL("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/metametrics-opt-in"),await t.locator('[data-testid="page-container-footer-next"]').click(),await t.waitForURL("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/create-password/import-with-seed-phrase"),await t.locator("select").selectOption("24");const e="hockey   dilemma   magic   rigid   blade   crawl   soldier   screen   mind   siege   disorder   hint   ramp   solid   flat   caution   swamp   anger   attend   trim   tell   obscure   rice   math".split(/\s+/);for(const[n,l]of Object.entries(e)){const c=t.locator(`[data-testid="import-srp__srp-word-${n}"]`);await c.click(),await c.fill(l)}await t.locator("text=I have read and agree to the Terms of Use").click(),await t.locator("#password").click(),await t.locator("#password").fill("Over123456"),await t.locator("#confirm-password").click(),await t.locator("#confirm-password").fill("Over123456"),await t.locator('button:has-text("Import")').click(),await t.waitForURL("chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/home.html#initialize/end-of-flow"),await t.locator("text=All Done").click(),await t.locator(".popover-header__title button").click()},g=h.test.extend({context:async({},t)=>{const a=f.default.join(__dirname,"./extension"),e=await k.chromium.launchPersistentContext("",{devtools:!1,headless:!1,timeout:0,args:[`--disable-extensions-except=${a}`,`--load-extension=${a}`]});await t(e),await e.close()},metaMaskPage:async({context:t,extensionId:a},e)=>{const n=`chrome-extension://${a}/popup.html`,l=t.pages(),c=l.length>0?l[0]:await t.newPage();await r(c),await c.goto(n);for(const w of t.pages())w.url().includes("home.html#initialize/welcome")&&await w.close();await e(c)},extensionId:async({context:t},a)=>{let[e]=t.backgroundPages();e||(e=await t.waitForEvent("backgroundpage"));const n=e.url().split("/")[2];await a(n)}}),o={confirmFeeEtcBtn:["button",{hasText:"Confirm"}],approveAddNetworkBtn:["button",{hasText:"Approve"}],switchNetworkBtn:["button",{hasText:"Switch network"}],rejectBtn:["button",{hasText:"Reject"}],nextBtn:["button",{hasText:"Next"}],connectBtn:["button",{hasText:"Connect"}]},s=async(t,a,e)=>{let n=!1;for(;!n;)await t.reload(),await t.waitForTimeout(1500),n=await t.locator(a,e).isVisible();return t.locator(a,e)};class u{constructor(a){this.metaMaskPage=a}async connect2Wallet(){await s(this.metaMaskPage,...o.nextBtn),await this.metaMaskPage.locator(...o.nextBtn).click(),await this.metaMaskPage.locator(...o.connectBtn).click()}async addAndSwitchNetwork(){await s(this.metaMaskPage,...o.approveAddNetworkBtn),await this.metaMaskPage.locator(...o.approveAddNetworkBtn).click(),await this.metaMaskPage.locator(...o.switchNetworkBtn).click()}async confirmTx(){await s(this.metaMaskPage,...o.confirmFeeEtcBtn),await this.metaMaskPage.locator(...o.confirmFeeEtcBtn).click()}}const b=t=>{console.log(`
---pages begin----`),t.pages().forEach(a=>console.log("pageurl",a.url())),t.backgroundPages().forEach(a=>console.log("background page url",a.url())),console.log(`---pages end----
`)};return i.Metamask=u,i.SELECTORS=o,i.printPageUrls=b,i.signinWallet=r,i.testWithMetaMask=g,i.waitForMetaMask=s,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),i}({},test,path,playwright);
