const e=e=>void 0===e,n=(t=e,(e,n,s)=>t(e)?s?.():n(e));var t;const s=(e,n,t)=>e.slice(n,t),o=(e,n)=>e?.delete(n),c=Object.freeze,r=e=>new Map(e),a=(e,n)=>e?.get(n),d=(e,n,t)=>void 0===t?(o(e,n),e):e?.set(n,t),i=/\/([^?]*)/,v=t=>{const v=r();return t.on("connection",(t,c)=>{return n((l=c.url,u=i,l?.match(u)),([,i])=>n(c.headers["sec-websocket-key"],async n=>{const c=(f=r,g=l=v,h=u=i,g?.has(h)||d(l,u,f()),a(l,u));var l,u,f,g,h;d(c,n,t),t.on("message",e=>(e=>{const t=e.indexOf("\n");-1!==t&&((e,t)=>{const s=((e,n)=>e+"\n"+n)(n,t);""===e?(e=>{((e,n)=>{e?.forEach(n)})(e,(e,t)=>{return o=e,t!==n?o.send(s):0;var o})})(c):a(c,e)?.send(s)})(s(e,0,t),s(e,t+1))})(e.toString("utf8"))),t.on("close",()=>{o(c,n),(n=>e(n)||0==(e=>e?.size??0)(n))(c)&&o(v,i)})}));var l,u}),c({getWebSocketServer:()=>t,destroy:async()=>{v.clear(),t.close()}})};export{v as createWsServerSimple};
