import{o as e}from"./chunk-mlkTr37E.js";import{t}from"./query-string-RcCSSKcJ.js";import{c as n,g as r,l as i,o as a,r as o,s,u as c}from"./event-B-4OIAbe.js";import{n as l,r as u}from"./axios-fetch-adapter-C745mZql.js";import{t as d}from"./delay-CW5VuKve.js";import{i as f}from"./utils-B6GFbts6.js";var p=e(d()),m=(e=``,n={})=>[`popup.html`,`#`,e||`/`,n?`?`:``,n?t.stringify(n):``].filter(e=>e).join(``),h=(e=``,t={})=>{a({url:m(e,t),active:!0})},g=(e,t=!0)=>{a({url:e,active:t})},_=(e,t=!1)=>n(e,{bypassCache:t}),v=e=>i(e),y=async(e,t=1e3)=>{let n=await a({url:e,active:!1});return await(0,p.default)(t),v(n.id),n},b=async()=>(await s({active:!0}))[0],x=async()=>{let e=await s({active:!0,lastFocusedWindow:!0});return e&&e.length?e[0]:null},S=async()=>s({}),C=async()=>{let e=await s({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:{}})=>{try{return await c(e,t)}catch{return null}},E=async(e,t,n={})=>{let i=!1,a={data:n,_id:f(),event:t};return new Promise(async t=>{r.addListener((e,n,o)=>{if(!i){if(e._id===a._id){t(e.data),i=!0;try{r.removeListener(arguments.callee)}catch{}}return o(!0),!0}}),T(e,a)})},D=async(e,t={})=>E(e,o,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};