import{dr as e,lr as t}from"./vendor-neo4j-ndl.llONqzcp.js";import{i as n,t as r,u as i}from"./load-script.D723anRf.js";function a(a,o,s){return t(this,void 0,void 0,function(){var c,l,u,d,f,p=this;return e(this,function(m){switch(m.label){case 0:return i()?[2,[]]:(c=n(),l=o.enabledMiddleware??{},u=Object.entries(l).filter(function(e){return e[0],e[1]}).map(function(e){return e[0]}),d=u.map(function(n){return t(p,void 0,void 0,function(){var t,i,o,l;return e(this,function(e){switch(e.label){case 0:t=n.replace(`@segment/`,``),i=t,s&&(i=btoa(t).replace(/=/g,``)),o=`${c}/middleware/${i}/latest/${i}.js.gz`,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r(o)];case 2:return e.sent(),[2,window[`${t}Middleware`]];case 3:return l=e.sent(),a.log(`error`,l),a.stats.increment(`failed_remote_middleware`),[3,4];case 4:return[2]}})})}),[4,Promise.all(d)]);case 1:return f=m.sent(),f=f.filter(Boolean),[2,f]}})})}export{a as remoteMiddlewares};