var webextLaunchWebAuthFlow=function(){"use strict";function e(e,r,t,n,o,i,s){try{var u=e[i](s),c=u.value}catch(e){return void t(e)}u.done?r(c):Promise.resolve(c).then(n,o)}function r(r){return function(){var t=this,n=arguments;return new Promise((function(o,i){var s=r.apply(t,n);function u(r){e(s,o,i,u,c,"next",r)}function c(r){e(s,o,i,u,c,"throw",r)}u(void 0)}))}}function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(e){for(var r=1;r{e.resolve=r,e.reject=t}),e}function d(){return(d=r((function*({url:e,redirect_uri:r,interactive:t=!1,alwaysUseTab:n=!1,windowOptions:s}){const c=yield i(o({type:"popup",url:e,state:"minimized"},s),n),b=c.id,d=c.tabs[0].id,f=l(),p=f.promise,w=f.resolve,y=f.reject;browser.webRequest.onBeforeRequest.addListener(v,{urls:["*://*/*"],tabId:d,types:["main_frame"]},["blocking"]),browser.webNavigation.onDOMContentLoaded.addListener(m),browser.tabs.onRemoved.addListener(O);try{return yield p}finally{browser.webRequest.onBeforeRequest.removeListener(v),browser.webNavigation.onDOMContentLoaded.removeListener(m),browser.tabs.onRemoved.removeListener(O),a(b,d).catch(e=>console.error(e))}function v(e){if(!e.frameId&&e.tabId===d&&e.url.startsWith(r))return w(e.url),{cancel:!0}}function m(e){e.frameId||e.tabId!==d||(t?u(b,d,{focused:!0,state:"normal"}).catch(e=>console.error(e)):y(new Error("User interaction required")),browser.webNavigation.onDOMContentLoaded.removeListener(m))}function O(e){e===d&&y(new Error("Canceled by user"))}}))).apply(this,arguments)}return function(e){return d.apply(this,arguments)}}(); //# sourceMappingURL=webext-launch-web-auth-flow.min.js.map