import{y as e,z as r}from"./permissions-DQjjgS8V.js";import{aL as t,aE as n,aD as a}from"./Main-iyJ1wi9k.js";function i(i,s,o){var c;return e(this,void 0,void 0,function(){var l,u,d,f,m=this;return r(this,function(p){switch(p.label){case 0:return t()?[2,[]]:(l=n(),u=null!==(c=s.enabledMiddleware)&&void 0!==c?c:{},d=Object.entries(u).filter(function(e){return e[0],e[1]}).map(function(e){return e[0]}),f=d.map(function(t){return e(m,void 0,void 0,function(){var e,n,s,c;return r(this,function(r){switch(r.label){case 0:e=t.replace("@segment/",""),n=e,o&&(n=btoa(e).replace(/=/g,"")),s="".concat(l,"/middleware/").concat(n,"/latest/").concat(n,".js.gz"),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,a(s)];case 2:return r.sent(),[2,window["".concat(e,"Middleware")]];case 3:return c=r.sent(),i.log("error",c),i.stats.increment("failed_remote_middleware"),[3,4];case 4:return[2]}})})}),[4,Promise.all(f)]);case 1:return[2,p.sent().filter(Boolean)]}})})}export{i as remoteMiddlewares};
