diff --git a/dist/testing/mockserver/index.js b/dist/testing/mockserver/index.js index 4ce0c3a..a341a8c 100644 --- a/dist/testing/mockserver/index.js +++ b/dist/testing/mockserver/index.js @@ -1388,23 +1388,31 @@ function getRequestHeader(event, name) { return value; } const getHeader = (/* unused pure expression or super */ null && (getRequestHeader)); -function getRequestHost(event) { - const xForwardedHost = event.node.req.headers["x-forwarded-host"]; - if (xForwardedHost) { - return xForwardedHost; +function getRequestHost(event, opts = {}) { + if (opts.xForwardedHost) { + const xForwardedHost = event.node.req.headers["x-forwarded-host"]; + if (xForwardedHost) { + return xForwardedHost; + } } return event.node.req.headers.host || "localhost"; } -function getRequestProtocol(event) { - if (event.node.req.headers["x-forwarded-proto"] === "https") { +function getRequestProtocol(event, opts = {}) { + if (opts.xForwardedProto !== false && event.node.req.headers["x-forwarded-proto"] === "https") { return "https"; } return event.node.req.connection.encrypted ? "https" : "http"; } -function getRequestURL(event) { - const host = getRequestHost(event); +const DOUBLE_SLASH_RE = /[/\\]{2,}/g; +function getRequestPath(event) { + const path = (event.node.req.url || "/").replace(DOUBLE_SLASH_RE, "/"); + return path; +} +function getRequestURL(event, opts = {}) { + const host = getRequestHost(event, opts); const protocol = getRequestProtocol(event); - return new URL(event.path || "/", `${protocol}://${host}`); + const path = getRequestPath(event); + return new URL(path, `${protocol}://${host}`); } const RawBodySymbol = Symbol.for("h3RawBody"); @@ -2216,7 +2224,7 @@ class H3Event { this.node = { req, res }; } get path() { - return this.req.url; + return getRequestPath(this); } /** @deprecated Please use `event.node.req` instead. **/ get req() { diff --git a/dist/testing/mockserver/index.js.map b/dist/testing/mockserver/index.js.map index a5ffddc..0aff3d3 100644 --- a/dist/testing/mockserver/index.js.map +++ b/dist/testing/mockserver/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACpFA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACzBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACRA;AACA;AACA;AACA;AACA;;;;;ACJA;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACNA;AACA;;;;ACDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC55CA;;ACAA;;;;ACAA;;ACAA;;ACAA;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrJA;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AC1PA;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7fA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":["../webpack://speckle-automate-github-action/./node_modules/http-shutdown/index.js","../webpack://speckle-automate-github-action/external node-commonjs \"assert\"","../webpack://speckle-automate-github-action/external node-commonjs \"buffer\"","../webpack://speckle-automate-github-action/external node-commonjs \"child_process\"","../webpack://speckle-automate-github-action/external node-commonjs \"crypto\"","../webpack://speckle-automate-github-action/external node-commonjs \"events\"","../webpack://speckle-automate-github-action/external node-commonjs \"fs\"","../webpack://speckle-automate-github-action/external node-commonjs \"http\"","../webpack://speckle-automate-github-action/external node-commonjs \"https\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:path\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:process\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:url\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:util\"","../webpack://speckle-automate-github-action/external node-commonjs \"os\"","../webpack://speckle-automate-github-action/external node-commonjs \"path\"","../webpack://speckle-automate-github-action/external node-commonjs \"stream\"","../webpack://speckle-automate-github-action/external node-commonjs \"util\"","../webpack://speckle-automate-github-action/webpack/bootstrap","../webpack://speckle-automate-github-action/webpack/runtime/create fake namespace object","../webpack://speckle-automate-github-action/webpack/runtime/define property getters","../webpack://speckle-automate-github-action/webpack/runtime/ensure chunk","../webpack://speckle-automate-github-action/webpack/runtime/get javascript chunk filename","../webpack://speckle-automate-github-action/webpack/runtime/hasOwnProperty shorthand","../webpack://speckle-automate-github-action/webpack/runtime/make namespace object","../webpack://speckle-automate-github-action/webpack/runtime/compat","../webpack://speckle-automate-github-action/webpack/runtime/import chunk loading","../webpack://speckle-automate-github-action/./node_modules/h3/node_modules/ufo/dist/index.mjs","../webpack://speckle-automate-github-action/./node_modules/radix3/dist/index.mjs","../webpack://speckle-automate-github-action/./node_modules/defu/dist/defu.mjs","../webpack://speckle-automate-github-action/./node_modules/h3/dist/index.mjs","../webpack://speckle-automate-github-action/external node-commonjs \"node:http\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:https\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:fs\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:os\"","../webpack://speckle-automate-github-action/external node-commonjs \"tty\"","../webpack://speckle-automate-github-action/./node_modules/colorette/index.js","../webpack://speckle-automate-github-action/external node-commonjs \"node:net\"","../webpack://speckle-automate-github-action/./node_modules/get-port-please/dist/index.mjs","../webpack://speckle-automate-github-action/external node-commonjs \"node:child_process\"","../webpack://speckle-automate-github-action/./node_modules/listhen/dist/index.mjs","../webpack://speckle-automate-github-action/./src/tests/mock-server.ts"],"sourcesContent":["'use strict';\nvar http = require('http');\nvar https = require('https');\n\n/**\n * Expose `addShutdown`.\n */\nexports = module.exports = addShutdown;\n\n/**\n * Adds shutdown functionaility to the `http.Server` object\n * @param {http.Server} server The server to add shutdown functionaility to\n */\nfunction addShutdown(server) {\n var connections = {};\n var isShuttingDown = false;\n var connectionCounter = 0;\n\n function destroy(socket, force) {\n if (force || (socket._isIdle && isShuttingDown)) {\n socket.destroy();\n delete connections[socket._connectionId];\n }\n };\n\n function onConnection(socket) {\n var id = connectionCounter++;\n socket._isIdle = true;\n socket._connectionId = id;\n connections[id] = socket;\n\n socket.on('close', function() {\n delete connections[id];\n });\n };\n\n server.on('request', function(req, res) {\n req.socket._isIdle = false;\n\n res.on('finish', function() {\n req.socket._isIdle = true;\n destroy(req.socket);\n });\n });\n\n server.on('connection', onConnection);\n server.on('secureConnection', onConnection);\n\n function shutdown(force, cb) {\n isShuttingDown = true;\n server.close(function(err) {\n if (cb) {\n process.nextTick(function() { cb(err); });\n }\n });\n\n Object.keys(connections).forEach(function(key) {\n destroy(connections[key], force);\n });\n };\n\n server.shutdown = function(cb) {\n shutdown(false, cb);\n };\n\n server.forceShutdown = function(cb) {\n shutdown(true, cb);\n };\n\n return server;\n};\n\n/**\n * Extends the {http.Server} object with shutdown functionaility.\n * @return {http.Server} The decorated server object\n */\nexports.extend = function() {\n http.Server.prototype.withShutdown = function() {\n return addShutdown(this);\n };\n\n https.Server.prototype.withShutdown = function() {\n return addShutdown(this);\n };\n};\n","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"assert\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"buffer\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"child_process\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"crypto\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"events\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"fs\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"http\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"https\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:path\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:process\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:url\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:util\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"os\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"path\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"stream\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"util\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\tvar threw = true;\n\ttry {\n\t\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\t\tthrew = false;\n\t} finally {\n\t\tif(threw) delete __webpack_module_cache__[moduleId];\n\t}\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);\nvar leafPrototypes;\n// create a fake namespace object\n// mode & 1: value is a module id, require it\n// mode & 2: merge all properties of value into the ns\n// mode & 4: return value when already ns object\n// mode & 16: return value when it's Promise-like\n// mode & 8|1: behave like require\n__webpack_require__.t = function(value, mode) {\n\tif(mode & 1) value = this(value);\n\tif(mode & 8) return value;\n\tif(typeof value === 'object' && value) {\n\t\tif((mode & 4) && value.__esModule) return value;\n\t\tif((mode & 16) && typeof value.then === 'function') return value;\n\t}\n\tvar ns = Object.create(null);\n\t__webpack_require__.r(ns);\n\tvar def = {};\n\tleafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];\n\tfor(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {\n\t\tObject.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));\n\t}\n\tdef['default'] = () => (value);\n\t__webpack_require__.d(ns, def);\n\treturn ns;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = (chunkId) => {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"\" + chunkId + \".index.js\";\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","\nif (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\\/\\/\\/\\w:/) ? 1 : 0, -1) + \"/\";","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t179: 0\n};\n\nvar installChunk = (data) => {\n\tvar {ids, modules, runtime} = data;\n\t// add \"modules\" to the modules object,\n\t// then flag all \"ids\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tfor(moduleId in modules) {\n\t\tif(__webpack_require__.o(modules, moduleId)) {\n\t\t\t__webpack_require__.m[moduleId] = modules[moduleId];\n\t\t}\n\t}\n\tif(runtime) runtime(__webpack_require__);\n\tfor(;i < ids.length; i++) {\n\t\tchunkId = ids[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[ids[i]] = 0;\n\t}\n\n}\n\n__webpack_require__.f.j = (chunkId, promises) => {\n\t\t// import() chunk loading for javascript\n\t\tvar installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;\n\t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n\t\t\t// a Promise means \"currently loading\".\n\t\t\tif(installedChunkData) {\n\t\t\t\tpromises.push(installedChunkData[1]);\n\t\t\t} else {\n\t\t\t\tif(true) { // all chunks have JS\n\t\t\t\t\t// setup Promise in chunk cache\n\t\t\t\t\tvar promise = import(\"./\" + __webpack_require__.u(chunkId)).then(installChunk, (e) => {\n\t\t\t\t\t\tif(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined;\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t});\n\t\t\t\t\tvar promise = Promise.race([promise, new Promise((resolve) => (installedChunkData = installedChunks[chunkId] = [resolve]))])\n\t\t\t\t\tpromises.push(installedChunkData[1] = promise);\n\t\t\t\t} else installedChunks[chunkId] = 0;\n\t\t\t}\n\t\t}\n};\n\n// no external install chunk\n\n// no on chunks loaded","const n = /[^\\0-\\x7E]/;\nconst t = /[\\x2E\\u3002\\uFF0E\\uFF61]/g;\nconst o = {\n overflow: \"Overflow Error\",\n \"not-basic\": \"Illegal Input\",\n \"invalid-input\": \"Invalid Input\"\n};\nconst e = Math.floor;\nconst r = String.fromCharCode;\nfunction s(n2) {\n throw new RangeError(o[n2]);\n}\nconst c = function(n2, t2) {\n return n2 + 22 + 75 * (n2 < 26) - ((t2 != 0) << 5);\n};\nconst u = function(n2, t2, o2) {\n let r2 = 0;\n for (n2 = o2 ? e(n2 / 700) : n2 >> 1, n2 += e(n2 / t2); n2 > 455; r2 += 36) {\n n2 = e(n2 / 35);\n }\n return e(r2 + 36 * n2 / (n2 + 38));\n};\nfunction toASCII(o2) {\n return function(n2, o3) {\n const e2 = n2.split(\"@\");\n let r2 = \"\";\n e2.length > 1 && (r2 = e2[0] + \"@\", n2 = e2[1]);\n const s2 = function(n3, t2) {\n const o4 = [];\n let e3 = n3.length;\n for (; e3--; ) {\n o4[e3] = t2(n3[e3]);\n }\n return o4;\n }((n2 = n2.replace(t, \".\")).split(\".\"), o3).join(\".\");\n return r2 + s2;\n }(o2, function(t2) {\n return n.test(t2) ? \"xn--\" + function(n2) {\n const t3 = [];\n const o3 = (n2 = function(n3) {\n const t4 = [];\n let o4 = 0;\n const e2 = n3.length;\n for (; o4 < e2; ) {\n const r2 = n3.charCodeAt(o4++);\n if (r2 >= 55296 && r2 <= 56319 && o4 < e2) {\n const e3 = n3.charCodeAt(o4++);\n (64512 & e3) == 56320 ? t4.push(((1023 & r2) << 10) + (1023 & e3) + 65536) : (t4.push(r2), o4--);\n } else {\n t4.push(r2);\n }\n }\n return t4;\n }(n2)).length;\n let f = 128;\n let i = 0;\n let l = 72;\n for (const o4 of n2) {\n o4 < 128 && t3.push(r(o4));\n }\n const h = t3.length;\n let p = h;\n for (h && t3.push(\"-\"); p < o3; ) {\n let o4 = 2147483647;\n for (const t4 of n2) {\n t4 >= f && t4 < o4 && (o4 = t4);\n }\n const a = p + 1;\n o4 - f > e((2147483647 - i) / a) && s(\"overflow\"), i += (o4 - f) * a, f = o4;\n for (const o5 of n2) {\n if (o5 < f && ++i > 2147483647 && s(\"overflow\"), o5 == f) {\n let n3 = i;\n for (let o6 = 36; ; o6 += 36) {\n const s2 = o6 <= l ? 1 : o6 >= l + 26 ? 26 : o6 - l;\n if (n3 < s2) {\n break;\n }\n const u2 = n3 - s2;\n const f2 = 36 - s2;\n t3.push(r(c(s2 + u2 % f2, 0))), n3 = e(u2 / f2);\n }\n t3.push(r(c(n3, 0))), l = u(i, a, p == h), i = 0, ++p;\n }\n }\n ++i, ++f;\n }\n return t3.join(\"\");\n }(t2) : t2;\n });\n}\n\nconst HASH_RE = /#/g;\nconst AMPERSAND_RE = /&/g;\nconst SLASH_RE = /\\//g;\nconst EQUAL_RE = /=/g;\nconst IM_RE = /\\?/g;\nconst PLUS_RE = /\\+/g;\nconst ENC_CARET_RE = /%5e/gi;\nconst ENC_BACKTICK_RE = /%60/gi;\nconst ENC_CURLY_OPEN_RE = /%7b/gi;\nconst ENC_PIPE_RE = /%7c/gi;\nconst ENC_CURLY_CLOSE_RE = /%7d/gi;\nconst ENC_SPACE_RE = /%20/gi;\nconst ENC_SLASH_RE = /%2f/gi;\nconst ENC_ENC_SLASH_RE = /%252f/gi;\nfunction encode(text) {\n return encodeURI(\"\" + text).replace(ENC_PIPE_RE, \"|\");\n}\nfunction encodeHash(text) {\n return encode(text).replace(ENC_CURLY_OPEN_RE, \"{\").replace(ENC_CURLY_CLOSE_RE, \"}\").replace(ENC_CARET_RE, \"^\");\n}\nfunction encodeQueryValue(input) {\n return encode(typeof input === \"string\" ? input : JSON.stringify(input)).replace(PLUS_RE, \"%2B\").replace(ENC_SPACE_RE, \"+\").replace(HASH_RE, \"%23\").replace(AMPERSAND_RE, \"%26\").replace(ENC_BACKTICK_RE, \"`\").replace(ENC_CARET_RE, \"^\");\n}\nfunction encodeQueryKey(text) {\n return encodeQueryValue(text).replace(EQUAL_RE, \"%3D\");\n}\nfunction encodePath(text) {\n return encode(text).replace(HASH_RE, \"%23\").replace(IM_RE, \"%3F\").replace(ENC_ENC_SLASH_RE, \"%2F\").replace(AMPERSAND_RE, \"%26\").replace(PLUS_RE, \"%2B\");\n}\nfunction encodeParam(text) {\n return encodePath(text).replace(SLASH_RE, \"%2F\");\n}\nfunction decode(text = \"\") {\n try {\n return decodeURIComponent(\"\" + text);\n } catch {\n return \"\" + text;\n }\n}\nfunction decodePath(text) {\n return decode(text.replace(ENC_SLASH_RE, \"%252F\"));\n}\nfunction decodeQueryValue(text) {\n return decode(text.replace(PLUS_RE, \" \"));\n}\nfunction encodeHost(name = \"\") {\n return toASCII(name);\n}\n\nfunction parseQuery(parametersString = \"\") {\n const object = {};\n if (parametersString[0] === \"?\") {\n parametersString = parametersString.slice(1);\n }\n for (const parameter of parametersString.split(\"&\")) {\n const s = parameter.match(/([^=]+)=?(.*)/) || [];\n if (s.length < 2) {\n continue;\n }\n const key = decode(s[1]);\n if (key === \"__proto__\" || key === \"constructor\") {\n continue;\n }\n const value = decodeQueryValue(s[2] || \"\");\n if (typeof object[key] !== \"undefined\") {\n if (Array.isArray(object[key])) {\n object[key].push(value);\n } else {\n object[key] = [object[key], value];\n }\n } else {\n object[key] = value;\n }\n }\n return object;\n}\nfunction encodeQueryItem(key, value) {\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n value = String(value);\n }\n if (!value) {\n return encodeQueryKey(key);\n }\n if (Array.isArray(value)) {\n return value.map((_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`).join(\"&\");\n }\n return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;\n}\nfunction stringifyQuery(query) {\n return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).join(\"&\");\n}\n\nclass $URL {\n constructor(input = \"\") {\n this.query = {};\n if (typeof input !== \"string\") {\n throw new TypeError(\n `URL input should be string received ${typeof input} (${input})`\n );\n }\n const parsed = parseURL(input);\n this.protocol = decode(parsed.protocol);\n this.host = decode(parsed.host);\n this.auth = decode(parsed.auth);\n this.pathname = decodePath(parsed.pathname);\n this.query = parseQuery(parsed.search);\n this.hash = decode(parsed.hash);\n }\n get hostname() {\n return parseHost(this.host).hostname;\n }\n get port() {\n return parseHost(this.host).port || \"\";\n }\n get username() {\n return parseAuth(this.auth).username;\n }\n get password() {\n return parseAuth(this.auth).password || \"\";\n }\n get hasProtocol() {\n return this.protocol.length;\n }\n get isAbsolute() {\n return this.hasProtocol || this.pathname[0] === \"/\";\n }\n get search() {\n const q = stringifyQuery(this.query);\n return q.length > 0 ? \"?\" + q : \"\";\n }\n get searchParams() {\n const p = new URLSearchParams();\n for (const name in this.query) {\n const value = this.query[name];\n if (Array.isArray(value)) {\n for (const v of value) {\n p.append(name, v);\n }\n } else {\n p.append(\n name,\n typeof value === \"string\" ? value : JSON.stringify(value)\n );\n }\n }\n return p;\n }\n get origin() {\n return (this.protocol ? this.protocol + \"//\" : \"\") + encodeHost(this.host);\n }\n get fullpath() {\n return encodePath(this.pathname) + this.search + encodeHash(this.hash);\n }\n get encodedAuth() {\n if (!this.auth) {\n return \"\";\n }\n const { username, password } = parseAuth(this.auth);\n return encodeURIComponent(username) + (password ? \":\" + encodeURIComponent(password) : \"\");\n }\n get href() {\n const auth = this.encodedAuth;\n const originWithAuth = (this.protocol ? this.protocol + \"//\" : \"\") + (auth ? auth + \"@\" : \"\") + encodeHost(this.host);\n return this.hasProtocol && this.isAbsolute ? originWithAuth + this.fullpath : this.fullpath;\n }\n append(url) {\n if (url.hasProtocol) {\n throw new Error(\"Cannot append a URL with protocol\");\n }\n Object.assign(this.query, url.query);\n if (url.pathname) {\n this.pathname = withTrailingSlash(this.pathname) + withoutLeadingSlash(url.pathname);\n }\n if (url.hash) {\n this.hash = url.hash;\n }\n }\n toJSON() {\n return this.href;\n }\n toString() {\n return this.href;\n }\n}\n\nfunction isRelative(inputString) {\n return [\"./\", \"../\"].some((string_) => inputString.startsWith(string_));\n}\nconst PROTOCOL_STRICT_REGEX = /^\\w{2,}:([/\\\\]{1,2})/;\nconst PROTOCOL_REGEX = /^\\w{2,}:([/\\\\]{2})?/;\nconst PROTOCOL_RELATIVE_REGEX = /^([/\\\\]\\s*){2,}[^/\\\\]/;\nfunction hasProtocol(inputString, opts = {}) {\n if (typeof opts === \"boolean\") {\n opts = { acceptRelative: opts };\n }\n if (opts.strict) {\n return PROTOCOL_STRICT_REGEX.test(inputString);\n }\n return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);\n}\nconst TRAILING_SLASH_RE = /\\/$|\\/\\?/;\nfunction hasTrailingSlash(input = \"\", queryParameters = false) {\n if (!queryParameters) {\n return input.endsWith(\"/\");\n }\n return TRAILING_SLASH_RE.test(input);\n}\nfunction withoutTrailingSlash(input = \"\", queryParameters = false) {\n if (!queryParameters) {\n return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || \"/\";\n }\n if (!hasTrailingSlash(input, true)) {\n return input || \"/\";\n }\n const [s0, ...s] = input.split(\"?\");\n return (s0.slice(0, -1) || \"/\") + (s.length > 0 ? `?${s.join(\"?\")}` : \"\");\n}\nfunction withTrailingSlash(input = \"\", queryParameters = false) {\n if (!queryParameters) {\n return input.endsWith(\"/\") ? input : input + \"/\";\n }\n if (hasTrailingSlash(input, true)) {\n return input || \"/\";\n }\n const [s0, ...s] = input.split(\"?\");\n return s0 + \"/\" + (s.length > 0 ? `?${s.join(\"?\")}` : \"\");\n}\nfunction hasLeadingSlash(input = \"\") {\n return input.startsWith(\"/\");\n}\nfunction withoutLeadingSlash(input = \"\") {\n return (hasLeadingSlash(input) ? input.slice(1) : input) || \"/\";\n}\nfunction withLeadingSlash(input = \"\") {\n return hasLeadingSlash(input) ? input : \"/\" + input;\n}\nfunction cleanDoubleSlashes(input = \"\") {\n return input.split(\"://\").map((string_) => string_.replace(/\\/{2,}/g, \"/\")).join(\"://\");\n}\nfunction withBase(input, base) {\n if (isEmptyURL(base) || hasProtocol(input)) {\n return input;\n }\n const _base = withoutTrailingSlash(base);\n if (input.startsWith(_base)) {\n return input;\n }\n return joinURL(_base, input);\n}\nfunction withoutBase(input, base) {\n if (isEmptyURL(base)) {\n return input;\n }\n const _base = withoutTrailingSlash(base);\n if (!input.startsWith(_base)) {\n return input;\n }\n const trimmed = input.slice(_base.length);\n return trimmed[0] === \"/\" ? trimmed : \"/\" + trimmed;\n}\nfunction withQuery(input, query) {\n const parsed = parseURL(input);\n const mergedQuery = { ...parseQuery(parsed.search), ...query };\n parsed.search = stringifyQuery(mergedQuery);\n return stringifyParsedURL(parsed);\n}\nfunction getQuery(input) {\n return parseQuery(parseURL(input).search);\n}\nfunction isEmptyURL(url) {\n return !url || url === \"/\";\n}\nfunction isNonEmptyURL(url) {\n return url && url !== \"/\";\n}\nfunction joinURL(base, ...input) {\n let url = base || \"\";\n for (const index of input.filter((url2) => isNonEmptyURL(url2))) {\n url = url ? withTrailingSlash(url) + withoutLeadingSlash(index) : index;\n }\n return url;\n}\nfunction withHttp(input) {\n return withProtocol(input, \"http://\");\n}\nfunction withHttps(input) {\n return withProtocol(input, \"https://\");\n}\nfunction withoutProtocol(input) {\n return withProtocol(input, \"\");\n}\nfunction withProtocol(input, protocol) {\n const match = input.match(PROTOCOL_REGEX);\n if (!match) {\n return protocol + input;\n }\n return protocol + input.slice(match[0].length);\n}\nfunction createURL(input) {\n return new $URL(input);\n}\nfunction normalizeURL(input) {\n return createURL(input).toString();\n}\nfunction resolveURL(base, ...input) {\n const url = createURL(base);\n for (const index of input.filter((url2) => isNonEmptyURL(url2))) {\n url.append(createURL(index));\n }\n return url.toString();\n}\nfunction isSamePath(p1, p2) {\n return decode(withoutTrailingSlash(p1)) === decode(withoutTrailingSlash(p2));\n}\nfunction isEqual(a, b, options = {}) {\n if (!options.trailingSlash) {\n a = withTrailingSlash(a);\n b = withTrailingSlash(b);\n }\n if (!options.leadingSlash) {\n a = withLeadingSlash(a);\n b = withLeadingSlash(b);\n }\n if (!options.encoding) {\n a = decode(a);\n b = decode(b);\n }\n return a === b;\n}\n\nfunction parseURL(input = \"\", defaultProto) {\n if (!hasProtocol(input, { acceptRelative: true })) {\n return defaultProto ? parseURL(defaultProto + input) : parsePath(input);\n }\n const [protocol = \"\", auth, hostAndPath = \"\"] = (input.replace(/\\\\/g, \"/\").match(/([^/:]+:)?\\/\\/([^/@]+@)?(.*)/) || []).splice(1);\n const [host = \"\", path = \"\"] = (hostAndPath.match(/([^#/?]*)(.*)?/) || []).splice(1);\n const { pathname, search, hash } = parsePath(\n path.replace(/\\/(?=[A-Za-z]:)/, \"\")\n );\n return {\n protocol,\n auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : \"\",\n host,\n pathname,\n search,\n hash\n };\n}\nfunction parsePath(input = \"\") {\n const [pathname = \"\", search = \"\", hash = \"\"] = (input.match(/([^#?]*)(\\?[^#]*)?(#.*)?/) || []).splice(1);\n return {\n pathname,\n search,\n hash\n };\n}\nfunction parseAuth(input = \"\") {\n const [username, password] = input.split(\":\");\n return {\n username: decode(username),\n password: decode(password)\n };\n}\nfunction parseHost(input = \"\") {\n const [hostname, port] = (input.match(/([^/:]*):?(\\d+)?/) || []).splice(1);\n return {\n hostname: decode(hostname),\n port\n };\n}\nfunction stringifyParsedURL(parsed) {\n const fullpath = parsed.pathname + (parsed.search ? (parsed.search.startsWith(\"?\") ? \"\" : \"?\") + parsed.search : \"\") + parsed.hash;\n if (!parsed.protocol) {\n return fullpath;\n }\n return parsed.protocol + \"//\" + (parsed.auth ? parsed.auth + \"@\" : \"\") + parsed.host + fullpath;\n}\n\nexport { $URL, cleanDoubleSlashes, createURL, decode, decodePath, decodeQueryValue, encode, encodeHash, encodeHost, encodeParam, encodePath, encodeQueryItem, encodeQueryKey, encodeQueryValue, getQuery, hasLeadingSlash, hasProtocol, hasTrailingSlash, isEmptyURL, isEqual, isNonEmptyURL, isRelative, isSamePath, joinURL, normalizeURL, parseAuth, parseHost, parsePath, parseQuery, parseURL, resolveURL, stringifyParsedURL, stringifyQuery, withBase, withHttp, withHttps, withLeadingSlash, withProtocol, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutProtocol, withoutTrailingSlash };\n","const NODE_TYPES = {\n NORMAL: 0,\n WILDCARD: 1,\n PLACEHOLDER: 2\n};\n\nfunction createRouter(options = {}) {\n const ctx = {\n options,\n rootNode: createRadixNode(),\n staticRoutesMap: {}\n };\n const normalizeTrailingSlash = (p) => options.strictTrailingSlash ? p : p.replace(/\\/$/, \"\") || \"/\";\n if (options.routes) {\n for (const path in options.routes) {\n insert(ctx, normalizeTrailingSlash(path), options.routes[path]);\n }\n }\n return {\n ctx,\n // @ts-ignore\n lookup: (path) => lookup(ctx, normalizeTrailingSlash(path)),\n insert: (path, data) => insert(ctx, normalizeTrailingSlash(path), data),\n remove: (path) => remove(ctx, normalizeTrailingSlash(path))\n };\n}\nfunction lookup(ctx, path) {\n const staticPathNode = ctx.staticRoutesMap[path];\n if (staticPathNode) {\n return staticPathNode.data;\n }\n const sections = path.split(\"/\");\n const params = {};\n let paramsFound = false;\n let wildcardNode = null;\n let node = ctx.rootNode;\n let wildCardParam = null;\n for (let i = 0; i < sections.length; i++) {\n const section = sections[i];\n if (node.wildcardChildNode !== null) {\n wildcardNode = node.wildcardChildNode;\n wildCardParam = sections.slice(i).join(\"/\");\n }\n const nextNode = node.children.get(section);\n if (nextNode !== void 0) {\n node = nextNode;\n } else {\n node = node.placeholderChildNode;\n if (node !== null) {\n params[node.paramName] = section;\n paramsFound = true;\n } else {\n break;\n }\n }\n }\n if ((node === null || node.data === null) && wildcardNode !== null) {\n node = wildcardNode;\n params[node.paramName || \"_\"] = wildCardParam;\n paramsFound = true;\n }\n if (!node) {\n return null;\n }\n if (paramsFound) {\n return {\n ...node.data,\n params: paramsFound ? params : void 0\n };\n }\n return node.data;\n}\nfunction insert(ctx, path, data) {\n let isStaticRoute = true;\n const sections = path.split(\"/\");\n let node = ctx.rootNode;\n let _unnamedPlaceholderCtr = 0;\n for (const section of sections) {\n let childNode;\n if (childNode = node.children.get(section)) {\n node = childNode;\n } else {\n const type = getNodeType(section);\n childNode = createRadixNode({ type, parent: node });\n node.children.set(section, childNode);\n if (type === NODE_TYPES.PLACEHOLDER) {\n childNode.paramName = section === \"*\" ? `_${_unnamedPlaceholderCtr++}` : section.slice(1);\n node.placeholderChildNode = childNode;\n isStaticRoute = false;\n } else if (type === NODE_TYPES.WILDCARD) {\n node.wildcardChildNode = childNode;\n childNode.paramName = section.slice(\n 3\n /* \"**:\" */\n ) || \"_\";\n isStaticRoute = false;\n }\n node = childNode;\n }\n }\n node.data = data;\n if (isStaticRoute === true) {\n ctx.staticRoutesMap[path] = node;\n }\n return node;\n}\nfunction remove(ctx, path) {\n let success = false;\n const sections = path.split(\"/\");\n let node = ctx.rootNode;\n for (const section of sections) {\n node = node.children.get(section);\n if (!node) {\n return success;\n }\n }\n if (node.data) {\n const lastSection = sections[sections.length - 1];\n node.data = null;\n if (Object.keys(node.children).length === 0) {\n const parentNode = node.parent;\n parentNode.children.delete(lastSection);\n parentNode.wildcardChildNode = null;\n parentNode.placeholderChildNode = null;\n }\n success = true;\n }\n return success;\n}\nfunction createRadixNode(options = {}) {\n return {\n type: options.type || NODE_TYPES.NORMAL,\n parent: options.parent || null,\n children: /* @__PURE__ */ new Map(),\n data: options.data || null,\n paramName: options.paramName || null,\n wildcardChildNode: null,\n placeholderChildNode: null\n };\n}\nfunction getNodeType(str) {\n if (str.startsWith(\"**\")) {\n return NODE_TYPES.WILDCARD;\n }\n if (str[0] === \":\" || str === \"*\") {\n return NODE_TYPES.PLACEHOLDER;\n }\n return NODE_TYPES.NORMAL;\n}\n\nfunction toRouteMatcher(router) {\n const table = _routerNodeToTable(\"\", router.ctx.rootNode);\n return _createMatcher(table);\n}\nfunction _createMatcher(table) {\n return {\n ctx: { table },\n matchAll: (path) => _matchRoutes(path, table)\n };\n}\nfunction _createRouteTable() {\n return {\n static: /* @__PURE__ */ new Map(),\n wildcard: /* @__PURE__ */ new Map(),\n dynamic: /* @__PURE__ */ new Map()\n };\n}\nfunction _matchRoutes(path, table) {\n const matches = [];\n for (const [key, value] of _sortRoutesMap(table.wildcard)) {\n if (path.startsWith(key)) {\n matches.push(value);\n }\n }\n for (const [key, value] of _sortRoutesMap(table.dynamic)) {\n if (path.startsWith(key + \"/\")) {\n const subPath = \"/\" + path.slice(key.length).split(\"/\").splice(2).join(\"/\");\n matches.push(..._matchRoutes(subPath, value));\n }\n }\n const staticMatch = table.static.get(path);\n if (staticMatch) {\n matches.push(staticMatch);\n }\n return matches.filter(Boolean);\n}\nfunction _sortRoutesMap(m) {\n return [...m.entries()].sort((a, b) => a[0].length - b[0].length);\n}\nfunction _routerNodeToTable(initialPath, initialNode) {\n const table = _createRouteTable();\n function _addNode(path, node) {\n if (path) {\n if (node.type === NODE_TYPES.NORMAL && !(path.includes(\"*\") || path.includes(\":\"))) {\n table.static.set(path, node.data);\n } else if (node.type === NODE_TYPES.WILDCARD) {\n table.wildcard.set(path.replace(\"/**\", \"\"), node.data);\n } else if (node.type === NODE_TYPES.PLACEHOLDER) {\n const subTable = _routerNodeToTable(\"\", node);\n if (node.data) {\n subTable.static.set(\"/\", node.data);\n }\n table.dynamic.set(path.replace(/\\/\\*|\\/:\\w+/, \"\"), subTable);\n return;\n }\n }\n for (const [childPath, child] of node.children.entries()) {\n _addNode(`${path}/${childPath}`.replace(\"//\", \"/\"), child);\n }\n }\n _addNode(initialPath, initialNode);\n return table;\n}\n\nexport { NODE_TYPES, createRouter, toRouteMatcher };\n","function isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction _defu(baseObject, defaults, namespace = \".\", merger) {\n if (!isObject(defaults)) {\n return _defu(baseObject, {}, namespace, merger);\n }\n const object = Object.assign({}, defaults);\n for (const key in baseObject) {\n if (key === \"__proto__\" || key === \"constructor\") {\n continue;\n }\n const value = baseObject[key];\n if (value === null || value === void 0) {\n continue;\n }\n if (merger && merger(object, key, value, namespace)) {\n continue;\n }\n if (Array.isArray(value) && Array.isArray(object[key])) {\n object[key] = [...value, ...object[key]];\n } else if (isObject(value) && isObject(object[key])) {\n object[key] = _defu(\n value,\n object[key],\n (namespace ? `${namespace}.` : \"\") + key.toString(),\n merger\n );\n } else {\n object[key] = value;\n }\n }\n return object;\n}\nfunction createDefu(merger) {\n return (...arguments_) => (\n // eslint-disable-next-line unicorn/no-array-reduce\n arguments_.reduce((p, c) => _defu(p, c, \"\", merger), {})\n );\n}\nconst defu = createDefu();\nconst defuFn = createDefu((object, key, currentValue) => {\n if (typeof object[key] !== \"undefined\" && typeof currentValue === \"function\") {\n object[key] = currentValue(object[key]);\n return true;\n }\n});\nconst defuArrayFn = createDefu((object, key, currentValue) => {\n if (Array.isArray(object[key]) && typeof currentValue === \"function\") {\n object[key] = currentValue(object[key]);\n return true;\n }\n});\n\nexport { createDefu, defu as default, defu, defuArrayFn, defuFn };\n","import { withoutTrailingSlash, withoutBase, getQuery as getQuery$1 } from 'ufo';\nimport { createRouter as createRouter$1 } from 'radix3';\nimport destr from 'destr';\nimport { parse as parse$1, serialize } from 'cookie-es';\nimport crypto from 'uncrypto';\nimport { seal, defaults, unseal } from 'iron-webcrypto';\nimport { defu } from 'defu';\n\nfunction useBase(base, handler) {\n base = withoutTrailingSlash(base);\n if (!base) {\n return handler;\n }\n return eventHandler((event) => {\n event.node.req.originalUrl = event.node.req.originalUrl || event.node.req.url || \"/\";\n event.node.req.url = withoutBase(event.node.req.url || \"/\", base);\n return handler(event);\n });\n}\n\nfunction parse(multipartBodyBuffer, boundary) {\n let lastline = \"\";\n let state = 0 /* INIT */;\n let buffer = [];\n const allParts = [];\n let currentPartHeaders = [];\n for (let i = 0; i < multipartBodyBuffer.length; i++) {\n const prevByte = i > 0 ? multipartBodyBuffer[i - 1] : null;\n const currByte = multipartBodyBuffer[i];\n const newLineChar = currByte === 10 || currByte === 13;\n if (!newLineChar) {\n lastline += String.fromCodePoint(currByte);\n }\n const newLineDetected = currByte === 10 && prevByte === 13;\n if (0 /* INIT */ === state && newLineDetected) {\n if (\"--\" + boundary === lastline) {\n state = 1 /* READING_HEADERS */;\n }\n lastline = \"\";\n } else if (1 /* READING_HEADERS */ === state && newLineDetected) {\n if (lastline.length > 0) {\n const i2 = lastline.indexOf(\":\");\n if (i2 > 0) {\n const name = lastline.slice(0, i2).toLowerCase();\n const value = lastline.slice(i2 + 1).trim();\n currentPartHeaders.push([name, value]);\n }\n } else {\n state = 2 /* READING_DATA */;\n buffer = [];\n }\n lastline = \"\";\n } else if (2 /* READING_DATA */ === state) {\n if (lastline.length > boundary.length + 4) {\n lastline = \"\";\n }\n if (\"--\" + boundary === lastline) {\n const j = buffer.length - lastline.length;\n const part = buffer.slice(0, j - 1);\n allParts.push(process(part, currentPartHeaders));\n buffer = [];\n currentPartHeaders = [];\n lastline = \"\";\n state = 3 /* READING_PART_SEPARATOR */;\n } else {\n buffer.push(currByte);\n }\n if (newLineDetected) {\n lastline = \"\";\n }\n } else if (3 /* READING_PART_SEPARATOR */ === state && newLineDetected) {\n state = 1 /* READING_HEADERS */;\n }\n }\n return allParts;\n}\nfunction process(data, headers) {\n const dataObj = {};\n const contentDispositionHeader = headers.find((h) => h[0] === \"content-disposition\")?.[1] || \"\";\n for (const i of contentDispositionHeader.split(\";\")) {\n const s = i.split(\"=\");\n if (s.length !== 2) {\n continue;\n }\n const key = (s[0] || \"\").trim();\n if (key === \"name\" || key === \"filename\") {\n dataObj[key] = (s[1] || \"\").trim().replace(/\"/g, \"\");\n }\n }\n const contentType = headers.find((h) => h[0] === \"content-type\")?.[1] || \"\";\n if (contentType) {\n dataObj.type = contentType;\n }\n dataObj.data = Buffer.from(data);\n return dataObj;\n}\n\nclass H3Error extends Error {\n constructor() {\n super(...arguments);\n this.statusCode = 500;\n this.fatal = false;\n this.unhandled = false;\n this.statusMessage = void 0;\n }\n toJSON() {\n const obj = {\n message: this.message,\n statusCode: sanitizeStatusCode(this.statusCode, 500)\n };\n if (this.statusMessage) {\n obj.statusMessage = sanitizeStatusMessage(this.statusMessage);\n }\n if (this.data !== void 0) {\n obj.data = this.data;\n }\n return obj;\n }\n}\nH3Error.__h3_error__ = true;\nfunction createError(input) {\n if (typeof input === \"string\") {\n return new H3Error(input);\n }\n if (isError(input)) {\n return input;\n }\n const err = new H3Error(\n input.message ?? input.statusMessage,\n // @ts-ignore\n input.cause ? { cause: input.cause } : void 0\n );\n if (\"stack\" in input) {\n try {\n Object.defineProperty(err, \"stack\", {\n get() {\n return input.stack;\n }\n });\n } catch {\n try {\n err.stack = input.stack;\n } catch {\n }\n }\n }\n if (input.data) {\n err.data = input.data;\n }\n if (input.statusCode) {\n err.statusCode = sanitizeStatusCode(input.statusCode, err.statusCode);\n } else if (input.status) {\n err.statusCode = sanitizeStatusCode(input.status, err.statusCode);\n }\n if (input.statusMessage) {\n err.statusMessage = input.statusMessage;\n } else if (input.statusText) {\n err.statusMessage = input.statusText;\n }\n if (err.statusMessage) {\n const originalMessage = err.statusMessage;\n const sanitizedMessage = sanitizeStatusMessage(err.statusMessage);\n if (sanitizedMessage !== originalMessage) {\n console.warn(\n \"[h3] Please prefer using `message` for longer error messages instead of `statusMessage`. In the future `statusMessage` will be sanitized by default.\"\n );\n }\n }\n if (input.fatal !== void 0) {\n err.fatal = input.fatal;\n }\n if (input.unhandled !== void 0) {\n err.unhandled = input.unhandled;\n }\n return err;\n}\nfunction sendError(event, error, debug) {\n if (event.node.res.writableEnded) {\n return;\n }\n const h3Error = isError(error) ? error : createError(error);\n const responseBody = {\n statusCode: h3Error.statusCode,\n statusMessage: h3Error.statusMessage,\n stack: [],\n data: h3Error.data\n };\n if (debug) {\n responseBody.stack = (h3Error.stack || \"\").split(\"\\n\").map((l) => l.trim());\n }\n if (event.node.res.writableEnded) {\n return;\n }\n const _code = Number.parseInt(h3Error.statusCode);\n setResponseStatus(event, _code, h3Error.statusMessage);\n event.node.res.setHeader(\"content-type\", MIMES.json);\n event.node.res.end(JSON.stringify(responseBody, void 0, 2));\n}\nfunction isError(input) {\n return input?.constructor?.__h3_error__ === true;\n}\n\nfunction getQuery(event) {\n return getQuery$1(event.node.req.url || \"\");\n}\nfunction getRouterParams(event) {\n return event.context.params || {};\n}\nfunction getRouterParam(event, name) {\n const params = getRouterParams(event);\n return params[name];\n}\nfunction getMethod(event, defaultMethod = \"GET\") {\n return (event.node.req.method || defaultMethod).toUpperCase();\n}\nfunction isMethod(event, expected, allowHead) {\n const method = getMethod(event);\n if (allowHead && method === \"HEAD\") {\n return true;\n }\n if (typeof expected === \"string\") {\n if (method === expected) {\n return true;\n }\n } else if (expected.includes(method)) {\n return true;\n }\n return false;\n}\nfunction assertMethod(event, expected, allowHead) {\n if (!isMethod(event, expected, allowHead)) {\n throw createError({\n statusCode: 405,\n statusMessage: \"HTTP method is not allowed.\"\n });\n }\n}\nfunction getRequestHeaders(event) {\n const _headers = {};\n for (const key in event.node.req.headers) {\n const val = event.node.req.headers[key];\n _headers[key] = Array.isArray(val) ? val.filter(Boolean).join(\", \") : val;\n }\n return _headers;\n}\nconst getHeaders = getRequestHeaders;\nfunction getRequestHeader(event, name) {\n const headers = getRequestHeaders(event);\n const value = headers[name.toLowerCase()];\n return value;\n}\nconst getHeader = getRequestHeader;\nfunction getRequestHost(event) {\n const xForwardedHost = event.node.req.headers[\"x-forwarded-host\"];\n if (xForwardedHost) {\n return xForwardedHost;\n }\n return event.node.req.headers.host || \"localhost\";\n}\nfunction getRequestProtocol(event) {\n if (event.node.req.headers[\"x-forwarded-proto\"] === \"https\") {\n return \"https\";\n }\n return event.node.req.connection.encrypted ? \"https\" : \"http\";\n}\nfunction getRequestURL(event) {\n const host = getRequestHost(event);\n const protocol = getRequestProtocol(event);\n return new URL(event.path || \"/\", `${protocol}://${host}`);\n}\n\nconst RawBodySymbol = Symbol.for(\"h3RawBody\");\nconst ParsedBodySymbol = Symbol.for(\"h3ParsedBody\");\nconst PayloadMethods$1 = [\"PATCH\", \"POST\", \"PUT\", \"DELETE\"];\nfunction readRawBody(event, encoding = \"utf8\") {\n assertMethod(event, PayloadMethods$1);\n const _rawBody = event.node.req[RawBodySymbol] || event.node.req.body;\n if (_rawBody) {\n const promise2 = Promise.resolve(_rawBody).then(\n (_resolved) => Buffer.isBuffer(_resolved) ? _resolved : Buffer.from(_resolved)\n );\n return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;\n }\n if (!Number.parseInt(event.node.req.headers[\"content-length\"] || \"\")) {\n return Promise.resolve(void 0);\n }\n const promise = event.node.req[RawBodySymbol] = new Promise(\n (resolve, reject) => {\n const bodyData = [];\n event.node.req.on(\"error\", (err) => {\n reject(err);\n }).on(\"data\", (chunk) => {\n bodyData.push(chunk);\n }).on(\"end\", () => {\n resolve(Buffer.concat(bodyData));\n });\n }\n );\n const result = encoding ? promise.then((buff) => buff.toString(encoding)) : promise;\n return result;\n}\nasync function readBody(event) {\n if (ParsedBodySymbol in event.node.req) {\n return event.node.req[ParsedBodySymbol];\n }\n const body = await readRawBody(event, \"utf8\");\n if (event.node.req.headers[\"content-type\"] === \"application/x-www-form-urlencoded\") {\n const form = new URLSearchParams(body);\n const parsedForm = /* @__PURE__ */ Object.create(null);\n for (const [key, value] of form.entries()) {\n if (key in parsedForm) {\n if (!Array.isArray(parsedForm[key])) {\n parsedForm[key] = [parsedForm[key]];\n }\n parsedForm[key].push(value);\n } else {\n parsedForm[key] = value;\n }\n }\n return parsedForm;\n }\n const json = destr(body);\n event.node.req[ParsedBodySymbol] = json;\n return json;\n}\nasync function readMultipartFormData(event) {\n const contentType = getRequestHeader(event, \"content-type\");\n if (!contentType || !contentType.startsWith(\"multipart/form-data\")) {\n return;\n }\n const boundary = contentType.match(/boundary=([^;]*)(;|$)/i)?.[1];\n if (!boundary) {\n return;\n }\n const body = await readRawBody(event, false);\n if (!body) {\n return;\n }\n return parse(body, boundary);\n}\n\nfunction handleCacheHeaders(event, opts) {\n const cacheControls = [\"public\", ...opts.cacheControls || []];\n let cacheMatched = false;\n if (opts.maxAge !== void 0) {\n cacheControls.push(`max-age=${+opts.maxAge}`, `s-maxage=${+opts.maxAge}`);\n }\n if (opts.modifiedTime) {\n const modifiedTime = new Date(opts.modifiedTime);\n const ifModifiedSince = event.node.req.headers[\"if-modified-since\"];\n event.node.res.setHeader(\"last-modified\", modifiedTime.toUTCString());\n if (ifModifiedSince && new Date(ifModifiedSince) >= opts.modifiedTime) {\n cacheMatched = true;\n }\n }\n if (opts.etag) {\n event.node.res.setHeader(\"etag\", opts.etag);\n const ifNonMatch = event.node.req.headers[\"if-none-match\"];\n if (ifNonMatch === opts.etag) {\n cacheMatched = true;\n }\n }\n event.node.res.setHeader(\"cache-control\", cacheControls.join(\", \"));\n if (cacheMatched) {\n event.node.res.statusCode = 304;\n event.node.res.end();\n return true;\n }\n return false;\n}\n\nconst MIMES = {\n html: \"text/html\",\n json: \"application/json\"\n};\n\nfunction parseCookies(event) {\n return parse$1(event.node.req.headers.cookie || \"\");\n}\nfunction getCookie(event, name) {\n return parseCookies(event)[name];\n}\nfunction setCookie(event, name, value, serializeOptions) {\n const cookieStr = serialize(name, value, {\n path: \"/\",\n ...serializeOptions\n });\n let setCookies = event.node.res.getHeader(\"set-cookie\");\n if (!Array.isArray(setCookies)) {\n setCookies = [setCookies];\n }\n setCookies = setCookies.filter((cookieValue) => {\n return cookieValue && !cookieValue.startsWith(name + \"=\");\n });\n event.node.res.setHeader(\"set-cookie\", [...setCookies, cookieStr]);\n}\nfunction deleteCookie(event, name, serializeOptions) {\n setCookie(event, name, \"\", {\n ...serializeOptions,\n maxAge: 0\n });\n}\nfunction splitCookiesString(cookiesString) {\n if (typeof cookiesString !== \"string\") {\n return [];\n }\n const cookiesStrings = [];\n let pos = 0;\n let start;\n let ch;\n let lastComma;\n let nextStart;\n let cookiesSeparatorFound;\n function skipWhitespace() {\n while (pos < cookiesString.length && /\\s/.test(cookiesString.charAt(pos))) {\n pos += 1;\n }\n return pos < cookiesString.length;\n }\n function notSpecialChar() {\n ch = cookiesString.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n }\n while (pos < cookiesString.length) {\n start = pos;\n cookiesSeparatorFound = false;\n while (skipWhitespace()) {\n ch = cookiesString.charAt(pos);\n if (ch === \",\") {\n lastComma = pos;\n pos += 1;\n skipWhitespace();\n nextStart = pos;\n while (pos < cookiesString.length && notSpecialChar()) {\n pos += 1;\n }\n if (pos < cookiesString.length && cookiesString.charAt(pos) === \"=\") {\n cookiesSeparatorFound = true;\n pos = nextStart;\n cookiesStrings.push(cookiesString.slice(start, lastComma));\n start = pos;\n } else {\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n if (!cookiesSeparatorFound || pos >= cookiesString.length) {\n cookiesStrings.push(cookiesString.slice(start, cookiesString.length));\n }\n }\n return cookiesStrings;\n}\n\nconst DISALLOWED_STATUS_CHARS = /[^\\u0009\\u0020-\\u007E]/g;\nfunction sanitizeStatusMessage(statusMessage = \"\") {\n return statusMessage.replace(DISALLOWED_STATUS_CHARS, \"\");\n}\nfunction sanitizeStatusCode(statusCode, defaultStatusCode = 200) {\n if (!statusCode) {\n return defaultStatusCode;\n }\n if (typeof statusCode === \"string\") {\n statusCode = Number.parseInt(statusCode, 10);\n }\n if (statusCode < 100 || statusCode > 999) {\n return defaultStatusCode;\n }\n return statusCode;\n}\n\nconst PayloadMethods = /* @__PURE__ */ new Set([\"PATCH\", \"POST\", \"PUT\", \"DELETE\"]);\nconst ignoredHeaders = /* @__PURE__ */ new Set([\n \"transfer-encoding\",\n \"connection\",\n \"keep-alive\",\n \"upgrade\",\n \"expect\",\n \"host\"\n]);\nasync function proxyRequest(event, target, opts = {}) {\n const method = getMethod(event);\n let body;\n if (PayloadMethods.has(method)) {\n body = await readRawBody(event).catch(() => void 0);\n }\n const headers = getProxyRequestHeaders(event);\n if (opts.fetchOptions?.headers) {\n Object.assign(headers, opts.fetchOptions.headers);\n }\n if (opts.headers) {\n Object.assign(headers, opts.headers);\n }\n return sendProxy(event, target, {\n ...opts,\n fetchOptions: {\n headers,\n method,\n body,\n ...opts.fetchOptions\n }\n });\n}\nasync function sendProxy(event, target, opts = {}) {\n const response = await _getFetch(opts.fetch)(target, {\n headers: opts.headers,\n ...opts.fetchOptions\n });\n event.node.res.statusCode = sanitizeStatusCode(\n response.status,\n event.node.res.statusCode\n );\n event.node.res.statusMessage = sanitizeStatusMessage(response.statusText);\n for (const [key, value] of response.headers.entries()) {\n if (key === \"content-encoding\") {\n continue;\n }\n if (key === \"content-length\") {\n continue;\n }\n if (key === \"set-cookie\") {\n const cookies = splitCookiesString(value).map((cookie) => {\n if (opts.cookieDomainRewrite) {\n cookie = rewriteCookieProperty(\n cookie,\n opts.cookieDomainRewrite,\n \"domain\"\n );\n }\n if (opts.cookiePathRewrite) {\n cookie = rewriteCookieProperty(\n cookie,\n opts.cookiePathRewrite,\n \"path\"\n );\n }\n return cookie;\n });\n event.node.res.setHeader(\"set-cookie\", cookies);\n continue;\n }\n event.node.res.setHeader(key, value);\n }\n if (response._data !== void 0) {\n return response._data;\n }\n if (opts.sendStream === false) {\n const data = new Uint8Array(await response.arrayBuffer());\n return event.node.res.end(data);\n }\n for await (const chunk of response.body) {\n event.node.res.write(chunk);\n }\n return event.node.res.end();\n}\nfunction getProxyRequestHeaders(event) {\n const headers = /* @__PURE__ */ Object.create(null);\n const reqHeaders = getRequestHeaders(event);\n for (const name in reqHeaders) {\n if (!ignoredHeaders.has(name)) {\n headers[name] = reqHeaders[name];\n }\n }\n return headers;\n}\nfunction fetchWithEvent(event, req, init, options) {\n return _getFetch(options?.fetch)(req, {\n ...init,\n context: init?.context || event.context,\n headers: {\n ...getProxyRequestHeaders(event),\n ...init?.headers\n }\n });\n}\nfunction _getFetch(_fetch) {\n if (_fetch) {\n return _fetch;\n }\n if (globalThis.fetch) {\n return globalThis.fetch;\n }\n throw new Error(\n \"fetch is not available. Try importing `node-fetch-native/polyfill` for Node.js.\"\n );\n}\nfunction rewriteCookieProperty(header, map, property) {\n const _map = typeof map === \"string\" ? { \"*\": map } : map;\n return header.replace(\n new RegExp(`(;\\\\s*${property}=)([^;]+)`, \"gi\"),\n (match, prefix, previousValue) => {\n let newValue;\n if (previousValue in _map) {\n newValue = _map[previousValue];\n } else if (\"*\" in _map) {\n newValue = _map[\"*\"];\n } else {\n return match;\n }\n return newValue ? prefix + newValue : \"\";\n }\n );\n}\n\nconst defer = typeof setImmediate !== \"undefined\" ? setImmediate : (fn) => fn();\nfunction send(event, data, type) {\n if (type) {\n defaultContentType(event, type);\n }\n return new Promise((resolve) => {\n defer(() => {\n event.node.res.end(data);\n resolve();\n });\n });\n}\nfunction sendNoContent(event, code = 204) {\n event.node.res.statusCode = sanitizeStatusCode(code, 204);\n if (event.node.res.statusCode === 204) {\n event.node.res.removeHeader(\"content-length\");\n }\n event.node.res.end();\n}\nfunction setResponseStatus(event, code, text) {\n if (code) {\n event.node.res.statusCode = sanitizeStatusCode(\n code,\n event.node.res.statusCode\n );\n }\n if (text) {\n event.node.res.statusMessage = sanitizeStatusMessage(text);\n }\n}\nfunction getResponseStatus(event) {\n return event.node.res.statusCode;\n}\nfunction getResponseStatusText(event) {\n return event.node.res.statusMessage;\n}\nfunction defaultContentType(event, type) {\n if (type && !event.node.res.getHeader(\"content-type\")) {\n event.node.res.setHeader(\"content-type\", type);\n }\n}\nfunction sendRedirect(event, location, code = 302) {\n event.node.res.statusCode = sanitizeStatusCode(\n code,\n event.node.res.statusCode\n );\n event.node.res.setHeader(\"location\", location);\n const encodedLoc = location.replace(/\"/g, \"%22\");\n const html = ``;\n return send(event, html, MIMES.html);\n}\nfunction getResponseHeaders(event) {\n return event.node.res.getHeaders();\n}\nfunction getResponseHeader(event, name) {\n return event.node.res.getHeader(name);\n}\nfunction setResponseHeaders(event, headers) {\n for (const [name, value] of Object.entries(headers)) {\n event.node.res.setHeader(name, value);\n }\n}\nconst setHeaders = setResponseHeaders;\nfunction setResponseHeader(event, name, value) {\n event.node.res.setHeader(name, value);\n}\nconst setHeader = setResponseHeader;\nfunction appendResponseHeaders(event, headers) {\n for (const [name, value] of Object.entries(headers)) {\n appendResponseHeader(event, name, value);\n }\n}\nconst appendHeaders = appendResponseHeaders;\nfunction appendResponseHeader(event, name, value) {\n let current = event.node.res.getHeader(name);\n if (!current) {\n event.node.res.setHeader(name, value);\n return;\n }\n if (!Array.isArray(current)) {\n current = [current.toString()];\n }\n event.node.res.setHeader(name, [...current, value]);\n}\nconst appendHeader = appendResponseHeader;\nfunction isStream(data) {\n return data && typeof data === \"object\" && typeof data.pipe === \"function\" && typeof data.on === \"function\";\n}\nfunction sendStream(event, data) {\n return new Promise((resolve, reject) => {\n data.pipe(event.node.res);\n data.on(\"end\", () => resolve());\n data.on(\"error\", (error) => reject(createError(error)));\n });\n}\nconst noop = () => {\n};\nfunction writeEarlyHints(event, hints, cb = noop) {\n if (!event.node.res.socket) {\n cb();\n return;\n }\n if (typeof hints === \"string\" || Array.isArray(hints)) {\n hints = { link: hints };\n }\n if (hints.link) {\n hints.link = Array.isArray(hints.link) ? hints.link : hints.link.split(\",\");\n }\n const headers = Object.entries(hints).map(\n (e) => [e[0].toLowerCase(), e[1]]\n );\n if (headers.length === 0) {\n cb();\n return;\n }\n let hint = \"HTTP/1.1 103 Early Hints\";\n if (hints.link) {\n hint += `\\r\nLink: ${hints.link.join(\", \")}`;\n }\n for (const [header, value] of headers) {\n if (header === \"link\") {\n continue;\n }\n hint += `\\r\n${header}: ${value}`;\n }\n if (event.node.res.socket) {\n event.node.res.socket.write(\n `${hint}\\r\n\\r\n`,\n \"utf8\",\n cb\n );\n } else {\n cb();\n }\n}\n\nconst DEFAULT_NAME = \"h3\";\nconst DEFAULT_COOKIE = {\n path: \"/\",\n secure: true,\n httpOnly: true\n};\nasync function useSession(event, config) {\n const sessionName = config.name || DEFAULT_NAME;\n await getSession(event, config);\n const sessionManager = {\n get id() {\n return event.context.sessions?.[sessionName]?.id;\n },\n get data() {\n return event.context.sessions?.[sessionName]?.data || {};\n },\n update: async (update) => {\n await updateSession(event, config, update);\n return sessionManager;\n },\n clear: async () => {\n await clearSession(event, config);\n return sessionManager;\n }\n };\n return sessionManager;\n}\nasync function getSession(event, config) {\n const sessionName = config.name || DEFAULT_NAME;\n if (!event.context.sessions) {\n event.context.sessions = /* @__PURE__ */ Object.create(null);\n }\n if (event.context.sessions[sessionName]) {\n return event.context.sessions[sessionName];\n }\n const session = {\n id: \"\",\n createdAt: 0,\n data: /* @__PURE__ */ Object.create(null)\n };\n event.context.sessions[sessionName] = session;\n let sealedSession;\n if (config.sessionHeader !== false) {\n const headerName = typeof config.sessionHeader === \"string\" ? config.sessionHeader.toLowerCase() : `x-${sessionName.toLowerCase()}-session`;\n const headerValue = event.node.req.headers[headerName];\n if (typeof headerValue === \"string\") {\n sealedSession = headerValue;\n }\n }\n if (!sealedSession) {\n sealedSession = getCookie(event, sessionName);\n }\n if (sealedSession) {\n const unsealed = await unsealSession(event, config, sealedSession).catch(\n () => {\n }\n );\n Object.assign(session, unsealed);\n }\n if (!session.id) {\n session.id = (config.crypto || crypto).randomUUID();\n session.createdAt = Date.now();\n await updateSession(event, config);\n }\n return session;\n}\nasync function updateSession(event, config, update) {\n const sessionName = config.name || DEFAULT_NAME;\n const session = event.context.sessions?.[sessionName] || await getSession(event, config);\n if (typeof update === \"function\") {\n update = update(session.data);\n }\n if (update) {\n Object.assign(session.data, update);\n }\n if (config.cookie !== false) {\n const sealed = await sealSession(event, config);\n setCookie(event, sessionName, sealed, {\n ...DEFAULT_COOKIE,\n expires: config.maxAge ? new Date(session.createdAt + config.maxAge * 1e3) : void 0,\n ...config.cookie\n });\n }\n return session;\n}\nasync function sealSession(event, config) {\n const sessionName = config.name || DEFAULT_NAME;\n const session = event.context.sessions?.[sessionName] || await getSession(event, config);\n const sealed = await seal(config.crypto || crypto, session, config.password, {\n ...defaults,\n ttl: config.maxAge ? config.maxAge * 1e3 : 0,\n ...config.seal\n });\n return sealed;\n}\nasync function unsealSession(_event, config, sealed) {\n const unsealed = await unseal(\n config.crypto || crypto,\n sealed,\n config.password,\n {\n ...defaults,\n ttl: config.maxAge ? config.maxAge * 1e3 : 0,\n ...config.seal\n }\n );\n if (config.maxAge) {\n const age = Date.now() - (unsealed.createdAt || Number.NEGATIVE_INFINITY);\n if (age > config.maxAge * 1e3) {\n throw new Error(\"Session expired!\");\n }\n }\n return unsealed;\n}\nasync function clearSession(event, config) {\n const sessionName = config.name || DEFAULT_NAME;\n if (event.context.sessions?.[sessionName]) {\n delete event.context.sessions[sessionName];\n }\n await setCookie(event, sessionName, \"\", {\n ...DEFAULT_COOKIE,\n ...config.cookie\n });\n}\n\nfunction resolveCorsOptions(options = {}) {\n const defaultOptions = {\n origin: \"*\",\n methods: \"*\",\n allowHeaders: \"*\",\n exposeHeaders: \"*\",\n credentials: false,\n maxAge: false,\n preflight: {\n statusCode: 204\n }\n };\n return defu(options, defaultOptions);\n}\nfunction isPreflightRequest(event) {\n const method = getMethod(event);\n const origin = getRequestHeader(event, \"origin\");\n const accessControlRequestMethod = getRequestHeader(\n event,\n \"access-control-request-method\"\n );\n return method === \"OPTIONS\" && !!origin && !!accessControlRequestMethod;\n}\nfunction isCorsOriginAllowed(origin, options) {\n const { origin: originOption } = options;\n if (!origin || !originOption || originOption === \"*\" || originOption === \"null\") {\n return true;\n }\n if (Array.isArray(originOption)) {\n return originOption.some((_origin) => {\n if (_origin instanceof RegExp) {\n return _origin.test(origin);\n }\n return origin === _origin;\n });\n }\n return originOption(origin);\n}\nfunction createOriginHeaders(event, options) {\n const { origin: originOption } = options;\n const origin = getRequestHeader(event, \"origin\");\n if (!origin || !originOption || originOption === \"*\") {\n return { \"access-control-allow-origin\": \"*\" };\n }\n if (typeof originOption === \"string\") {\n return { \"access-control-allow-origin\": originOption, vary: \"origin\" };\n }\n return isCorsOriginAllowed(origin, options) ? { \"access-control-allow-origin\": origin, vary: \"origin\" } : {};\n}\nfunction createMethodsHeaders(options) {\n const { methods } = options;\n if (!methods) {\n return {};\n }\n if (methods === \"*\") {\n return { \"access-control-allow-methods\": \"*\" };\n }\n return methods.length > 0 ? { \"access-control-allow-methods\": methods.join(\",\") } : {};\n}\nfunction createCredentialsHeaders(options) {\n const { credentials } = options;\n if (credentials) {\n return { \"access-control-allow-credentials\": \"true\" };\n }\n return {};\n}\nfunction createAllowHeaderHeaders(event, options) {\n const { allowHeaders } = options;\n if (!allowHeaders || allowHeaders === \"*\" || allowHeaders.length === 0) {\n const header = getRequestHeader(event, \"access-control-request-headers\");\n return header ? {\n \"access-control-allow-headers\": header,\n vary: \"access-control-request-headers\"\n } : {};\n }\n return {\n \"access-control-allow-headers\": allowHeaders.join(\",\"),\n vary: \"access-control-request-headers\"\n };\n}\nfunction createExposeHeaders(options) {\n const { exposeHeaders } = options;\n if (!exposeHeaders) {\n return {};\n }\n if (exposeHeaders === \"*\") {\n return { \"access-control-expose-headers\": exposeHeaders };\n }\n return { \"access-control-expose-headers\": exposeHeaders.join(\",\") };\n}\nfunction appendCorsPreflightHeaders(event, options) {\n appendHeaders(event, createOriginHeaders(event, options));\n appendHeaders(event, createCredentialsHeaders(options));\n appendHeaders(event, createExposeHeaders(options));\n appendHeaders(event, createMethodsHeaders(options));\n appendHeaders(event, createAllowHeaderHeaders(event, options));\n}\nfunction appendCorsHeaders(event, options) {\n appendHeaders(event, createOriginHeaders(event, options));\n appendHeaders(event, createCredentialsHeaders(options));\n appendHeaders(event, createExposeHeaders(options));\n}\n\nfunction handleCors(event, options) {\n const _options = resolveCorsOptions(options);\n if (isPreflightRequest(event)) {\n appendCorsPreflightHeaders(event, options);\n sendNoContent(event, _options.preflight.statusCode);\n return true;\n }\n appendCorsHeaders(event, options);\n return false;\n}\n\nclass H3Headers {\n constructor(init) {\n if (!init) {\n this._headers = {};\n } else if (Array.isArray(init)) {\n this._headers = Object.fromEntries(\n init.map(([key, value]) => [key.toLowerCase(), value])\n );\n } else if (init && \"append\" in init) {\n this._headers = Object.fromEntries(init.entries());\n } else {\n this._headers = Object.fromEntries(\n Object.entries(init).map(([key, value]) => [key.toLowerCase(), value])\n );\n }\n }\n [Symbol.iterator]() {\n return this.entries();\n }\n entries() {\n throw Object.entries(this._headers)[Symbol.iterator]();\n }\n keys() {\n return Object.keys(this._headers)[Symbol.iterator]();\n }\n values() {\n throw Object.values(this._headers)[Symbol.iterator]();\n }\n append(name, value) {\n const _name = name.toLowerCase();\n this.set(_name, [this.get(_name), value].filter(Boolean).join(\", \"));\n }\n delete(name) {\n delete this._headers[name.toLowerCase()];\n }\n get(name) {\n return this._headers[name.toLowerCase()];\n }\n has(name) {\n return name.toLowerCase() in this._headers;\n }\n set(name, value) {\n this._headers[name.toLowerCase()] = String(value);\n }\n forEach(callbackfn) {\n for (const [key, value] of Object.entries(this._headers)) {\n callbackfn(value, key, this);\n }\n }\n}\n\nclass H3Response {\n constructor(body = null, init = {}) {\n // TODO: yet to implement\n this.body = null;\n this.type = \"default\";\n this.bodyUsed = false;\n this.headers = new H3Headers(init.headers);\n this.status = init.status ?? 200;\n this.statusText = init.statusText || \"\";\n this.redirected = !!init.status && [301, 302, 307, 308].includes(init.status);\n this._body = body;\n this.url = \"\";\n this.ok = this.status < 300 && this.status > 199;\n }\n clone() {\n return new H3Response(this.body, {\n headers: this.headers,\n status: this.status,\n statusText: this.statusText\n });\n }\n arrayBuffer() {\n return Promise.resolve(this._body);\n }\n blob() {\n return Promise.resolve(this._body);\n }\n formData() {\n return Promise.resolve(this._body);\n }\n json() {\n return Promise.resolve(this._body);\n }\n text() {\n return Promise.resolve(this._body);\n }\n}\n\nclass H3Event {\n constructor(req, res) {\n this[\"__is_event__\"] = true;\n this.context = {};\n this.node = { req, res };\n }\n get path() {\n return this.req.url;\n }\n /** @deprecated Please use `event.node.req` instead. **/\n get req() {\n return this.node.req;\n }\n /** @deprecated Please use `event.node.res` instead. **/\n get res() {\n return this.node.res;\n }\n // Implementation of FetchEvent\n respondWith(r) {\n Promise.resolve(r).then((_response) => {\n if (this.res.writableEnded) {\n return;\n }\n const response = _response instanceof H3Response ? _response : new H3Response(_response);\n for (const [key, value] of response.headers.entries()) {\n this.res.setHeader(key, value);\n }\n if (response.status) {\n this.res.statusCode = sanitizeStatusCode(\n response.status,\n this.res.statusCode\n );\n }\n if (response.statusText) {\n this.res.statusMessage = sanitizeStatusMessage(response.statusText);\n }\n if (response.redirected) {\n this.res.setHeader(\"location\", response.url);\n }\n if (!response._body) {\n return this.res.end();\n }\n if (typeof response._body === \"string\" || \"buffer\" in response._body || \"byteLength\" in response._body) {\n return this.res.end(response._body);\n }\n if (!response.headers.has(\"content-type\")) {\n response.headers.set(\"content-type\", MIMES.json);\n }\n this.res.end(JSON.stringify(response._body));\n });\n }\n}\nfunction isEvent(input) {\n return \"__is_event__\" in input;\n}\nfunction createEvent(req, res) {\n return new H3Event(req, res);\n}\n\nfunction defineEventHandler(handler) {\n handler.__is_handler__ = true;\n return handler;\n}\nconst eventHandler = defineEventHandler;\nfunction isEventHandler(input) {\n return \"__is_handler__\" in input;\n}\nfunction toEventHandler(input, _, _route) {\n if (!isEventHandler(input)) {\n console.warn(\n \"[h3] Implicit event handler conversion is deprecated. Use `eventHandler()` or `fromNodeMiddleware()` to define event handlers.\",\n _route && _route !== \"/\" ? `\n Route: ${_route}` : \"\",\n `\n Handler: ${input}`\n );\n }\n return input;\n}\nfunction dynamicEventHandler(initial) {\n let current = initial;\n const wrapper = eventHandler((event) => {\n if (current) {\n return current(event);\n }\n });\n wrapper.set = (handler) => {\n current = handler;\n };\n return wrapper;\n}\nfunction defineLazyEventHandler(factory) {\n let _promise;\n let _resolved;\n const resolveHandler = () => {\n if (_resolved) {\n return Promise.resolve(_resolved);\n }\n if (!_promise) {\n _promise = Promise.resolve(factory()).then((r) => {\n const handler = r.default || r;\n if (typeof handler !== \"function\") {\n throw new TypeError(\n \"Invalid lazy handler result. It should be a function:\",\n handler\n );\n }\n _resolved = toEventHandler(r.default || r);\n return _resolved;\n });\n }\n return _promise;\n };\n return eventHandler((event) => {\n if (_resolved) {\n return _resolved(event);\n }\n return resolveHandler().then((handler) => handler(event));\n });\n}\nconst lazyEventHandler = defineLazyEventHandler;\n\nfunction createApp(options = {}) {\n const stack = [];\n const handler = createAppEventHandler(stack, options);\n const app = {\n // @ts-ignore\n use: (arg1, arg2, arg3) => use(app, arg1, arg2, arg3),\n handler,\n stack,\n options\n };\n return app;\n}\nfunction use(app, arg1, arg2, arg3) {\n if (Array.isArray(arg1)) {\n for (const i of arg1) {\n use(app, i, arg2, arg3);\n }\n } else if (Array.isArray(arg2)) {\n for (const i of arg2) {\n use(app, arg1, i, arg3);\n }\n } else if (typeof arg1 === \"string\") {\n app.stack.push(\n normalizeLayer({ ...arg3, route: arg1, handler: arg2 })\n );\n } else if (typeof arg1 === \"function\") {\n app.stack.push(\n normalizeLayer({ ...arg2, route: \"/\", handler: arg1 })\n );\n } else {\n app.stack.push(normalizeLayer({ ...arg1 }));\n }\n return app;\n}\nfunction createAppEventHandler(stack, options) {\n const spacing = options.debug ? 2 : void 0;\n return eventHandler(async (event) => {\n event.node.req.originalUrl = event.node.req.originalUrl || event.node.req.url || \"/\";\n const reqUrl = event.node.req.url || \"/\";\n for (const layer of stack) {\n if (layer.route.length > 1) {\n if (!reqUrl.startsWith(layer.route)) {\n continue;\n }\n event.node.req.url = reqUrl.slice(layer.route.length) || \"/\";\n } else {\n event.node.req.url = reqUrl;\n }\n if (layer.match && !layer.match(event.node.req.url, event)) {\n continue;\n }\n const val = await layer.handler(event);\n if (event.node.res.writableEnded) {\n return;\n }\n const type = typeof val;\n if (type === \"string\") {\n return send(event, val, MIMES.html);\n } else if (isStream(val)) {\n return sendStream(event, val);\n } else if (val === null) {\n event.node.res.statusCode = 204;\n return send(event);\n } else if (type === \"object\" || type === \"boolean\" || type === \"number\") {\n if (val.buffer) {\n return send(event, val);\n } else if (val instanceof Error) {\n throw createError(val);\n } else {\n return send(\n event,\n JSON.stringify(val, void 0, spacing),\n MIMES.json\n );\n }\n }\n }\n if (!event.node.res.writableEnded) {\n throw createError({\n statusCode: 404,\n statusMessage: `Cannot find any route matching ${event.node.req.url || \"/\"}.`\n });\n }\n });\n}\nfunction normalizeLayer(input) {\n let handler = input.handler;\n if (handler.handler) {\n handler = handler.handler;\n }\n if (input.lazy) {\n handler = lazyEventHandler(handler);\n } else if (!isEventHandler(handler)) {\n handler = toEventHandler(handler, void 0, input.route);\n }\n return {\n route: withoutTrailingSlash(input.route),\n match: input.match,\n handler\n };\n}\n\nconst defineNodeListener = (handler) => handler;\nconst defineNodeMiddleware = (middleware) => middleware;\nfunction fromNodeMiddleware(handler) {\n if (isEventHandler(handler)) {\n return handler;\n }\n if (typeof handler !== \"function\") {\n throw new TypeError(\n \"Invalid handler. It should be a function:\",\n handler\n );\n }\n return eventHandler((event) => {\n return callNodeListener(\n handler,\n event.node.req,\n event.node.res\n );\n });\n}\nfunction toNodeListener(app) {\n const toNodeHandle = async function(req, res) {\n const event = createEvent(req, res);\n try {\n await app.handler(event);\n } catch (_error) {\n const error = createError(_error);\n if (!isError(_error)) {\n error.unhandled = true;\n }\n if (app.options.onError) {\n await app.options.onError(error, event);\n } else {\n if (error.unhandled || error.fatal) {\n console.error(\"[h3]\", error.fatal ? \"[fatal]\" : \"[unhandled]\", error);\n }\n await sendError(event, error, !!app.options.debug);\n }\n }\n };\n return toNodeHandle;\n}\nfunction promisifyNodeListener(handler) {\n return function(req, res) {\n return callNodeListener(handler, req, res);\n };\n}\nfunction callNodeListener(handler, req, res) {\n const isMiddleware = handler.length > 2;\n return new Promise((resolve, reject) => {\n const next = (err) => {\n if (isMiddleware) {\n res.off(\"close\", next);\n res.off(\"error\", next);\n }\n return err ? reject(createError(err)) : resolve(void 0);\n };\n try {\n const returned = handler(req, res, next);\n if (isMiddleware && returned === void 0) {\n res.once(\"close\", next);\n res.once(\"error\", next);\n } else {\n resolve(returned);\n }\n } catch (error) {\n next(error);\n }\n });\n}\n\nconst RouterMethods = [\n \"connect\",\n \"delete\",\n \"get\",\n \"head\",\n \"options\",\n \"post\",\n \"put\",\n \"trace\",\n \"patch\"\n];\nfunction createRouter(opts = {}) {\n const _router = createRouter$1({});\n const routes = {};\n const router = {};\n const addRoute = (path, handler, method) => {\n let route = routes[path];\n if (!route) {\n routes[path] = route = { handlers: {} };\n _router.insert(path, route);\n }\n if (Array.isArray(method)) {\n for (const m of method) {\n addRoute(path, handler, m);\n }\n } else {\n route.handlers[method] = toEventHandler(handler, void 0, path);\n }\n return router;\n };\n router.use = router.add = (path, handler, method) => addRoute(path, handler, method || \"all\");\n for (const method of RouterMethods) {\n router[method] = (path, handle) => router.add(path, handle, method);\n }\n router.handler = eventHandler((event) => {\n let path = event.node.req.url || \"/\";\n const qIndex = path.indexOf(\"?\");\n if (qIndex !== -1) {\n path = path.slice(0, Math.max(0, qIndex));\n }\n const matched = _router.lookup(path);\n if (!matched || !matched.handlers) {\n if (opts.preemptive || opts.preemtive) {\n throw createError({\n statusCode: 404,\n name: \"Not Found\",\n statusMessage: `Cannot find any route matching ${event.node.req.url || \"/\"}.`\n });\n } else {\n return;\n }\n }\n const method = (event.node.req.method || \"get\").toLowerCase();\n const handler = matched.handlers[method] || matched.handlers.all;\n if (!handler) {\n throw createError({\n statusCode: 405,\n name: \"Method Not Allowed\",\n statusMessage: `Method ${method} is not allowed on this route.`\n });\n }\n const params = matched.params || {};\n event.context.params = params;\n return handler(event);\n });\n return router;\n}\n\nexport { H3Error, H3Event, H3Headers, H3Response, MIMES, appendCorsHeaders, appendCorsPreflightHeaders, appendHeader, appendHeaders, appendResponseHeader, appendResponseHeaders, assertMethod, callNodeListener, clearSession, createApp, createAppEventHandler, createError, createEvent, createRouter, defaultContentType, defineEventHandler, defineLazyEventHandler, defineNodeListener, defineNodeMiddleware, deleteCookie, dynamicEventHandler, eventHandler, fetchWithEvent, fromNodeMiddleware, getCookie, getHeader, getHeaders, getMethod, getProxyRequestHeaders, getQuery, getRequestHeader, getRequestHeaders, getRequestHost, getRequestProtocol, getRequestURL, getResponseHeader, getResponseHeaders, getResponseStatus, getResponseStatusText, getRouterParam, getRouterParams, getSession, handleCacheHeaders, handleCors, isCorsOriginAllowed, isError, isEvent, isEventHandler, isMethod, isPreflightRequest, isStream, lazyEventHandler, parseCookies, promisifyNodeListener, proxyRequest, readBody, readMultipartFormData, readRawBody, sanitizeStatusCode, sanitizeStatusMessage, sealSession, send, sendError, sendNoContent, sendProxy, sendRedirect, sendStream, setCookie, setHeader, setHeaders, setResponseHeader, setResponseHeaders, setResponseStatus, splitCookiesString, toEventHandler, toNodeListener, unsealSession, updateSession, use, useBase, useSession, writeEarlyHints };\n","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:http\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:https\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:fs\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:os\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"tty\");","import * as tty from \"tty\"\n\nconst {\n env = {},\n argv = [],\n platform = \"\",\n} = typeof process === \"undefined\" ? {} : process\n\nconst isDisabled = \"NO_COLOR\" in env || argv.includes(\"--no-color\")\nconst isForced = \"FORCE_COLOR\" in env || argv.includes(\"--color\")\nconst isWindows = platform === \"win32\"\nconst isDumbTerminal = env.TERM === \"dumb\"\n\nconst isCompatibleTerminal =\n tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal\n\nconst isCI =\n \"CI\" in env &&\n (\"GITHUB_ACTIONS\" in env || \"GITLAB_CI\" in env || \"CIRCLECI\" in env)\n\nexport const isColorSupported =\n !isDisabled &&\n (isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI)\n\nconst replaceClose = (\n index,\n string,\n close,\n replace,\n head = string.substring(0, index) + replace,\n tail = string.substring(index + close.length),\n next = tail.indexOf(close)\n) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace))\n\nconst clearBleed = (index, string, open, close, replace) =>\n index < 0\n ? open + string + close\n : open + replaceClose(index, string, close, replace) + close\n\nconst filterEmpty =\n (open, close, replace = open, at = open.length + 1) =>\n (string) =>\n string || !(string === \"\" || string === undefined)\n ? clearBleed(\n (\"\" + string).indexOf(close, at),\n string,\n open,\n close,\n replace\n )\n : \"\"\n\nconst init = (open, close, replace) =>\n filterEmpty(`\\x1b[${open}m`, `\\x1b[${close}m`, replace)\n\nconst colors = {\n reset: init(0, 0),\n bold: init(1, 22, \"\\x1b[22m\\x1b[1m\"),\n dim: init(2, 22, \"\\x1b[22m\\x1b[2m\"),\n italic: init(3, 23),\n underline: init(4, 24),\n inverse: init(7, 27),\n hidden: init(8, 28),\n strikethrough: init(9, 29),\n black: init(30, 39),\n red: init(31, 39),\n green: init(32, 39),\n yellow: init(33, 39),\n blue: init(34, 39),\n magenta: init(35, 39),\n cyan: init(36, 39),\n white: init(37, 39),\n gray: init(90, 39),\n bgBlack: init(40, 49),\n bgRed: init(41, 49),\n bgGreen: init(42, 49),\n bgYellow: init(43, 49),\n bgBlue: init(44, 49),\n bgMagenta: init(45, 49),\n bgCyan: init(46, 49),\n bgWhite: init(47, 49),\n blackBright: init(90, 39),\n redBright: init(91, 39),\n greenBright: init(92, 39),\n yellowBright: init(93, 39),\n blueBright: init(94, 39),\n magentaBright: init(95, 39),\n cyanBright: init(96, 39),\n whiteBright: init(97, 39),\n bgBlackBright: init(100, 49),\n bgRedBright: init(101, 49),\n bgGreenBright: init(102, 49),\n bgYellowBright: init(103, 49),\n bgBlueBright: init(104, 49),\n bgMagentaBright: init(105, 49),\n bgCyanBright: init(106, 49),\n bgWhiteBright: init(107, 49),\n}\n\nexport const createColors = ({ useColor = isColorSupported } = {}) =>\n useColor\n ? colors\n : Object.keys(colors).reduce(\n (colors, key) => ({ ...colors, [key]: String }),\n {}\n )\n\nexport const {\n reset,\n bold,\n dim,\n italic,\n underline,\n inverse,\n hidden,\n strikethrough,\n black,\n red,\n green,\n yellow,\n blue,\n magenta,\n cyan,\n white,\n gray,\n bgBlack,\n bgRed,\n bgGreen,\n bgYellow,\n bgBlue,\n bgMagenta,\n bgCyan,\n bgWhite,\n blackBright,\n redBright,\n greenBright,\n yellowBright,\n blueBright,\n magentaBright,\n cyanBright,\n whiteBright,\n bgBlackBright,\n bgRedBright,\n bgGreenBright,\n bgYellowBright,\n bgBlueBright,\n bgMagentaBright,\n bgCyanBright,\n bgWhiteBright,\n} = createColors()\n","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:net\");","import { createServer } from 'node:net';\nimport { networkInterfaces } from 'node:os';\n\nconst unsafePorts = /* @__PURE__ */ new Set([\n 1,\n 7,\n 9,\n 11,\n 13,\n 15,\n 17,\n 19,\n 20,\n 21,\n 22,\n 23,\n 25,\n 37,\n 42,\n 43,\n 53,\n 69,\n 77,\n 79,\n 87,\n 95,\n 101,\n 102,\n 103,\n 104,\n 109,\n 110,\n 111,\n 113,\n 115,\n 117,\n 119,\n 123,\n 135,\n 137,\n 139,\n 143,\n 161,\n 179,\n 389,\n 427,\n 465,\n 512,\n 513,\n 514,\n 515,\n 526,\n 530,\n 531,\n 532,\n 540,\n 548,\n 554,\n 556,\n 563,\n 587,\n 601,\n 636,\n 989,\n 990,\n 993,\n 995,\n 1719,\n 1720,\n 1723,\n 2049,\n 3659,\n 4045,\n 5060,\n 5061,\n 6e3,\n 6566,\n 6665,\n 6666,\n 6667,\n 6668,\n 6669,\n 6697,\n 10080\n]);\nfunction isUnsafePort(port) {\n return unsafePorts.has(port);\n}\nfunction isSafePort(port) {\n return !isUnsafePort(port);\n}\n\nfunction log(...arguments_) {\n console.log(\"[get-port]\", ...arguments_);\n}\nasync function getPort(config = {}) {\n if (typeof config === \"number\" || typeof config === \"string\") {\n config = { port: Number.parseInt(config + \"\") || 0 };\n }\n const options = {\n name: \"default\",\n random: false,\n ports: [],\n portRange: [],\n alternativePortRange: config.port ? [] : [3e3, 3100],\n host: void 0,\n verbose: false,\n ...config,\n port: config.port || Number.parseInt(process.env.PORT || \"\") || 3e3\n };\n if (options.random) {\n return getRandomPort(options.host);\n }\n const portsToCheck = [\n options.port,\n ...options.ports,\n ...generateRange(...options.portRange)\n ].filter((port) => {\n if (!port) {\n return false;\n }\n if (!isSafePort(port)) {\n if (options.verbose) {\n log(\"Ignoring unsafe port:\", port);\n }\n return false;\n }\n return true;\n });\n let availablePort = await findPort(\n portsToCheck,\n options.host,\n options.verbose,\n false\n );\n if (!availablePort) {\n availablePort = await findPort(\n generateRange(...options.alternativePortRange),\n options.host,\n options.verbose\n );\n if (options.verbose) {\n log(\n `Unable to find an available port (tried ${portsToCheck.join(\", \") || \"-\"}). Using alternative port:`,\n availablePort\n );\n }\n }\n return availablePort;\n}\nasync function getRandomPort(host) {\n const port = await checkPort(0, host);\n if (port === false) {\n throw new Error(\"Unable to obtain an available random port number!\");\n }\n return port;\n}\nasync function waitForPort(port, options = {}) {\n const delay = options.delay || 500;\n const retries = options.retries || 4;\n for (let index = retries; index > 0; index--) {\n if (await checkPort(port, options.host) === false) {\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n throw new Error(\n `Timeout waiting for port ${port} after ${retries} retries with ${delay}ms interval.`\n );\n}\nasync function checkPort(port, host = process.env.HOST, _verbose) {\n if (!host) {\n host = getLocalHosts([void 0, \"0.0.0.0\"]);\n }\n if (!Array.isArray(host)) {\n return _checkPort(port, host);\n }\n for (const _host of host) {\n const _port = await _checkPort(port, _host);\n if (_port === false) {\n if (port < 1024 && _verbose) {\n log(\"Unable to listen to priviliged port:\", `${_host}:${port}`);\n }\n return false;\n }\n if (port === 0 && _port !== 0) {\n port = _port;\n }\n }\n return port;\n}\nfunction generateRange(from, to) {\n if (to < from) {\n return [];\n }\n const r = [];\n for (let index = from; index < to; index++) {\n r.push(index);\n }\n return r;\n}\nfunction _checkPort(port, host) {\n return new Promise((resolve) => {\n const server = createServer();\n server.unref();\n server.on(\"error\", (error) => {\n if (error.code === \"EINVAL\" || error.code === \"EADDRNOTAVAIL\") {\n resolve(port !== 0 && isSafePort(port) && port);\n } else {\n resolve(false);\n }\n });\n server.listen({ port, host }, () => {\n const { port: port2 } = server.address();\n server.close(() => {\n resolve(isSafePort(port2) && port2);\n });\n });\n });\n}\nfunction getLocalHosts(additional) {\n const hosts = new Set(additional);\n for (const _interface of Object.values(networkInterfaces())) {\n for (const config of _interface || []) {\n hosts.add(config.address);\n }\n }\n return [...hosts];\n}\nasync function findPort(ports, host, _verbose = false, _random = true) {\n for (const port of ports) {\n const r = await checkPort(port, host, _verbose);\n if (r) {\n return r;\n }\n }\n if (_random) {\n const randomPort = await getRandomPort(host);\n if (_verbose) {\n log(\n `Unable to find an available port (tried ${ports.join(\", \") || \"-\"}). Using random port:`,\n randomPort\n );\n }\n return randomPort;\n } else {\n return 0;\n }\n}\n\nexport { checkPort, getPort, getRandomPort, isSafePort, isUnsafePort, waitForPort };\n","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:child_process\");","import { createServer as createServer$1 } from 'node:http';\nimport { createServer } from 'node:https';\nimport { promisify } from 'node:util';\nimport { readFileSync, existsSync, writeFileSync, chmodSync, statSync, promises, constants } from 'node:fs';\nimport os, { networkInterfaces } from 'node:os';\nimport { gray, cyan, underline, bold } from 'colorette';\nimport { getPort } from 'get-port-please';\nimport addShutdown from 'http-shutdown';\nimport { defu } from 'defu';\nimport childProcess from 'node:child_process';\nimport { join } from 'node:path';\n\nconst { platform, arch } = process;\nconst getWslDrivesMountPoint = (() => {\n const defaultMountPoint = \"/mnt/\";\n let mountPoint;\n return async function() {\n if (mountPoint) {\n return mountPoint;\n }\n const configFilePath = \"/etc/wsl.conf\";\n let isConfigFileExists = false;\n try {\n await promises.access(configFilePath, constants.F_OK);\n isConfigFileExists = true;\n } catch {\n }\n if (!isConfigFileExists) {\n return defaultMountPoint;\n }\n const configContent = await promises.readFile(configFilePath, {\n encoding: \"utf8\"\n });\n const configMountPoint = /(?.*)/g.exec(\n configContent\n );\n if (!configMountPoint) {\n return defaultMountPoint;\n }\n mountPoint = configMountPoint.groups.mountPoint.trim();\n mountPoint = mountPoint.endsWith(\"/\") ? mountPoint : `${mountPoint}/`;\n return mountPoint;\n };\n})();\nconst pTryEach = async (array, mapper) => {\n let latestError;\n for (const item of array) {\n try {\n return await mapper(item);\n } catch (error) {\n latestError = error;\n }\n }\n throw latestError;\n};\nconst baseOpen = async (options) => {\n options = {\n wait: false,\n background: false,\n newInstance: false,\n allowNonzeroExitCode: false,\n ...options\n };\n if (Array.isArray(options.app)) {\n return pTryEach(\n options.app,\n (singleApp) => baseOpen({\n ...options,\n app: singleApp\n })\n );\n }\n let { name: app, arguments: appArguments = [] } = options.app || {};\n appArguments = [...appArguments];\n if (Array.isArray(app)) {\n return pTryEach(\n app,\n (appName) => baseOpen({\n ...options,\n app: {\n name: appName,\n arguments: appArguments\n }\n })\n );\n }\n let command;\n const cliArguments = [];\n const childProcessOptions = {};\n if (platform === \"darwin\") {\n command = \"open\";\n if (options.wait) {\n cliArguments.push(\"--wait-apps\");\n }\n if (options.background) {\n cliArguments.push(\"--background\");\n }\n if (options.newInstance) {\n cliArguments.push(\"--new\");\n }\n if (app) {\n cliArguments.push(\"-a\", app);\n }\n } else if (platform === \"win32\" || isWsl() && !isDocker()) {\n const mountPoint = await getWslDrivesMountPoint();\n command = isWsl() ? `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process.env.SYSTEMROOT}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell`;\n cliArguments.push(\n \"-NoProfile\",\n \"-NonInteractive\",\n \"\\u2013ExecutionPolicy\",\n \"Bypass\",\n \"-EncodedCommand\"\n );\n if (!isWsl()) {\n childProcessOptions.windowsVerbatimArguments = true;\n }\n const encodedArguments = [\"Start\"];\n if (options.wait) {\n encodedArguments.push(\"-Wait\");\n }\n if (app) {\n encodedArguments.push(`\"\\`\"${app}\\`\"\"`, \"-ArgumentList\");\n if (options.target) {\n appArguments.unshift(options.target);\n }\n } else if (options.target) {\n encodedArguments.push(`\"${options.target}\"`);\n }\n if (appArguments.length > 0) {\n appArguments = appArguments.map((argument) => `\"\\`\"${argument}\\`\"\"`);\n encodedArguments.push(appArguments.join(\",\"));\n }\n options.target = Buffer.from(\n encodedArguments.join(\" \"),\n \"utf16le\"\n ).toString(\"base64\");\n } else {\n if (app) {\n command = app;\n } else {\n command = \"xdg-open\";\n const useSystemXdgOpen = process.versions.electron || platform === \"android\";\n if (!useSystemXdgOpen) {\n command = join(os.tmpdir(), \"xdg-open\");\n if (!existsSync(command)) {\n try {\n writeFileSync(\n join(os.tmpdir(), \"xdg-open\"),\n await import('./chunks/xdg-open.mjs').then((r) => r.xdgOpenScript()),\n \"utf8\"\n );\n chmodSync(\n command,\n 493\n /* rwx r-x r-x */\n );\n } catch {\n command = \"xdg-open\";\n }\n }\n }\n }\n if (appArguments.length > 0) {\n cliArguments.push(...appArguments);\n }\n if (!options.wait) {\n childProcessOptions.stdio = \"ignore\";\n childProcessOptions.detached = true;\n }\n }\n if (options.target) {\n cliArguments.push(options.target);\n }\n if (platform === \"darwin\" && appArguments.length > 0) {\n cliArguments.push(\"--args\", ...appArguments);\n }\n const subprocess = childProcess.spawn(\n command,\n cliArguments,\n childProcessOptions\n );\n if (options.wait) {\n return new Promise((resolve, reject) => {\n subprocess.once(\"error\", reject);\n subprocess.once(\"close\", (exitCode) => {\n if (options.allowNonzeroExitCode && exitCode > 0) {\n reject(new Error(`Exited with code ${exitCode}`));\n return;\n }\n resolve(subprocess);\n });\n });\n }\n subprocess.unref();\n return subprocess;\n};\nconst open = (target, options = {}) => {\n if (typeof target !== \"string\") {\n throw new TypeError(\"Expected a `target`\");\n }\n return baseOpen({\n ...options,\n target\n });\n};\nconst openApp = (name, options) => {\n if (typeof name !== \"string\") {\n throw new TypeError(\"Expected a `name`\");\n }\n const { arguments: appArguments = [] } = options || {};\n if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) {\n throw new TypeError(\"Expected `appArguments` as Array type\");\n }\n return baseOpen({\n ...options,\n app: {\n name,\n arguments: appArguments\n }\n });\n};\nfunction detectArchBinary(binary) {\n if (typeof binary === \"string\" || Array.isArray(binary)) {\n return binary;\n }\n const { [arch]: archBinary } = binary;\n if (!archBinary) {\n throw new Error(`${arch} is not supported`);\n }\n return archBinary;\n}\nfunction detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {\n if (wsl && isWsl()) {\n return detectArchBinary(wsl);\n }\n if (!platformBinary) {\n throw new Error(`${platform} is not supported`);\n }\n return detectArchBinary(platformBinary);\n}\nconst apps = {};\ndefineLazyProperty(\n apps,\n \"chrome\",\n () => detectPlatformBinary(\n {\n darwin: \"google chrome\",\n win32: \"chrome\",\n linux: [\"google-chrome\", \"google-chrome-stable\", \"chromium\"]\n },\n {\n wsl: {\n ia32: \"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe\",\n x64: [\n \"/mnt/c/Program Files/Google/Chrome/Application/chrome.exe\",\n \"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe\"\n ]\n }\n }\n )\n);\ndefineLazyProperty(\n apps,\n \"firefox\",\n () => detectPlatformBinary(\n {\n darwin: \"firefox\",\n win32: \"C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe\",\n linux: \"firefox\"\n },\n {\n wsl: \"/mnt/c/Program Files/Mozilla Firefox/firefox.exe\"\n }\n )\n);\ndefineLazyProperty(\n apps,\n \"edge\",\n () => detectPlatformBinary(\n {\n darwin: \"microsoft edge\",\n win32: \"msedge\",\n linux: [\"microsoft-edge\", \"microsoft-edge-dev\"]\n },\n {\n wsl: \"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe\"\n }\n )\n);\nopen.apps = apps;\nopen.openApp = openApp;\nfunction defineLazyProperty(object, propertyName, valueGetter) {\n const define = (value) => Object.defineProperty(object, propertyName, {\n value,\n enumerable: true,\n writable: true\n });\n Object.defineProperty(object, propertyName, {\n configurable: true,\n enumerable: true,\n get() {\n const result = valueGetter();\n define(result);\n return result;\n },\n set(value) {\n define(value);\n }\n });\n return object;\n}\nfunction _isWsl() {\n if (process.platform !== \"linux\") {\n return false;\n }\n if (os.release().toLowerCase().includes(\"microsoft\")) {\n if (isDocker()) {\n return false;\n }\n return true;\n }\n try {\n return readFileSync(\"/proc/version\", \"utf8\").toLowerCase().includes(\"microsoft\") ? !isDocker() : false;\n } catch {\n return false;\n }\n}\nlet isWSLCached;\nfunction isWsl() {\n if (isWSLCached === void 0) {\n isWSLCached = _isWsl();\n }\n return isWSLCached;\n}\nfunction hasDockerEnvironment() {\n try {\n statSync(\"/.dockerenv\");\n return true;\n } catch {\n return false;\n }\n}\nfunction hasDockerCGroup() {\n try {\n return readFileSync(\"/proc/self/cgroup\", \"utf8\").includes(\"docker\");\n } catch {\n return false;\n }\n}\nlet isDockerCached;\nfunction isDocker() {\n if (isDockerCached === void 0) {\n isDockerCached = hasDockerEnvironment() || hasDockerCGroup();\n }\n return isDockerCached;\n}\n\nasync function listen(handle, options_ = {}) {\n options_ = defu(options_, {\n port: process.env.PORT || 3e3,\n hostname: process.env.HOST || \"\",\n showURL: true,\n baseURL: \"/\",\n open: false,\n clipboard: false,\n isTest: process.env.NODE_ENV === \"test\",\n isProd: process.env.NODE_ENV === \"production\",\n autoClose: true\n });\n if (options_.isTest) {\n options_.showURL = false;\n }\n if (options_.isProd || options_.isTest) {\n options_.open = false;\n options_.clipboard = false;\n }\n const port = await getPort({\n port: Number(options_.port),\n verbose: !options_.isTest,\n host: options_.hostname,\n alternativePortRange: [3e3, 3100],\n ...typeof options_.port === \"object\" && options_.port\n });\n let server;\n let addr;\n const getURL = (host, baseURL) => {\n const anyV4 = addr?.addr === \"0.0.0.0\";\n const anyV6 = addr?.addr === \"[::]\";\n return `${addr.proto}://${host || options_.hostname || (anyV4 || anyV6 ? \"localhost\" : addr.addr)}:${addr.port}${baseURL || options_.baseURL}`;\n };\n let https = false;\n if (options_.https) {\n const { key, cert } = await resolveCert(\n { ...options_.https },\n options_.hostname\n );\n https = { key, cert };\n server = createServer({ key, cert }, handle);\n addShutdown(server);\n await promisify(server.listen.bind(server))(port, options_.hostname);\n const _addr = server.address();\n addr = { proto: \"https\", addr: formatAddress(_addr), port: _addr.port };\n } else {\n server = createServer$1(handle);\n addShutdown(server);\n await promisify(server.listen.bind(server))(port, options_.hostname);\n const _addr = server.address();\n addr = { proto: \"http\", addr: formatAddress(_addr), port: _addr.port };\n }\n let _closed = false;\n const close = () => {\n if (_closed) {\n return Promise.resolve();\n }\n _closed = true;\n return promisify(server.shutdown)();\n };\n if (options_.clipboard) {\n const clipboardy = await import('clipboardy').then((r) => r.default || r);\n await clipboardy.write(getURL()).catch(() => {\n options_.clipboard = false;\n });\n }\n const showURL = (options) => {\n const add = options_.clipboard ? gray(\"(copied to clipboard)\") : \"\";\n const lines = [];\n const baseURL = options?.baseURL || options_.baseURL || \"\";\n const name = options?.name ? ` (${options.name})` : \"\";\n const anyV4 = addr?.addr === \"0.0.0.0\";\n const anyV6 = addr?.addr === \"[::]\";\n if (anyV4 || anyV6) {\n lines.push(\n ` > Local${name}: ${formatURL(getURL(\"localhost\", baseURL))} ${add}`\n );\n for (const addr2 of getNetworkInterfaces(anyV4)) {\n lines.push(` > Network${name}: ${formatURL(getURL(addr2, baseURL))}`);\n }\n } else {\n lines.push(\n ` > Listening${name}: ${formatURL(\n getURL(void 0, baseURL)\n )} ${add}`\n );\n }\n console.log(\"\\n\" + lines.join(\"\\n\") + \"\\n\");\n };\n if (options_.showURL) {\n showURL();\n }\n const _open = async () => {\n await open(getURL()).catch(() => {\n });\n };\n if (options_.open) {\n await _open();\n }\n if (options_.autoClose) {\n process.on(\"exit\", () => close());\n }\n return {\n url: getURL(),\n https,\n server,\n open: _open,\n showURL,\n close\n };\n}\nasync function resolveCert(options, host) {\n if (options.key && options.cert) {\n const isInline = (s = \"\") => s.startsWith(\"--\");\n const r = (s) => isInline(s) ? s : promises.readFile(s, \"utf8\");\n return {\n key: await r(options.key),\n cert: await r(options.cert)\n };\n }\n const { generateCA, generateSSLCert } = await import('./chunks/cert.mjs');\n const ca = await generateCA();\n const cert = await generateSSLCert({\n caCert: ca.cert,\n caKey: ca.key,\n domains: options.domains || [\"localhost\", \"127.0.0.1\", \"::1\", host].filter(Boolean),\n validityDays: options.validityDays || 1\n });\n return cert;\n}\nfunction getNetworkInterfaces(v4Only = true) {\n const addrs = /* @__PURE__ */ new Set();\n for (const details of Object.values(networkInterfaces())) {\n if (details) {\n for (const d of details) {\n if (!d.internal && !(d.mac === \"00:00:00:00:00:00\") && !d.address.startsWith(\"fe80::\") && !(v4Only && (d.family === \"IPv6\" || +d.family === 6))) {\n addrs.add(formatAddress(d));\n }\n }\n }\n }\n return [...addrs].sort();\n}\nfunction formatAddress(addr) {\n return addr.family === \"IPv6\" || addr.family === 6 ? `[${addr.address}]` : addr.address;\n}\nfunction formatURL(url) {\n return cyan(\n underline(decodeURI(url).replace(/:(\\d+)\\//g, `:${bold(\"$1\")}/`))\n );\n}\n\nexport { listen };\n","import { eventHandler, createApp, createRouter, toNodeListener } from 'h3';\nimport { listen } from 'listhen';\nimport { getPort } from 'get-port-please';\nasync function run() {\n const hostname = '127.0.0.1';\n const app = createApp({ debug: false });\n const router = createRouter().post('/api/v1/functions', eventHandler((event) => {\n event.node.res.statusCode = 201;\n event.node.res.statusMessage = 'Created';\n event.node.res.setHeader('Content-Type', 'application/json');\n return {\n functionId: 'minimalfunctionid',\n versionId: 'minimalversionid',\n imageName: 'speckle/minimalfunctionid:minimalversionid'\n };\n }));\n app.use(router);\n const port = await getPort(3000);\n listen(toNodeListener(app), {\n hostname,\n port\n });\n}\nrun();\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACpFA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACzBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACRA;AACA;AACA;AACA;AACA;;;;;ACJA;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACNA;AACA;;;;ACDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACp6CA;;ACAA;;;;ACAA;;ACAA;;ACAA;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrJA;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AC1PA;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7fA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":["../webpack://speckle-automate-github-action/./node_modules/http-shutdown/index.js","../webpack://speckle-automate-github-action/external node-commonjs \"assert\"","../webpack://speckle-automate-github-action/external node-commonjs \"buffer\"","../webpack://speckle-automate-github-action/external node-commonjs \"child_process\"","../webpack://speckle-automate-github-action/external node-commonjs \"crypto\"","../webpack://speckle-automate-github-action/external node-commonjs \"events\"","../webpack://speckle-automate-github-action/external node-commonjs \"fs\"","../webpack://speckle-automate-github-action/external node-commonjs \"http\"","../webpack://speckle-automate-github-action/external node-commonjs \"https\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:path\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:process\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:url\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:util\"","../webpack://speckle-automate-github-action/external node-commonjs \"os\"","../webpack://speckle-automate-github-action/external node-commonjs \"path\"","../webpack://speckle-automate-github-action/external node-commonjs \"stream\"","../webpack://speckle-automate-github-action/external node-commonjs \"util\"","../webpack://speckle-automate-github-action/webpack/bootstrap","../webpack://speckle-automate-github-action/webpack/runtime/create fake namespace object","../webpack://speckle-automate-github-action/webpack/runtime/define property getters","../webpack://speckle-automate-github-action/webpack/runtime/ensure chunk","../webpack://speckle-automate-github-action/webpack/runtime/get javascript chunk filename","../webpack://speckle-automate-github-action/webpack/runtime/hasOwnProperty shorthand","../webpack://speckle-automate-github-action/webpack/runtime/make namespace object","../webpack://speckle-automate-github-action/webpack/runtime/compat","../webpack://speckle-automate-github-action/webpack/runtime/import chunk loading","../webpack://speckle-automate-github-action/./node_modules/h3/node_modules/ufo/dist/index.mjs","../webpack://speckle-automate-github-action/./node_modules/radix3/dist/index.mjs","../webpack://speckle-automate-github-action/./node_modules/defu/dist/defu.mjs","../webpack://speckle-automate-github-action/./node_modules/h3/dist/index.mjs","../webpack://speckle-automate-github-action/external node-commonjs \"node:http\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:https\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:fs\"","../webpack://speckle-automate-github-action/external node-commonjs \"node:os\"","../webpack://speckle-automate-github-action/external node-commonjs \"tty\"","../webpack://speckle-automate-github-action/./node_modules/colorette/index.js","../webpack://speckle-automate-github-action/external node-commonjs \"node:net\"","../webpack://speckle-automate-github-action/./node_modules/get-port-please/dist/index.mjs","../webpack://speckle-automate-github-action/external node-commonjs \"node:child_process\"","../webpack://speckle-automate-github-action/./node_modules/listhen/dist/index.mjs","../webpack://speckle-automate-github-action/./src/tests/mock-server.ts"],"sourcesContent":["'use strict';\nvar http = require('http');\nvar https = require('https');\n\n/**\n * Expose `addShutdown`.\n */\nexports = module.exports = addShutdown;\n\n/**\n * Adds shutdown functionaility to the `http.Server` object\n * @param {http.Server} server The server to add shutdown functionaility to\n */\nfunction addShutdown(server) {\n var connections = {};\n var isShuttingDown = false;\n var connectionCounter = 0;\n\n function destroy(socket, force) {\n if (force || (socket._isIdle && isShuttingDown)) {\n socket.destroy();\n delete connections[socket._connectionId];\n }\n };\n\n function onConnection(socket) {\n var id = connectionCounter++;\n socket._isIdle = true;\n socket._connectionId = id;\n connections[id] = socket;\n\n socket.on('close', function() {\n delete connections[id];\n });\n };\n\n server.on('request', function(req, res) {\n req.socket._isIdle = false;\n\n res.on('finish', function() {\n req.socket._isIdle = true;\n destroy(req.socket);\n });\n });\n\n server.on('connection', onConnection);\n server.on('secureConnection', onConnection);\n\n function shutdown(force, cb) {\n isShuttingDown = true;\n server.close(function(err) {\n if (cb) {\n process.nextTick(function() { cb(err); });\n }\n });\n\n Object.keys(connections).forEach(function(key) {\n destroy(connections[key], force);\n });\n };\n\n server.shutdown = function(cb) {\n shutdown(false, cb);\n };\n\n server.forceShutdown = function(cb) {\n shutdown(true, cb);\n };\n\n return server;\n};\n\n/**\n * Extends the {http.Server} object with shutdown functionaility.\n * @return {http.Server} The decorated server object\n */\nexports.extend = function() {\n http.Server.prototype.withShutdown = function() {\n return addShutdown(this);\n };\n\n https.Server.prototype.withShutdown = function() {\n return addShutdown(this);\n };\n};\n","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"assert\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"buffer\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"child_process\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"crypto\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"events\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"fs\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"http\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"https\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:path\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:process\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:url\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:util\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"os\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"path\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"stream\");","module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"util\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\tvar threw = true;\n\ttry {\n\t\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\t\tthrew = false;\n\t} finally {\n\t\tif(threw) delete __webpack_module_cache__[moduleId];\n\t}\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);\nvar leafPrototypes;\n// create a fake namespace object\n// mode & 1: value is a module id, require it\n// mode & 2: merge all properties of value into the ns\n// mode & 4: return value when already ns object\n// mode & 16: return value when it's Promise-like\n// mode & 8|1: behave like require\n__webpack_require__.t = function(value, mode) {\n\tif(mode & 1) value = this(value);\n\tif(mode & 8) return value;\n\tif(typeof value === 'object' && value) {\n\t\tif((mode & 4) && value.__esModule) return value;\n\t\tif((mode & 16) && typeof value.then === 'function') return value;\n\t}\n\tvar ns = Object.create(null);\n\t__webpack_require__.r(ns);\n\tvar def = {};\n\tleafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];\n\tfor(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {\n\t\tObject.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));\n\t}\n\tdef['default'] = () => (value);\n\t__webpack_require__.d(ns, def);\n\treturn ns;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = (chunkId) => {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"\" + chunkId + \".index.js\";\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","\nif (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\\/\\/\\/\\w:/) ? 1 : 0, -1) + \"/\";","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t179: 0\n};\n\nvar installChunk = (data) => {\n\tvar {ids, modules, runtime} = data;\n\t// add \"modules\" to the modules object,\n\t// then flag all \"ids\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tfor(moduleId in modules) {\n\t\tif(__webpack_require__.o(modules, moduleId)) {\n\t\t\t__webpack_require__.m[moduleId] = modules[moduleId];\n\t\t}\n\t}\n\tif(runtime) runtime(__webpack_require__);\n\tfor(;i < ids.length; i++) {\n\t\tchunkId = ids[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[ids[i]] = 0;\n\t}\n\n}\n\n__webpack_require__.f.j = (chunkId, promises) => {\n\t\t// import() chunk loading for javascript\n\t\tvar installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;\n\t\tif(installedChunkData !== 0) { // 0 means \"already installed\".\n\n\t\t\t// a Promise means \"currently loading\".\n\t\t\tif(installedChunkData) {\n\t\t\t\tpromises.push(installedChunkData[1]);\n\t\t\t} else {\n\t\t\t\tif(true) { // all chunks have JS\n\t\t\t\t\t// setup Promise in chunk cache\n\t\t\t\t\tvar promise = import(\"./\" + __webpack_require__.u(chunkId)).then(installChunk, (e) => {\n\t\t\t\t\t\tif(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined;\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t});\n\t\t\t\t\tvar promise = Promise.race([promise, new Promise((resolve) => (installedChunkData = installedChunks[chunkId] = [resolve]))])\n\t\t\t\t\tpromises.push(installedChunkData[1] = promise);\n\t\t\t\t} else installedChunks[chunkId] = 0;\n\t\t\t}\n\t\t}\n};\n\n// no external install chunk\n\n// no on chunks loaded","const n = /[^\\0-\\x7E]/;\nconst t = /[\\x2E\\u3002\\uFF0E\\uFF61]/g;\nconst o = {\n overflow: \"Overflow Error\",\n \"not-basic\": \"Illegal Input\",\n \"invalid-input\": \"Invalid Input\"\n};\nconst e = Math.floor;\nconst r = String.fromCharCode;\nfunction s(n2) {\n throw new RangeError(o[n2]);\n}\nconst c = function(n2, t2) {\n return n2 + 22 + 75 * (n2 < 26) - ((t2 != 0) << 5);\n};\nconst u = function(n2, t2, o2) {\n let r2 = 0;\n for (n2 = o2 ? e(n2 / 700) : n2 >> 1, n2 += e(n2 / t2); n2 > 455; r2 += 36) {\n n2 = e(n2 / 35);\n }\n return e(r2 + 36 * n2 / (n2 + 38));\n};\nfunction toASCII(o2) {\n return function(n2, o3) {\n const e2 = n2.split(\"@\");\n let r2 = \"\";\n e2.length > 1 && (r2 = e2[0] + \"@\", n2 = e2[1]);\n const s2 = function(n3, t2) {\n const o4 = [];\n let e3 = n3.length;\n for (; e3--; ) {\n o4[e3] = t2(n3[e3]);\n }\n return o4;\n }((n2 = n2.replace(t, \".\")).split(\".\"), o3).join(\".\");\n return r2 + s2;\n }(o2, function(t2) {\n return n.test(t2) ? \"xn--\" + function(n2) {\n const t3 = [];\n const o3 = (n2 = function(n3) {\n const t4 = [];\n let o4 = 0;\n const e2 = n3.length;\n for (; o4 < e2; ) {\n const r2 = n3.charCodeAt(o4++);\n if (r2 >= 55296 && r2 <= 56319 && o4 < e2) {\n const e3 = n3.charCodeAt(o4++);\n (64512 & e3) == 56320 ? t4.push(((1023 & r2) << 10) + (1023 & e3) + 65536) : (t4.push(r2), o4--);\n } else {\n t4.push(r2);\n }\n }\n return t4;\n }(n2)).length;\n let f = 128;\n let i = 0;\n let l = 72;\n for (const o4 of n2) {\n o4 < 128 && t3.push(r(o4));\n }\n const h = t3.length;\n let p = h;\n for (h && t3.push(\"-\"); p < o3; ) {\n let o4 = 2147483647;\n for (const t4 of n2) {\n t4 >= f && t4 < o4 && (o4 = t4);\n }\n const a = p + 1;\n o4 - f > e((2147483647 - i) / a) && s(\"overflow\"), i += (o4 - f) * a, f = o4;\n for (const o5 of n2) {\n if (o5 < f && ++i > 2147483647 && s(\"overflow\"), o5 == f) {\n let n3 = i;\n for (let o6 = 36; ; o6 += 36) {\n const s2 = o6 <= l ? 1 : o6 >= l + 26 ? 26 : o6 - l;\n if (n3 < s2) {\n break;\n }\n const u2 = n3 - s2;\n const f2 = 36 - s2;\n t3.push(r(c(s2 + u2 % f2, 0))), n3 = e(u2 / f2);\n }\n t3.push(r(c(n3, 0))), l = u(i, a, p == h), i = 0, ++p;\n }\n }\n ++i, ++f;\n }\n return t3.join(\"\");\n }(t2) : t2;\n });\n}\n\nconst HASH_RE = /#/g;\nconst AMPERSAND_RE = /&/g;\nconst SLASH_RE = /\\//g;\nconst EQUAL_RE = /=/g;\nconst IM_RE = /\\?/g;\nconst PLUS_RE = /\\+/g;\nconst ENC_CARET_RE = /%5e/gi;\nconst ENC_BACKTICK_RE = /%60/gi;\nconst ENC_CURLY_OPEN_RE = /%7b/gi;\nconst ENC_PIPE_RE = /%7c/gi;\nconst ENC_CURLY_CLOSE_RE = /%7d/gi;\nconst ENC_SPACE_RE = /%20/gi;\nconst ENC_SLASH_RE = /%2f/gi;\nconst ENC_ENC_SLASH_RE = /%252f/gi;\nfunction encode(text) {\n return encodeURI(\"\" + text).replace(ENC_PIPE_RE, \"|\");\n}\nfunction encodeHash(text) {\n return encode(text).replace(ENC_CURLY_OPEN_RE, \"{\").replace(ENC_CURLY_CLOSE_RE, \"}\").replace(ENC_CARET_RE, \"^\");\n}\nfunction encodeQueryValue(input) {\n return encode(typeof input === \"string\" ? input : JSON.stringify(input)).replace(PLUS_RE, \"%2B\").replace(ENC_SPACE_RE, \"+\").replace(HASH_RE, \"%23\").replace(AMPERSAND_RE, \"%26\").replace(ENC_BACKTICK_RE, \"`\").replace(ENC_CARET_RE, \"^\");\n}\nfunction encodeQueryKey(text) {\n return encodeQueryValue(text).replace(EQUAL_RE, \"%3D\");\n}\nfunction encodePath(text) {\n return encode(text).replace(HASH_RE, \"%23\").replace(IM_RE, \"%3F\").replace(ENC_ENC_SLASH_RE, \"%2F\").replace(AMPERSAND_RE, \"%26\").replace(PLUS_RE, \"%2B\");\n}\nfunction encodeParam(text) {\n return encodePath(text).replace(SLASH_RE, \"%2F\");\n}\nfunction decode(text = \"\") {\n try {\n return decodeURIComponent(\"\" + text);\n } catch {\n return \"\" + text;\n }\n}\nfunction decodePath(text) {\n return decode(text.replace(ENC_SLASH_RE, \"%252F\"));\n}\nfunction decodeQueryValue(text) {\n return decode(text.replace(PLUS_RE, \" \"));\n}\nfunction encodeHost(name = \"\") {\n return toASCII(name);\n}\n\nfunction parseQuery(parametersString = \"\") {\n const object = {};\n if (parametersString[0] === \"?\") {\n parametersString = parametersString.slice(1);\n }\n for (const parameter of parametersString.split(\"&\")) {\n const s = parameter.match(/([^=]+)=?(.*)/) || [];\n if (s.length < 2) {\n continue;\n }\n const key = decode(s[1]);\n if (key === \"__proto__\" || key === \"constructor\") {\n continue;\n }\n const value = decodeQueryValue(s[2] || \"\");\n if (typeof object[key] !== \"undefined\") {\n if (Array.isArray(object[key])) {\n object[key].push(value);\n } else {\n object[key] = [object[key], value];\n }\n } else {\n object[key] = value;\n }\n }\n return object;\n}\nfunction encodeQueryItem(key, value) {\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n value = String(value);\n }\n if (!value) {\n return encodeQueryKey(key);\n }\n if (Array.isArray(value)) {\n return value.map((_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`).join(\"&\");\n }\n return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;\n}\nfunction stringifyQuery(query) {\n return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).join(\"&\");\n}\n\nclass $URL {\n constructor(input = \"\") {\n this.query = {};\n if (typeof input !== \"string\") {\n throw new TypeError(\n `URL input should be string received ${typeof input} (${input})`\n );\n }\n const parsed = parseURL(input);\n this.protocol = decode(parsed.protocol);\n this.host = decode(parsed.host);\n this.auth = decode(parsed.auth);\n this.pathname = decodePath(parsed.pathname);\n this.query = parseQuery(parsed.search);\n this.hash = decode(parsed.hash);\n }\n get hostname() {\n return parseHost(this.host).hostname;\n }\n get port() {\n return parseHost(this.host).port || \"\";\n }\n get username() {\n return parseAuth(this.auth).username;\n }\n get password() {\n return parseAuth(this.auth).password || \"\";\n }\n get hasProtocol() {\n return this.protocol.length;\n }\n get isAbsolute() {\n return this.hasProtocol || this.pathname[0] === \"/\";\n }\n get search() {\n const q = stringifyQuery(this.query);\n return q.length > 0 ? \"?\" + q : \"\";\n }\n get searchParams() {\n const p = new URLSearchParams();\n for (const name in this.query) {\n const value = this.query[name];\n if (Array.isArray(value)) {\n for (const v of value) {\n p.append(name, v);\n }\n } else {\n p.append(\n name,\n typeof value === \"string\" ? value : JSON.stringify(value)\n );\n }\n }\n return p;\n }\n get origin() {\n return (this.protocol ? this.protocol + \"//\" : \"\") + encodeHost(this.host);\n }\n get fullpath() {\n return encodePath(this.pathname) + this.search + encodeHash(this.hash);\n }\n get encodedAuth() {\n if (!this.auth) {\n return \"\";\n }\n const { username, password } = parseAuth(this.auth);\n return encodeURIComponent(username) + (password ? \":\" + encodeURIComponent(password) : \"\");\n }\n get href() {\n const auth = this.encodedAuth;\n const originWithAuth = (this.protocol ? this.protocol + \"//\" : \"\") + (auth ? auth + \"@\" : \"\") + encodeHost(this.host);\n return this.hasProtocol && this.isAbsolute ? originWithAuth + this.fullpath : this.fullpath;\n }\n append(url) {\n if (url.hasProtocol) {\n throw new Error(\"Cannot append a URL with protocol\");\n }\n Object.assign(this.query, url.query);\n if (url.pathname) {\n this.pathname = withTrailingSlash(this.pathname) + withoutLeadingSlash(url.pathname);\n }\n if (url.hash) {\n this.hash = url.hash;\n }\n }\n toJSON() {\n return this.href;\n }\n toString() {\n return this.href;\n }\n}\n\nfunction isRelative(inputString) {\n return [\"./\", \"../\"].some((string_) => inputString.startsWith(string_));\n}\nconst PROTOCOL_STRICT_REGEX = /^\\w{2,}:([/\\\\]{1,2})/;\nconst PROTOCOL_REGEX = /^\\w{2,}:([/\\\\]{2})?/;\nconst PROTOCOL_RELATIVE_REGEX = /^([/\\\\]\\s*){2,}[^/\\\\]/;\nfunction hasProtocol(inputString, opts = {}) {\n if (typeof opts === \"boolean\") {\n opts = { acceptRelative: opts };\n }\n if (opts.strict) {\n return PROTOCOL_STRICT_REGEX.test(inputString);\n }\n return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);\n}\nconst TRAILING_SLASH_RE = /\\/$|\\/\\?/;\nfunction hasTrailingSlash(input = \"\", queryParameters = false) {\n if (!queryParameters) {\n return input.endsWith(\"/\");\n }\n return TRAILING_SLASH_RE.test(input);\n}\nfunction withoutTrailingSlash(input = \"\", queryParameters = false) {\n if (!queryParameters) {\n return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || \"/\";\n }\n if (!hasTrailingSlash(input, true)) {\n return input || \"/\";\n }\n const [s0, ...s] = input.split(\"?\");\n return (s0.slice(0, -1) || \"/\") + (s.length > 0 ? `?${s.join(\"?\")}` : \"\");\n}\nfunction withTrailingSlash(input = \"\", queryParameters = false) {\n if (!queryParameters) {\n return input.endsWith(\"/\") ? input : input + \"/\";\n }\n if (hasTrailingSlash(input, true)) {\n return input || \"/\";\n }\n const [s0, ...s] = input.split(\"?\");\n return s0 + \"/\" + (s.length > 0 ? `?${s.join(\"?\")}` : \"\");\n}\nfunction hasLeadingSlash(input = \"\") {\n return input.startsWith(\"/\");\n}\nfunction withoutLeadingSlash(input = \"\") {\n return (hasLeadingSlash(input) ? input.slice(1) : input) || \"/\";\n}\nfunction withLeadingSlash(input = \"\") {\n return hasLeadingSlash(input) ? input : \"/\" + input;\n}\nfunction cleanDoubleSlashes(input = \"\") {\n return input.split(\"://\").map((string_) => string_.replace(/\\/{2,}/g, \"/\")).join(\"://\");\n}\nfunction withBase(input, base) {\n if (isEmptyURL(base) || hasProtocol(input)) {\n return input;\n }\n const _base = withoutTrailingSlash(base);\n if (input.startsWith(_base)) {\n return input;\n }\n return joinURL(_base, input);\n}\nfunction withoutBase(input, base) {\n if (isEmptyURL(base)) {\n return input;\n }\n const _base = withoutTrailingSlash(base);\n if (!input.startsWith(_base)) {\n return input;\n }\n const trimmed = input.slice(_base.length);\n return trimmed[0] === \"/\" ? trimmed : \"/\" + trimmed;\n}\nfunction withQuery(input, query) {\n const parsed = parseURL(input);\n const mergedQuery = { ...parseQuery(parsed.search), ...query };\n parsed.search = stringifyQuery(mergedQuery);\n return stringifyParsedURL(parsed);\n}\nfunction getQuery(input) {\n return parseQuery(parseURL(input).search);\n}\nfunction isEmptyURL(url) {\n return !url || url === \"/\";\n}\nfunction isNonEmptyURL(url) {\n return url && url !== \"/\";\n}\nfunction joinURL(base, ...input) {\n let url = base || \"\";\n for (const index of input.filter((url2) => isNonEmptyURL(url2))) {\n url = url ? withTrailingSlash(url) + withoutLeadingSlash(index) : index;\n }\n return url;\n}\nfunction withHttp(input) {\n return withProtocol(input, \"http://\");\n}\nfunction withHttps(input) {\n return withProtocol(input, \"https://\");\n}\nfunction withoutProtocol(input) {\n return withProtocol(input, \"\");\n}\nfunction withProtocol(input, protocol) {\n const match = input.match(PROTOCOL_REGEX);\n if (!match) {\n return protocol + input;\n }\n return protocol + input.slice(match[0].length);\n}\nfunction createURL(input) {\n return new $URL(input);\n}\nfunction normalizeURL(input) {\n return createURL(input).toString();\n}\nfunction resolveURL(base, ...input) {\n const url = createURL(base);\n for (const index of input.filter((url2) => isNonEmptyURL(url2))) {\n url.append(createURL(index));\n }\n return url.toString();\n}\nfunction isSamePath(p1, p2) {\n return decode(withoutTrailingSlash(p1)) === decode(withoutTrailingSlash(p2));\n}\nfunction isEqual(a, b, options = {}) {\n if (!options.trailingSlash) {\n a = withTrailingSlash(a);\n b = withTrailingSlash(b);\n }\n if (!options.leadingSlash) {\n a = withLeadingSlash(a);\n b = withLeadingSlash(b);\n }\n if (!options.encoding) {\n a = decode(a);\n b = decode(b);\n }\n return a === b;\n}\n\nfunction parseURL(input = \"\", defaultProto) {\n if (!hasProtocol(input, { acceptRelative: true })) {\n return defaultProto ? parseURL(defaultProto + input) : parsePath(input);\n }\n const [protocol = \"\", auth, hostAndPath = \"\"] = (input.replace(/\\\\/g, \"/\").match(/([^/:]+:)?\\/\\/([^/@]+@)?(.*)/) || []).splice(1);\n const [host = \"\", path = \"\"] = (hostAndPath.match(/([^#/?]*)(.*)?/) || []).splice(1);\n const { pathname, search, hash } = parsePath(\n path.replace(/\\/(?=[A-Za-z]:)/, \"\")\n );\n return {\n protocol,\n auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : \"\",\n host,\n pathname,\n search,\n hash\n };\n}\nfunction parsePath(input = \"\") {\n const [pathname = \"\", search = \"\", hash = \"\"] = (input.match(/([^#?]*)(\\?[^#]*)?(#.*)?/) || []).splice(1);\n return {\n pathname,\n search,\n hash\n };\n}\nfunction parseAuth(input = \"\") {\n const [username, password] = input.split(\":\");\n return {\n username: decode(username),\n password: decode(password)\n };\n}\nfunction parseHost(input = \"\") {\n const [hostname, port] = (input.match(/([^/:]*):?(\\d+)?/) || []).splice(1);\n return {\n hostname: decode(hostname),\n port\n };\n}\nfunction stringifyParsedURL(parsed) {\n const fullpath = parsed.pathname + (parsed.search ? (parsed.search.startsWith(\"?\") ? \"\" : \"?\") + parsed.search : \"\") + parsed.hash;\n if (!parsed.protocol) {\n return fullpath;\n }\n return parsed.protocol + \"//\" + (parsed.auth ? parsed.auth + \"@\" : \"\") + parsed.host + fullpath;\n}\n\nexport { $URL, cleanDoubleSlashes, createURL, decode, decodePath, decodeQueryValue, encode, encodeHash, encodeHost, encodeParam, encodePath, encodeQueryItem, encodeQueryKey, encodeQueryValue, getQuery, hasLeadingSlash, hasProtocol, hasTrailingSlash, isEmptyURL, isEqual, isNonEmptyURL, isRelative, isSamePath, joinURL, normalizeURL, parseAuth, parseHost, parsePath, parseQuery, parseURL, resolveURL, stringifyParsedURL, stringifyQuery, withBase, withHttp, withHttps, withLeadingSlash, withProtocol, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutProtocol, withoutTrailingSlash };\n","const NODE_TYPES = {\n NORMAL: 0,\n WILDCARD: 1,\n PLACEHOLDER: 2\n};\n\nfunction createRouter(options = {}) {\n const ctx = {\n options,\n rootNode: createRadixNode(),\n staticRoutesMap: {}\n };\n const normalizeTrailingSlash = (p) => options.strictTrailingSlash ? p : p.replace(/\\/$/, \"\") || \"/\";\n if (options.routes) {\n for (const path in options.routes) {\n insert(ctx, normalizeTrailingSlash(path), options.routes[path]);\n }\n }\n return {\n ctx,\n // @ts-ignore\n lookup: (path) => lookup(ctx, normalizeTrailingSlash(path)),\n insert: (path, data) => insert(ctx, normalizeTrailingSlash(path), data),\n remove: (path) => remove(ctx, normalizeTrailingSlash(path))\n };\n}\nfunction lookup(ctx, path) {\n const staticPathNode = ctx.staticRoutesMap[path];\n if (staticPathNode) {\n return staticPathNode.data;\n }\n const sections = path.split(\"/\");\n const params = {};\n let paramsFound = false;\n let wildcardNode = null;\n let node = ctx.rootNode;\n let wildCardParam = null;\n for (let i = 0; i < sections.length; i++) {\n const section = sections[i];\n if (node.wildcardChildNode !== null) {\n wildcardNode = node.wildcardChildNode;\n wildCardParam = sections.slice(i).join(\"/\");\n }\n const nextNode = node.children.get(section);\n if (nextNode !== void 0) {\n node = nextNode;\n } else {\n node = node.placeholderChildNode;\n if (node !== null) {\n params[node.paramName] = section;\n paramsFound = true;\n } else {\n break;\n }\n }\n }\n if ((node === null || node.data === null) && wildcardNode !== null) {\n node = wildcardNode;\n params[node.paramName || \"_\"] = wildCardParam;\n paramsFound = true;\n }\n if (!node) {\n return null;\n }\n if (paramsFound) {\n return {\n ...node.data,\n params: paramsFound ? params : void 0\n };\n }\n return node.data;\n}\nfunction insert(ctx, path, data) {\n let isStaticRoute = true;\n const sections = path.split(\"/\");\n let node = ctx.rootNode;\n let _unnamedPlaceholderCtr = 0;\n for (const section of sections) {\n let childNode;\n if (childNode = node.children.get(section)) {\n node = childNode;\n } else {\n const type = getNodeType(section);\n childNode = createRadixNode({ type, parent: node });\n node.children.set(section, childNode);\n if (type === NODE_TYPES.PLACEHOLDER) {\n childNode.paramName = section === \"*\" ? `_${_unnamedPlaceholderCtr++}` : section.slice(1);\n node.placeholderChildNode = childNode;\n isStaticRoute = false;\n } else if (type === NODE_TYPES.WILDCARD) {\n node.wildcardChildNode = childNode;\n childNode.paramName = section.slice(\n 3\n /* \"**:\" */\n ) || \"_\";\n isStaticRoute = false;\n }\n node = childNode;\n }\n }\n node.data = data;\n if (isStaticRoute === true) {\n ctx.staticRoutesMap[path] = node;\n }\n return node;\n}\nfunction remove(ctx, path) {\n let success = false;\n const sections = path.split(\"/\");\n let node = ctx.rootNode;\n for (const section of sections) {\n node = node.children.get(section);\n if (!node) {\n return success;\n }\n }\n if (node.data) {\n const lastSection = sections[sections.length - 1];\n node.data = null;\n if (Object.keys(node.children).length === 0) {\n const parentNode = node.parent;\n parentNode.children.delete(lastSection);\n parentNode.wildcardChildNode = null;\n parentNode.placeholderChildNode = null;\n }\n success = true;\n }\n return success;\n}\nfunction createRadixNode(options = {}) {\n return {\n type: options.type || NODE_TYPES.NORMAL,\n parent: options.parent || null,\n children: /* @__PURE__ */ new Map(),\n data: options.data || null,\n paramName: options.paramName || null,\n wildcardChildNode: null,\n placeholderChildNode: null\n };\n}\nfunction getNodeType(str) {\n if (str.startsWith(\"**\")) {\n return NODE_TYPES.WILDCARD;\n }\n if (str[0] === \":\" || str === \"*\") {\n return NODE_TYPES.PLACEHOLDER;\n }\n return NODE_TYPES.NORMAL;\n}\n\nfunction toRouteMatcher(router) {\n const table = _routerNodeToTable(\"\", router.ctx.rootNode);\n return _createMatcher(table);\n}\nfunction _createMatcher(table) {\n return {\n ctx: { table },\n matchAll: (path) => _matchRoutes(path, table)\n };\n}\nfunction _createRouteTable() {\n return {\n static: /* @__PURE__ */ new Map(),\n wildcard: /* @__PURE__ */ new Map(),\n dynamic: /* @__PURE__ */ new Map()\n };\n}\nfunction _matchRoutes(path, table) {\n const matches = [];\n for (const [key, value] of _sortRoutesMap(table.wildcard)) {\n if (path.startsWith(key)) {\n matches.push(value);\n }\n }\n for (const [key, value] of _sortRoutesMap(table.dynamic)) {\n if (path.startsWith(key + \"/\")) {\n const subPath = \"/\" + path.slice(key.length).split(\"/\").splice(2).join(\"/\");\n matches.push(..._matchRoutes(subPath, value));\n }\n }\n const staticMatch = table.static.get(path);\n if (staticMatch) {\n matches.push(staticMatch);\n }\n return matches.filter(Boolean);\n}\nfunction _sortRoutesMap(m) {\n return [...m.entries()].sort((a, b) => a[0].length - b[0].length);\n}\nfunction _routerNodeToTable(initialPath, initialNode) {\n const table = _createRouteTable();\n function _addNode(path, node) {\n if (path) {\n if (node.type === NODE_TYPES.NORMAL && !(path.includes(\"*\") || path.includes(\":\"))) {\n table.static.set(path, node.data);\n } else if (node.type === NODE_TYPES.WILDCARD) {\n table.wildcard.set(path.replace(\"/**\", \"\"), node.data);\n } else if (node.type === NODE_TYPES.PLACEHOLDER) {\n const subTable = _routerNodeToTable(\"\", node);\n if (node.data) {\n subTable.static.set(\"/\", node.data);\n }\n table.dynamic.set(path.replace(/\\/\\*|\\/:\\w+/, \"\"), subTable);\n return;\n }\n }\n for (const [childPath, child] of node.children.entries()) {\n _addNode(`${path}/${childPath}`.replace(\"//\", \"/\"), child);\n }\n }\n _addNode(initialPath, initialNode);\n return table;\n}\n\nexport { NODE_TYPES, createRouter, toRouteMatcher };\n","function isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction _defu(baseObject, defaults, namespace = \".\", merger) {\n if (!isObject(defaults)) {\n return _defu(baseObject, {}, namespace, merger);\n }\n const object = Object.assign({}, defaults);\n for (const key in baseObject) {\n if (key === \"__proto__\" || key === \"constructor\") {\n continue;\n }\n const value = baseObject[key];\n if (value === null || value === void 0) {\n continue;\n }\n if (merger && merger(object, key, value, namespace)) {\n continue;\n }\n if (Array.isArray(value) && Array.isArray(object[key])) {\n object[key] = [...value, ...object[key]];\n } else if (isObject(value) && isObject(object[key])) {\n object[key] = _defu(\n value,\n object[key],\n (namespace ? `${namespace}.` : \"\") + key.toString(),\n merger\n );\n } else {\n object[key] = value;\n }\n }\n return object;\n}\nfunction createDefu(merger) {\n return (...arguments_) => (\n // eslint-disable-next-line unicorn/no-array-reduce\n arguments_.reduce((p, c) => _defu(p, c, \"\", merger), {})\n );\n}\nconst defu = createDefu();\nconst defuFn = createDefu((object, key, currentValue) => {\n if (typeof object[key] !== \"undefined\" && typeof currentValue === \"function\") {\n object[key] = currentValue(object[key]);\n return true;\n }\n});\nconst defuArrayFn = createDefu((object, key, currentValue) => {\n if (Array.isArray(object[key]) && typeof currentValue === \"function\") {\n object[key] = currentValue(object[key]);\n return true;\n }\n});\n\nexport { createDefu, defu as default, defu, defuArrayFn, defuFn };\n","import { withoutTrailingSlash, withoutBase, getQuery as getQuery$1 } from 'ufo';\nimport { createRouter as createRouter$1 } from 'radix3';\nimport destr from 'destr';\nimport { parse as parse$1, serialize } from 'cookie-es';\nimport crypto from 'uncrypto';\nimport { seal, defaults, unseal } from 'iron-webcrypto';\nimport { defu } from 'defu';\n\nfunction useBase(base, handler) {\n base = withoutTrailingSlash(base);\n if (!base) {\n return handler;\n }\n return eventHandler((event) => {\n event.node.req.originalUrl = event.node.req.originalUrl || event.node.req.url || \"/\";\n event.node.req.url = withoutBase(event.node.req.url || \"/\", base);\n return handler(event);\n });\n}\n\nfunction parse(multipartBodyBuffer, boundary) {\n let lastline = \"\";\n let state = 0 /* INIT */;\n let buffer = [];\n const allParts = [];\n let currentPartHeaders = [];\n for (let i = 0; i < multipartBodyBuffer.length; i++) {\n const prevByte = i > 0 ? multipartBodyBuffer[i - 1] : null;\n const currByte = multipartBodyBuffer[i];\n const newLineChar = currByte === 10 || currByte === 13;\n if (!newLineChar) {\n lastline += String.fromCodePoint(currByte);\n }\n const newLineDetected = currByte === 10 && prevByte === 13;\n if (0 /* INIT */ === state && newLineDetected) {\n if (\"--\" + boundary === lastline) {\n state = 1 /* READING_HEADERS */;\n }\n lastline = \"\";\n } else if (1 /* READING_HEADERS */ === state && newLineDetected) {\n if (lastline.length > 0) {\n const i2 = lastline.indexOf(\":\");\n if (i2 > 0) {\n const name = lastline.slice(0, i2).toLowerCase();\n const value = lastline.slice(i2 + 1).trim();\n currentPartHeaders.push([name, value]);\n }\n } else {\n state = 2 /* READING_DATA */;\n buffer = [];\n }\n lastline = \"\";\n } else if (2 /* READING_DATA */ === state) {\n if (lastline.length > boundary.length + 4) {\n lastline = \"\";\n }\n if (\"--\" + boundary === lastline) {\n const j = buffer.length - lastline.length;\n const part = buffer.slice(0, j - 1);\n allParts.push(process(part, currentPartHeaders));\n buffer = [];\n currentPartHeaders = [];\n lastline = \"\";\n state = 3 /* READING_PART_SEPARATOR */;\n } else {\n buffer.push(currByte);\n }\n if (newLineDetected) {\n lastline = \"\";\n }\n } else if (3 /* READING_PART_SEPARATOR */ === state && newLineDetected) {\n state = 1 /* READING_HEADERS */;\n }\n }\n return allParts;\n}\nfunction process(data, headers) {\n const dataObj = {};\n const contentDispositionHeader = headers.find((h) => h[0] === \"content-disposition\")?.[1] || \"\";\n for (const i of contentDispositionHeader.split(\";\")) {\n const s = i.split(\"=\");\n if (s.length !== 2) {\n continue;\n }\n const key = (s[0] || \"\").trim();\n if (key === \"name\" || key === \"filename\") {\n dataObj[key] = (s[1] || \"\").trim().replace(/\"/g, \"\");\n }\n }\n const contentType = headers.find((h) => h[0] === \"content-type\")?.[1] || \"\";\n if (contentType) {\n dataObj.type = contentType;\n }\n dataObj.data = Buffer.from(data);\n return dataObj;\n}\n\nclass H3Error extends Error {\n constructor() {\n super(...arguments);\n this.statusCode = 500;\n this.fatal = false;\n this.unhandled = false;\n this.statusMessage = void 0;\n }\n toJSON() {\n const obj = {\n message: this.message,\n statusCode: sanitizeStatusCode(this.statusCode, 500)\n };\n if (this.statusMessage) {\n obj.statusMessage = sanitizeStatusMessage(this.statusMessage);\n }\n if (this.data !== void 0) {\n obj.data = this.data;\n }\n return obj;\n }\n}\nH3Error.__h3_error__ = true;\nfunction createError(input) {\n if (typeof input === \"string\") {\n return new H3Error(input);\n }\n if (isError(input)) {\n return input;\n }\n const err = new H3Error(\n input.message ?? input.statusMessage,\n // @ts-ignore\n input.cause ? { cause: input.cause } : void 0\n );\n if (\"stack\" in input) {\n try {\n Object.defineProperty(err, \"stack\", {\n get() {\n return input.stack;\n }\n });\n } catch {\n try {\n err.stack = input.stack;\n } catch {\n }\n }\n }\n if (input.data) {\n err.data = input.data;\n }\n if (input.statusCode) {\n err.statusCode = sanitizeStatusCode(input.statusCode, err.statusCode);\n } else if (input.status) {\n err.statusCode = sanitizeStatusCode(input.status, err.statusCode);\n }\n if (input.statusMessage) {\n err.statusMessage = input.statusMessage;\n } else if (input.statusText) {\n err.statusMessage = input.statusText;\n }\n if (err.statusMessage) {\n const originalMessage = err.statusMessage;\n const sanitizedMessage = sanitizeStatusMessage(err.statusMessage);\n if (sanitizedMessage !== originalMessage) {\n console.warn(\n \"[h3] Please prefer using `message` for longer error messages instead of `statusMessage`. In the future `statusMessage` will be sanitized by default.\"\n );\n }\n }\n if (input.fatal !== void 0) {\n err.fatal = input.fatal;\n }\n if (input.unhandled !== void 0) {\n err.unhandled = input.unhandled;\n }\n return err;\n}\nfunction sendError(event, error, debug) {\n if (event.node.res.writableEnded) {\n return;\n }\n const h3Error = isError(error) ? error : createError(error);\n const responseBody = {\n statusCode: h3Error.statusCode,\n statusMessage: h3Error.statusMessage,\n stack: [],\n data: h3Error.data\n };\n if (debug) {\n responseBody.stack = (h3Error.stack || \"\").split(\"\\n\").map((l) => l.trim());\n }\n if (event.node.res.writableEnded) {\n return;\n }\n const _code = Number.parseInt(h3Error.statusCode);\n setResponseStatus(event, _code, h3Error.statusMessage);\n event.node.res.setHeader(\"content-type\", MIMES.json);\n event.node.res.end(JSON.stringify(responseBody, void 0, 2));\n}\nfunction isError(input) {\n return input?.constructor?.__h3_error__ === true;\n}\n\nfunction getQuery(event) {\n return getQuery$1(event.node.req.url || \"\");\n}\nfunction getRouterParams(event) {\n return event.context.params || {};\n}\nfunction getRouterParam(event, name) {\n const params = getRouterParams(event);\n return params[name];\n}\nfunction getMethod(event, defaultMethod = \"GET\") {\n return (event.node.req.method || defaultMethod).toUpperCase();\n}\nfunction isMethod(event, expected, allowHead) {\n const method = getMethod(event);\n if (allowHead && method === \"HEAD\") {\n return true;\n }\n if (typeof expected === \"string\") {\n if (method === expected) {\n return true;\n }\n } else if (expected.includes(method)) {\n return true;\n }\n return false;\n}\nfunction assertMethod(event, expected, allowHead) {\n if (!isMethod(event, expected, allowHead)) {\n throw createError({\n statusCode: 405,\n statusMessage: \"HTTP method is not allowed.\"\n });\n }\n}\nfunction getRequestHeaders(event) {\n const _headers = {};\n for (const key in event.node.req.headers) {\n const val = event.node.req.headers[key];\n _headers[key] = Array.isArray(val) ? val.filter(Boolean).join(\", \") : val;\n }\n return _headers;\n}\nconst getHeaders = getRequestHeaders;\nfunction getRequestHeader(event, name) {\n const headers = getRequestHeaders(event);\n const value = headers[name.toLowerCase()];\n return value;\n}\nconst getHeader = getRequestHeader;\nfunction getRequestHost(event, opts = {}) {\n if (opts.xForwardedHost) {\n const xForwardedHost = event.node.req.headers[\"x-forwarded-host\"];\n if (xForwardedHost) {\n return xForwardedHost;\n }\n }\n return event.node.req.headers.host || \"localhost\";\n}\nfunction getRequestProtocol(event, opts = {}) {\n if (opts.xForwardedProto !== false && event.node.req.headers[\"x-forwarded-proto\"] === \"https\") {\n return \"https\";\n }\n return event.node.req.connection.encrypted ? \"https\" : \"http\";\n}\nconst DOUBLE_SLASH_RE = /[/\\\\]{2,}/g;\nfunction getRequestPath(event) {\n const path = (event.node.req.url || \"/\").replace(DOUBLE_SLASH_RE, \"/\");\n return path;\n}\nfunction getRequestURL(event, opts = {}) {\n const host = getRequestHost(event, opts);\n const protocol = getRequestProtocol(event);\n const path = getRequestPath(event);\n return new URL(path, `${protocol}://${host}`);\n}\n\nconst RawBodySymbol = Symbol.for(\"h3RawBody\");\nconst ParsedBodySymbol = Symbol.for(\"h3ParsedBody\");\nconst PayloadMethods$1 = [\"PATCH\", \"POST\", \"PUT\", \"DELETE\"];\nfunction readRawBody(event, encoding = \"utf8\") {\n assertMethod(event, PayloadMethods$1);\n const _rawBody = event.node.req[RawBodySymbol] || event.node.req.body;\n if (_rawBody) {\n const promise2 = Promise.resolve(_rawBody).then(\n (_resolved) => Buffer.isBuffer(_resolved) ? _resolved : Buffer.from(_resolved)\n );\n return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;\n }\n if (!Number.parseInt(event.node.req.headers[\"content-length\"] || \"\")) {\n return Promise.resolve(void 0);\n }\n const promise = event.node.req[RawBodySymbol] = new Promise(\n (resolve, reject) => {\n const bodyData = [];\n event.node.req.on(\"error\", (err) => {\n reject(err);\n }).on(\"data\", (chunk) => {\n bodyData.push(chunk);\n }).on(\"end\", () => {\n resolve(Buffer.concat(bodyData));\n });\n }\n );\n const result = encoding ? promise.then((buff) => buff.toString(encoding)) : promise;\n return result;\n}\nasync function readBody(event) {\n if (ParsedBodySymbol in event.node.req) {\n return event.node.req[ParsedBodySymbol];\n }\n const body = await readRawBody(event, \"utf8\");\n if (event.node.req.headers[\"content-type\"] === \"application/x-www-form-urlencoded\") {\n const form = new URLSearchParams(body);\n const parsedForm = /* @__PURE__ */ Object.create(null);\n for (const [key, value] of form.entries()) {\n if (key in parsedForm) {\n if (!Array.isArray(parsedForm[key])) {\n parsedForm[key] = [parsedForm[key]];\n }\n parsedForm[key].push(value);\n } else {\n parsedForm[key] = value;\n }\n }\n return parsedForm;\n }\n const json = destr(body);\n event.node.req[ParsedBodySymbol] = json;\n return json;\n}\nasync function readMultipartFormData(event) {\n const contentType = getRequestHeader(event, \"content-type\");\n if (!contentType || !contentType.startsWith(\"multipart/form-data\")) {\n return;\n }\n const boundary = contentType.match(/boundary=([^;]*)(;|$)/i)?.[1];\n if (!boundary) {\n return;\n }\n const body = await readRawBody(event, false);\n if (!body) {\n return;\n }\n return parse(body, boundary);\n}\n\nfunction handleCacheHeaders(event, opts) {\n const cacheControls = [\"public\", ...opts.cacheControls || []];\n let cacheMatched = false;\n if (opts.maxAge !== void 0) {\n cacheControls.push(`max-age=${+opts.maxAge}`, `s-maxage=${+opts.maxAge}`);\n }\n if (opts.modifiedTime) {\n const modifiedTime = new Date(opts.modifiedTime);\n const ifModifiedSince = event.node.req.headers[\"if-modified-since\"];\n event.node.res.setHeader(\"last-modified\", modifiedTime.toUTCString());\n if (ifModifiedSince && new Date(ifModifiedSince) >= opts.modifiedTime) {\n cacheMatched = true;\n }\n }\n if (opts.etag) {\n event.node.res.setHeader(\"etag\", opts.etag);\n const ifNonMatch = event.node.req.headers[\"if-none-match\"];\n if (ifNonMatch === opts.etag) {\n cacheMatched = true;\n }\n }\n event.node.res.setHeader(\"cache-control\", cacheControls.join(\", \"));\n if (cacheMatched) {\n event.node.res.statusCode = 304;\n event.node.res.end();\n return true;\n }\n return false;\n}\n\nconst MIMES = {\n html: \"text/html\",\n json: \"application/json\"\n};\n\nfunction parseCookies(event) {\n return parse$1(event.node.req.headers.cookie || \"\");\n}\nfunction getCookie(event, name) {\n return parseCookies(event)[name];\n}\nfunction setCookie(event, name, value, serializeOptions) {\n const cookieStr = serialize(name, value, {\n path: \"/\",\n ...serializeOptions\n });\n let setCookies = event.node.res.getHeader(\"set-cookie\");\n if (!Array.isArray(setCookies)) {\n setCookies = [setCookies];\n }\n setCookies = setCookies.filter((cookieValue) => {\n return cookieValue && !cookieValue.startsWith(name + \"=\");\n });\n event.node.res.setHeader(\"set-cookie\", [...setCookies, cookieStr]);\n}\nfunction deleteCookie(event, name, serializeOptions) {\n setCookie(event, name, \"\", {\n ...serializeOptions,\n maxAge: 0\n });\n}\nfunction splitCookiesString(cookiesString) {\n if (typeof cookiesString !== \"string\") {\n return [];\n }\n const cookiesStrings = [];\n let pos = 0;\n let start;\n let ch;\n let lastComma;\n let nextStart;\n let cookiesSeparatorFound;\n function skipWhitespace() {\n while (pos < cookiesString.length && /\\s/.test(cookiesString.charAt(pos))) {\n pos += 1;\n }\n return pos < cookiesString.length;\n }\n function notSpecialChar() {\n ch = cookiesString.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n }\n while (pos < cookiesString.length) {\n start = pos;\n cookiesSeparatorFound = false;\n while (skipWhitespace()) {\n ch = cookiesString.charAt(pos);\n if (ch === \",\") {\n lastComma = pos;\n pos += 1;\n skipWhitespace();\n nextStart = pos;\n while (pos < cookiesString.length && notSpecialChar()) {\n pos += 1;\n }\n if (pos < cookiesString.length && cookiesString.charAt(pos) === \"=\") {\n cookiesSeparatorFound = true;\n pos = nextStart;\n cookiesStrings.push(cookiesString.slice(start, lastComma));\n start = pos;\n } else {\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n if (!cookiesSeparatorFound || pos >= cookiesString.length) {\n cookiesStrings.push(cookiesString.slice(start, cookiesString.length));\n }\n }\n return cookiesStrings;\n}\n\nconst DISALLOWED_STATUS_CHARS = /[^\\u0009\\u0020-\\u007E]/g;\nfunction sanitizeStatusMessage(statusMessage = \"\") {\n return statusMessage.replace(DISALLOWED_STATUS_CHARS, \"\");\n}\nfunction sanitizeStatusCode(statusCode, defaultStatusCode = 200) {\n if (!statusCode) {\n return defaultStatusCode;\n }\n if (typeof statusCode === \"string\") {\n statusCode = Number.parseInt(statusCode, 10);\n }\n if (statusCode < 100 || statusCode > 999) {\n return defaultStatusCode;\n }\n return statusCode;\n}\n\nconst PayloadMethods = /* @__PURE__ */ new Set([\"PATCH\", \"POST\", \"PUT\", \"DELETE\"]);\nconst ignoredHeaders = /* @__PURE__ */ new Set([\n \"transfer-encoding\",\n \"connection\",\n \"keep-alive\",\n \"upgrade\",\n \"expect\",\n \"host\"\n]);\nasync function proxyRequest(event, target, opts = {}) {\n const method = getMethod(event);\n let body;\n if (PayloadMethods.has(method)) {\n body = await readRawBody(event).catch(() => void 0);\n }\n const headers = getProxyRequestHeaders(event);\n if (opts.fetchOptions?.headers) {\n Object.assign(headers, opts.fetchOptions.headers);\n }\n if (opts.headers) {\n Object.assign(headers, opts.headers);\n }\n return sendProxy(event, target, {\n ...opts,\n fetchOptions: {\n headers,\n method,\n body,\n ...opts.fetchOptions\n }\n });\n}\nasync function sendProxy(event, target, opts = {}) {\n const response = await _getFetch(opts.fetch)(target, {\n headers: opts.headers,\n ...opts.fetchOptions\n });\n event.node.res.statusCode = sanitizeStatusCode(\n response.status,\n event.node.res.statusCode\n );\n event.node.res.statusMessage = sanitizeStatusMessage(response.statusText);\n for (const [key, value] of response.headers.entries()) {\n if (key === \"content-encoding\") {\n continue;\n }\n if (key === \"content-length\") {\n continue;\n }\n if (key === \"set-cookie\") {\n const cookies = splitCookiesString(value).map((cookie) => {\n if (opts.cookieDomainRewrite) {\n cookie = rewriteCookieProperty(\n cookie,\n opts.cookieDomainRewrite,\n \"domain\"\n );\n }\n if (opts.cookiePathRewrite) {\n cookie = rewriteCookieProperty(\n cookie,\n opts.cookiePathRewrite,\n \"path\"\n );\n }\n return cookie;\n });\n event.node.res.setHeader(\"set-cookie\", cookies);\n continue;\n }\n event.node.res.setHeader(key, value);\n }\n if (response._data !== void 0) {\n return response._data;\n }\n if (opts.sendStream === false) {\n const data = new Uint8Array(await response.arrayBuffer());\n return event.node.res.end(data);\n }\n for await (const chunk of response.body) {\n event.node.res.write(chunk);\n }\n return event.node.res.end();\n}\nfunction getProxyRequestHeaders(event) {\n const headers = /* @__PURE__ */ Object.create(null);\n const reqHeaders = getRequestHeaders(event);\n for (const name in reqHeaders) {\n if (!ignoredHeaders.has(name)) {\n headers[name] = reqHeaders[name];\n }\n }\n return headers;\n}\nfunction fetchWithEvent(event, req, init, options) {\n return _getFetch(options?.fetch)(req, {\n ...init,\n context: init?.context || event.context,\n headers: {\n ...getProxyRequestHeaders(event),\n ...init?.headers\n }\n });\n}\nfunction _getFetch(_fetch) {\n if (_fetch) {\n return _fetch;\n }\n if (globalThis.fetch) {\n return globalThis.fetch;\n }\n throw new Error(\n \"fetch is not available. Try importing `node-fetch-native/polyfill` for Node.js.\"\n );\n}\nfunction rewriteCookieProperty(header, map, property) {\n const _map = typeof map === \"string\" ? { \"*\": map } : map;\n return header.replace(\n new RegExp(`(;\\\\s*${property}=)([^;]+)`, \"gi\"),\n (match, prefix, previousValue) => {\n let newValue;\n if (previousValue in _map) {\n newValue = _map[previousValue];\n } else if (\"*\" in _map) {\n newValue = _map[\"*\"];\n } else {\n return match;\n }\n return newValue ? prefix + newValue : \"\";\n }\n );\n}\n\nconst defer = typeof setImmediate !== \"undefined\" ? setImmediate : (fn) => fn();\nfunction send(event, data, type) {\n if (type) {\n defaultContentType(event, type);\n }\n return new Promise((resolve) => {\n defer(() => {\n event.node.res.end(data);\n resolve();\n });\n });\n}\nfunction sendNoContent(event, code = 204) {\n event.node.res.statusCode = sanitizeStatusCode(code, 204);\n if (event.node.res.statusCode === 204) {\n event.node.res.removeHeader(\"content-length\");\n }\n event.node.res.end();\n}\nfunction setResponseStatus(event, code, text) {\n if (code) {\n event.node.res.statusCode = sanitizeStatusCode(\n code,\n event.node.res.statusCode\n );\n }\n if (text) {\n event.node.res.statusMessage = sanitizeStatusMessage(text);\n }\n}\nfunction getResponseStatus(event) {\n return event.node.res.statusCode;\n}\nfunction getResponseStatusText(event) {\n return event.node.res.statusMessage;\n}\nfunction defaultContentType(event, type) {\n if (type && !event.node.res.getHeader(\"content-type\")) {\n event.node.res.setHeader(\"content-type\", type);\n }\n}\nfunction sendRedirect(event, location, code = 302) {\n event.node.res.statusCode = sanitizeStatusCode(\n code,\n event.node.res.statusCode\n );\n event.node.res.setHeader(\"location\", location);\n const encodedLoc = location.replace(/\"/g, \"%22\");\n const html = ``;\n return send(event, html, MIMES.html);\n}\nfunction getResponseHeaders(event) {\n return event.node.res.getHeaders();\n}\nfunction getResponseHeader(event, name) {\n return event.node.res.getHeader(name);\n}\nfunction setResponseHeaders(event, headers) {\n for (const [name, value] of Object.entries(headers)) {\n event.node.res.setHeader(name, value);\n }\n}\nconst setHeaders = setResponseHeaders;\nfunction setResponseHeader(event, name, value) {\n event.node.res.setHeader(name, value);\n}\nconst setHeader = setResponseHeader;\nfunction appendResponseHeaders(event, headers) {\n for (const [name, value] of Object.entries(headers)) {\n appendResponseHeader(event, name, value);\n }\n}\nconst appendHeaders = appendResponseHeaders;\nfunction appendResponseHeader(event, name, value) {\n let current = event.node.res.getHeader(name);\n if (!current) {\n event.node.res.setHeader(name, value);\n return;\n }\n if (!Array.isArray(current)) {\n current = [current.toString()];\n }\n event.node.res.setHeader(name, [...current, value]);\n}\nconst appendHeader = appendResponseHeader;\nfunction isStream(data) {\n return data && typeof data === \"object\" && typeof data.pipe === \"function\" && typeof data.on === \"function\";\n}\nfunction sendStream(event, data) {\n return new Promise((resolve, reject) => {\n data.pipe(event.node.res);\n data.on(\"end\", () => resolve());\n data.on(\"error\", (error) => reject(createError(error)));\n });\n}\nconst noop = () => {\n};\nfunction writeEarlyHints(event, hints, cb = noop) {\n if (!event.node.res.socket) {\n cb();\n return;\n }\n if (typeof hints === \"string\" || Array.isArray(hints)) {\n hints = { link: hints };\n }\n if (hints.link) {\n hints.link = Array.isArray(hints.link) ? hints.link : hints.link.split(\",\");\n }\n const headers = Object.entries(hints).map(\n (e) => [e[0].toLowerCase(), e[1]]\n );\n if (headers.length === 0) {\n cb();\n return;\n }\n let hint = \"HTTP/1.1 103 Early Hints\";\n if (hints.link) {\n hint += `\\r\nLink: ${hints.link.join(\", \")}`;\n }\n for (const [header, value] of headers) {\n if (header === \"link\") {\n continue;\n }\n hint += `\\r\n${header}: ${value}`;\n }\n if (event.node.res.socket) {\n event.node.res.socket.write(\n `${hint}\\r\n\\r\n`,\n \"utf8\",\n cb\n );\n } else {\n cb();\n }\n}\n\nconst DEFAULT_NAME = \"h3\";\nconst DEFAULT_COOKIE = {\n path: \"/\",\n secure: true,\n httpOnly: true\n};\nasync function useSession(event, config) {\n const sessionName = config.name || DEFAULT_NAME;\n await getSession(event, config);\n const sessionManager = {\n get id() {\n return event.context.sessions?.[sessionName]?.id;\n },\n get data() {\n return event.context.sessions?.[sessionName]?.data || {};\n },\n update: async (update) => {\n await updateSession(event, config, update);\n return sessionManager;\n },\n clear: async () => {\n await clearSession(event, config);\n return sessionManager;\n }\n };\n return sessionManager;\n}\nasync function getSession(event, config) {\n const sessionName = config.name || DEFAULT_NAME;\n if (!event.context.sessions) {\n event.context.sessions = /* @__PURE__ */ Object.create(null);\n }\n if (event.context.sessions[sessionName]) {\n return event.context.sessions[sessionName];\n }\n const session = {\n id: \"\",\n createdAt: 0,\n data: /* @__PURE__ */ Object.create(null)\n };\n event.context.sessions[sessionName] = session;\n let sealedSession;\n if (config.sessionHeader !== false) {\n const headerName = typeof config.sessionHeader === \"string\" ? config.sessionHeader.toLowerCase() : `x-${sessionName.toLowerCase()}-session`;\n const headerValue = event.node.req.headers[headerName];\n if (typeof headerValue === \"string\") {\n sealedSession = headerValue;\n }\n }\n if (!sealedSession) {\n sealedSession = getCookie(event, sessionName);\n }\n if (sealedSession) {\n const unsealed = await unsealSession(event, config, sealedSession).catch(\n () => {\n }\n );\n Object.assign(session, unsealed);\n }\n if (!session.id) {\n session.id = (config.crypto || crypto).randomUUID();\n session.createdAt = Date.now();\n await updateSession(event, config);\n }\n return session;\n}\nasync function updateSession(event, config, update) {\n const sessionName = config.name || DEFAULT_NAME;\n const session = event.context.sessions?.[sessionName] || await getSession(event, config);\n if (typeof update === \"function\") {\n update = update(session.data);\n }\n if (update) {\n Object.assign(session.data, update);\n }\n if (config.cookie !== false) {\n const sealed = await sealSession(event, config);\n setCookie(event, sessionName, sealed, {\n ...DEFAULT_COOKIE,\n expires: config.maxAge ? new Date(session.createdAt + config.maxAge * 1e3) : void 0,\n ...config.cookie\n });\n }\n return session;\n}\nasync function sealSession(event, config) {\n const sessionName = config.name || DEFAULT_NAME;\n const session = event.context.sessions?.[sessionName] || await getSession(event, config);\n const sealed = await seal(config.crypto || crypto, session, config.password, {\n ...defaults,\n ttl: config.maxAge ? config.maxAge * 1e3 : 0,\n ...config.seal\n });\n return sealed;\n}\nasync function unsealSession(_event, config, sealed) {\n const unsealed = await unseal(\n config.crypto || crypto,\n sealed,\n config.password,\n {\n ...defaults,\n ttl: config.maxAge ? config.maxAge * 1e3 : 0,\n ...config.seal\n }\n );\n if (config.maxAge) {\n const age = Date.now() - (unsealed.createdAt || Number.NEGATIVE_INFINITY);\n if (age > config.maxAge * 1e3) {\n throw new Error(\"Session expired!\");\n }\n }\n return unsealed;\n}\nasync function clearSession(event, config) {\n const sessionName = config.name || DEFAULT_NAME;\n if (event.context.sessions?.[sessionName]) {\n delete event.context.sessions[sessionName];\n }\n await setCookie(event, sessionName, \"\", {\n ...DEFAULT_COOKIE,\n ...config.cookie\n });\n}\n\nfunction resolveCorsOptions(options = {}) {\n const defaultOptions = {\n origin: \"*\",\n methods: \"*\",\n allowHeaders: \"*\",\n exposeHeaders: \"*\",\n credentials: false,\n maxAge: false,\n preflight: {\n statusCode: 204\n }\n };\n return defu(options, defaultOptions);\n}\nfunction isPreflightRequest(event) {\n const method = getMethod(event);\n const origin = getRequestHeader(event, \"origin\");\n const accessControlRequestMethod = getRequestHeader(\n event,\n \"access-control-request-method\"\n );\n return method === \"OPTIONS\" && !!origin && !!accessControlRequestMethod;\n}\nfunction isCorsOriginAllowed(origin, options) {\n const { origin: originOption } = options;\n if (!origin || !originOption || originOption === \"*\" || originOption === \"null\") {\n return true;\n }\n if (Array.isArray(originOption)) {\n return originOption.some((_origin) => {\n if (_origin instanceof RegExp) {\n return _origin.test(origin);\n }\n return origin === _origin;\n });\n }\n return originOption(origin);\n}\nfunction createOriginHeaders(event, options) {\n const { origin: originOption } = options;\n const origin = getRequestHeader(event, \"origin\");\n if (!origin || !originOption || originOption === \"*\") {\n return { \"access-control-allow-origin\": \"*\" };\n }\n if (typeof originOption === \"string\") {\n return { \"access-control-allow-origin\": originOption, vary: \"origin\" };\n }\n return isCorsOriginAllowed(origin, options) ? { \"access-control-allow-origin\": origin, vary: \"origin\" } : {};\n}\nfunction createMethodsHeaders(options) {\n const { methods } = options;\n if (!methods) {\n return {};\n }\n if (methods === \"*\") {\n return { \"access-control-allow-methods\": \"*\" };\n }\n return methods.length > 0 ? { \"access-control-allow-methods\": methods.join(\",\") } : {};\n}\nfunction createCredentialsHeaders(options) {\n const { credentials } = options;\n if (credentials) {\n return { \"access-control-allow-credentials\": \"true\" };\n }\n return {};\n}\nfunction createAllowHeaderHeaders(event, options) {\n const { allowHeaders } = options;\n if (!allowHeaders || allowHeaders === \"*\" || allowHeaders.length === 0) {\n const header = getRequestHeader(event, \"access-control-request-headers\");\n return header ? {\n \"access-control-allow-headers\": header,\n vary: \"access-control-request-headers\"\n } : {};\n }\n return {\n \"access-control-allow-headers\": allowHeaders.join(\",\"),\n vary: \"access-control-request-headers\"\n };\n}\nfunction createExposeHeaders(options) {\n const { exposeHeaders } = options;\n if (!exposeHeaders) {\n return {};\n }\n if (exposeHeaders === \"*\") {\n return { \"access-control-expose-headers\": exposeHeaders };\n }\n return { \"access-control-expose-headers\": exposeHeaders.join(\",\") };\n}\nfunction appendCorsPreflightHeaders(event, options) {\n appendHeaders(event, createOriginHeaders(event, options));\n appendHeaders(event, createCredentialsHeaders(options));\n appendHeaders(event, createExposeHeaders(options));\n appendHeaders(event, createMethodsHeaders(options));\n appendHeaders(event, createAllowHeaderHeaders(event, options));\n}\nfunction appendCorsHeaders(event, options) {\n appendHeaders(event, createOriginHeaders(event, options));\n appendHeaders(event, createCredentialsHeaders(options));\n appendHeaders(event, createExposeHeaders(options));\n}\n\nfunction handleCors(event, options) {\n const _options = resolveCorsOptions(options);\n if (isPreflightRequest(event)) {\n appendCorsPreflightHeaders(event, options);\n sendNoContent(event, _options.preflight.statusCode);\n return true;\n }\n appendCorsHeaders(event, options);\n return false;\n}\n\nclass H3Headers {\n constructor(init) {\n if (!init) {\n this._headers = {};\n } else if (Array.isArray(init)) {\n this._headers = Object.fromEntries(\n init.map(([key, value]) => [key.toLowerCase(), value])\n );\n } else if (init && \"append\" in init) {\n this._headers = Object.fromEntries(init.entries());\n } else {\n this._headers = Object.fromEntries(\n Object.entries(init).map(([key, value]) => [key.toLowerCase(), value])\n );\n }\n }\n [Symbol.iterator]() {\n return this.entries();\n }\n entries() {\n throw Object.entries(this._headers)[Symbol.iterator]();\n }\n keys() {\n return Object.keys(this._headers)[Symbol.iterator]();\n }\n values() {\n throw Object.values(this._headers)[Symbol.iterator]();\n }\n append(name, value) {\n const _name = name.toLowerCase();\n this.set(_name, [this.get(_name), value].filter(Boolean).join(\", \"));\n }\n delete(name) {\n delete this._headers[name.toLowerCase()];\n }\n get(name) {\n return this._headers[name.toLowerCase()];\n }\n has(name) {\n return name.toLowerCase() in this._headers;\n }\n set(name, value) {\n this._headers[name.toLowerCase()] = String(value);\n }\n forEach(callbackfn) {\n for (const [key, value] of Object.entries(this._headers)) {\n callbackfn(value, key, this);\n }\n }\n}\n\nclass H3Response {\n constructor(body = null, init = {}) {\n // TODO: yet to implement\n this.body = null;\n this.type = \"default\";\n this.bodyUsed = false;\n this.headers = new H3Headers(init.headers);\n this.status = init.status ?? 200;\n this.statusText = init.statusText || \"\";\n this.redirected = !!init.status && [301, 302, 307, 308].includes(init.status);\n this._body = body;\n this.url = \"\";\n this.ok = this.status < 300 && this.status > 199;\n }\n clone() {\n return new H3Response(this.body, {\n headers: this.headers,\n status: this.status,\n statusText: this.statusText\n });\n }\n arrayBuffer() {\n return Promise.resolve(this._body);\n }\n blob() {\n return Promise.resolve(this._body);\n }\n formData() {\n return Promise.resolve(this._body);\n }\n json() {\n return Promise.resolve(this._body);\n }\n text() {\n return Promise.resolve(this._body);\n }\n}\n\nclass H3Event {\n constructor(req, res) {\n this[\"__is_event__\"] = true;\n this.context = {};\n this.node = { req, res };\n }\n get path() {\n return getRequestPath(this);\n }\n /** @deprecated Please use `event.node.req` instead. **/\n get req() {\n return this.node.req;\n }\n /** @deprecated Please use `event.node.res` instead. **/\n get res() {\n return this.node.res;\n }\n // Implementation of FetchEvent\n respondWith(r) {\n Promise.resolve(r).then((_response) => {\n if (this.res.writableEnded) {\n return;\n }\n const response = _response instanceof H3Response ? _response : new H3Response(_response);\n for (const [key, value] of response.headers.entries()) {\n this.res.setHeader(key, value);\n }\n if (response.status) {\n this.res.statusCode = sanitizeStatusCode(\n response.status,\n this.res.statusCode\n );\n }\n if (response.statusText) {\n this.res.statusMessage = sanitizeStatusMessage(response.statusText);\n }\n if (response.redirected) {\n this.res.setHeader(\"location\", response.url);\n }\n if (!response._body) {\n return this.res.end();\n }\n if (typeof response._body === \"string\" || \"buffer\" in response._body || \"byteLength\" in response._body) {\n return this.res.end(response._body);\n }\n if (!response.headers.has(\"content-type\")) {\n response.headers.set(\"content-type\", MIMES.json);\n }\n this.res.end(JSON.stringify(response._body));\n });\n }\n}\nfunction isEvent(input) {\n return \"__is_event__\" in input;\n}\nfunction createEvent(req, res) {\n return new H3Event(req, res);\n}\n\nfunction defineEventHandler(handler) {\n handler.__is_handler__ = true;\n return handler;\n}\nconst eventHandler = defineEventHandler;\nfunction isEventHandler(input) {\n return \"__is_handler__\" in input;\n}\nfunction toEventHandler(input, _, _route) {\n if (!isEventHandler(input)) {\n console.warn(\n \"[h3] Implicit event handler conversion is deprecated. Use `eventHandler()` or `fromNodeMiddleware()` to define event handlers.\",\n _route && _route !== \"/\" ? `\n Route: ${_route}` : \"\",\n `\n Handler: ${input}`\n );\n }\n return input;\n}\nfunction dynamicEventHandler(initial) {\n let current = initial;\n const wrapper = eventHandler((event) => {\n if (current) {\n return current(event);\n }\n });\n wrapper.set = (handler) => {\n current = handler;\n };\n return wrapper;\n}\nfunction defineLazyEventHandler(factory) {\n let _promise;\n let _resolved;\n const resolveHandler = () => {\n if (_resolved) {\n return Promise.resolve(_resolved);\n }\n if (!_promise) {\n _promise = Promise.resolve(factory()).then((r) => {\n const handler = r.default || r;\n if (typeof handler !== \"function\") {\n throw new TypeError(\n \"Invalid lazy handler result. It should be a function:\",\n handler\n );\n }\n _resolved = toEventHandler(r.default || r);\n return _resolved;\n });\n }\n return _promise;\n };\n return eventHandler((event) => {\n if (_resolved) {\n return _resolved(event);\n }\n return resolveHandler().then((handler) => handler(event));\n });\n}\nconst lazyEventHandler = defineLazyEventHandler;\n\nfunction createApp(options = {}) {\n const stack = [];\n const handler = createAppEventHandler(stack, options);\n const app = {\n // @ts-ignore\n use: (arg1, arg2, arg3) => use(app, arg1, arg2, arg3),\n handler,\n stack,\n options\n };\n return app;\n}\nfunction use(app, arg1, arg2, arg3) {\n if (Array.isArray(arg1)) {\n for (const i of arg1) {\n use(app, i, arg2, arg3);\n }\n } else if (Array.isArray(arg2)) {\n for (const i of arg2) {\n use(app, arg1, i, arg3);\n }\n } else if (typeof arg1 === \"string\") {\n app.stack.push(\n normalizeLayer({ ...arg3, route: arg1, handler: arg2 })\n );\n } else if (typeof arg1 === \"function\") {\n app.stack.push(\n normalizeLayer({ ...arg2, route: \"/\", handler: arg1 })\n );\n } else {\n app.stack.push(normalizeLayer({ ...arg1 }));\n }\n return app;\n}\nfunction createAppEventHandler(stack, options) {\n const spacing = options.debug ? 2 : void 0;\n return eventHandler(async (event) => {\n event.node.req.originalUrl = event.node.req.originalUrl || event.node.req.url || \"/\";\n const reqUrl = event.node.req.url || \"/\";\n for (const layer of stack) {\n if (layer.route.length > 1) {\n if (!reqUrl.startsWith(layer.route)) {\n continue;\n }\n event.node.req.url = reqUrl.slice(layer.route.length) || \"/\";\n } else {\n event.node.req.url = reqUrl;\n }\n if (layer.match && !layer.match(event.node.req.url, event)) {\n continue;\n }\n const val = await layer.handler(event);\n if (event.node.res.writableEnded) {\n return;\n }\n const type = typeof val;\n if (type === \"string\") {\n return send(event, val, MIMES.html);\n } else if (isStream(val)) {\n return sendStream(event, val);\n } else if (val === null) {\n event.node.res.statusCode = 204;\n return send(event);\n } else if (type === \"object\" || type === \"boolean\" || type === \"number\") {\n if (val.buffer) {\n return send(event, val);\n } else if (val instanceof Error) {\n throw createError(val);\n } else {\n return send(\n event,\n JSON.stringify(val, void 0, spacing),\n MIMES.json\n );\n }\n }\n }\n if (!event.node.res.writableEnded) {\n throw createError({\n statusCode: 404,\n statusMessage: `Cannot find any route matching ${event.node.req.url || \"/\"}.`\n });\n }\n });\n}\nfunction normalizeLayer(input) {\n let handler = input.handler;\n if (handler.handler) {\n handler = handler.handler;\n }\n if (input.lazy) {\n handler = lazyEventHandler(handler);\n } else if (!isEventHandler(handler)) {\n handler = toEventHandler(handler, void 0, input.route);\n }\n return {\n route: withoutTrailingSlash(input.route),\n match: input.match,\n handler\n };\n}\n\nconst defineNodeListener = (handler) => handler;\nconst defineNodeMiddleware = (middleware) => middleware;\nfunction fromNodeMiddleware(handler) {\n if (isEventHandler(handler)) {\n return handler;\n }\n if (typeof handler !== \"function\") {\n throw new TypeError(\n \"Invalid handler. It should be a function:\",\n handler\n );\n }\n return eventHandler((event) => {\n return callNodeListener(\n handler,\n event.node.req,\n event.node.res\n );\n });\n}\nfunction toNodeListener(app) {\n const toNodeHandle = async function(req, res) {\n const event = createEvent(req, res);\n try {\n await app.handler(event);\n } catch (_error) {\n const error = createError(_error);\n if (!isError(_error)) {\n error.unhandled = true;\n }\n if (app.options.onError) {\n await app.options.onError(error, event);\n } else {\n if (error.unhandled || error.fatal) {\n console.error(\"[h3]\", error.fatal ? \"[fatal]\" : \"[unhandled]\", error);\n }\n await sendError(event, error, !!app.options.debug);\n }\n }\n };\n return toNodeHandle;\n}\nfunction promisifyNodeListener(handler) {\n return function(req, res) {\n return callNodeListener(handler, req, res);\n };\n}\nfunction callNodeListener(handler, req, res) {\n const isMiddleware = handler.length > 2;\n return new Promise((resolve, reject) => {\n const next = (err) => {\n if (isMiddleware) {\n res.off(\"close\", next);\n res.off(\"error\", next);\n }\n return err ? reject(createError(err)) : resolve(void 0);\n };\n try {\n const returned = handler(req, res, next);\n if (isMiddleware && returned === void 0) {\n res.once(\"close\", next);\n res.once(\"error\", next);\n } else {\n resolve(returned);\n }\n } catch (error) {\n next(error);\n }\n });\n}\n\nconst RouterMethods = [\n \"connect\",\n \"delete\",\n \"get\",\n \"head\",\n \"options\",\n \"post\",\n \"put\",\n \"trace\",\n \"patch\"\n];\nfunction createRouter(opts = {}) {\n const _router = createRouter$1({});\n const routes = {};\n const router = {};\n const addRoute = (path, handler, method) => {\n let route = routes[path];\n if (!route) {\n routes[path] = route = { handlers: {} };\n _router.insert(path, route);\n }\n if (Array.isArray(method)) {\n for (const m of method) {\n addRoute(path, handler, m);\n }\n } else {\n route.handlers[method] = toEventHandler(handler, void 0, path);\n }\n return router;\n };\n router.use = router.add = (path, handler, method) => addRoute(path, handler, method || \"all\");\n for (const method of RouterMethods) {\n router[method] = (path, handle) => router.add(path, handle, method);\n }\n router.handler = eventHandler((event) => {\n let path = event.node.req.url || \"/\";\n const qIndex = path.indexOf(\"?\");\n if (qIndex !== -1) {\n path = path.slice(0, Math.max(0, qIndex));\n }\n const matched = _router.lookup(path);\n if (!matched || !matched.handlers) {\n if (opts.preemptive || opts.preemtive) {\n throw createError({\n statusCode: 404,\n name: \"Not Found\",\n statusMessage: `Cannot find any route matching ${event.node.req.url || \"/\"}.`\n });\n } else {\n return;\n }\n }\n const method = (event.node.req.method || \"get\").toLowerCase();\n const handler = matched.handlers[method] || matched.handlers.all;\n if (!handler) {\n throw createError({\n statusCode: 405,\n name: \"Method Not Allowed\",\n statusMessage: `Method ${method} is not allowed on this route.`\n });\n }\n const params = matched.params || {};\n event.context.params = params;\n return handler(event);\n });\n return router;\n}\n\nexport { H3Error, H3Event, H3Headers, H3Response, MIMES, appendCorsHeaders, appendCorsPreflightHeaders, appendHeader, appendHeaders, appendResponseHeader, appendResponseHeaders, assertMethod, callNodeListener, clearSession, createApp, createAppEventHandler, createError, createEvent, createRouter, defaultContentType, defineEventHandler, defineLazyEventHandler, defineNodeListener, defineNodeMiddleware, deleteCookie, dynamicEventHandler, eventHandler, fetchWithEvent, fromNodeMiddleware, getCookie, getHeader, getHeaders, getMethod, getProxyRequestHeaders, getQuery, getRequestHeader, getRequestHeaders, getRequestHost, getRequestPath, getRequestProtocol, getRequestURL, getResponseHeader, getResponseHeaders, getResponseStatus, getResponseStatusText, getRouterParam, getRouterParams, getSession, handleCacheHeaders, handleCors, isCorsOriginAllowed, isError, isEvent, isEventHandler, isMethod, isPreflightRequest, isStream, lazyEventHandler, parseCookies, promisifyNodeListener, proxyRequest, readBody, readMultipartFormData, readRawBody, sanitizeStatusCode, sanitizeStatusMessage, sealSession, send, sendError, sendNoContent, sendProxy, sendRedirect, sendStream, setCookie, setHeader, setHeaders, setResponseHeader, setResponseHeaders, setResponseStatus, splitCookiesString, toEventHandler, toNodeListener, unsealSession, updateSession, use, useBase, useSession, writeEarlyHints };\n","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:http\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:https\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:fs\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:os\");","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"tty\");","import * as tty from \"tty\"\n\nconst {\n env = {},\n argv = [],\n platform = \"\",\n} = typeof process === \"undefined\" ? {} : process\n\nconst isDisabled = \"NO_COLOR\" in env || argv.includes(\"--no-color\")\nconst isForced = \"FORCE_COLOR\" in env || argv.includes(\"--color\")\nconst isWindows = platform === \"win32\"\nconst isDumbTerminal = env.TERM === \"dumb\"\n\nconst isCompatibleTerminal =\n tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal\n\nconst isCI =\n \"CI\" in env &&\n (\"GITHUB_ACTIONS\" in env || \"GITLAB_CI\" in env || \"CIRCLECI\" in env)\n\nexport const isColorSupported =\n !isDisabled &&\n (isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI)\n\nconst replaceClose = (\n index,\n string,\n close,\n replace,\n head = string.substring(0, index) + replace,\n tail = string.substring(index + close.length),\n next = tail.indexOf(close)\n) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace))\n\nconst clearBleed = (index, string, open, close, replace) =>\n index < 0\n ? open + string + close\n : open + replaceClose(index, string, close, replace) + close\n\nconst filterEmpty =\n (open, close, replace = open, at = open.length + 1) =>\n (string) =>\n string || !(string === \"\" || string === undefined)\n ? clearBleed(\n (\"\" + string).indexOf(close, at),\n string,\n open,\n close,\n replace\n )\n : \"\"\n\nconst init = (open, close, replace) =>\n filterEmpty(`\\x1b[${open}m`, `\\x1b[${close}m`, replace)\n\nconst colors = {\n reset: init(0, 0),\n bold: init(1, 22, \"\\x1b[22m\\x1b[1m\"),\n dim: init(2, 22, \"\\x1b[22m\\x1b[2m\"),\n italic: init(3, 23),\n underline: init(4, 24),\n inverse: init(7, 27),\n hidden: init(8, 28),\n strikethrough: init(9, 29),\n black: init(30, 39),\n red: init(31, 39),\n green: init(32, 39),\n yellow: init(33, 39),\n blue: init(34, 39),\n magenta: init(35, 39),\n cyan: init(36, 39),\n white: init(37, 39),\n gray: init(90, 39),\n bgBlack: init(40, 49),\n bgRed: init(41, 49),\n bgGreen: init(42, 49),\n bgYellow: init(43, 49),\n bgBlue: init(44, 49),\n bgMagenta: init(45, 49),\n bgCyan: init(46, 49),\n bgWhite: init(47, 49),\n blackBright: init(90, 39),\n redBright: init(91, 39),\n greenBright: init(92, 39),\n yellowBright: init(93, 39),\n blueBright: init(94, 39),\n magentaBright: init(95, 39),\n cyanBright: init(96, 39),\n whiteBright: init(97, 39),\n bgBlackBright: init(100, 49),\n bgRedBright: init(101, 49),\n bgGreenBright: init(102, 49),\n bgYellowBright: init(103, 49),\n bgBlueBright: init(104, 49),\n bgMagentaBright: init(105, 49),\n bgCyanBright: init(106, 49),\n bgWhiteBright: init(107, 49),\n}\n\nexport const createColors = ({ useColor = isColorSupported } = {}) =>\n useColor\n ? colors\n : Object.keys(colors).reduce(\n (colors, key) => ({ ...colors, [key]: String }),\n {}\n )\n\nexport const {\n reset,\n bold,\n dim,\n italic,\n underline,\n inverse,\n hidden,\n strikethrough,\n black,\n red,\n green,\n yellow,\n blue,\n magenta,\n cyan,\n white,\n gray,\n bgBlack,\n bgRed,\n bgGreen,\n bgYellow,\n bgBlue,\n bgMagenta,\n bgCyan,\n bgWhite,\n blackBright,\n redBright,\n greenBright,\n yellowBright,\n blueBright,\n magentaBright,\n cyanBright,\n whiteBright,\n bgBlackBright,\n bgRedBright,\n bgGreenBright,\n bgYellowBright,\n bgBlueBright,\n bgMagentaBright,\n bgCyanBright,\n bgWhiteBright,\n} = createColors()\n","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:net\");","import { createServer } from 'node:net';\nimport { networkInterfaces } from 'node:os';\n\nconst unsafePorts = /* @__PURE__ */ new Set([\n 1,\n 7,\n 9,\n 11,\n 13,\n 15,\n 17,\n 19,\n 20,\n 21,\n 22,\n 23,\n 25,\n 37,\n 42,\n 43,\n 53,\n 69,\n 77,\n 79,\n 87,\n 95,\n 101,\n 102,\n 103,\n 104,\n 109,\n 110,\n 111,\n 113,\n 115,\n 117,\n 119,\n 123,\n 135,\n 137,\n 139,\n 143,\n 161,\n 179,\n 389,\n 427,\n 465,\n 512,\n 513,\n 514,\n 515,\n 526,\n 530,\n 531,\n 532,\n 540,\n 548,\n 554,\n 556,\n 563,\n 587,\n 601,\n 636,\n 989,\n 990,\n 993,\n 995,\n 1719,\n 1720,\n 1723,\n 2049,\n 3659,\n 4045,\n 5060,\n 5061,\n 6e3,\n 6566,\n 6665,\n 6666,\n 6667,\n 6668,\n 6669,\n 6697,\n 10080\n]);\nfunction isUnsafePort(port) {\n return unsafePorts.has(port);\n}\nfunction isSafePort(port) {\n return !isUnsafePort(port);\n}\n\nfunction log(...arguments_) {\n console.log(\"[get-port]\", ...arguments_);\n}\nasync function getPort(config = {}) {\n if (typeof config === \"number\" || typeof config === \"string\") {\n config = { port: Number.parseInt(config + \"\") || 0 };\n }\n const options = {\n name: \"default\",\n random: false,\n ports: [],\n portRange: [],\n alternativePortRange: config.port ? [] : [3e3, 3100],\n host: void 0,\n verbose: false,\n ...config,\n port: config.port || Number.parseInt(process.env.PORT || \"\") || 3e3\n };\n if (options.random) {\n return getRandomPort(options.host);\n }\n const portsToCheck = [\n options.port,\n ...options.ports,\n ...generateRange(...options.portRange)\n ].filter((port) => {\n if (!port) {\n return false;\n }\n if (!isSafePort(port)) {\n if (options.verbose) {\n log(\"Ignoring unsafe port:\", port);\n }\n return false;\n }\n return true;\n });\n let availablePort = await findPort(\n portsToCheck,\n options.host,\n options.verbose,\n false\n );\n if (!availablePort) {\n availablePort = await findPort(\n generateRange(...options.alternativePortRange),\n options.host,\n options.verbose\n );\n if (options.verbose) {\n log(\n `Unable to find an available port (tried ${portsToCheck.join(\", \") || \"-\"}). Using alternative port:`,\n availablePort\n );\n }\n }\n return availablePort;\n}\nasync function getRandomPort(host) {\n const port = await checkPort(0, host);\n if (port === false) {\n throw new Error(\"Unable to obtain an available random port number!\");\n }\n return port;\n}\nasync function waitForPort(port, options = {}) {\n const delay = options.delay || 500;\n const retries = options.retries || 4;\n for (let index = retries; index > 0; index--) {\n if (await checkPort(port, options.host) === false) {\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n throw new Error(\n `Timeout waiting for port ${port} after ${retries} retries with ${delay}ms interval.`\n );\n}\nasync function checkPort(port, host = process.env.HOST, _verbose) {\n if (!host) {\n host = getLocalHosts([void 0, \"0.0.0.0\"]);\n }\n if (!Array.isArray(host)) {\n return _checkPort(port, host);\n }\n for (const _host of host) {\n const _port = await _checkPort(port, _host);\n if (_port === false) {\n if (port < 1024 && _verbose) {\n log(\"Unable to listen to priviliged port:\", `${_host}:${port}`);\n }\n return false;\n }\n if (port === 0 && _port !== 0) {\n port = _port;\n }\n }\n return port;\n}\nfunction generateRange(from, to) {\n if (to < from) {\n return [];\n }\n const r = [];\n for (let index = from; index < to; index++) {\n r.push(index);\n }\n return r;\n}\nfunction _checkPort(port, host) {\n return new Promise((resolve) => {\n const server = createServer();\n server.unref();\n server.on(\"error\", (error) => {\n if (error.code === \"EINVAL\" || error.code === \"EADDRNOTAVAIL\") {\n resolve(port !== 0 && isSafePort(port) && port);\n } else {\n resolve(false);\n }\n });\n server.listen({ port, host }, () => {\n const { port: port2 } = server.address();\n server.close(() => {\n resolve(isSafePort(port2) && port2);\n });\n });\n });\n}\nfunction getLocalHosts(additional) {\n const hosts = new Set(additional);\n for (const _interface of Object.values(networkInterfaces())) {\n for (const config of _interface || []) {\n hosts.add(config.address);\n }\n }\n return [...hosts];\n}\nasync function findPort(ports, host, _verbose = false, _random = true) {\n for (const port of ports) {\n const r = await checkPort(port, host, _verbose);\n if (r) {\n return r;\n }\n }\n if (_random) {\n const randomPort = await getRandomPort(host);\n if (_verbose) {\n log(\n `Unable to find an available port (tried ${ports.join(\", \") || \"-\"}). Using random port:`,\n randomPort\n );\n }\n return randomPort;\n } else {\n return 0;\n }\n}\n\nexport { checkPort, getPort, getRandomPort, isSafePort, isUnsafePort, waitForPort };\n","const __WEBPACK_NAMESPACE_OBJECT__ = __WEBPACK_EXTERNAL_createRequire(import.meta.url)(\"node:child_process\");","import { createServer as createServer$1 } from 'node:http';\nimport { createServer } from 'node:https';\nimport { promisify } from 'node:util';\nimport { readFileSync, existsSync, writeFileSync, chmodSync, statSync, promises, constants } from 'node:fs';\nimport os, { networkInterfaces } from 'node:os';\nimport { gray, cyan, underline, bold } from 'colorette';\nimport { getPort } from 'get-port-please';\nimport addShutdown from 'http-shutdown';\nimport { defu } from 'defu';\nimport childProcess from 'node:child_process';\nimport { join } from 'node:path';\n\nconst { platform, arch } = process;\nconst getWslDrivesMountPoint = (() => {\n const defaultMountPoint = \"/mnt/\";\n let mountPoint;\n return async function() {\n if (mountPoint) {\n return mountPoint;\n }\n const configFilePath = \"/etc/wsl.conf\";\n let isConfigFileExists = false;\n try {\n await promises.access(configFilePath, constants.F_OK);\n isConfigFileExists = true;\n } catch {\n }\n if (!isConfigFileExists) {\n return defaultMountPoint;\n }\n const configContent = await promises.readFile(configFilePath, {\n encoding: \"utf8\"\n });\n const configMountPoint = /(?.*)/g.exec(\n configContent\n );\n if (!configMountPoint) {\n return defaultMountPoint;\n }\n mountPoint = configMountPoint.groups.mountPoint.trim();\n mountPoint = mountPoint.endsWith(\"/\") ? mountPoint : `${mountPoint}/`;\n return mountPoint;\n };\n})();\nconst pTryEach = async (array, mapper) => {\n let latestError;\n for (const item of array) {\n try {\n return await mapper(item);\n } catch (error) {\n latestError = error;\n }\n }\n throw latestError;\n};\nconst baseOpen = async (options) => {\n options = {\n wait: false,\n background: false,\n newInstance: false,\n allowNonzeroExitCode: false,\n ...options\n };\n if (Array.isArray(options.app)) {\n return pTryEach(\n options.app,\n (singleApp) => baseOpen({\n ...options,\n app: singleApp\n })\n );\n }\n let { name: app, arguments: appArguments = [] } = options.app || {};\n appArguments = [...appArguments];\n if (Array.isArray(app)) {\n return pTryEach(\n app,\n (appName) => baseOpen({\n ...options,\n app: {\n name: appName,\n arguments: appArguments\n }\n })\n );\n }\n let command;\n const cliArguments = [];\n const childProcessOptions = {};\n if (platform === \"darwin\") {\n command = \"open\";\n if (options.wait) {\n cliArguments.push(\"--wait-apps\");\n }\n if (options.background) {\n cliArguments.push(\"--background\");\n }\n if (options.newInstance) {\n cliArguments.push(\"--new\");\n }\n if (app) {\n cliArguments.push(\"-a\", app);\n }\n } else if (platform === \"win32\" || isWsl() && !isDocker()) {\n const mountPoint = await getWslDrivesMountPoint();\n command = isWsl() ? `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process.env.SYSTEMROOT}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell`;\n cliArguments.push(\n \"-NoProfile\",\n \"-NonInteractive\",\n \"\\u2013ExecutionPolicy\",\n \"Bypass\",\n \"-EncodedCommand\"\n );\n if (!isWsl()) {\n childProcessOptions.windowsVerbatimArguments = true;\n }\n const encodedArguments = [\"Start\"];\n if (options.wait) {\n encodedArguments.push(\"-Wait\");\n }\n if (app) {\n encodedArguments.push(`\"\\`\"${app}\\`\"\"`, \"-ArgumentList\");\n if (options.target) {\n appArguments.unshift(options.target);\n }\n } else if (options.target) {\n encodedArguments.push(`\"${options.target}\"`);\n }\n if (appArguments.length > 0) {\n appArguments = appArguments.map((argument) => `\"\\`\"${argument}\\`\"\"`);\n encodedArguments.push(appArguments.join(\",\"));\n }\n options.target = Buffer.from(\n encodedArguments.join(\" \"),\n \"utf16le\"\n ).toString(\"base64\");\n } else {\n if (app) {\n command = app;\n } else {\n command = \"xdg-open\";\n const useSystemXdgOpen = process.versions.electron || platform === \"android\";\n if (!useSystemXdgOpen) {\n command = join(os.tmpdir(), \"xdg-open\");\n if (!existsSync(command)) {\n try {\n writeFileSync(\n join(os.tmpdir(), \"xdg-open\"),\n await import('./chunks/xdg-open.mjs').then((r) => r.xdgOpenScript()),\n \"utf8\"\n );\n chmodSync(\n command,\n 493\n /* rwx r-x r-x */\n );\n } catch {\n command = \"xdg-open\";\n }\n }\n }\n }\n if (appArguments.length > 0) {\n cliArguments.push(...appArguments);\n }\n if (!options.wait) {\n childProcessOptions.stdio = \"ignore\";\n childProcessOptions.detached = true;\n }\n }\n if (options.target) {\n cliArguments.push(options.target);\n }\n if (platform === \"darwin\" && appArguments.length > 0) {\n cliArguments.push(\"--args\", ...appArguments);\n }\n const subprocess = childProcess.spawn(\n command,\n cliArguments,\n childProcessOptions\n );\n if (options.wait) {\n return new Promise((resolve, reject) => {\n subprocess.once(\"error\", reject);\n subprocess.once(\"close\", (exitCode) => {\n if (options.allowNonzeroExitCode && exitCode > 0) {\n reject(new Error(`Exited with code ${exitCode}`));\n return;\n }\n resolve(subprocess);\n });\n });\n }\n subprocess.unref();\n return subprocess;\n};\nconst open = (target, options = {}) => {\n if (typeof target !== \"string\") {\n throw new TypeError(\"Expected a `target`\");\n }\n return baseOpen({\n ...options,\n target\n });\n};\nconst openApp = (name, options) => {\n if (typeof name !== \"string\") {\n throw new TypeError(\"Expected a `name`\");\n }\n const { arguments: appArguments = [] } = options || {};\n if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) {\n throw new TypeError(\"Expected `appArguments` as Array type\");\n }\n return baseOpen({\n ...options,\n app: {\n name,\n arguments: appArguments\n }\n });\n};\nfunction detectArchBinary(binary) {\n if (typeof binary === \"string\" || Array.isArray(binary)) {\n return binary;\n }\n const { [arch]: archBinary } = binary;\n if (!archBinary) {\n throw new Error(`${arch} is not supported`);\n }\n return archBinary;\n}\nfunction detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {\n if (wsl && isWsl()) {\n return detectArchBinary(wsl);\n }\n if (!platformBinary) {\n throw new Error(`${platform} is not supported`);\n }\n return detectArchBinary(platformBinary);\n}\nconst apps = {};\ndefineLazyProperty(\n apps,\n \"chrome\",\n () => detectPlatformBinary(\n {\n darwin: \"google chrome\",\n win32: \"chrome\",\n linux: [\"google-chrome\", \"google-chrome-stable\", \"chromium\"]\n },\n {\n wsl: {\n ia32: \"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe\",\n x64: [\n \"/mnt/c/Program Files/Google/Chrome/Application/chrome.exe\",\n \"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe\"\n ]\n }\n }\n )\n);\ndefineLazyProperty(\n apps,\n \"firefox\",\n () => detectPlatformBinary(\n {\n darwin: \"firefox\",\n win32: \"C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe\",\n linux: \"firefox\"\n },\n {\n wsl: \"/mnt/c/Program Files/Mozilla Firefox/firefox.exe\"\n }\n )\n);\ndefineLazyProperty(\n apps,\n \"edge\",\n () => detectPlatformBinary(\n {\n darwin: \"microsoft edge\",\n win32: \"msedge\",\n linux: [\"microsoft-edge\", \"microsoft-edge-dev\"]\n },\n {\n wsl: \"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe\"\n }\n )\n);\nopen.apps = apps;\nopen.openApp = openApp;\nfunction defineLazyProperty(object, propertyName, valueGetter) {\n const define = (value) => Object.defineProperty(object, propertyName, {\n value,\n enumerable: true,\n writable: true\n });\n Object.defineProperty(object, propertyName, {\n configurable: true,\n enumerable: true,\n get() {\n const result = valueGetter();\n define(result);\n return result;\n },\n set(value) {\n define(value);\n }\n });\n return object;\n}\nfunction _isWsl() {\n if (process.platform !== \"linux\") {\n return false;\n }\n if (os.release().toLowerCase().includes(\"microsoft\")) {\n if (isDocker()) {\n return false;\n }\n return true;\n }\n try {\n return readFileSync(\"/proc/version\", \"utf8\").toLowerCase().includes(\"microsoft\") ? !isDocker() : false;\n } catch {\n return false;\n }\n}\nlet isWSLCached;\nfunction isWsl() {\n if (isWSLCached === void 0) {\n isWSLCached = _isWsl();\n }\n return isWSLCached;\n}\nfunction hasDockerEnvironment() {\n try {\n statSync(\"/.dockerenv\");\n return true;\n } catch {\n return false;\n }\n}\nfunction hasDockerCGroup() {\n try {\n return readFileSync(\"/proc/self/cgroup\", \"utf8\").includes(\"docker\");\n } catch {\n return false;\n }\n}\nlet isDockerCached;\nfunction isDocker() {\n if (isDockerCached === void 0) {\n isDockerCached = hasDockerEnvironment() || hasDockerCGroup();\n }\n return isDockerCached;\n}\n\nasync function listen(handle, options_ = {}) {\n options_ = defu(options_, {\n port: process.env.PORT || 3e3,\n hostname: process.env.HOST || \"\",\n showURL: true,\n baseURL: \"/\",\n open: false,\n clipboard: false,\n isTest: process.env.NODE_ENV === \"test\",\n isProd: process.env.NODE_ENV === \"production\",\n autoClose: true\n });\n if (options_.isTest) {\n options_.showURL = false;\n }\n if (options_.isProd || options_.isTest) {\n options_.open = false;\n options_.clipboard = false;\n }\n const port = await getPort({\n port: Number(options_.port),\n verbose: !options_.isTest,\n host: options_.hostname,\n alternativePortRange: [3e3, 3100],\n ...typeof options_.port === \"object\" && options_.port\n });\n let server;\n let addr;\n const getURL = (host, baseURL) => {\n const anyV4 = addr?.addr === \"0.0.0.0\";\n const anyV6 = addr?.addr === \"[::]\";\n return `${addr.proto}://${host || options_.hostname || (anyV4 || anyV6 ? \"localhost\" : addr.addr)}:${addr.port}${baseURL || options_.baseURL}`;\n };\n let https = false;\n if (options_.https) {\n const { key, cert } = await resolveCert(\n { ...options_.https },\n options_.hostname\n );\n https = { key, cert };\n server = createServer({ key, cert }, handle);\n addShutdown(server);\n await promisify(server.listen.bind(server))(port, options_.hostname);\n const _addr = server.address();\n addr = { proto: \"https\", addr: formatAddress(_addr), port: _addr.port };\n } else {\n server = createServer$1(handle);\n addShutdown(server);\n await promisify(server.listen.bind(server))(port, options_.hostname);\n const _addr = server.address();\n addr = { proto: \"http\", addr: formatAddress(_addr), port: _addr.port };\n }\n let _closed = false;\n const close = () => {\n if (_closed) {\n return Promise.resolve();\n }\n _closed = true;\n return promisify(server.shutdown)();\n };\n if (options_.clipboard) {\n const clipboardy = await import('clipboardy').then((r) => r.default || r);\n await clipboardy.write(getURL()).catch(() => {\n options_.clipboard = false;\n });\n }\n const showURL = (options) => {\n const add = options_.clipboard ? gray(\"(copied to clipboard)\") : \"\";\n const lines = [];\n const baseURL = options?.baseURL || options_.baseURL || \"\";\n const name = options?.name ? ` (${options.name})` : \"\";\n const anyV4 = addr?.addr === \"0.0.0.0\";\n const anyV6 = addr?.addr === \"[::]\";\n if (anyV4 || anyV6) {\n lines.push(\n ` > Local${name}: ${formatURL(getURL(\"localhost\", baseURL))} ${add}`\n );\n for (const addr2 of getNetworkInterfaces(anyV4)) {\n lines.push(` > Network${name}: ${formatURL(getURL(addr2, baseURL))}`);\n }\n } else {\n lines.push(\n ` > Listening${name}: ${formatURL(\n getURL(void 0, baseURL)\n )} ${add}`\n );\n }\n console.log(\"\\n\" + lines.join(\"\\n\") + \"\\n\");\n };\n if (options_.showURL) {\n showURL();\n }\n const _open = async () => {\n await open(getURL()).catch(() => {\n });\n };\n if (options_.open) {\n await _open();\n }\n if (options_.autoClose) {\n process.on(\"exit\", () => close());\n }\n return {\n url: getURL(),\n https,\n server,\n open: _open,\n showURL,\n close\n };\n}\nasync function resolveCert(options, host) {\n if (options.key && options.cert) {\n const isInline = (s = \"\") => s.startsWith(\"--\");\n const r = (s) => isInline(s) ? s : promises.readFile(s, \"utf8\");\n return {\n key: await r(options.key),\n cert: await r(options.cert)\n };\n }\n const { generateCA, generateSSLCert } = await import('./chunks/cert.mjs');\n const ca = await generateCA();\n const cert = await generateSSLCert({\n caCert: ca.cert,\n caKey: ca.key,\n domains: options.domains || [\"localhost\", \"127.0.0.1\", \"::1\", host].filter(Boolean),\n validityDays: options.validityDays || 1\n });\n return cert;\n}\nfunction getNetworkInterfaces(v4Only = true) {\n const addrs = /* @__PURE__ */ new Set();\n for (const details of Object.values(networkInterfaces())) {\n if (details) {\n for (const d of details) {\n if (!d.internal && !(d.mac === \"00:00:00:00:00:00\") && !d.address.startsWith(\"fe80::\") && !(v4Only && (d.family === \"IPv6\" || +d.family === 6))) {\n addrs.add(formatAddress(d));\n }\n }\n }\n }\n return [...addrs].sort();\n}\nfunction formatAddress(addr) {\n return addr.family === \"IPv6\" || addr.family === 6 ? `[${addr.address}]` : addr.address;\n}\nfunction formatURL(url) {\n return cyan(\n underline(decodeURI(url).replace(/:(\\d+)\\//g, `:${bold(\"$1\")}/`))\n );\n}\n\nexport { listen };\n","import { eventHandler, createApp, createRouter, toNodeListener } from 'h3';\nimport { listen } from 'listhen';\nimport { getPort } from 'get-port-please';\nasync function run() {\n const hostname = '127.0.0.1';\n const app = createApp({ debug: false });\n const router = createRouter().post('/api/v1/functions', eventHandler((event) => {\n event.node.res.statusCode = 201;\n event.node.res.statusMessage = 'Created';\n event.node.res.setHeader('Content-Type', 'application/json');\n return {\n functionId: 'minimalfunctionid',\n versionId: 'minimalversionid',\n imageName: 'speckle/minimalfunctionid:minimalversionid'\n };\n }));\n app.use(router);\n const port = await getPort(3000);\n listen(toNodeListener(app), {\n hostname,\n port\n });\n}\nrun();\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 896f9b4..5d0d5a6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vitest": "^0.2.2", "get-port-please": "^3.0.1", - "h3": "^1.6.5", + "h3": "^1.6.6", "js-yaml": "^4.1.0", "listhen": "^1.0.4", "msw": "^1.2.1", diff --git a/yarn.lock b/yarn.lock index eda9d85..eab6bf0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3114,9 +3114,9 @@ __metadata: languageName: node linkType: hard -"h3@npm:^1.6.5": - version: 1.6.5 - resolution: "h3@npm:1.6.5" +"h3@npm:^1.6.6": + version: 1.6.6 + resolution: "h3@npm:1.6.6" dependencies: cookie-es: ^1.0.0 defu: ^6.1.2 @@ -3125,7 +3125,7 @@ __metadata: radix3: ^1.0.1 ufo: ^1.1.2 uncrypto: ^0.1.2 - checksum: 23b34f7cc62a46bcf5ac2e51b39af4a4ff425483b90cde8ca8310e8dcd6d1f7c2377dd72f26c1fcaff88497bd14957f2fd14422e2306990b4541d23077f1e131 + checksum: 58a24d0f5eeff0e36caf7299d0237c43e0e10b9fcc8f8858aec51bcac0a0ab6ed28ebff199119a62e5571c0c35e6788acb69fe63468ff04c3134598c7ee46f1a languageName: node linkType: hard @@ -5266,7 +5266,7 @@ __metadata: eslint-plugin-prettier: ^4.2.1 eslint-plugin-vitest: ^0.2.2 get-port-please: ^3.0.1 - h3: ^1.6.5 + h3: ^1.6.6 js-yaml: ^4.1.0 listhen: ^1.0.4 msw: ^1.2.1