import{o as e}from"./chunk-mlkTr37E.js";import{t}from"./query-string-RcCSSKcJ.js";import{a as n,c as r,h as i,l as a,o,r as s,s as c}from"./event-TggoEIzN.js";import{n as l,r as u}from"./axios-fetch-adapter-m8Kx6J-y.js";import{t as d}from"./delay-DkB8DMH7.js";import{i as f}from"./utils-Cskn-wTg.js";var p=e(d()),m=(e=``,n={})=>[`popup.html`,`#`,e||`/`,n?`?`:``,n?t.stringify(n):``].filter(e=>e).join(``),h=(e=``,t={})=>{n({url:m(e,t),active:!0})},g=(e,t=!0)=>{n({url:e,active:t})},_=(e,t=!1)=>c(e,{bypassCache:t}),v=e=>r(e),y=async(e,t=1e3)=>{let r=await n({url:e,active:!1});return await(0,p.default)(t),v(r.id),r},b=async()=>(await o({active:!0}))[0],x=async()=>{let e=await o({active:!0,lastFocusedWindow:!0});return e&&e.length?e[0]:null},S=async()=>o({}),C=async()=>{let e=await o({active:!0,lastFocusedWindow:!0});return e&&e.length?e[0].url:``},w=async(e=!1)=>{_((await x()).id,e)},T=async(e,t={_id:{},event:``,data:{}})=>new Promise(n=>{a(e,t,e=>{if(chrome.runtime.lastError){n(null);return}n(e)})}),E=async(e,t,n={})=>{let r=!1,a={data:n,_id:f(),event:t};return new Promise(async t=>{i.addListener((e,n,o)=>{if(!r){if(e._id===a._id){t(e.data),r=!0;try{i.removeListener(arguments.callee)}catch{}}return o(!0),!0}}),T(e,a)})},D=async(e,t={})=>E(e,s,t),O=`${u}/portal/product`,k=async e=>(await S()).find(t=>t.url.includes(e)),A=async()=>k(l),j=async()=>k(O),M=async()=>await j()||(await g(O,!1),new Promise(async e=>{await(0,p.default)(3e3),j().then(t=>{e(t)}),setTimeout(()=>{e(null)},5e4)})),N=async(e=``)=>await A()||(await g(e||l,!1),await(0,p.default)(2e3),A()),P=`https://shopee.vn`,F=[`/verify/captcha`],I=async(e=P)=>{let t=await N();return t?D(t.id,{url:e,method:`GET`}):null},L=async()=>(await S()).filter(e=>e.url.includes(P)).some(e=>{if(F.some(t=>e.url.includes(t)))return!0});export{S as a,y as c,w as d,m as i,g as l,I as n,C as o,M as r,b as s,L as t,h as u};