import{d as p,e as v}from"./inherits_browser-Dbwsx_3T.js";import{e as g,a as M,l as N}from"./index-DXTs-5KJ.js";import"./index-BL19ZEBD.js";function S(o,w,h){var i;return p(this,void 0,void 0,function(){var s,l,c,d,a,b=this;return v(this,function(u){switch(u.label){case 0:return g()?[2,[]]:(s=M(),l=(i=w.enabledMiddleware)!==null&&i!==void 0?i:{},c=Object.entries(l).filter(function(r){r[0];var e=r[1];return e}).map(function(r){var e=r[0];return e}),d=c.map(function(r){return p(b,void 0,void 0,function(){var e,n,m,f;return v(this,function(t){switch(t.label){case 0:e=r.replace("@segment/",""),n=e,h&&(n=btoa(e).replace(/=/g,"")),m="".concat(s,"/middleware/").concat(n,"/latest/").concat(n,".js.gz"),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,N(m)];case 2:return t.sent(),[2,window["".concat(e,"Middleware")]];case 3:return f=t.sent(),o.log("error",f),o.stats.increment("failed_remote_middleware"),[3,4];case 4:return[2]}})})}),[4,Promise.all(d)]);case 1:return a=u.sent(),a=a.filter(Boolean),[2,a]}})})}export{S as remoteMiddlewares};
