Created
August 15, 2023 18:24
-
-
Save bisand/9187fcefbecea3fe6b617dd0ac33b323 to your computer and use it in GitHub Desktop.
Auto generated script by wrangler or Miniflare
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
(() => { | |
// ../../tmp/tmp-3050-1TOePBVBXz5o/checked-fetch.js | |
var urls = /* @__PURE__ */ new Set(); | |
function checkURL(request, init) { | |
const url = request instanceof URL ? request : new URL( | |
(typeof request === "string" ? new Request(request, init) : request).url | |
); | |
if (url.port && url.port !== "443" && url.protocol === "https:") { | |
if (!urls.has(url.toString())) { | |
urls.add(url.toString()); | |
console.warn( | |
`WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers: | |
- ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command. | |
` | |
); | |
} | |
} | |
} | |
globalThis.fetch = new Proxy(globalThis.fetch, { | |
apply(target, thisArg, argArray) { | |
const [request, init] = argArray; | |
checkURL(request, init); | |
return Reflect.apply(target, thisArg, argArray); | |
} | |
}); | |
// node_modules/wrangler/templates/middleware/common.ts | |
var __facade_middleware__ = []; | |
function __facade_register__(...args) { | |
__facade_middleware__.push(...args.flat()); | |
} | |
function __facade_registerInternal__(...args) { | |
__facade_middleware__.unshift(...args.flat()); | |
} | |
function __facade_invokeChain__(request, env, ctx, dispatch, middlewareChain) { | |
const [head, ...tail] = middlewareChain; | |
const middlewareCtx = { | |
dispatch, | |
next(newRequest, newEnv) { | |
return __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail); | |
} | |
}; | |
return head(request, env, ctx, middlewareCtx); | |
} | |
function __facade_invoke__(request, env, ctx, dispatch, finalMiddleware) { | |
return __facade_invokeChain__(request, env, ctx, dispatch, [ | |
...__facade_middleware__, | |
finalMiddleware | |
]); | |
} | |
// node_modules/wrangler/templates/middleware/loader-sw.ts | |
var __FACADE_EVENT_TARGET__; | |
if (globalThis.MINIFLARE) { | |
__FACADE_EVENT_TARGET__ = new (Object.getPrototypeOf(WorkerGlobalScope))(); | |
} else { | |
__FACADE_EVENT_TARGET__ = new EventTarget(); | |
} | |
function __facade_isSpecialEvent__(type) { | |
return type === "fetch" || type === "scheduled"; | |
} | |
var __facade__originalAddEventListener__ = globalThis.addEventListener; | |
var __facade__originalRemoveEventListener__ = globalThis.removeEventListener; | |
var __facade__originalDispatchEvent__ = globalThis.dispatchEvent; | |
globalThis.addEventListener = function(type, listener, options) { | |
if (__facade_isSpecialEvent__(type)) { | |
__FACADE_EVENT_TARGET__.addEventListener( | |
type, | |
listener, | |
options | |
); | |
} else { | |
__facade__originalAddEventListener__(type, listener, options); | |
} | |
}; | |
globalThis.removeEventListener = function(type, listener, options) { | |
if (__facade_isSpecialEvent__(type)) { | |
__FACADE_EVENT_TARGET__.removeEventListener( | |
type, | |
listener, | |
options | |
); | |
} else { | |
__facade__originalRemoveEventListener__(type, listener, options); | |
} | |
}; | |
globalThis.dispatchEvent = function(event) { | |
if (__facade_isSpecialEvent__(event.type)) { | |
return __FACADE_EVENT_TARGET__.dispatchEvent(event); | |
} else { | |
return __facade__originalDispatchEvent__(event); | |
} | |
}; | |
globalThis.addMiddleware = __facade_register__; | |
globalThis.addMiddlewareInternal = __facade_registerInternal__; | |
var __facade_waitUntil__ = Symbol("__facade_waitUntil__"); | |
var __facade_response__ = Symbol("__facade_response__"); | |
var __facade_dispatched__ = Symbol("__facade_dispatched__"); | |
var __Facade_ExtendableEvent__ = class extends Event { | |
[__facade_waitUntil__] = []; | |
waitUntil(promise) { | |
if (!(this instanceof __Facade_ExtendableEvent__)) { | |
throw new TypeError("Illegal invocation"); | |
} | |
this[__facade_waitUntil__].push(promise); | |
} | |
}; | |
var __Facade_FetchEvent__ = class extends __Facade_ExtendableEvent__ { | |
#request; | |
#passThroughOnException; | |
[__facade_response__]; | |
[__facade_dispatched__] = false; | |
constructor(type, init) { | |
super(type); | |
this.#request = init.request; | |
this.#passThroughOnException = init.passThroughOnException; | |
} | |
get request() { | |
return this.#request; | |
} | |
respondWith(response) { | |
if (!(this instanceof __Facade_FetchEvent__)) { | |
throw new TypeError("Illegal invocation"); | |
} | |
if (this[__facade_response__] !== void 0) { | |
throw new DOMException( | |
"FetchEvent.respondWith() has already been called; it can only be called once.", | |
"InvalidStateError" | |
); | |
} | |
if (this[__facade_dispatched__]) { | |
throw new DOMException( | |
"Too late to call FetchEvent.respondWith(). It must be called synchronously in the event handler.", | |
"InvalidStateError" | |
); | |
} | |
this.stopImmediatePropagation(); | |
this[__facade_response__] = response; | |
} | |
passThroughOnException() { | |
if (!(this instanceof __Facade_FetchEvent__)) { | |
throw new TypeError("Illegal invocation"); | |
} | |
this.#passThroughOnException(); | |
} | |
}; | |
var __Facade_ScheduledEvent__ = class extends __Facade_ExtendableEvent__ { | |
#scheduledTime; | |
#cron; | |
#noRetry; | |
constructor(type, init) { | |
super(type); | |
this.#scheduledTime = init.scheduledTime; | |
this.#cron = init.cron; | |
this.#noRetry = init.noRetry; | |
} | |
get scheduledTime() { | |
return this.#scheduledTime; | |
} | |
get cron() { | |
return this.#cron; | |
} | |
noRetry() { | |
if (!(this instanceof __Facade_ScheduledEvent__)) { | |
throw new TypeError("Illegal invocation"); | |
} | |
this.#noRetry(); | |
} | |
}; | |
__facade__originalAddEventListener__("fetch", (event) => { | |
const ctx = { | |
waitUntil: event.waitUntil.bind(event), | |
passThroughOnException: event.passThroughOnException.bind(event) | |
}; | |
const __facade_sw_dispatch__ = function(type, init) { | |
if (type === "scheduled") { | |
const facadeEvent = new __Facade_ScheduledEvent__("scheduled", { | |
scheduledTime: Date.now(), | |
cron: init.cron ?? "", | |
noRetry() { | |
} | |
}); | |
__FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent); | |
event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__])); | |
} | |
}; | |
const __facade_sw_fetch__ = function(request, _env, ctx2) { | |
const facadeEvent = new __Facade_FetchEvent__("fetch", { | |
request, | |
passThroughOnException: ctx2.passThroughOnException | |
}); | |
__FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent); | |
facadeEvent[__facade_dispatched__] = true; | |
event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__])); | |
const response = facadeEvent[__facade_response__]; | |
if (response === void 0) { | |
throw new Error("No response!"); | |
} | |
return response; | |
}; | |
event.respondWith( | |
__facade_invoke__( | |
event.request, | |
globalThis, | |
ctx, | |
__facade_sw_dispatch__, | |
__facade_sw_fetch__ | |
) | |
); | |
}); | |
__facade__originalAddEventListener__("scheduled", (event) => { | |
const facadeEvent = new __Facade_ScheduledEvent__("scheduled", { | |
scheduledTime: event.scheduledTime, | |
cron: event.cron, | |
noRetry: event.noRetry.bind(event) | |
}); | |
__FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent); | |
event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__])); | |
}); | |
// node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts | |
function reduceError(e) { | |
return { | |
name: e?.name, | |
message: e?.message ?? String(e), | |
stack: e?.stack, | |
cause: e?.cause === void 0 ? void 0 : reduceError(e.cause) | |
}; | |
} | |
var jsonError = async (request, env, _ctx, middlewareCtx) => { | |
try { | |
return await middlewareCtx.next(request, env); | |
} catch (e) { | |
const error = reduceError(e); | |
return Response.json(error, { | |
status: 500, | |
headers: { "MF-Experimental-Error-Stack": "true" } | |
}); | |
} | |
}; | |
var middleware_miniflare3_json_error_default = jsonError; | |
// ../../tmp/tmp-3050-1TOePBVBXz5o/middleware-insertion-facade.js | |
__facade_registerInternal__([middleware_miniflare3_json_error_default]); | |
// .output/server/index.mjs | |
globalThis._importMeta_ = { url: "file:///_entry.js", env: {} }, function() { | |
"use strict"; | |
function _mergeNamespaces(e2, t2) { | |
for (var r2 = 0; r2 < t2.length; r2++) { | |
const n2 = t2[r2]; | |
if ("string" != typeof n2 && !Array.isArray(n2)) { | |
for (const t3 in n2) | |
if ("default" !== t3 && !(t3 in e2)) { | |
const r3 = Object.getOwnPropertyDescriptor(n2, t3); | |
r3 && Object.defineProperty(e2, t3, r3.get ? r3 : { enumerable: true, get: function() { | |
return n2[t3]; | |
} }); | |
} | |
} | |
} | |
return Object.freeze(Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" })); | |
} | |
function notImplemented(e2) { | |
return Object.assign(() => { | |
throw new Error(`[unenv] ${e2} is not implemented yet!`); | |
}, { __unenv__: true }); | |
} | |
function notImplementedClass(e2) { | |
return class { | |
__unenv__ = true; | |
constructor() { | |
throw new Error(`[unenv] ${e2} is not implemented yet!`); | |
} | |
}; | |
} | |
const e = [], t = [], r = "undefined" == typeof Uint8Array ? Array : Uint8Array, n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
for (let r2 = 0, i2 = 64; r2 < i2; ++r2) | |
e[r2] = n[r2], t[n.charCodeAt(r2)] = r2; | |
function toByteArray(e2) { | |
let n2; | |
const i2 = function(e3) { | |
const t2 = e3.length; | |
if (t2 % 4 > 0) | |
throw new Error("Invalid string. Length must be a multiple of 4"); | |
let r2 = e3.indexOf("="); | |
return -1 === r2 && (r2 = t2), [r2, r2 === t2 ? 0 : 4 - r2 % 4]; | |
}(e2), a2 = i2[0], c2 = i2[1], u2 = new r(function(e3, t2, r2) { | |
return 3 * (t2 + r2) / 4 - r2; | |
}(0, a2, c2)); | |
let m2 = 0; | |
const g2 = c2 > 0 ? a2 - 4 : a2; | |
let b2; | |
for (b2 = 0; b2 < g2; b2 += 4) | |
n2 = t[e2.charCodeAt(b2)] << 18 | t[e2.charCodeAt(b2 + 1)] << 12 | t[e2.charCodeAt(b2 + 2)] << 6 | t[e2.charCodeAt(b2 + 3)], u2[m2++] = n2 >> 16 & 255, u2[m2++] = n2 >> 8 & 255, u2[m2++] = 255 & n2; | |
return 2 === c2 && (n2 = t[e2.charCodeAt(b2)] << 2 | t[e2.charCodeAt(b2 + 1)] >> 4, u2[m2++] = 255 & n2), 1 === c2 && (n2 = t[e2.charCodeAt(b2)] << 10 | t[e2.charCodeAt(b2 + 1)] << 4 | t[e2.charCodeAt(b2 + 2)] >> 2, u2[m2++] = n2 >> 8 & 255, u2[m2++] = 255 & n2), u2; | |
} | |
function encodeChunk(t2, r2, n2) { | |
let i2; | |
const a2 = []; | |
for (let u2 = r2; u2 < n2; u2 += 3) | |
i2 = (t2[u2] << 16 & 16711680) + (t2[u2 + 1] << 8 & 65280) + (255 & t2[u2 + 2]), a2.push(e[(c2 = i2) >> 18 & 63] + e[c2 >> 12 & 63] + e[c2 >> 6 & 63] + e[63 & c2]); | |
var c2; | |
return a2.join(""); | |
} | |
function fromByteArray(t2) { | |
let r2; | |
const n2 = t2.length, i2 = n2 % 3, a2 = [], c2 = 16383; | |
for (let e2 = 0, r3 = n2 - i2; e2 < r3; e2 += c2) | |
a2.push(encodeChunk(t2, e2, e2 + c2 > r3 ? r3 : e2 + c2)); | |
return 1 === i2 ? (r2 = t2[n2 - 1], a2.push(e[r2 >> 2] + e[r2 << 4 & 63] + "==")) : 2 === i2 && (r2 = (t2[n2 - 2] << 8) + t2[n2 - 1], a2.push(e[r2 >> 10] + e[r2 >> 4 & 63] + e[r2 << 2 & 63] + "=")), a2.join(""); | |
} | |
function read(e2, t2, r2, n2, i2) { | |
let a2, c2; | |
const u2 = 8 * i2 - n2 - 1, m2 = (1 << u2) - 1, g2 = m2 >> 1; | |
let b2 = -7, x2 = r2 ? i2 - 1 : 0; | |
const C2 = r2 ? -1 : 1; | |
let A2 = e2[t2 + x2]; | |
for (x2 += C2, a2 = A2 & (1 << -b2) - 1, A2 >>= -b2, b2 += u2; b2 > 0; ) | |
a2 = 256 * a2 + e2[t2 + x2], x2 += C2, b2 -= 8; | |
for (c2 = a2 & (1 << -b2) - 1, a2 >>= -b2, b2 += n2; b2 > 0; ) | |
c2 = 256 * c2 + e2[t2 + x2], x2 += C2, b2 -= 8; | |
if (0 === a2) | |
a2 = 1 - g2; | |
else { | |
if (a2 === m2) | |
return c2 ? Number.NaN : (A2 ? -1 : 1) * Number.POSITIVE_INFINITY; | |
c2 += Math.pow(2, n2), a2 -= g2; | |
} | |
return (A2 ? -1 : 1) * c2 * Math.pow(2, a2 - n2); | |
} | |
function write(e2, t2, r2, n2, i2, a2) { | |
let c2, u2, m2, g2 = 8 * a2 - i2 - 1; | |
const b2 = (1 << g2) - 1, x2 = b2 >> 1, C2 = 23 === i2 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; | |
let A2 = n2 ? 0 : a2 - 1; | |
const P2 = n2 ? 1 : -1, T2 = t2 < 0 || 0 === t2 && 1 / t2 < 0 ? 1 : 0; | |
for (t2 = Math.abs(t2), Number.isNaN(t2) || t2 === Number.POSITIVE_INFINITY ? (u2 = Number.isNaN(t2) ? 1 : 0, c2 = b2) : (c2 = Math.floor(Math.log2(t2)), t2 * (m2 = Math.pow(2, -c2)) < 1 && (c2--, m2 *= 2), (t2 += c2 + x2 >= 1 ? C2 / m2 : C2 * Math.pow(2, 1 - x2)) * m2 >= 2 && (c2++, m2 /= 2), c2 + x2 >= b2 ? (u2 = 0, c2 = b2) : c2 + x2 >= 1 ? (u2 = (t2 * m2 - 1) * Math.pow(2, i2), c2 += x2) : (u2 = t2 * Math.pow(2, x2 - 1) * Math.pow(2, i2), c2 = 0)); i2 >= 8; ) | |
e2[r2 + A2] = 255 & u2, A2 += P2, u2 /= 256, i2 -= 8; | |
for (c2 = c2 << i2 | u2, g2 += i2; g2 > 0; ) | |
e2[r2 + A2] = 255 & c2, A2 += P2, c2 /= 256, g2 -= 8; | |
e2[r2 + A2 - P2] |= 128 * T2; | |
} | |
t["-".charCodeAt(0)] = 62, t["_".charCodeAt(0)] = 63; | |
const i = "function" == typeof Symbol && "function" == typeof Symbol.for ? Symbol.for("nodejs.util.inspect.custom") : null, a = 2147483647; | |
function createBuffer$1(e2) { | |
if (e2 > a) | |
throw new RangeError('The value "' + e2 + '" is invalid for option "size"'); | |
const t2 = new Uint8Array(e2); | |
return Object.setPrototypeOf(t2, Buffer$1.prototype), t2; | |
} | |
function Buffer$1(e2, t2, r2) { | |
if ("number" == typeof e2) { | |
if ("string" == typeof t2) | |
throw new TypeError('The "string" argument must be of type string. Received type number'); | |
return allocUnsafe(e2); | |
} | |
return from(e2, t2, r2); | |
} | |
function from(e2, t2, r2) { | |
if ("string" == typeof e2) | |
return function(e3, t3) { | |
"string" == typeof t3 && "" !== t3 || (t3 = "utf8"); | |
if (!Buffer$1.isEncoding(t3)) | |
throw new TypeError("Unknown encoding: " + t3); | |
const r3 = 0 | byteLength(e3, t3); | |
let n3 = createBuffer$1(r3); | |
const i3 = n3.write(e3, t3); | |
i3 !== r3 && (n3 = n3.slice(0, i3)); | |
return n3; | |
}(e2, t2); | |
if (ArrayBuffer.isView(e2)) | |
return function(e3) { | |
if (isInstance(e3, Uint8Array)) { | |
const t3 = new Uint8Array(e3); | |
return fromArrayBuffer(t3.buffer, t3.byteOffset, t3.byteLength); | |
} | |
return fromArrayLike(e3); | |
}(e2); | |
if (null == e2) | |
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e2); | |
if (isInstance(e2, ArrayBuffer) || e2 && isInstance(e2.buffer, ArrayBuffer)) | |
return fromArrayBuffer(e2, t2, r2); | |
if ("undefined" != typeof SharedArrayBuffer && (isInstance(e2, SharedArrayBuffer) || e2 && isInstance(e2.buffer, SharedArrayBuffer))) | |
return fromArrayBuffer(e2, t2, r2); | |
if ("number" == typeof e2) | |
throw new TypeError('The "value" argument must not be of type number. Received type number'); | |
const n2 = e2.valueOf && e2.valueOf(); | |
if (null != n2 && n2 !== e2) | |
return Buffer$1.from(n2, t2, r2); | |
const i2 = function(e3) { | |
if (Buffer$1.isBuffer(e3)) { | |
const t3 = 0 | checked(e3.length), r3 = createBuffer$1(t3); | |
return 0 === r3.length || e3.copy(r3, 0, 0, t3), r3; | |
} | |
if (void 0 !== e3.length) | |
return "number" != typeof e3.length || numberIsNaN(e3.length) ? createBuffer$1(0) : fromArrayLike(e3); | |
if ("Buffer" === e3.type && Array.isArray(e3.data)) | |
return fromArrayLike(e3.data); | |
}(e2); | |
if (i2) | |
return i2; | |
if ("undefined" != typeof Symbol && null != Symbol.toPrimitive && "function" == typeof e2[Symbol.toPrimitive]) | |
return Buffer$1.from(e2[Symbol.toPrimitive]("string"), t2, r2); | |
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e2); | |
} | |
function assertSize(e2) { | |
if ("number" != typeof e2) | |
throw new TypeError('"size" argument must be of type number'); | |
if (e2 < 0) | |
throw new RangeError('The value "' + e2 + '" is invalid for option "size"'); | |
} | |
function allocUnsafe(e2) { | |
return assertSize(e2), createBuffer$1(e2 < 0 ? 0 : 0 | checked(e2)); | |
} | |
function fromArrayLike(e2) { | |
const t2 = e2.length < 0 ? 0 : 0 | checked(e2.length), r2 = createBuffer$1(t2); | |
for (let n2 = 0; n2 < t2; n2 += 1) | |
r2[n2] = 255 & e2[n2]; | |
return r2; | |
} | |
function fromArrayBuffer(e2, t2, r2) { | |
if (t2 < 0 || e2.byteLength < t2) | |
throw new RangeError('"offset" is outside of buffer bounds'); | |
if (e2.byteLength < t2 + (r2 || 0)) | |
throw new RangeError('"length" is outside of buffer bounds'); | |
let n2; | |
return n2 = void 0 === t2 && void 0 === r2 ? new Uint8Array(e2) : void 0 === r2 ? new Uint8Array(e2, t2) : new Uint8Array(e2, t2, r2), Object.setPrototypeOf(n2, Buffer$1.prototype), n2; | |
} | |
function checked(e2) { | |
if (e2 >= a) | |
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + a.toString(16) + " bytes"); | |
return 0 | e2; | |
} | |
function byteLength(e2, t2) { | |
if (Buffer$1.isBuffer(e2)) | |
return e2.length; | |
if (ArrayBuffer.isView(e2) || isInstance(e2, ArrayBuffer)) | |
return e2.byteLength; | |
if ("string" != typeof e2) | |
throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof e2); | |
const r2 = e2.length, n2 = arguments.length > 2 && true === arguments[2]; | |
if (!n2 && 0 === r2) | |
return 0; | |
let i2 = false; | |
for (; ; ) | |
switch (t2) { | |
case "ascii": | |
case "latin1": | |
case "binary": | |
return r2; | |
case "utf8": | |
case "utf-8": | |
return utf8ToBytes(e2).length; | |
case "ucs2": | |
case "ucs-2": | |
case "utf16le": | |
case "utf-16le": | |
return 2 * r2; | |
case "hex": | |
return r2 >>> 1; | |
case "base64": | |
return base64ToBytes(e2).length; | |
default: | |
if (i2) | |
return n2 ? -1 : utf8ToBytes(e2).length; | |
t2 = ("" + t2).toLowerCase(), i2 = true; | |
} | |
} | |
function slowToString(e2, t2, r2) { | |
let n2 = false; | |
if ((void 0 === t2 || t2 < 0) && (t2 = 0), t2 > this.length) | |
return ""; | |
if ((void 0 === r2 || r2 > this.length) && (r2 = this.length), r2 <= 0) | |
return ""; | |
if ((r2 >>>= 0) <= (t2 >>>= 0)) | |
return ""; | |
for (e2 || (e2 = "utf8"); ; ) | |
switch (e2) { | |
case "hex": | |
return hexSlice(this, t2, r2); | |
case "utf8": | |
case "utf-8": | |
return utf8Slice(this, t2, r2); | |
case "ascii": | |
return asciiSlice(this, t2, r2); | |
case "latin1": | |
case "binary": | |
return latin1Slice(this, t2, r2); | |
case "base64": | |
return base64Slice(this, t2, r2); | |
case "ucs2": | |
case "ucs-2": | |
case "utf16le": | |
case "utf-16le": | |
return utf16leSlice(this, t2, r2); | |
default: | |
if (n2) | |
throw new TypeError("Unknown encoding: " + e2); | |
e2 = (e2 + "").toLowerCase(), n2 = true; | |
} | |
} | |
function swap(e2, t2, r2) { | |
const n2 = e2[t2]; | |
e2[t2] = e2[r2], e2[r2] = n2; | |
} | |
function bidirectionalIndexOf(e2, t2, r2, n2, i2) { | |
if (0 === e2.length) | |
return -1; | |
if ("string" == typeof r2 ? (n2 = r2, r2 = 0) : r2 > 2147483647 ? r2 = 2147483647 : r2 < -2147483648 && (r2 = -2147483648), numberIsNaN(r2 = +r2) && (r2 = i2 ? 0 : e2.length - 1), r2 < 0 && (r2 = e2.length + r2), r2 >= e2.length) { | |
if (i2) | |
return -1; | |
r2 = e2.length - 1; | |
} else if (r2 < 0) { | |
if (!i2) | |
return -1; | |
r2 = 0; | |
} | |
if ("string" == typeof t2 && (t2 = Buffer$1.from(t2, n2)), Buffer$1.isBuffer(t2)) | |
return 0 === t2.length ? -1 : arrayIndexOf(e2, t2, r2, n2, i2); | |
if ("number" == typeof t2) | |
return t2 &= 255, "function" == typeof Uint8Array.prototype.indexOf ? i2 ? Uint8Array.prototype.indexOf.call(e2, t2, r2) : Uint8Array.prototype.lastIndexOf.call(e2, t2, r2) : arrayIndexOf(e2, [t2], r2, n2, i2); | |
throw new TypeError("val must be string, number or Buffer"); | |
} | |
function arrayIndexOf(e2, t2, r2, n2, i2) { | |
let a2, c2 = 1, u2 = e2.length, m2 = t2.length; | |
if (void 0 !== n2 && ("ucs2" === (n2 = String(n2).toLowerCase()) || "ucs-2" === n2 || "utf16le" === n2 || "utf-16le" === n2)) { | |
if (e2.length < 2 || t2.length < 2) | |
return -1; | |
c2 = 2, u2 /= 2, m2 /= 2, r2 /= 2; | |
} | |
function read2(e3, t3) { | |
return 1 === c2 ? e3[t3] : e3.readUInt16BE(t3 * c2); | |
} | |
if (i2) { | |
let n3 = -1; | |
for (a2 = r2; a2 < u2; a2++) | |
if (read2(e2, a2) === read2(t2, -1 === n3 ? 0 : a2 - n3)) { | |
if (-1 === n3 && (n3 = a2), a2 - n3 + 1 === m2) | |
return n3 * c2; | |
} else | |
-1 !== n3 && (a2 -= a2 - n3), n3 = -1; | |
} else | |
for (r2 + m2 > u2 && (r2 = u2 - m2), a2 = r2; a2 >= 0; a2--) { | |
let r3 = true; | |
for (let n3 = 0; n3 < m2; n3++) | |
if (read2(e2, a2 + n3) !== read2(t2, n3)) { | |
r3 = false; | |
break; | |
} | |
if (r3) | |
return a2; | |
} | |
return -1; | |
} | |
function hexWrite(e2, t2, r2, n2) { | |
r2 = Number(r2) || 0; | |
const i2 = e2.length - r2; | |
n2 ? (n2 = Number(n2)) > i2 && (n2 = i2) : n2 = i2; | |
const a2 = t2.length; | |
let c2; | |
for (n2 > a2 / 2 && (n2 = a2 / 2), c2 = 0; c2 < n2; ++c2) { | |
const n3 = Number.parseInt(t2.slice(2 * c2, 2 * c2 + 2), 16); | |
if (numberIsNaN(n3)) | |
return c2; | |
e2[r2 + c2] = n3; | |
} | |
return c2; | |
} | |
function utf8Write(e2, t2, r2, n2) { | |
return blitBuffer(utf8ToBytes(t2, e2.length - r2), e2, r2, n2); | |
} | |
function asciiWrite(e2, t2, r2, n2) { | |
return blitBuffer(function(e3) { | |
const t3 = []; | |
for (let r3 = 0; r3 < e3.length; ++r3) | |
t3.push(255 & e3.charCodeAt(r3)); | |
return t3; | |
}(t2), e2, r2, n2); | |
} | |
function base64Write(e2, t2, r2, n2) { | |
return blitBuffer(base64ToBytes(t2), e2, r2, n2); | |
} | |
function ucs2Write(e2, t2, r2, n2) { | |
return blitBuffer(function(e3, t3) { | |
let r3, n3, i2; | |
const a2 = []; | |
for (let c2 = 0; c2 < e3.length && !((t3 -= 2) < 0); ++c2) | |
r3 = e3.charCodeAt(c2), n3 = r3 >> 8, i2 = r3 % 256, a2.push(i2, n3); | |
return a2; | |
}(t2, e2.length - r2), e2, r2, n2); | |
} | |
function base64Slice(e2, t2, r2) { | |
return 0 === t2 && r2 === e2.length ? fromByteArray(e2) : fromByteArray(e2.slice(t2, r2)); | |
} | |
function utf8Slice(e2, t2, r2) { | |
r2 = Math.min(e2.length, r2); | |
const n2 = []; | |
let i2 = t2; | |
for (; i2 < r2; ) { | |
const t3 = e2[i2]; | |
let a2 = null, c2 = t3 > 239 ? 4 : t3 > 223 ? 3 : t3 > 191 ? 2 : 1; | |
if (i2 + c2 <= r2) { | |
let r3, n3, u2, m2; | |
switch (c2) { | |
case 1: | |
t3 < 128 && (a2 = t3); | |
break; | |
case 2: | |
r3 = e2[i2 + 1], 128 == (192 & r3) && (m2 = (31 & t3) << 6 | 63 & r3, m2 > 127 && (a2 = m2)); | |
break; | |
case 3: | |
r3 = e2[i2 + 1], n3 = e2[i2 + 2], 128 == (192 & r3) && 128 == (192 & n3) && (m2 = (15 & t3) << 12 | (63 & r3) << 6 | 63 & n3, m2 > 2047 && (m2 < 55296 || m2 > 57343) && (a2 = m2)); | |
break; | |
case 4: | |
r3 = e2[i2 + 1], n3 = e2[i2 + 2], u2 = e2[i2 + 3], 128 == (192 & r3) && 128 == (192 & n3) && 128 == (192 & u2) && (m2 = (15 & t3) << 18 | (63 & r3) << 12 | (63 & n3) << 6 | 63 & u2, m2 > 65535 && m2 < 1114112 && (a2 = m2)); | |
} | |
} | |
null === a2 ? (a2 = 65533, c2 = 1) : a2 > 65535 && (a2 -= 65536, n2.push(a2 >>> 10 & 1023 | 55296), a2 = 56320 | 1023 & a2), n2.push(a2), i2 += c2; | |
} | |
return function(e3) { | |
const t3 = e3.length; | |
if (t3 <= c) | |
return String.fromCharCode.apply(String, e3); | |
let r3 = "", n3 = 0; | |
for (; n3 < t3; ) | |
r3 += String.fromCharCode.apply(String, e3.slice(n3, n3 += c)); | |
return r3; | |
}(n2); | |
} | |
Buffer$1.TYPED_ARRAY_SUPPORT = function() { | |
try { | |
const e2 = new Uint8Array(1), t2 = { foo: function() { | |
return 42; | |
} }; | |
return Object.setPrototypeOf(t2, Uint8Array.prototype), Object.setPrototypeOf(e2, t2), 42 === e2.foo(); | |
} catch { | |
return false; | |
} | |
}(), Buffer$1.TYPED_ARRAY_SUPPORT || "undefined" == typeof console || "function" != typeof console.error || console.error("This environment lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."), Object.defineProperty(Buffer$1.prototype, "parent", { enumerable: true, get: function() { | |
if (Buffer$1.isBuffer(this)) | |
return this.buffer; | |
} }), Object.defineProperty(Buffer$1.prototype, "offset", { enumerable: true, get: function() { | |
if (Buffer$1.isBuffer(this)) | |
return this.byteOffset; | |
} }), Buffer$1.poolSize = 8192, Buffer$1.from = function(e2, t2, r2) { | |
return from(e2, t2, r2); | |
}, Object.setPrototypeOf(Buffer$1.prototype, Uint8Array.prototype), Object.setPrototypeOf(Buffer$1, Uint8Array), Buffer$1.alloc = function(e2, t2, r2) { | |
return function(e3, t3, r3) { | |
return assertSize(e3), e3 <= 0 ? createBuffer$1(e3) : void 0 !== t3 ? "string" == typeof r3 ? createBuffer$1(e3).fill(t3, r3) : createBuffer$1(e3).fill(t3) : createBuffer$1(e3); | |
}(e2, t2, r2); | |
}, Buffer$1.allocUnsafe = function(e2) { | |
return allocUnsafe(e2); | |
}, Buffer$1.allocUnsafeSlow = function(e2) { | |
return allocUnsafe(e2); | |
}, Buffer$1.isBuffer = function(e2) { | |
return null != e2 && true === e2._isBuffer && e2 !== Buffer$1.prototype; | |
}, Buffer$1.compare = function(e2, t2) { | |
if (isInstance(e2, Uint8Array) && (e2 = Buffer$1.from(e2, e2.offset, e2.byteLength)), isInstance(t2, Uint8Array) && (t2 = Buffer$1.from(t2, t2.offset, t2.byteLength)), !Buffer$1.isBuffer(e2) || !Buffer$1.isBuffer(t2)) | |
throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); | |
if (e2 === t2) | |
return 0; | |
let r2 = e2.length, n2 = t2.length; | |
for (let i2 = 0, a2 = Math.min(r2, n2); i2 < a2; ++i2) | |
if (e2[i2] !== t2[i2]) { | |
r2 = e2[i2], n2 = t2[i2]; | |
break; | |
} | |
return r2 < n2 ? -1 : n2 < r2 ? 1 : 0; | |
}, Buffer$1.isEncoding = function(e2) { | |
switch (String(e2).toLowerCase()) { | |
case "hex": | |
case "utf8": | |
case "utf-8": | |
case "ascii": | |
case "latin1": | |
case "binary": | |
case "base64": | |
case "ucs2": | |
case "ucs-2": | |
case "utf16le": | |
case "utf-16le": | |
return true; | |
default: | |
return false; | |
} | |
}, Buffer$1.concat = function(e2, t2) { | |
if (!Array.isArray(e2)) | |
throw new TypeError('"list" argument must be an Array of Buffers'); | |
if (0 === e2.length) | |
return Buffer$1.alloc(0); | |
let r2; | |
if (void 0 === t2) | |
for (t2 = 0, r2 = 0; r2 < e2.length; ++r2) | |
t2 += e2[r2].length; | |
const n2 = Buffer$1.allocUnsafe(t2); | |
let i2 = 0; | |
for (r2 = 0; r2 < e2.length; ++r2) { | |
let t3 = e2[r2]; | |
if (isInstance(t3, Uint8Array)) | |
i2 + t3.length > n2.length ? (Buffer$1.isBuffer(t3) || (t3 = Buffer$1.from(t3.buffer, t3.byteOffset, t3.byteLength)), t3.copy(n2, i2)) : Uint8Array.prototype.set.call(n2, t3, i2); | |
else { | |
if (!Buffer$1.isBuffer(t3)) | |
throw new TypeError('"list" argument must be an Array of Buffers'); | |
t3.copy(n2, i2); | |
} | |
i2 += t3.length; | |
} | |
return n2; | |
}, Buffer$1.byteLength = byteLength, Buffer$1.prototype._isBuffer = true, Buffer$1.prototype.swap16 = function() { | |
const e2 = this.length; | |
if (e2 % 2 != 0) | |
throw new RangeError("Buffer size must be a multiple of 16-bits"); | |
for (let t2 = 0; t2 < e2; t2 += 2) | |
swap(this, t2, t2 + 1); | |
return this; | |
}, Buffer$1.prototype.swap32 = function() { | |
const e2 = this.length; | |
if (e2 % 4 != 0) | |
throw new RangeError("Buffer size must be a multiple of 32-bits"); | |
for (let t2 = 0; t2 < e2; t2 += 4) | |
swap(this, t2, t2 + 3), swap(this, t2 + 1, t2 + 2); | |
return this; | |
}, Buffer$1.prototype.swap64 = function() { | |
const e2 = this.length; | |
if (e2 % 8 != 0) | |
throw new RangeError("Buffer size must be a multiple of 64-bits"); | |
for (let t2 = 0; t2 < e2; t2 += 8) | |
swap(this, t2, t2 + 7), swap(this, t2 + 1, t2 + 6), swap(this, t2 + 2, t2 + 5), swap(this, t2 + 3, t2 + 4); | |
return this; | |
}, Buffer$1.prototype.toString = function() { | |
const e2 = this.length; | |
return 0 === e2 ? "" : 0 === arguments.length ? utf8Slice(this, 0, e2) : Reflect.apply(slowToString, this, arguments); | |
}, Buffer$1.prototype.toLocaleString = Buffer$1.prototype.toString, Buffer$1.prototype.equals = function(e2) { | |
if (!Buffer$1.isBuffer(e2)) | |
throw new TypeError("Argument must be a Buffer"); | |
return this === e2 || 0 === Buffer$1.compare(this, e2); | |
}, Buffer$1.prototype.inspect = function() { | |
let e2 = ""; | |
return e2 = this.toString("hex", 0, 50).replace(/(.{2})/g, "$1 ").trim(), this.length > 50 && (e2 += " ... "), "<Buffer " + e2 + ">"; | |
}, i && (Buffer$1.prototype[i] = Buffer$1.prototype.inspect), Buffer$1.prototype.compare = function(e2, t2, r2, n2, i2) { | |
if (isInstance(e2, Uint8Array) && (e2 = Buffer$1.from(e2, e2.offset, e2.byteLength)), !Buffer$1.isBuffer(e2)) | |
throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof e2); | |
if (void 0 === t2 && (t2 = 0), void 0 === r2 && (r2 = e2 ? e2.length : 0), void 0 === n2 && (n2 = 0), void 0 === i2 && (i2 = this.length), t2 < 0 || r2 > e2.length || n2 < 0 || i2 > this.length) | |
throw new RangeError("out of range index"); | |
if (n2 >= i2 && t2 >= r2) | |
return 0; | |
if (n2 >= i2) | |
return -1; | |
if (t2 >= r2) | |
return 1; | |
if (this === e2) | |
return 0; | |
let a2 = (i2 >>>= 0) - (n2 >>>= 0), c2 = (r2 >>>= 0) - (t2 >>>= 0); | |
const u2 = Math.min(a2, c2), m2 = this.slice(n2, i2), g2 = e2.slice(t2, r2); | |
for (let e3 = 0; e3 < u2; ++e3) | |
if (m2[e3] !== g2[e3]) { | |
a2 = m2[e3], c2 = g2[e3]; | |
break; | |
} | |
return a2 < c2 ? -1 : c2 < a2 ? 1 : 0; | |
}, Buffer$1.prototype.includes = function(e2, t2, r2) { | |
return -1 !== this.indexOf(e2, t2, r2); | |
}, Buffer$1.prototype.indexOf = function(e2, t2, r2) { | |
return bidirectionalIndexOf(this, e2, t2, r2, true); | |
}, Buffer$1.prototype.lastIndexOf = function(e2, t2, r2) { | |
return bidirectionalIndexOf(this, e2, t2, r2, false); | |
}, Buffer$1.prototype.write = function(e2, t2, r2, n2) { | |
if (void 0 === t2) | |
n2 = "utf8", r2 = this.length, t2 = 0; | |
else if (void 0 === r2 && "string" == typeof t2) | |
n2 = t2, r2 = this.length, t2 = 0; | |
else { | |
if (!Number.isFinite(t2)) | |
throw new TypeError("Buffer.write(string, encoding, offset[, length]) is no longer supported"); | |
t2 >>>= 0, Number.isFinite(r2) ? (r2 >>>= 0, void 0 === n2 && (n2 = "utf8")) : (n2 = r2, r2 = void 0); | |
} | |
const i2 = this.length - t2; | |
if ((void 0 === r2 || r2 > i2) && (r2 = i2), e2.length > 0 && (r2 < 0 || t2 < 0) || t2 > this.length) | |
throw new RangeError("Attempt to write outside buffer bounds"); | |
n2 || (n2 = "utf8"); | |
let a2 = false; | |
for (; ; ) | |
switch (n2) { | |
case "hex": | |
return hexWrite(this, e2, t2, r2); | |
case "utf8": | |
case "utf-8": | |
return utf8Write(this, e2, t2, r2); | |
case "ascii": | |
case "latin1": | |
case "binary": | |
return asciiWrite(this, e2, t2, r2); | |
case "base64": | |
return base64Write(this, e2, t2, r2); | |
case "ucs2": | |
case "ucs-2": | |
case "utf16le": | |
case "utf-16le": | |
return ucs2Write(this, e2, t2, r2); | |
default: | |
if (a2) | |
throw new TypeError("Unknown encoding: " + n2); | |
n2 = ("" + n2).toLowerCase(), a2 = true; | |
} | |
}, Buffer$1.prototype.toJSON = function() { | |
return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) }; | |
}; | |
const c = 4096; | |
function asciiSlice(e2, t2, r2) { | |
let n2 = ""; | |
r2 = Math.min(e2.length, r2); | |
for (let i2 = t2; i2 < r2; ++i2) | |
n2 += String.fromCharCode(127 & e2[i2]); | |
return n2; | |
} | |
function latin1Slice(e2, t2, r2) { | |
let n2 = ""; | |
r2 = Math.min(e2.length, r2); | |
for (let i2 = t2; i2 < r2; ++i2) | |
n2 += String.fromCharCode(e2[i2]); | |
return n2; | |
} | |
function hexSlice(e2, t2, r2) { | |
const n2 = e2.length; | |
(!t2 || t2 < 0) && (t2 = 0), (!r2 || r2 < 0 || r2 > n2) && (r2 = n2); | |
let i2 = ""; | |
for (let n3 = t2; n3 < r2; ++n3) | |
i2 += g[e2[n3]]; | |
return i2; | |
} | |
function utf16leSlice(e2, t2, r2) { | |
const n2 = e2.slice(t2, r2); | |
let i2 = ""; | |
for (let e3 = 0; e3 < n2.length - 1; e3 += 2) | |
i2 += String.fromCharCode(n2[e3] + 256 * n2[e3 + 1]); | |
return i2; | |
} | |
function checkOffset(e2, t2, r2) { | |
if (e2 % 1 != 0 || e2 < 0) | |
throw new RangeError("offset is not uint"); | |
if (e2 + t2 > r2) | |
throw new RangeError("Trying to access beyond buffer length"); | |
} | |
function checkInt(e2, t2, r2, n2, i2, a2) { | |
if (!Buffer$1.isBuffer(e2)) | |
throw new TypeError('"buffer" argument must be a Buffer instance'); | |
if (t2 > i2 || t2 < a2) | |
throw new RangeError('"value" argument is out of bounds'); | |
if (r2 + n2 > e2.length) | |
throw new RangeError("Index out of range"); | |
} | |
function wrtBigUInt64LE(e2, t2, r2, n2, i2) { | |
checkIntBI(t2, n2, i2, e2, r2, 7); | |
let a2 = Number(t2 & BigInt(4294967295)); | |
e2[r2++] = a2, a2 >>= 8, e2[r2++] = a2, a2 >>= 8, e2[r2++] = a2, a2 >>= 8, e2[r2++] = a2; | |
let c2 = Number(t2 >> BigInt(32) & BigInt(4294967295)); | |
return e2[r2++] = c2, c2 >>= 8, e2[r2++] = c2, c2 >>= 8, e2[r2++] = c2, c2 >>= 8, e2[r2++] = c2, r2; | |
} | |
function wrtBigUInt64BE(e2, t2, r2, n2, i2) { | |
checkIntBI(t2, n2, i2, e2, r2, 7); | |
let a2 = Number(t2 & BigInt(4294967295)); | |
e2[r2 + 7] = a2, a2 >>= 8, e2[r2 + 6] = a2, a2 >>= 8, e2[r2 + 5] = a2, a2 >>= 8, e2[r2 + 4] = a2; | |
let c2 = Number(t2 >> BigInt(32) & BigInt(4294967295)); | |
return e2[r2 + 3] = c2, c2 >>= 8, e2[r2 + 2] = c2, c2 >>= 8, e2[r2 + 1] = c2, c2 >>= 8, e2[r2] = c2, r2 + 8; | |
} | |
function checkIEEE754(e2, t2, r2, n2, i2, a2) { | |
if (r2 + n2 > e2.length) | |
throw new RangeError("Index out of range"); | |
if (r2 < 0) | |
throw new RangeError("Index out of range"); | |
} | |
function writeFloat(e2, t2, r2, n2, i2) { | |
return t2 = +t2, r2 >>>= 0, i2 || checkIEEE754(e2, 0, r2, 4), write(e2, t2, r2, n2, 23, 4), r2 + 4; | |
} | |
function writeDouble(e2, t2, r2, n2, i2) { | |
return t2 = +t2, r2 >>>= 0, i2 || checkIEEE754(e2, 0, r2, 8), write(e2, t2, r2, n2, 52, 8), r2 + 8; | |
} | |
Buffer$1.prototype.slice = function(e2, t2) { | |
const r2 = this.length; | |
(e2 = Math.trunc(e2)) < 0 ? (e2 += r2) < 0 && (e2 = 0) : e2 > r2 && (e2 = r2), (t2 = void 0 === t2 ? r2 : Math.trunc(t2)) < 0 ? (t2 += r2) < 0 && (t2 = 0) : t2 > r2 && (t2 = r2), t2 < e2 && (t2 = e2); | |
const n2 = this.subarray(e2, t2); | |
return Object.setPrototypeOf(n2, Buffer$1.prototype), n2; | |
}, Buffer$1.prototype.readUintLE = Buffer$1.prototype.readUIntLE = function(e2, t2, r2) { | |
e2 >>>= 0, t2 >>>= 0, r2 || checkOffset(e2, t2, this.length); | |
let n2 = this[e2], i2 = 1, a2 = 0; | |
for (; ++a2 < t2 && (i2 *= 256); ) | |
n2 += this[e2 + a2] * i2; | |
return n2; | |
}, Buffer$1.prototype.readUintBE = Buffer$1.prototype.readUIntBE = function(e2, t2, r2) { | |
e2 >>>= 0, t2 >>>= 0, r2 || checkOffset(e2, t2, this.length); | |
let n2 = this[e2 + --t2], i2 = 1; | |
for (; t2 > 0 && (i2 *= 256); ) | |
n2 += this[e2 + --t2] * i2; | |
return n2; | |
}, Buffer$1.prototype.readUint8 = Buffer$1.prototype.readUInt8 = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 1, this.length), this[e2]; | |
}, Buffer$1.prototype.readUint16LE = Buffer$1.prototype.readUInt16LE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 2, this.length), this[e2] | this[e2 + 1] << 8; | |
}, Buffer$1.prototype.readUint16BE = Buffer$1.prototype.readUInt16BE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 2, this.length), this[e2] << 8 | this[e2 + 1]; | |
}, Buffer$1.prototype.readUint32LE = Buffer$1.prototype.readUInt32LE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 4, this.length), (this[e2] | this[e2 + 1] << 8 | this[e2 + 2] << 16) + 16777216 * this[e2 + 3]; | |
}, Buffer$1.prototype.readUint32BE = Buffer$1.prototype.readUInt32BE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 4, this.length), 16777216 * this[e2] + (this[e2 + 1] << 16 | this[e2 + 2] << 8 | this[e2 + 3]); | |
}, Buffer$1.prototype.readBigUInt64LE = defineBigIntMethod(function(e2) { | |
validateNumber(e2 >>>= 0, "offset"); | |
const t2 = this[e2], r2 = this[e2 + 7]; | |
void 0 !== t2 && void 0 !== r2 || boundsError(e2, this.length - 8); | |
const n2 = t2 + 256 * this[++e2] + 65536 * this[++e2] + this[++e2] * 2 ** 24, i2 = this[++e2] + 256 * this[++e2] + 65536 * this[++e2] + r2 * 2 ** 24; | |
return BigInt(n2) + (BigInt(i2) << BigInt(32)); | |
}), Buffer$1.prototype.readBigUInt64BE = defineBigIntMethod(function(e2) { | |
validateNumber(e2 >>>= 0, "offset"); | |
const t2 = this[e2], r2 = this[e2 + 7]; | |
void 0 !== t2 && void 0 !== r2 || boundsError(e2, this.length - 8); | |
const n2 = t2 * 2 ** 24 + 65536 * this[++e2] + 256 * this[++e2] + this[++e2], i2 = this[++e2] * 2 ** 24 + 65536 * this[++e2] + 256 * this[++e2] + r2; | |
return (BigInt(n2) << BigInt(32)) + BigInt(i2); | |
}), Buffer$1.prototype.readIntLE = function(e2, t2, r2) { | |
e2 >>>= 0, t2 >>>= 0, r2 || checkOffset(e2, t2, this.length); | |
let n2 = this[e2], i2 = 1, a2 = 0; | |
for (; ++a2 < t2 && (i2 *= 256); ) | |
n2 += this[e2 + a2] * i2; | |
return i2 *= 128, n2 >= i2 && (n2 -= Math.pow(2, 8 * t2)), n2; | |
}, Buffer$1.prototype.readIntBE = function(e2, t2, r2) { | |
e2 >>>= 0, t2 >>>= 0, r2 || checkOffset(e2, t2, this.length); | |
let n2 = t2, i2 = 1, a2 = this[e2 + --n2]; | |
for (; n2 > 0 && (i2 *= 256); ) | |
a2 += this[e2 + --n2] * i2; | |
return i2 *= 128, a2 >= i2 && (a2 -= Math.pow(2, 8 * t2)), a2; | |
}, Buffer$1.prototype.readInt8 = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 1, this.length), 128 & this[e2] ? -1 * (255 - this[e2] + 1) : this[e2]; | |
}, Buffer$1.prototype.readInt16LE = function(e2, t2) { | |
e2 >>>= 0, t2 || checkOffset(e2, 2, this.length); | |
const r2 = this[e2] | this[e2 + 1] << 8; | |
return 32768 & r2 ? 4294901760 | r2 : r2; | |
}, Buffer$1.prototype.readInt16BE = function(e2, t2) { | |
e2 >>>= 0, t2 || checkOffset(e2, 2, this.length); | |
const r2 = this[e2 + 1] | this[e2] << 8; | |
return 32768 & r2 ? 4294901760 | r2 : r2; | |
}, Buffer$1.prototype.readInt32LE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 4, this.length), this[e2] | this[e2 + 1] << 8 | this[e2 + 2] << 16 | this[e2 + 3] << 24; | |
}, Buffer$1.prototype.readInt32BE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 4, this.length), this[e2] << 24 | this[e2 + 1] << 16 | this[e2 + 2] << 8 | this[e2 + 3]; | |
}, Buffer$1.prototype.readBigInt64LE = defineBigIntMethod(function(e2) { | |
validateNumber(e2 >>>= 0, "offset"); | |
const t2 = this[e2], r2 = this[e2 + 7]; | |
void 0 !== t2 && void 0 !== r2 || boundsError(e2, this.length - 8); | |
const n2 = this[e2 + 4] + 256 * this[e2 + 5] + 65536 * this[e2 + 6] + (r2 << 24); | |
return (BigInt(n2) << BigInt(32)) + BigInt(t2 + 256 * this[++e2] + 65536 * this[++e2] + this[++e2] * 2 ** 24); | |
}), Buffer$1.prototype.readBigInt64BE = defineBigIntMethod(function(e2) { | |
validateNumber(e2 >>>= 0, "offset"); | |
const t2 = this[e2], r2 = this[e2 + 7]; | |
void 0 !== t2 && void 0 !== r2 || boundsError(e2, this.length - 8); | |
const n2 = (t2 << 24) + 65536 * this[++e2] + 256 * this[++e2] + this[++e2]; | |
return (BigInt(n2) << BigInt(32)) + BigInt(this[++e2] * 2 ** 24 + 65536 * this[++e2] + 256 * this[++e2] + r2); | |
}), Buffer$1.prototype.readFloatLE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 4, this.length), read(this, e2, true, 23, 4); | |
}, Buffer$1.prototype.readFloatBE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 4, this.length), read(this, e2, false, 23, 4); | |
}, Buffer$1.prototype.readDoubleLE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 8, this.length), read(this, e2, true, 52, 8); | |
}, Buffer$1.prototype.readDoubleBE = function(e2, t2) { | |
return e2 >>>= 0, t2 || checkOffset(e2, 8, this.length), read(this, e2, false, 52, 8); | |
}, Buffer$1.prototype.writeUintLE = Buffer$1.prototype.writeUIntLE = function(e2, t2, r2, n2) { | |
if (e2 = +e2, t2 >>>= 0, r2 >>>= 0, !n2) { | |
checkInt(this, e2, t2, r2, Math.pow(2, 8 * r2) - 1, 0); | |
} | |
let i2 = 1, a2 = 0; | |
for (this[t2] = 255 & e2; ++a2 < r2 && (i2 *= 256); ) | |
this[t2 + a2] = e2 / i2 & 255; | |
return t2 + r2; | |
}, Buffer$1.prototype.writeUintBE = Buffer$1.prototype.writeUIntBE = function(e2, t2, r2, n2) { | |
if (e2 = +e2, t2 >>>= 0, r2 >>>= 0, !n2) { | |
checkInt(this, e2, t2, r2, Math.pow(2, 8 * r2) - 1, 0); | |
} | |
let i2 = r2 - 1, a2 = 1; | |
for (this[t2 + i2] = 255 & e2; --i2 >= 0 && (a2 *= 256); ) | |
this[t2 + i2] = e2 / a2 & 255; | |
return t2 + r2; | |
}, Buffer$1.prototype.writeUint8 = Buffer$1.prototype.writeUInt8 = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 1, 255, 0), this[t2] = 255 & e2, t2 + 1; | |
}, Buffer$1.prototype.writeUint16LE = Buffer$1.prototype.writeUInt16LE = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 2, 65535, 0), this[t2] = 255 & e2, this[t2 + 1] = e2 >>> 8, t2 + 2; | |
}, Buffer$1.prototype.writeUint16BE = Buffer$1.prototype.writeUInt16BE = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 2, 65535, 0), this[t2] = e2 >>> 8, this[t2 + 1] = 255 & e2, t2 + 2; | |
}, Buffer$1.prototype.writeUint32LE = Buffer$1.prototype.writeUInt32LE = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 4, 4294967295, 0), this[t2 + 3] = e2 >>> 24, this[t2 + 2] = e2 >>> 16, this[t2 + 1] = e2 >>> 8, this[t2] = 255 & e2, t2 + 4; | |
}, Buffer$1.prototype.writeUint32BE = Buffer$1.prototype.writeUInt32BE = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 4, 4294967295, 0), this[t2] = e2 >>> 24, this[t2 + 1] = e2 >>> 16, this[t2 + 2] = e2 >>> 8, this[t2 + 3] = 255 & e2, t2 + 4; | |
}, Buffer$1.prototype.writeBigUInt64LE = defineBigIntMethod(function(e2, t2 = 0) { | |
return wrtBigUInt64LE(this, e2, t2, BigInt(0), BigInt("0xffffffffffffffff")); | |
}), Buffer$1.prototype.writeBigUInt64BE = defineBigIntMethod(function(e2, t2 = 0) { | |
return wrtBigUInt64BE(this, e2, t2, BigInt(0), BigInt("0xffffffffffffffff")); | |
}), Buffer$1.prototype.writeIntLE = function(e2, t2, r2, n2) { | |
if (e2 = +e2, t2 >>>= 0, !n2) { | |
const n3 = Math.pow(2, 8 * r2 - 1); | |
checkInt(this, e2, t2, r2, n3 - 1, -n3); | |
} | |
let i2 = 0, a2 = 1, c2 = 0; | |
for (this[t2] = 255 & e2; ++i2 < r2 && (a2 *= 256); ) | |
e2 < 0 && 0 === c2 && 0 !== this[t2 + i2 - 1] && (c2 = 1), this[t2 + i2] = Math.trunc(e2 / a2) - c2 & 255; | |
return t2 + r2; | |
}, Buffer$1.prototype.writeIntBE = function(e2, t2, r2, n2) { | |
if (e2 = +e2, t2 >>>= 0, !n2) { | |
const n3 = Math.pow(2, 8 * r2 - 1); | |
checkInt(this, e2, t2, r2, n3 - 1, -n3); | |
} | |
let i2 = r2 - 1, a2 = 1, c2 = 0; | |
for (this[t2 + i2] = 255 & e2; --i2 >= 0 && (a2 *= 256); ) | |
e2 < 0 && 0 === c2 && 0 !== this[t2 + i2 + 1] && (c2 = 1), this[t2 + i2] = Math.trunc(e2 / a2) - c2 & 255; | |
return t2 + r2; | |
}, Buffer$1.prototype.writeInt8 = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 1, 127, -128), e2 < 0 && (e2 = 255 + e2 + 1), this[t2] = 255 & e2, t2 + 1; | |
}, Buffer$1.prototype.writeInt16LE = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 2, 32767, -32768), this[t2] = 255 & e2, this[t2 + 1] = e2 >>> 8, t2 + 2; | |
}, Buffer$1.prototype.writeInt16BE = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 2, 32767, -32768), this[t2] = e2 >>> 8, this[t2 + 1] = 255 & e2, t2 + 2; | |
}, Buffer$1.prototype.writeInt32LE = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 4, 2147483647, -2147483648), this[t2] = 255 & e2, this[t2 + 1] = e2 >>> 8, this[t2 + 2] = e2 >>> 16, this[t2 + 3] = e2 >>> 24, t2 + 4; | |
}, Buffer$1.prototype.writeInt32BE = function(e2, t2, r2) { | |
return e2 = +e2, t2 >>>= 0, r2 || checkInt(this, e2, t2, 4, 2147483647, -2147483648), e2 < 0 && (e2 = 4294967295 + e2 + 1), this[t2] = e2 >>> 24, this[t2 + 1] = e2 >>> 16, this[t2 + 2] = e2 >>> 8, this[t2 + 3] = 255 & e2, t2 + 4; | |
}, Buffer$1.prototype.writeBigInt64LE = defineBigIntMethod(function(e2, t2 = 0) { | |
return wrtBigUInt64LE(this, e2, t2, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); | |
}), Buffer$1.prototype.writeBigInt64BE = defineBigIntMethod(function(e2, t2 = 0) { | |
return wrtBigUInt64BE(this, e2, t2, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); | |
}), Buffer$1.prototype.writeFloatLE = function(e2, t2, r2) { | |
return writeFloat(this, e2, t2, true, r2); | |
}, Buffer$1.prototype.writeFloatBE = function(e2, t2, r2) { | |
return writeFloat(this, e2, t2, false, r2); | |
}, Buffer$1.prototype.writeDoubleLE = function(e2, t2, r2) { | |
return writeDouble(this, e2, t2, true, r2); | |
}, Buffer$1.prototype.writeDoubleBE = function(e2, t2, r2) { | |
return writeDouble(this, e2, t2, false, r2); | |
}, Buffer$1.prototype.copy = function(e2, t2, r2, n2) { | |
if (!Buffer$1.isBuffer(e2)) | |
throw new TypeError("argument should be a Buffer"); | |
if (r2 || (r2 = 0), n2 || 0 === n2 || (n2 = this.length), t2 >= e2.length && (t2 = e2.length), t2 || (t2 = 0), n2 > 0 && n2 < r2 && (n2 = r2), n2 === r2) | |
return 0; | |
if (0 === e2.length || 0 === this.length) | |
return 0; | |
if (t2 < 0) | |
throw new RangeError("targetStart out of bounds"); | |
if (r2 < 0 || r2 >= this.length) | |
throw new RangeError("Index out of range"); | |
if (n2 < 0) | |
throw new RangeError("sourceEnd out of bounds"); | |
n2 > this.length && (n2 = this.length), e2.length - t2 < n2 - r2 && (n2 = e2.length - t2 + r2); | |
const i2 = n2 - r2; | |
return this === e2 && "function" == typeof Uint8Array.prototype.copyWithin ? this.copyWithin(t2, r2, n2) : Uint8Array.prototype.set.call(e2, this.subarray(r2, n2), t2), i2; | |
}, Buffer$1.prototype.fill = function(e2, t2, r2, n2) { | |
if ("string" == typeof e2) { | |
if ("string" == typeof t2 ? (n2 = t2, t2 = 0, r2 = this.length) : "string" == typeof r2 && (n2 = r2, r2 = this.length), void 0 !== n2 && "string" != typeof n2) | |
throw new TypeError("encoding must be a string"); | |
if ("string" == typeof n2 && !Buffer$1.isEncoding(n2)) | |
throw new TypeError("Unknown encoding: " + n2); | |
if (1 === e2.length) { | |
const t3 = e2.charCodeAt(0); | |
("utf8" === n2 && t3 < 128 || "latin1" === n2) && (e2 = t3); | |
} | |
} else | |
"number" == typeof e2 ? e2 &= 255 : "boolean" == typeof e2 && (e2 = Number(e2)); | |
if (t2 < 0 || this.length < t2 || this.length < r2) | |
throw new RangeError("Out of range index"); | |
if (r2 <= t2) | |
return this; | |
let i2; | |
if (t2 >>>= 0, r2 = void 0 === r2 ? this.length : r2 >>> 0, e2 || (e2 = 0), "number" == typeof e2) | |
for (i2 = t2; i2 < r2; ++i2) | |
this[i2] = e2; | |
else { | |
const a2 = Buffer$1.isBuffer(e2) ? e2 : Buffer$1.from(e2, n2), c2 = a2.length; | |
if (0 === c2) | |
throw new TypeError('The value "' + e2 + '" is invalid for argument "value"'); | |
for (i2 = 0; i2 < r2 - t2; ++i2) | |
this[i2 + t2] = a2[i2 % c2]; | |
} | |
return this; | |
}; | |
const u = {}; | |
function E(e2, t2, r2) { | |
u[e2] = class extends r2 { | |
constructor() { | |
super(), Object.defineProperty(this, "message", { value: Reflect.apply(t2, this, arguments), writable: true, configurable: true }), this.name = `${this.name} [${e2}]`, this.stack, delete this.name; | |
} | |
get code() { | |
return e2; | |
} | |
set code(e3) { | |
Object.defineProperty(this, "code", { configurable: true, enumerable: true, value: e3, writable: true }); | |
} | |
toString() { | |
return `${this.name} [${e2}]: ${this.message}`; | |
} | |
}; | |
} | |
function addNumericalSeparator(e2) { | |
let t2 = "", r2 = e2.length; | |
const n2 = "-" === e2[0] ? 1 : 0; | |
for (; r2 >= n2 + 4; r2 -= 3) | |
t2 = `_${e2.slice(r2 - 3, r2)}${t2}`; | |
return `${e2.slice(0, r2)}${t2}`; | |
} | |
function checkIntBI(e2, t2, r2, n2, i2, a2) { | |
if (e2 > r2 || e2 < t2) { | |
const n3 = "bigint" == typeof t2 ? "n" : ""; | |
let i3; | |
throw i3 = a2 > 3 ? 0 === t2 || t2 === BigInt(0) ? `>= 0${n3} and < 2${n3} ** ${8 * (a2 + 1)}${n3}` : `>= -(2${n3} ** ${8 * (a2 + 1) - 1}${n3}) and < 2 ** ${8 * (a2 + 1) - 1}${n3}` : `>= ${t2}${n3} and <= ${r2}${n3}`, new u.ERR_OUT_OF_RANGE("value", i3, e2); | |
} | |
!function(e3, t3, r3) { | |
validateNumber(t3, "offset"), void 0 !== e3[t3] && void 0 !== e3[t3 + r3] || boundsError(t3, e3.length - (r3 + 1)); | |
}(n2, i2, a2); | |
} | |
function validateNumber(e2, t2) { | |
if ("number" != typeof e2) | |
throw new u.ERR_INVALID_ARG_TYPE(t2, "number", e2); | |
} | |
function boundsError(e2, t2, r2) { | |
if (Math.floor(e2) !== e2) | |
throw validateNumber(e2, r2), new u.ERR_OUT_OF_RANGE(r2 || "offset", "an integer", e2); | |
if (t2 < 0) | |
throw new u.ERR_BUFFER_OUT_OF_BOUNDS(); | |
throw new u.ERR_OUT_OF_RANGE(r2 || "offset", `>= ${r2 ? 1 : 0} and <= ${t2}`, e2); | |
} | |
E("ERR_BUFFER_OUT_OF_BOUNDS", function(e2) { | |
return e2 ? `${e2} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds"; | |
}, RangeError), E("ERR_INVALID_ARG_TYPE", function(e2, t2) { | |
return `The "${e2}" argument must be of type number. Received type ${typeof t2}`; | |
}, TypeError), E("ERR_OUT_OF_RANGE", function(e2, t2, r2) { | |
let n2 = `The value of "${e2}" is out of range.`, i2 = r2; | |
return Number.isInteger(r2) && Math.abs(r2) > 2 ** 32 ? i2 = addNumericalSeparator(String(r2)) : "bigint" == typeof r2 && (i2 = String(r2), (r2 > BigInt(2) ** BigInt(32) || r2 < -(BigInt(2) ** BigInt(32))) && (i2 = addNumericalSeparator(i2)), i2 += "n"), n2 += ` It must be ${t2}. Received ${i2}`, n2; | |
}, RangeError); | |
const m = /[^\w+/-]/g; | |
function utf8ToBytes(e2, t2) { | |
let r2; | |
t2 = t2 || Number.POSITIVE_INFINITY; | |
const n2 = e2.length; | |
let i2 = null; | |
const a2 = []; | |
for (let c2 = 0; c2 < n2; ++c2) { | |
if (r2 = e2.charCodeAt(c2), r2 > 55295 && r2 < 57344) { | |
if (!i2) { | |
if (r2 > 56319) { | |
(t2 -= 3) > -1 && a2.push(239, 191, 189); | |
continue; | |
} | |
if (c2 + 1 === n2) { | |
(t2 -= 3) > -1 && a2.push(239, 191, 189); | |
continue; | |
} | |
i2 = r2; | |
continue; | |
} | |
if (r2 < 56320) { | |
(t2 -= 3) > -1 && a2.push(239, 191, 189), i2 = r2; | |
continue; | |
} | |
r2 = 65536 + (i2 - 55296 << 10 | r2 - 56320); | |
} else | |
i2 && (t2 -= 3) > -1 && a2.push(239, 191, 189); | |
if (i2 = null, r2 < 128) { | |
if ((t2 -= 1) < 0) | |
break; | |
a2.push(r2); | |
} else if (r2 < 2048) { | |
if ((t2 -= 2) < 0) | |
break; | |
a2.push(r2 >> 6 | 192, 63 & r2 | 128); | |
} else if (r2 < 65536) { | |
if ((t2 -= 3) < 0) | |
break; | |
a2.push(r2 >> 12 | 224, r2 >> 6 & 63 | 128, 63 & r2 | 128); | |
} else { | |
if (!(r2 < 1114112)) | |
throw new Error("Invalid code point"); | |
if ((t2 -= 4) < 0) | |
break; | |
a2.push(r2 >> 18 | 240, r2 >> 12 & 63 | 128, r2 >> 6 & 63 | 128, 63 & r2 | 128); | |
} | |
} | |
return a2; | |
} | |
function base64ToBytes(e2) { | |
return toByteArray(function(e3) { | |
if ((e3 = (e3 = e3.split("=")[0]).trim().replace(m, "")).length < 2) | |
return ""; | |
for (; e3.length % 4 != 0; ) | |
e3 += "="; | |
return e3; | |
}(e2)); | |
} | |
function blitBuffer(e2, t2, r2, n2) { | |
let i2; | |
for (i2 = 0; i2 < n2 && !(i2 + r2 >= t2.length || i2 >= e2.length); ++i2) | |
t2[i2 + r2] = e2[i2]; | |
return i2; | |
} | |
function isInstance(e2, t2) { | |
return e2 instanceof t2 || null != e2 && null != e2.constructor && null != e2.constructor.name && e2.constructor.name === t2.name; | |
} | |
function numberIsNaN(e2) { | |
return e2 != e2; | |
} | |
const g = function() { | |
const e2 = "0123456789abcdef", t2 = Array.from({ length: 256 }); | |
for (let r2 = 0; r2 < 16; ++r2) { | |
const n2 = 16 * r2; | |
for (let i2 = 0; i2 < 16; ++i2) | |
t2[n2 + i2] = e2[r2] + e2[i2]; | |
} | |
return t2; | |
}(); | |
function defineBigIntMethod(e2) { | |
return "undefined" == typeof BigInt ? BufferBigIntNotDefined : e2; | |
} | |
function BufferBigIntNotDefined() { | |
throw new Error("BigInt not supported"); | |
} | |
const b = globalThis.Buffer || Buffer$1; | |
notImplemented("buffer.resolveObjectURL"), notImplemented("buffer.transcode"), notImplemented("buffer.isUtf8"), notImplemented("buffer.isAscii"); | |
const x = {}; | |
let C, A; | |
function defaultSetTimeout() { | |
throw new Error("setTimeout has not been defined"); | |
} | |
function defaultClearTimeout() { | |
throw new Error("clearTimeout has not been defined"); | |
} | |
function runTimeout(e2) { | |
if (C === setTimeout) | |
return setTimeout(e2, 0); | |
if ((C === defaultSetTimeout || !C) && setTimeout) | |
return C = setTimeout, setTimeout(e2, 0); | |
try { | |
return C(e2, 0); | |
} catch { | |
try { | |
return C.call(null, e2, 0); | |
} catch { | |
return C.call(this, e2, 0); | |
} | |
} | |
} | |
!function() { | |
try { | |
C = "function" == typeof setTimeout ? setTimeout : defaultSetTimeout; | |
} catch { | |
C = defaultSetTimeout; | |
} | |
try { | |
A = "function" == typeof clearTimeout ? clearTimeout : defaultClearTimeout; | |
} catch { | |
A = defaultClearTimeout; | |
} | |
}(); | |
let P, T = [], _ = false, I = -1; | |
function cleanUpNextTick() { | |
_ && P && (_ = false, P.length > 0 ? T = [...P, ...T] : I = -1, T.length > 0 && drainQueue()); | |
} | |
function drainQueue() { | |
if (_) | |
return; | |
const e2 = runTimeout(cleanUpNextTick); | |
_ = true; | |
let t2 = T.length; | |
for (; t2; ) { | |
for (P = T, T = []; ++I < t2; ) | |
P && P[I].run(); | |
I = -1, t2 = T.length; | |
} | |
P = null, _ = false, function(e3) { | |
if (A === clearTimeout) | |
return clearTimeout(e3); | |
if ((A === defaultClearTimeout || !A) && clearTimeout) | |
return A = clearTimeout, clearTimeout(e3); | |
try { | |
return A(e3); | |
} catch { | |
try { | |
return A.call(null, e3); | |
} catch { | |
return A.call(this, e3); | |
} | |
} | |
}(e2); | |
} | |
function Item(e2, t2) { | |
this.fun = e2, this.array = t2; | |
} | |
x.nextTick = function(e2) { | |
const t2 = Array.from({ length: arguments.length - 1 }); | |
if (arguments.length > 1) | |
for (let e3 = 1; e3 < arguments.length; e3++) | |
t2[e3 - 1] = arguments[e3]; | |
T.push(new Item(e2, t2)), 1 !== T.length || _ || runTimeout(drainQueue); | |
}, Item.prototype.run = function() { | |
this.fun.apply(null, this.array); | |
}, x.title = "unenv"; | |
const D = /* @__PURE__ */ Object.create(null), N = globalThis.process?.env, _getEnv$1 = (e2) => N || globalThis.__env__ || (e2 ? D : globalThis); | |
function noop$2() { | |
return x; | |
} | |
x.env = new Proxy(D, { get: (e2, t2) => _getEnv$1()[t2] ?? D[t2], has: (e2, t2) => t2 in _getEnv$1() || t2 in D, set: (e2, t2, r2) => (_getEnv$1(true)[t2] = r2, true), deleteProperty(e2, t2) { | |
delete _getEnv$1(true)[t2]; | |
}, ownKeys() { | |
const e2 = _getEnv$1(); | |
return Object.keys(e2); | |
} }), x.argv = [], x.version = "", x.versions = {}, x.on = noop$2, x.addListener = noop$2, x.once = noop$2, x.off = noop$2, x.removeListener = noop$2, x.removeAllListeners = noop$2, x.emit = noop$2, x.prependListener = noop$2, x.prependOnceListener = noop$2, x.listeners = function(e2) { | |
return []; | |
}, x.binding = function(e2) { | |
throw new Error("[unenv] process.binding is not supported"); | |
}; | |
let O = "/"; | |
x.cwd = function() { | |
return O; | |
}, x.chdir = function(e2) { | |
O = e2; | |
}, x.umask = function() { | |
return 0; | |
}; | |
const L = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : "undefined" != typeof global ? global : {}; | |
L.process = L.process || x; | |
const R = L.process; | |
var M = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}; | |
function getDefaultExportFromCjs(e2) { | |
return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2; | |
} | |
function getDefaultExportFromNamespaceIfNotNamed(e2) { | |
return e2 && Object.prototype.hasOwnProperty.call(e2, "default") && 1 === Object.keys(e2).length ? e2.default : e2; | |
} | |
var F = { exports: {} }, B = F.exports; | |
Object.defineProperty(B, "__esModule", { value: true }), F.exports = void 0; | |
const fn$1 = function() { | |
}; | |
var $ = function createMock$1(e2, t2 = {}) { | |
fn$1.prototype.name = e2; | |
const r2 = {}; | |
return new Proxy(fn$1, { get: (n2, i2) => "caller" === i2 ? null : "__createMock__" === i2 ? createMock$1 : "__unenv__" === i2 || (i2 in t2 ? t2[i2] : r2[i2] = r2[i2] || createMock$1(`${e2}.${i2.toString()}`)), apply: (t3, r3, n2) => createMock$1(`${e2}()`), construct: (t3, r3, n2) => createMock$1(`[${e2}]`), enumerate: () => [] }); | |
}("mock"); | |
F.exports = $; | |
var U = F.exports; | |
const H = getDefaultExportFromCjs(U); | |
var V, z = {}; | |
function requireUtils() { | |
if (V) | |
return z; | |
return V = 1, Object.defineProperty(z, "__esModule", { value: true }), z.mergeFns = function(...e2) { | |
return function(...t2) { | |
for (const r2 of e2) | |
r2(...t2); | |
}; | |
}, z.notImplemented = function(e2) { | |
return Object.assign(() => { | |
throw new Error(`[unenv] ${e2} is not implemented yet!`); | |
}, { __unenv__: true }); | |
}, z.notImplementedClass = function(e2) { | |
return class { | |
__unenv__ = true; | |
constructor() { | |
throw new Error(`[unenv] ${e2} is not implemented yet!`); | |
} | |
}; | |
}, z.rawHeaders = function(e2) { | |
const t2 = []; | |
for (const r2 in e2) | |
if (Array.isArray(e2[r2])) | |
for (const n2 of e2[r2]) | |
t2.push(r2, n2); | |
else | |
t2.push(r2, e2[r2]); | |
return t2; | |
}, z; | |
} | |
var q = {}, W = { exports: {} }; | |
function Mime$1() { | |
this._types = /* @__PURE__ */ Object.create(null), this._extensions = /* @__PURE__ */ Object.create(null); | |
for (let e2 = 0; e2 < arguments.length; e2++) | |
this.define(arguments[e2]); | |
this.define = this.define.bind(this), this.getType = this.getType.bind(this), this.getExtension = this.getExtension.bind(this); | |
} | |
Mime$1.prototype.define = function(e2, t2) { | |
for (let r2 in e2) { | |
let n2 = e2[r2].map(function(e3) { | |
return e3.toLowerCase(); | |
}); | |
r2 = r2.toLowerCase(); | |
for (let e3 = 0; e3 < n2.length; e3++) { | |
const i2 = n2[e3]; | |
if ("*" !== i2[0]) { | |
if (!t2 && i2 in this._types) | |
throw new Error('Attempt to change mapping for "' + i2 + '" extension from "' + this._types[i2] + '" to "' + r2 + '". Pass `force=true` to allow this, otherwise remove "' + i2 + '" from the list of extensions for "' + r2 + '".'); | |
this._types[i2] = r2; | |
} | |
} | |
if (t2 || !this._extensions[r2]) { | |
const e3 = n2[0]; | |
this._extensions[r2] = "*" !== e3[0] ? e3 : e3.substr(1); | |
} | |
} | |
}, Mime$1.prototype.getType = function(e2) { | |
let t2 = (e2 = String(e2)).replace(/^.*[/\\]/, "").toLowerCase(), r2 = t2.replace(/^.*\./, "").toLowerCase(), n2 = t2.length < e2.length; | |
return (r2.length < t2.length - 1 || !n2) && this._types[r2] || null; | |
}, Mime$1.prototype.getExtension = function(e2) { | |
return (e2 = /^\s*([^;\s]*)/.test(e2) && RegExp.$1) && this._extensions[e2.toLowerCase()] || null; | |
}; | |
var K, J = new Mime$1({ "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["js", "mjs"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["mp4s", "m4p"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-signature": ["asc", "sig"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avif": ["avif"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] }), G = W.exports; | |
Object.defineProperty(G, "__esModule", { value: true }), W.exports = void 0; | |
const Z = { ...((K = J) && K.__esModule ? K : { default: K }).default }; | |
Z.lookup = Z.getType, Z.extension = Z.getExtension; | |
const noop$1 = () => { | |
}; | |
Z.define = noop$1, Z.load = noop$1, Z.default_type = "application/octet-stream", Z.charsets = { lookup: () => "UTF-8" }; | |
var Y = Z; | |
W.exports = Y; | |
var X = W.exports, Q = {}; | |
Object.defineProperty(Q, "__esModule", { value: true }), Q.InternalError = Q.NotFoundError = Q.MethodNotAllowedError = Q.KVError = void 0; | |
class KVError extends Error { | |
constructor(e2, t2 = 500) { | |
super(e2), Object.setPrototypeOf(this, new.target.prototype), this.name = KVError.name, this.status = t2; | |
} | |
} | |
Q.KVError = KVError; | |
Q.MethodNotAllowedError = class extends KVError { | |
constructor(e2 = "Not a valid request method", t2 = 405) { | |
super(e2, t2); | |
} | |
}; | |
Q.NotFoundError = class extends KVError { | |
constructor(e2 = "Not Found", t2 = 404) { | |
super(e2, t2); | |
} | |
}; | |
Q.InternalError = class extends KVError { | |
constructor(e2 = "Internal Error in KV Asset Handler", t2 = 500) { | |
super(e2, t2); | |
} | |
}, function(e2) { | |
Object.defineProperty(e2, "__esModule", { value: true }), e2.InternalError = e2.NotFoundError = e2.MethodNotAllowedError = e2.serveSinglePageApp = e2.mapRequestToAsset = e2.getAssetFromKV = void 0; | |
const t2 = X, r2 = Q; | |
Object.defineProperty(e2, "MethodNotAllowedError", { enumerable: true, get: function() { | |
return r2.MethodNotAllowedError; | |
} }), Object.defineProperty(e2, "NotFoundError", { enumerable: true, get: function() { | |
return r2.NotFoundError; | |
} }), Object.defineProperty(e2, "InternalError", { enumerable: true, get: function() { | |
return r2.InternalError; | |
} }); | |
const n2 = { browserTTL: null, edgeTTL: 172800, bypassCache: false }, parseStringAsObject = (e3) => "string" == typeof e3 ? JSON.parse(e3) : e3, i2 = { ASSET_NAMESPACE: "undefined" != typeof __STATIC_CONTENT ? __STATIC_CONTENT : void 0, ASSET_MANIFEST: "undefined" != typeof __STATIC_CONTENT_MANIFEST ? parseStringAsObject(__STATIC_CONTENT_MANIFEST) : {}, cacheControl: n2, defaultMimeType: "text/plain", defaultDocument: "index.html", pathIsEncoded: false, defaultETag: "strong" }; | |
function assignOptions(e3) { | |
return Object.assign({}, i2, e3); | |
} | |
const mapRequestToAsset = (e3, r3) => { | |
r3 = assignOptions(r3); | |
const n3 = new URL(e3.url); | |
let i3 = n3.pathname; | |
return i3.endsWith("/") ? i3 = i3.concat(r3.defaultDocument) : t2.getType(i3) || (i3 = i3.concat("/" + r3.defaultDocument)), n3.pathname = i3, new Request(n3.toString(), e3); | |
}; | |
e2.mapRequestToAsset = mapRequestToAsset, e2.serveSinglePageApp = function(e3, t3) { | |
t3 = assignOptions(t3), e3 = mapRequestToAsset(e3, t3); | |
const r3 = new URL(e3.url); | |
return r3.pathname.endsWith(".html") ? new Request(`${r3.origin}/${t3.defaultDocument}`, e3) : e3; | |
}; | |
e2.getAssetFromKV = async (e3, i3) => { | |
i3 = assignOptions(i3); | |
const a2 = e3.request, c2 = i3.ASSET_NAMESPACE, u2 = parseStringAsObject(i3.ASSET_MANIFEST); | |
if (void 0 === c2) | |
throw new r2.InternalError("there is no KV namespace bound to the script"); | |
const m2 = new URL(a2.url).pathname.replace(/^\/+/, ""); | |
let g2, b2 = i3.pathIsEncoded; | |
if (i3.mapRequestToAsset) | |
g2 = i3.mapRequestToAsset(a2); | |
else if (u2[m2]) | |
g2 = a2; | |
else if (u2[decodeURIComponent(m2)]) | |
b2 = true, g2 = a2; | |
else { | |
const e4 = mapRequestToAsset(a2), t3 = new URL(e4.url).pathname.replace(/^\/+/, ""); | |
u2[decodeURIComponent(t3)] ? (b2 = true, g2 = e4) : g2 = mapRequestToAsset(a2, i3); | |
} | |
if (!["GET", "HEAD"].includes(g2.method)) | |
throw new r2.MethodNotAllowedError(`${g2.method} is not a valid request method`); | |
const x2 = new URL(g2.url); | |
let C2 = (b2 ? decodeURIComponent(x2.pathname) : x2.pathname).replace(/^\/+/, ""); | |
const A2 = caches.default; | |
let P2 = t2.getType(C2) || i3.defaultMimeType; | |
(P2.startsWith("text") || "application/javascript" === P2) && (P2 += "; charset=utf-8"); | |
let T2 = false; | |
void 0 !== u2 && u2[C2] && (C2 = u2[C2], T2 = true); | |
let _2 = new Request(`${x2.origin}/${C2}`, a2); | |
const I2 = (() => { | |
switch (typeof i3.cacheControl) { | |
case "function": | |
return i3.cacheControl(a2); | |
case "object": | |
return i3.cacheControl; | |
default: | |
return n2; | |
} | |
})(), formatETag = (e4 = C2, t3 = i3.defaultETag) => { | |
if (!e4) | |
return ""; | |
switch (t3) { | |
case "weak": | |
return e4.startsWith("W/") ? e4 : e4.startsWith('"') && e4.endsWith('"') ? `W/${e4}` : `W/"${e4}"`; | |
case "strong": | |
return e4.startsWith('W/"') && (e4 = e4.replace("W/", "")), e4.endsWith('"') || (e4 = `"${e4}"`), e4; | |
default: | |
return ""; | |
} | |
}; | |
i3.cacheControl = Object.assign({}, n2, I2), (i3.cacheControl.bypassCache || null === i3.cacheControl.edgeTTL || "HEAD" == a2.method) && (T2 = false); | |
const D2 = "number" == typeof i3.cacheControl.browserTTL; | |
let N2 = null; | |
if (T2 && (N2 = await A2.match(_2)), N2) | |
if (N2.status > 300 && N2.status < 400) | |
N2.body && "cancel" in Object.getPrototypeOf(N2.body) && N2.body.cancel(), N2 = new Response(null, N2); | |
else { | |
let e4 = { headers: new Headers(N2.headers), status: 0, statusText: "" }; | |
e4.headers.set("cf-cache-status", "HIT"), N2.status ? (e4.status = N2.status, e4.statusText = N2.statusText) : e4.headers.has("Content-Range") ? (e4.status = 206, e4.statusText = "Partial Content") : (e4.status = 200, e4.statusText = "OK"), N2 = new Response(N2.body, e4); | |
} | |
else { | |
const t3 = await c2.get(C2, "arrayBuffer"); | |
if (null === t3) | |
throw new r2.NotFoundError(`could not find ${C2} in your content namespace`); | |
N2 = new Response(t3), T2 && (N2.headers.set("Accept-Ranges", "bytes"), N2.headers.set("Content-Length", String(t3.byteLength)), N2.headers.has("etag") || N2.headers.set("etag", formatETag(C2)), N2.headers.set("Cache-Control", `max-age=${i3.cacheControl.edgeTTL}`), e3.waitUntil(A2.put(_2, N2.clone())), N2.headers.set("CF-Cache-Status", "MISS")); | |
} | |
if (N2.headers.set("Content-Type", P2), 304 === N2.status) { | |
let e4 = formatETag(N2.headers.get("etag")), t3 = _2.headers.get("if-none-match"), r3 = N2.headers.get("CF-Cache-Status"); | |
e4 && (t3 && t3 === e4 && "MISS" === r3 ? N2.headers.set("CF-Cache-Status", "EXPIRED") : N2.headers.set("CF-Cache-Status", "REVALIDATED"), N2.headers.set("etag", formatETag(e4, "weak"))); | |
} | |
return D2 ? N2.headers.set("Cache-Control", `max-age=${i3.cacheControl.browserTTL}`) : N2.headers.delete("Cache-Control"), N2; | |
}; | |
}(q); | |
const ee = /#/g, te = /&/g, re = /=/g, ne = /\+/g, se = /%5e/gi, ie = /%60/gi, oe = /%7c/gi, ae = /%20/gi; | |
function encodeQueryValue$1(e2) { | |
return (t2 = "string" == typeof e2 ? e2 : JSON.stringify(e2), encodeURI("" + t2).replace(oe, "|")).replace(ne, "%2B").replace(ae, "+").replace(ee, "%23").replace(te, "%26").replace(ie, "`").replace(se, "^"); | |
var t2; | |
} | |
function encodeQueryKey$1(e2) { | |
return encodeQueryValue$1(e2).replace(re, "%3D"); | |
} | |
function decode$6(e2 = "") { | |
try { | |
return decodeURIComponent("" + e2); | |
} catch { | |
return "" + e2; | |
} | |
} | |
function decodeQueryValue(e2) { | |
return decode$6(e2.replace(ne, " ")); | |
} | |
function parseQuery$1(e2 = "") { | |
const t2 = {}; | |
"?" === e2[0] && (e2 = e2.slice(1)); | |
for (const r2 of e2.split("&")) { | |
const e3 = r2.match(/([^=]+)=?(.*)/) || []; | |
if (e3.length < 2) | |
continue; | |
const n2 = decode$6(e3[1].replace(ne, " ")); | |
if ("__proto__" === n2 || "constructor" === n2) | |
continue; | |
const i2 = decodeQueryValue(e3[2] || ""); | |
void 0 === t2[n2] ? t2[n2] = i2 : Array.isArray(t2[n2]) ? t2[n2].push(i2) : t2[n2] = [t2[n2], i2]; | |
} | |
return t2; | |
} | |
function stringifyQuery$1(e2) { | |
return Object.keys(e2).filter((t2) => void 0 !== e2[t2]).map((t2) => { | |
return r2 = t2, "number" != typeof (n2 = e2[t2]) && "boolean" != typeof n2 || (n2 = String(n2)), n2 ? Array.isArray(n2) ? n2.map((e3) => `${encodeQueryKey$1(r2)}=${encodeQueryValue$1(e3)}`).join("&") : `${encodeQueryKey$1(r2)}=${encodeQueryValue$1(n2)}` : encodeQueryKey$1(r2); | |
var r2, n2; | |
}).filter(Boolean).join("&"); | |
} | |
const ce = /^\w{2,}:([/\\]{1,2})/, le = /^\w{2,}:([/\\]{2})?/, pe = /^([/\\]\s*){2,}[^/\\]/; | |
function hasProtocol(e2, t2 = {}) { | |
return "boolean" == typeof t2 && (t2 = { acceptRelative: t2 }), t2.strict ? ce.test(e2) : le.test(e2) || !!t2.acceptRelative && pe.test(e2); | |
} | |
const ue = /\/$|\/\?/; | |
function hasTrailingSlash(e2 = "", t2 = false) { | |
return t2 ? ue.test(e2) : e2.endsWith("/"); | |
} | |
function withoutTrailingSlash(e2 = "", t2 = false) { | |
if (!t2) | |
return (hasTrailingSlash(e2) ? e2.slice(0, -1) : e2) || "/"; | |
if (!hasTrailingSlash(e2, true)) | |
return e2 || "/"; | |
const [r2, ...n2] = e2.split("?"); | |
return (r2.slice(0, -1) || "/") + (n2.length > 0 ? `?${n2.join("?")}` : ""); | |
} | |
function withTrailingSlash(e2 = "", t2 = false) { | |
if (!t2) | |
return e2.endsWith("/") ? e2 : e2 + "/"; | |
if (hasTrailingSlash(e2, true)) | |
return e2 || "/"; | |
const [r2, ...n2] = e2.split("?"); | |
return r2 + "/" + (n2.length > 0 ? `?${n2.join("?")}` : ""); | |
} | |
function withLeadingSlash(e2 = "") { | |
return function(e3 = "") { | |
return e3.startsWith("/"); | |
}(e2) ? e2 : "/" + e2; | |
} | |
function withoutBase(e2, t2) { | |
if (isEmptyURL(t2)) | |
return e2; | |
const r2 = withoutTrailingSlash(t2); | |
if (!e2.startsWith(r2)) | |
return e2; | |
const n2 = e2.slice(r2.length); | |
return "/" === n2[0] ? n2 : "/" + n2; | |
} | |
function withQuery(e2, t2) { | |
const r2 = parseURL$1(e2), n2 = { ...parseQuery$1(r2.search), ...t2 }; | |
return r2.search = stringifyQuery$1(n2), function(e3) { | |
const t3 = e3.pathname + (e3.search ? (e3.search.startsWith("?") ? "" : "?") + e3.search : "") + e3.hash; | |
if (!e3.protocol) | |
return t3; | |
return e3.protocol + "//" + (e3.auth ? e3.auth + "@" : "") + e3.host + t3; | |
}(r2); | |
} | |
function getQuery$1(e2) { | |
return parseQuery$1(parseURL$1(e2).search); | |
} | |
function isEmptyURL(e2) { | |
return !e2 || "/" === e2; | |
} | |
const de = /^\.?\//; | |
function joinURL(e2, ...t2) { | |
let r2 = e2 || ""; | |
for (const e3 of t2.filter((e4) => function(e5) { | |
return e5 && "/" !== e5; | |
}(e4))) | |
if (r2) { | |
const t3 = e3.replace(de, ""); | |
r2 = withTrailingSlash(r2) + t3; | |
} else | |
r2 = e3; | |
return r2; | |
} | |
function parseURL$1(e2 = "", t2) { | |
if (!hasProtocol(e2, { acceptRelative: true })) | |
return t2 ? parseURL$1(t2 + e2) : parsePath(e2); | |
const [r2 = "", n2, i2 = ""] = (e2.replace(/\\/g, "/").match(/([^/:]+:)?\/\/([^/@]+@)?(.*)/) || []).splice(1), [a2 = "", c2 = ""] = (i2.match(/([^#/?]*)(.*)?/) || []).splice(1), { pathname: u2, search: m2, hash: g2 } = parsePath(c2.replace(/\/(?=[A-Za-z]:)/, "")); | |
return { protocol: r2, auth: n2 ? n2.slice(0, Math.max(0, n2.length - 1)) : "", host: a2, pathname: u2, search: m2, hash: g2 }; | |
} | |
function parsePath(e2 = "") { | |
const [t2 = "", r2 = "", n2 = ""] = (e2.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1); | |
return { pathname: t2, search: r2, hash: n2 }; | |
} | |
function tryDecode$1(e2, t2) { | |
try { | |
return t2(e2); | |
} catch { | |
return e2; | |
} | |
} | |
function decode$5(e2) { | |
return e2.includes("%") ? decodeURIComponent(e2) : e2; | |
} | |
const he = { NORMAL: 0, WILDCARD: 1, PLACEHOLDER: 2 }; | |
function createRouter$2(e2 = {}) { | |
const t2 = { options: e2, rootNode: createRadixNode(), staticRoutesMap: {} }, normalizeTrailingSlash = (t3) => e2.strictTrailingSlash ? t3 : t3.replace(/\/$/, "") || "/"; | |
if (e2.routes) | |
for (const r2 in e2.routes) | |
insert(t2, normalizeTrailingSlash(r2), e2.routes[r2]); | |
return { ctx: t2, lookup: (e3) => function(e4, t3) { | |
const r2 = e4.staticRoutesMap[t3]; | |
if (r2) | |
return r2.data; | |
const n2 = t3.split("/"), i2 = {}; | |
let a2 = false, c2 = null, u2 = e4.rootNode, m2 = null; | |
for (let e5 = 0; e5 < n2.length; e5++) { | |
const t4 = n2[e5]; | |
null !== u2.wildcardChildNode && (c2 = u2.wildcardChildNode, m2 = n2.slice(e5).join("/")); | |
const r3 = u2.children.get(t4); | |
if (void 0 !== r3) | |
u2 = r3; | |
else { | |
if (u2 = u2.placeholderChildNode, null === u2) | |
break; | |
i2[u2.paramName] = t4, a2 = true; | |
} | |
} | |
null !== u2 && null !== u2.data || null === c2 || (u2 = c2, i2[u2.paramName || "_"] = m2, a2 = true); | |
if (!u2) | |
return null; | |
if (a2) | |
return { ...u2.data, params: a2 ? i2 : void 0 }; | |
return u2.data; | |
}(t2, normalizeTrailingSlash(e3)), insert: (e3, r2) => insert(t2, normalizeTrailingSlash(e3), r2), remove: (e3) => function(e4, t3) { | |
let r2 = false; | |
const n2 = t3.split("/"); | |
let i2 = e4.rootNode; | |
for (const e5 of n2) | |
if (i2 = i2.children.get(e5), !i2) | |
return r2; | |
if (i2.data) { | |
const e5 = n2[n2.length - 1]; | |
if (i2.data = null, 0 === Object.keys(i2.children).length) { | |
const t4 = i2.parent; | |
t4.children.delete(e5), t4.wildcardChildNode = null, t4.placeholderChildNode = null; | |
} | |
r2 = true; | |
} | |
return r2; | |
}(t2, normalizeTrailingSlash(e3)) }; | |
} | |
function insert(e2, t2, r2) { | |
let n2 = true; | |
const i2 = t2.split("/"); | |
let a2 = e2.rootNode, c2 = 0; | |
for (const e3 of i2) { | |
let t3; | |
if (t3 = a2.children.get(e3)) | |
a2 = t3; | |
else { | |
const r3 = getNodeType(e3); | |
t3 = createRadixNode({ type: r3, parent: a2 }), a2.children.set(e3, t3), r3 === he.PLACEHOLDER ? (t3.paramName = "*" === e3 ? "_" + c2++ : e3.slice(1), a2.placeholderChildNode = t3, n2 = false) : r3 === he.WILDCARD && (a2.wildcardChildNode = t3, t3.paramName = e3.slice(3) || "_", n2 = false), a2 = t3; | |
} | |
} | |
return a2.data = r2, true === n2 && (e2.staticRoutesMap[t2] = a2), a2; | |
} | |
function createRadixNode(e2 = {}) { | |
return { type: e2.type || he.NORMAL, parent: e2.parent || null, children: /* @__PURE__ */ new Map(), data: e2.data || null, paramName: e2.paramName || null, wildcardChildNode: null, placeholderChildNode: null }; | |
} | |
function getNodeType(e2) { | |
return e2.startsWith("**") ? he.WILDCARD : ":" === e2[0] || "*" === e2 ? he.PLACEHOLDER : he.NORMAL; | |
} | |
function toRouteMatcher(e2) { | |
return function(e3) { | |
return { ctx: { table: e3 }, matchAll: (t2) => _matchRoutes(t2, e3) }; | |
}(_routerNodeToTable("", e2.ctx.rootNode)); | |
} | |
function _matchRoutes(e2, t2) { | |
const r2 = []; | |
for (const [n3, i2] of _sortRoutesMap(t2.wildcard)) | |
e2.startsWith(n3) && r2.push(i2); | |
for (const [n3, i2] of _sortRoutesMap(t2.dynamic)) | |
if (e2.startsWith(n3 + "/")) { | |
const t3 = "/" + e2.slice(n3.length).split("/").splice(2).join("/"); | |
r2.push(..._matchRoutes(t3, i2)); | |
} | |
const n2 = t2.static.get(e2); | |
return n2 && r2.push(n2), r2.filter(Boolean); | |
} | |
function _sortRoutesMap(e2) { | |
return [...e2.entries()].sort((e3, t2) => e3[0].length - t2[0].length); | |
} | |
function _routerNodeToTable(e2, t2) { | |
const r2 = { static: /* @__PURE__ */ new Map(), wildcard: /* @__PURE__ */ new Map(), dynamic: /* @__PURE__ */ new Map() }; | |
return function _addNode(e3, t3) { | |
if (e3) | |
if (t3.type !== he.NORMAL || e3.includes("*") || e3.includes(":")) { | |
if (t3.type === he.WILDCARD) | |
r2.wildcard.set(e3.replace("/**", ""), t3.data); | |
else if (t3.type === he.PLACEHOLDER) { | |
const n2 = _routerNodeToTable("", t3); | |
return t3.data && n2.static.set("/", t3.data), void r2.dynamic.set(e3.replace(/\/\*|\/:\w+/, ""), n2); | |
} | |
} else | |
r2.static.set(e3, t3.data); | |
for (const [r3, n2] of t3.children.entries()) | |
_addNode(`${e3}/${r3}`.replace("//", "/"), n2); | |
}(e2, t2), r2; | |
} | |
const fe = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/, me = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/, ge = /^\s*["[{]|^\s*-?\d[\d.]{0,14}\s*$/; | |
function jsonParseTransform(e2, t2) { | |
if (!("__proto__" === e2 || "constructor" === e2 && t2 && "object" == typeof t2 && "prototype" in t2)) | |
return t2; | |
!function(e3) { | |
console.warn(`[destr] Dropping "${e3}" key to prevent prototype pollution.`); | |
}(e2); | |
} | |
function destr(e2, t2 = {}) { | |
if ("string" != typeof e2) | |
return e2; | |
const r2 = e2.trim(); | |
if ('"' === e2[0] && '"' === e2[e2.length - 1]) | |
return r2.slice(1, -1); | |
if (r2.length <= 9) { | |
const e3 = r2.toLowerCase(); | |
if ("true" === e3) | |
return true; | |
if ("false" === e3) | |
return false; | |
if ("undefined" === e3) | |
return; | |
if ("null" === e3) | |
return null; | |
if ("nan" === e3) | |
return Number.NaN; | |
if ("infinity" === e3) | |
return Number.POSITIVE_INFINITY; | |
if ("-infinity" === e3) | |
return Number.NEGATIVE_INFINITY; | |
} | |
if (!ge.test(e2)) { | |
if (t2.strict) | |
throw new SyntaxError("[destr] Invalid JSON"); | |
return e2; | |
} | |
try { | |
if (fe.test(e2) || me.test(e2)) { | |
if (t2.strict) | |
throw new Error("[destr] Possible prototype pollution"); | |
return JSON.parse(e2, jsonParseTransform); | |
} | |
return JSON.parse(e2); | |
} catch (r3) { | |
if (t2.strict) | |
throw r3; | |
return e2; | |
} | |
} | |
function isObject$3(e2) { | |
return null !== e2 && "object" == typeof e2; | |
} | |
function _defu(e2, t2, r2 = ".", n2) { | |
if (!isObject$3(t2)) | |
return _defu(e2, {}, r2, n2); | |
const i2 = Object.assign({}, t2); | |
for (const t3 in e2) { | |
if ("__proto__" === t3 || "constructor" === t3) | |
continue; | |
const a2 = e2[t3]; | |
null != a2 && (n2 && n2(i2, t3, a2, r2) || (Array.isArray(a2) && Array.isArray(i2[t3]) ? i2[t3] = [...a2, ...i2[t3]] : isObject$3(a2) && isObject$3(i2[t3]) ? i2[t3] = _defu(a2, i2[t3], (r2 ? `${r2}.` : "") + t3.toString(), n2) : i2[t3] = a2)); | |
} | |
return i2; | |
} | |
function createDefu(e2) { | |
return (...t2) => t2.reduce((t3, r2) => _defu(t3, r2, "", e2), {}); | |
} | |
const ye = createDefu(), be = createDefu((e2, t2, r2) => { | |
if (void 0 !== e2[t2] && "function" == typeof r2) | |
return e2[t2] = r2(e2[t2]), true; | |
}), ve = globalThis.crypto?.subtle, randomUUID = () => globalThis.crypto?.randomUUID(), getRandomValues = (e2) => globalThis.crypto?.getRandomValues(e2), xe = Object.freeze(Object.defineProperty({ __proto__: null, getRandomValues, randomUUID, subtle: ve }, Symbol.toStringTag, { value: "Module" })), we = new Proxy(globalThis.crypto, { get: (e2, t2) => "CryptoKey" === t2 ? globalThis.CryptoKey : globalThis.crypto[t2] }), randomBytes$1 = (e2, t2) => { | |
const r2 = b.alloc(e2, 0, void 0); | |
for (let t3 = 0; t3 < e2; t3 += 65536) | |
getRandomValues(Uint8Array.prototype.slice.call(r2, t3, t3 + 65536)); | |
if ("function" != typeof t2) | |
return r2; | |
t2(null, r2); | |
}, Ce = {}, Ee = notImplemented("crypto.checkPrime"), Se = notImplemented("crypto.checkPrimeSync"), Ae = notImplemented("crypto.createCipher"), ke = notImplemented("crypto.createDecipher"), Pe = notImplemented("crypto.pseudoRandomBytes"), Te = notImplemented("crypto.createCipheriv"), _e = notImplemented("crypto.createDecipheriv"), Ie = notImplemented("crypto.createDiffieHellman"), De = notImplemented("crypto.createDiffieHellmanGroup"), Ne = notImplemented("crypto.createECDH"), Oe = notImplemented("crypto.createHash"), Le = notImplemented("crypto.createHmac"), Re = notImplemented("crypto.createPrivateKey"), Me = notImplemented("crypto.createPublicKey"), Fe = notImplemented("crypto.createSecretKey"), Be = notImplemented("crypto.createSign"), je = notImplemented("crypto.createVerify"), $e = notImplemented("crypto.diffieHellman"), Ue = notImplemented("crypto.generatePrime"), He = notImplemented("crypto.generatePrimeSync"), Ve = notImplemented("crypto.getCiphers"), ze = notImplemented("crypto.getCipherInfo"), qe = notImplemented("crypto.getCurves"), We = notImplemented("crypto.getDiffieHellman"), Ke = notImplemented("crypto.getHashes"), Je = notImplemented("crypto.hkdf"), Ge = notImplemented("crypto.hkdfSync"), Ze = notImplemented("crypto.pbkdf2"), Ye = notImplemented("crypto.pbkdf2Sync"), Xe = notImplemented("crypto.generateKeyPair"), Qe = notImplemented("crypto.generateKeyPairSync"), et = notImplemented("crypto.generateKey"), tt = notImplemented("crypto.generateKeySync"), rt = notImplemented("crypto.privateDecrypt"), nt = notImplemented("crypto.privateEncrypt"), st = notImplemented("crypto.publicDecrypt"), it = notImplemented("crypto.publicEncrypt"), ot = notImplemented("crypto.randomFill"), at = notImplemented("crypto.randomFillSync"), ct = notImplemented("crypto.randomInt"), lt = notImplemented("crypto.scrypt"), pt = notImplemented("crypto.scryptSync"), ut = notImplemented("crypto.sign"), dt = notImplemented("crypto.setEngine"), ht = notImplemented("crypto.timingSafeEqual"), ft = notImplemented("crypto.getFips"), mt = notImplemented("crypto.setFips"), gt = notImplemented("crypto.verify"), yt = notImplemented("crypto.secureHeapUsed"), bt = notImplementedClass("crypto.Certificate"), vt = notImplementedClass("crypto.Cipher"), xt = notImplementedClass("crypto.Cipheriv"), wt = notImplementedClass("crypto.Decipher"), Ct = notImplementedClass("crypto.Decipheriv"), Et = notImplementedClass("crypto.DiffieHellman"), St = notImplementedClass("crypto.DiffieHellmanGroup"), At = notImplementedClass("crypto.ECDH"), kt = notImplementedClass("crypto.Hash"), Pt = notImplementedClass("crypto.Hmac"), Tt = notImplementedClass("crypto.KeyObject"), _t = notImplementedClass("crypto.Sign"), It = notImplementedClass("crypto.Verify"), Dt = notImplementedClass("crypto.X509Certificate"), Nt = { ...xe, ...Object.freeze(Object.defineProperty({ __proto__: null, Certificate: bt, Cipher: vt, Cipheriv: xt, Decipher: wt, Decipheriv: Ct, DiffieHellman: Et, DiffieHellmanGroup: St, ECDH: At, Hash: kt, Hmac: Pt, KeyObject: Tt, Sign: _t, Verify: It, X509Certificate: Dt, checkPrime: Ee, checkPrimeSync: Se, constants: Ce, createCipher: Ae, createCipheriv: Te, createDecipher: ke, createDecipheriv: _e, createDiffieHellman: Ie, createDiffieHellmanGroup: De, createECDH: Ne, createHash: Oe, createHmac: Le, createPrivateKey: Re, createPublicKey: Me, createSecretKey: Fe, createSign: Be, createVerify: je, diffieHellman: $e, fips: false, generateKey: et, generateKeyPair: Xe, generateKeyPairSync: Qe, generateKeySync: tt, generatePrime: Ue, generatePrimeSync: He, getCipherInfo: ze, getCiphers: Ve, getCurves: qe, getDiffieHellman: We, getFips: ft, getHashes: Ke, hkdf: Je, hkdfSync: Ge, pbkdf2: Ze, pbkdf2Sync: Ye, privateDecrypt: rt, privateEncrypt: nt, pseudoRandomBytes: Pe, publicDecrypt: st, publicEncrypt: it, randomBytes: randomBytes$1, randomFill: ot, randomFillSync: at, randomInt: ct, scrypt: lt, scryptSync: pt, secureHeapUsed: yt, setEngine: dt, setFips: mt, sign: ut, timingSafeEqual: ht, verify: gt, webcrypto: we }, Symbol.toStringTag, { value: "Module" })) }, Ot = Object.freeze(Object.defineProperty({ __proto__: null, Certificate: bt, Cipher: vt, Cipheriv: xt, Decipher: wt, Decipheriv: Ct, DiffieHellman: Et, DiffieHellmanGroup: St, ECDH: At, Hash: kt, Hmac: Pt, KeyObject: Tt, Sign: _t, Verify: It, X509Certificate: Dt, checkPrime: Ee, checkPrimeSync: Se, constants: Ce, createCipher: Ae, createCipheriv: Te, createDecipher: ke, createDecipheriv: _e, createDiffieHellman: Ie, createDiffieHellmanGroup: De, createECDH: Ne, createHash: Oe, createHmac: Le, createPrivateKey: Re, createPublicKey: Me, createSecretKey: Fe, createSign: Be, createVerify: je, default: Nt, diffieHellman: $e, fips: false, generateKey: et, generateKeyPair: Xe, generateKeyPairSync: Qe, generateKeySync: tt, generatePrime: Ue, generatePrimeSync: He, getCipherInfo: ze, getCiphers: Ve, getCurves: qe, getDiffieHellman: We, getFips: ft, getHashes: Ke, getRandomValues, hkdf: Je, hkdfSync: Ge, pbkdf2: Ze, pbkdf2Sync: Ye, privateDecrypt: rt, privateEncrypt: nt, pseudoRandomBytes: Pe, publicDecrypt: st, publicEncrypt: it, randomBytes: randomBytes$1, randomFill: ot, randomFillSync: at, randomInt: ct, randomUUID, scrypt: lt, scryptSync: pt, secureHeapUsed: yt, setEngine: dt, setFips: mt, sign: ut, subtle: ve, timingSafeEqual: ht, verify: gt, webcrypto: we }, Symbol.toStringTag, { value: "Module" })); | |
let Lt = 10, Rt = class { | |
__unenv__ = true; | |
_events = /* @__PURE__ */ Object.create(null); | |
_maxListeners; | |
static get defaultMaxListeners() { | |
return Lt; | |
} | |
static set defaultMaxListeners(e2) { | |
if ("number" != typeof e2 || e2 < 0 || Number.isNaN(e2)) | |
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + e2 + "."); | |
Lt = e2; | |
} | |
setMaxListeners(e2) { | |
if ("number" != typeof e2 || e2 < 0 || Number.isNaN(e2)) | |
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e2 + "."); | |
return this._maxListeners = e2, this; | |
} | |
getMaxListeners() { | |
return _getMaxListeners(this); | |
} | |
emit(e2, ...t2) { | |
if (!this._events[e2] || 0 === this._events[e2].length) | |
return false; | |
if ("error" === e2) { | |
let e3; | |
if (t2.length > 0 && (e3 = t2[0]), e3 instanceof Error) | |
throw e3; | |
const r2 = new Error("Unhandled error." + (e3 ? " (" + e3.message + ")" : "")); | |
throw r2.context = e3, r2; | |
} | |
for (const r2 of this._events[e2]) | |
(r2.listener || r2).apply(this, t2); | |
return true; | |
} | |
addListener(e2, t2) { | |
return _addListener(this, e2, t2, false); | |
} | |
on(e2, t2) { | |
return _addListener(this, e2, t2, false); | |
} | |
prependListener(e2, t2) { | |
return _addListener(this, e2, t2, true); | |
} | |
once(e2, t2) { | |
return this.on(e2, _wrapOnce(this, e2, t2)); | |
} | |
prependOnceListener(e2, t2) { | |
return this.prependListener(e2, _wrapOnce(this, e2, t2)); | |
} | |
removeListener(e2, t2) { | |
return function(e3, t3, r2) { | |
if (_checkListener(r2), !e3._events[t3] || 0 === e3._events[t3].length) | |
return e3; | |
const n2 = e3._events[t3].length; | |
if (e3._events[t3] = e3._events[t3].filter((e4) => e4 !== r2), n2 === e3._events[t3].length) | |
return e3; | |
e3._events.removeListener && e3.emit("removeListener", t3, r2.listener || r2); | |
0 === e3._events[t3].length && delete e3._events[t3]; | |
return e3; | |
}(this, e2, t2); | |
} | |
off(e2, t2) { | |
return this.removeListener(e2, t2); | |
} | |
removeAllListeners(e2) { | |
return function(e3, t2) { | |
if (!e3._events[t2] || 0 === e3._events[t2].length) | |
return e3; | |
if (e3._events.removeListener) | |
for (const r2 of e3._events[t2]) | |
e3.emit("removeListener", t2, r2.listener || r2); | |
return delete e3._events[t2], e3; | |
}(this, e2); | |
} | |
listeners(e2) { | |
return _listeners(this, e2, true); | |
} | |
rawListeners(e2) { | |
return _listeners(this, e2, false); | |
} | |
listenerCount(e2) { | |
return this.rawListeners(e2).length; | |
} | |
eventNames() { | |
return Object.keys(this._events); | |
} | |
}; | |
function _addListener(e2, t2, r2, n2) { | |
_checkListener(r2), void 0 !== e2._events.newListener && e2.emit("newListener", t2, r2.listener || r2), e2._events[t2] || (e2._events[t2] = []), n2 ? e2._events[t2].unshift(r2) : e2._events[t2].push(r2); | |
const i2 = _getMaxListeners(e2); | |
if (i2 > 0 && e2._events[t2].length > i2 && !e2._events[t2].warned) { | |
e2._events[t2].warned = true; | |
const r3 = new Error(`[unenv] Possible EventEmitter memory leak detected. ${e2._events[t2].length} ${t2} listeners added. Use emitter.setMaxListeners() to increase limit`); | |
r3.name = "MaxListenersExceededWarning", r3.emitter = e2, r3.type = t2, r3.count = e2._events[t2]?.length, console.warn(r3); | |
} | |
return e2; | |
} | |
function _wrapOnce(e2, t2, r2) { | |
let n2 = false; | |
const wrapper = (...i2) => { | |
if (!n2) | |
return e2.removeListener(t2, wrapper), n2 = true, 0 === i2.length ? r2.call(e2) : r2.apply(e2, i2); | |
}; | |
return wrapper.listener = r2, wrapper; | |
} | |
function _getMaxListeners(e2) { | |
return e2._maxListeners ?? Rt.defaultMaxListeners; | |
} | |
function _listeners(e2, t2, r2) { | |
let n2 = e2._events[t2]; | |
return "function" == typeof n2 && (n2 = [n2]), r2 ? n2.map((e3) => e3.listener || e3) : n2; | |
} | |
function _checkListener(e2) { | |
if ("function" != typeof e2) | |
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof e2); | |
} | |
const Mt = globalThis.EventEmitter || Rt; | |
class _Readable extends Mt { | |
__unenv__ = true; | |
readableEncoding = null; | |
readableEnded = true; | |
readableFlowing = false; | |
readableHighWaterMark = 0; | |
readableLength = 0; | |
readableObjectMode = false; | |
readableAborted = false; | |
readableDidRead = false; | |
closed = false; | |
errored = null; | |
readable = false; | |
destroyed = false; | |
static from(e2, t2) { | |
return new _Readable(t2); | |
} | |
constructor(e2) { | |
super(); | |
} | |
_read(e2) { | |
} | |
read(e2) { | |
} | |
setEncoding(e2) { | |
return this; | |
} | |
pause() { | |
return this; | |
} | |
resume() { | |
return this; | |
} | |
isPaused() { | |
return true; | |
} | |
unpipe(e2) { | |
return this; | |
} | |
unshift(e2, t2) { | |
} | |
wrap(e2) { | |
return this; | |
} | |
push(e2, t2) { | |
return false; | |
} | |
_destroy(e2, t2) { | |
this.removeAllListeners(); | |
} | |
destroy(e2) { | |
return this.destroyed = true, this._destroy(e2), this; | |
} | |
pipe(e2, t2) { | |
return {}; | |
} | |
async *[Symbol.asyncIterator]() { | |
} | |
compose(e2, t2) { | |
throw new Error("[h3] Method not implemented."); | |
} | |
} | |
const Ft = globalThis.Readable || _Readable; | |
const Bt = globalThis.Writable || class extends Mt { | |
__unenv__ = true; | |
writable = true; | |
writableEnded = false; | |
writableFinished = false; | |
writableHighWaterMark = 0; | |
writableLength = 0; | |
writableObjectMode = false; | |
writableCorked = 0; | |
closed = false; | |
errored = null; | |
writableNeedDrain = false; | |
destroyed = false; | |
_data; | |
_encoding = "utf-8"; | |
constructor(e2) { | |
super(); | |
} | |
pipe(e2, t2) { | |
return {}; | |
} | |
_write(e2, t2, r2) { | |
if (this.writableEnded) | |
r2 && r2(); | |
else { | |
if (void 0 === this._data) | |
this._data = e2; | |
else { | |
const r3 = "string" == typeof this._data ? b.from(this._data, this._encoding || t2 || "utf8") : this._data, n2 = "string" == typeof e2 ? b.from(e2, t2 || this._encoding || "utf8") : e2; | |
this._data = b.concat([r3, n2]); | |
} | |
this._encoding = t2, r2 && r2(); | |
} | |
} | |
_writev(e2, t2) { | |
} | |
_destroy(e2, t2) { | |
} | |
_final(e2) { | |
} | |
write(e2, t2, r2) { | |
const n2 = "string" == typeof t2 ? this._encoding : "utf-8", i2 = "function" == typeof t2 ? t2 : "function" == typeof r2 ? r2 : void 0; | |
return this._write(e2, n2, i2), true; | |
} | |
setDefaultEncoding(e2) { | |
return this; | |
} | |
end(e2, t2, r2) { | |
const n2 = "function" == typeof e2 ? e2 : "function" == typeof t2 ? t2 : "function" == typeof r2 ? r2 : void 0; | |
if (this.writableEnded) | |
return n2 && n2(), this; | |
const i2 = e2 === n2 ? void 0 : e2; | |
if (i2) { | |
const e3 = t2 === n2 ? void 0 : t2; | |
this.write(i2, e3, n2); | |
} | |
return this.writableEnded = true, this.writableFinished = true, this.emit("close"), this.emit("finish"), this; | |
} | |
cork() { | |
} | |
uncork() { | |
} | |
destroy(e2) { | |
return this.destroyed = true, delete this._data, this.removeAllListeners(), this; | |
} | |
compose(e2, t2) { | |
throw new Error("[h3] Method not implemented."); | |
} | |
}, jt = class { | |
allowHalfOpen = true; | |
_destroy; | |
constructor(e2 = new Ft(), t2 = new Bt()) { | |
Object.assign(this, e2), Object.assign(this, t2), this._destroy = function(...e3) { | |
return function(...t3) { | |
for (const r2 of e3) | |
r2(...t3); | |
}; | |
}(e2._destroy, t2._destroy); | |
} | |
}; | |
function getDuplex() { | |
return Object.assign(jt.prototype, Ft.prototype), Object.assign(jt.prototype, Bt.prototype), jt; | |
} | |
const $t = getDuplex(), Ut = globalThis.Duplex || $t; | |
class Socket extends Ut { | |
__unenv__ = true; | |
bufferSize = 0; | |
bytesRead = 0; | |
bytesWritten = 0; | |
connecting = false; | |
destroyed = false; | |
pending = false; | |
localAddress = ""; | |
localPort = 0; | |
remoteAddress = ""; | |
remoteFamily = ""; | |
remotePort = 0; | |
readyState = "readOnly"; | |
constructor(e2) { | |
super(); | |
} | |
write(e2, t2, r2) { | |
return false; | |
} | |
connect(e2, t2, r2) { | |
return this; | |
} | |
end(e2, t2, r2) { | |
return this; | |
} | |
setEncoding(e2) { | |
return this; | |
} | |
pause() { | |
return this; | |
} | |
resume() { | |
return this; | |
} | |
setTimeout(e2, t2) { | |
return this; | |
} | |
setNoDelay(e2) { | |
return this; | |
} | |
setKeepAlive(e2, t2) { | |
return this; | |
} | |
address() { | |
return {}; | |
} | |
unref() { | |
return this; | |
} | |
ref() { | |
return this; | |
} | |
resetAndDestroy() { | |
const e2 = new Error("ERR_SOCKET_CLOSED"); | |
return e2.code = "ERR_SOCKET_CLOSED", this.destroy(e2), this; | |
} | |
} | |
class IncomingMessage extends Ft { | |
__unenv__ = {}; | |
aborted = false; | |
httpVersion = "1.1"; | |
httpVersionMajor = 1; | |
httpVersionMinor = 1; | |
complete = true; | |
connection; | |
socket; | |
headers = {}; | |
trailers = {}; | |
method = "GET"; | |
url = "/"; | |
statusCode = 200; | |
statusMessage = ""; | |
closed = false; | |
errored = null; | |
readable = false; | |
constructor(e2) { | |
super(), this.socket = this.connection = e2 || new Socket(); | |
} | |
get rawHeaders() { | |
return function(e2) { | |
const t2 = []; | |
for (const r2 in e2) | |
if (Array.isArray(e2[r2])) | |
for (const n2 of e2[r2]) | |
t2.push(r2, n2); | |
else | |
t2.push(r2, e2[r2]); | |
return t2; | |
}(this.headers); | |
} | |
get rawTrailers() { | |
return []; | |
} | |
setTimeout(e2, t2) { | |
return this; | |
} | |
get headersDistinct() { | |
return _distinct(this.headers); | |
} | |
get trailersDistinct() { | |
return _distinct(this.trailers); | |
} | |
} | |
function _distinct(e2) { | |
const t2 = {}; | |
for (const [r2, n2] of Object.entries(e2)) | |
r2 && (t2[r2] = (Array.isArray(n2) ? n2 : [n2]).filter(Boolean)); | |
return t2; | |
} | |
class ServerResponse extends Bt { | |
__unenv__ = true; | |
statusCode = 200; | |
statusMessage = ""; | |
upgrading = false; | |
chunkedEncoding = false; | |
shouldKeepAlive = false; | |
useChunkedEncodingByDefault = false; | |
sendDate = false; | |
finished = false; | |
headersSent = false; | |
strictContentLength = false; | |
connection = null; | |
socket = null; | |
req; | |
_headers = {}; | |
constructor(e2) { | |
super(), this.req = e2; | |
} | |
assignSocket(e2) { | |
e2._httpMessage = this, this.socket = e2, this.connection = e2, this.emit("socket", e2), this._flush(); | |
} | |
_flush() { | |
this.flushHeaders(); | |
} | |
detachSocket(e2) { | |
} | |
writeContinue(e2) { | |
} | |
writeHead(e2, t2, r2) { | |
e2 && (this.statusCode = e2), "string" == typeof t2 && (this.statusMessage = t2, t2 = void 0); | |
const n2 = r2 || t2; | |
if (n2) | |
if (Array.isArray(n2)) | |
; | |
else | |
for (const e3 in n2) | |
this.setHeader(e3, n2[e3]); | |
return this.headersSent = true, this; | |
} | |
writeProcessing() { | |
} | |
setTimeout(e2, t2) { | |
return this; | |
} | |
appendHeader(e2, t2) { | |
e2 = e2.toLowerCase(); | |
const r2 = this._headers[e2], n2 = [...Array.isArray(r2) ? r2 : [r2], ...Array.isArray(t2) ? t2 : [t2]].filter(Boolean); | |
return this._headers[e2] = n2.length > 1 ? n2 : n2[0], this; | |
} | |
setHeader(e2, t2) { | |
return this._headers[e2.toLowerCase()] = t2, this; | |
} | |
getHeader(e2) { | |
return this._headers[e2.toLowerCase()]; | |
} | |
getHeaders() { | |
return this._headers; | |
} | |
getHeaderNames() { | |
return Object.keys(this._headers); | |
} | |
hasHeader(e2) { | |
return e2.toLowerCase() in this._headers; | |
} | |
removeHeader(e2) { | |
delete this._headers[e2.toLowerCase()]; | |
} | |
addTrailers(e2) { | |
} | |
flushHeaders() { | |
} | |
writeEarlyHints(e2, t2) { | |
"function" == typeof t2 && t2(); | |
} | |
} | |
class H3Error extends Error { | |
constructor(e2, t2 = {}) { | |
super(e2, t2), this.statusCode = 500, this.fatal = false, this.unhandled = false, t2.cause && !this.cause && (this.cause = t2.cause); | |
} | |
toJSON() { | |
const e2 = { message: this.message, statusCode: sanitizeStatusCode(this.statusCode, 500) }; | |
return this.statusMessage && (e2.statusMessage = sanitizeStatusMessage(this.statusMessage)), void 0 !== this.data && (e2.data = this.data), e2; | |
} | |
} | |
function createError$1(e2) { | |
if ("string" == typeof e2) | |
return new H3Error(e2); | |
if (isError(e2)) | |
return e2; | |
const t2 = new H3Error(e2.message ?? e2.statusMessage ?? "", { cause: e2.cause || e2 }); | |
if ("stack" in e2) | |
try { | |
Object.defineProperty(t2, "stack", { get: () => e2.stack }); | |
} catch { | |
try { | |
t2.stack = e2.stack; | |
} catch { | |
} | |
} | |
if (e2.data && (t2.data = e2.data), e2.statusCode ? t2.statusCode = sanitizeStatusCode(e2.statusCode, t2.statusCode) : e2.status && (t2.statusCode = sanitizeStatusCode(e2.status, t2.statusCode)), e2.statusMessage ? t2.statusMessage = e2.statusMessage : e2.statusText && (t2.statusMessage = e2.statusText), t2.statusMessage) { | |
const e3 = t2.statusMessage; | |
sanitizeStatusMessage(t2.statusMessage) !== e3 && console.warn("[h3] Please prefer using `message` for longer error messages instead of `statusMessage`. In the future, `statusMessage` will be sanitized by default."); | |
} | |
return void 0 !== e2.fatal && (t2.fatal = e2.fatal), void 0 !== e2.unhandled && (t2.unhandled = e2.unhandled), t2; | |
} | |
function isError(e2) { | |
return true === e2?.constructor?.__h3_error__; | |
} | |
function getRequestHeaders(e2) { | |
const t2 = {}; | |
for (const r2 in e2.node.req.headers) { | |
const n2 = e2.node.req.headers[r2]; | |
t2[r2] = Array.isArray(n2) ? n2.filter(Boolean).join(", ") : n2; | |
} | |
return t2; | |
} | |
H3Error.__h3_error__ = true; | |
const Ht = /[/\\]{2,}/g; | |
function getRequestURL(e2, t2 = {}) { | |
const r2 = function(e3, t3 = {}) { | |
if (t3.xForwardedHost) { | |
const t4 = e3.node.req.headers["x-forwarded-host"]; | |
if (t4) | |
return t4; | |
} | |
return e3.node.req.headers.host || "localhost"; | |
}(e2, t2), n2 = function(e3, t3 = {}) { | |
return false !== t3.xForwardedProto && "https" === e3.node.req.headers["x-forwarded-proto"] || e3.node.req.connection.encrypted ? "https" : "http"; | |
}(e2), i2 = function(e3) { | |
const t3 = e3._originalPath; | |
if (t3.includes("?")) { | |
const [e4, r3] = t3.split("?"); | |
return e4.replace(Ht, "/") + "?" + r3; | |
} | |
return t3.replace(Ht, "/"); | |
}(e2); | |
return new URL(i2, `${n2}://${r2}`); | |
} | |
const Vt = Symbol.for("h3RawBody"), zt = ["PATCH", "POST", "PUT", "DELETE"]; | |
function readRawBody(e2, t2 = "utf8") { | |
!function(e3, t3, r3) { | |
if (!function(e4, t4, r4) { | |
if (r4 && "HEAD" === e4.method) | |
return true; | |
if ("string" == typeof t4) { | |
if (e4.method === t4) | |
return true; | |
} else if (t4.includes(e4.method)) | |
return true; | |
return false; | |
}(e3, t3, r3)) | |
throw createError$1({ statusCode: 405, statusMessage: "HTTP method is not allowed." }); | |
}(e2, zt); | |
const r2 = e2.node.req[Vt] || e2.node.req.body; | |
if (r2) { | |
const e3 = Promise.resolve(r2).then((e4) => b.isBuffer(e4) ? e4 : e4.constructor === Object ? b.from(JSON.stringify(e4)) : b.from(e4)); | |
return t2 ? e3.then((e4) => e4.toString(t2)) : e3; | |
} | |
if (!Number.parseInt(e2.node.req.headers["content-length"] || "")) | |
return Promise.resolve(void 0); | |
const n2 = e2.node.req[Vt] = new Promise((t3, r3) => { | |
const n3 = []; | |
e2.node.req.on("error", (e3) => { | |
r3(e3); | |
}).on("data", (e3) => { | |
n3.push(e3); | |
}).on("end", () => { | |
t3(b.concat(n3)); | |
}); | |
}); | |
return t2 ? n2.then((e3) => e3.toString(t2)) : n2; | |
} | |
function handleCacheHeaders(e2, t2) { | |
const r2 = ["public", ...t2.cacheControls || []]; | |
let n2 = false; | |
if (void 0 !== t2.maxAge && r2.push("max-age=" + +t2.maxAge, "s-maxage=" + +t2.maxAge), t2.modifiedTime) { | |
const r3 = new Date(t2.modifiedTime), i2 = e2.node.req.headers["if-modified-since"]; | |
e2.node.res.setHeader("last-modified", r3.toUTCString()), i2 && new Date(i2) >= t2.modifiedTime && (n2 = true); | |
} | |
if (t2.etag) { | |
e2.node.res.setHeader("etag", t2.etag); | |
e2.node.req.headers["if-none-match"] === t2.etag && (n2 = true); | |
} | |
return e2.node.res.setHeader("cache-control", r2.join(", ")), !!n2 && (e2.node.res.statusCode = 304, e2.handled || e2.node.res.end(), true); | |
} | |
const qt = { html: "text/html", json: "application/json" }, Wt = /[^\u0009\u0020-\u007E]/g; | |
function sanitizeStatusMessage(e2 = "") { | |
return e2.replace(Wt, ""); | |
} | |
function sanitizeStatusCode(e2, t2 = 200) { | |
return e2 ? ("string" == typeof e2 && (e2 = Number.parseInt(e2, 10)), e2 < 100 || e2 > 999 ? t2 : e2) : t2; | |
} | |
function splitCookiesString(e2) { | |
if (Array.isArray(e2)) | |
return e2.flatMap((e3) => splitCookiesString(e3)); | |
if ("string" != typeof e2) | |
return []; | |
const t2 = []; | |
let r2, n2, i2, a2, c2, u2 = 0; | |
const skipWhitespace = () => { | |
for (; u2 < e2.length && /\s/.test(e2.charAt(u2)); ) | |
u2 += 1; | |
return u2 < e2.length; | |
}; | |
for (; u2 < e2.length; ) { | |
for (r2 = u2, c2 = false; skipWhitespace(); ) | |
if (n2 = e2.charAt(u2), "," === n2) { | |
for (i2 = u2, u2 += 1, skipWhitespace(), a2 = u2; u2 < e2.length && (n2 = e2.charAt(u2), "=" !== n2 && ";" !== n2 && "," !== n2); ) | |
u2 += 1; | |
u2 < e2.length && "=" === e2.charAt(u2) ? (c2 = true, u2 = a2, t2.push(e2.slice(r2, i2)), r2 = u2) : u2 = i2 + 1; | |
} else | |
u2 += 1; | |
(!c2 || u2 >= e2.length) && t2.push(e2.slice(r2, e2.length)); | |
} | |
return t2; | |
} | |
const Kt = "undefined" == typeof setImmediate ? (e2) => e2() : setImmediate; | |
function send$1(e2, t2, r2) { | |
return r2 && function(e3, t3) { | |
t3 && !e3.node.res.getHeader("content-type") && e3.node.res.setHeader("content-type", t3); | |
}(e2, r2), new Promise((r3) => { | |
Kt(() => { | |
e2.handled || e2.node.res.end(t2), r3(); | |
}); | |
}); | |
} | |
function setResponseStatus(e2, t2, r2) { | |
t2 && (e2.node.res.statusCode = sanitizeStatusCode(t2, e2.node.res.statusCode)), r2 && (e2.node.res.statusMessage = sanitizeStatusMessage(r2)); | |
} | |
const setHeaders = function(e2, t2) { | |
for (const [r2, n2] of Object.entries(t2)) | |
e2.node.res.setHeader(r2, n2); | |
}; | |
function setResponseHeader(e2, t2, r2) { | |
e2.node.res.setHeader(t2, r2); | |
} | |
function sendStream(e2, t2) { | |
if (!t2 || "object" != typeof t2) | |
throw new Error("[h3] Invalid stream provided."); | |
if (e2.node.res._data = t2, !e2.node.res.socket) | |
return e2._handled = true, Promise.resolve(); | |
if ("pipeTo" in t2) | |
return t2.pipeTo(new WritableStream({ write(t3) { | |
e2.node.res.write(t3); | |
} })).then(() => { | |
e2.node.res.end(); | |
}); | |
if ("function" == typeof t2.pipe) | |
return new Promise((r2, n2) => { | |
t2.pipe(e2.node.res), t2.on && (t2.on("end", () => { | |
e2.node.res.end(), r2(); | |
}), t2.on("error", (e3) => { | |
n2(e3); | |
})), e2.node.res.on("close", () => { | |
t2.abort && t2.abort(); | |
}); | |
}); | |
throw new Error("[h3] Invalid or incompatible stream provided."); | |
} | |
function sendWebResponse(e2, t2) { | |
for (const [r2, n2] of t2.headers) | |
"set-cookie" === r2 ? e2.node.res.appendHeader(r2, splitCookiesString(n2)) : e2.node.res.setHeader(r2, n2); | |
if (t2.status && (e2.node.res.statusCode = sanitizeStatusCode(t2.status, e2.node.res.statusCode)), t2.statusText && (e2.node.res.statusMessage = sanitizeStatusMessage(t2.statusText)), t2.redirected && e2.node.res.setHeader("location", t2.url), t2.body) | |
return sendStream(e2, t2.body); | |
e2.node.res.end(); | |
} | |
const Jt = /* @__PURE__ */ new Set(["PATCH", "POST", "PUT", "DELETE"]), Gt = /* @__PURE__ */ new Set(["transfer-encoding", "connection", "keep-alive", "upgrade", "expect", "host"]); | |
async function proxyRequest(e2, t2, r2 = {}) { | |
let n2, i2; | |
Jt.has(e2.method) && (r2.streamRequest ? (n2 = e2.body, i2 = "half") : n2 = await readRawBody(e2, false).catch(() => { | |
})); | |
const a2 = r2.fetchOptions?.method || e2.method, c2 = function(e3, ...t3) { | |
const r3 = t3.filter(Boolean); | |
if (0 === r3.length) | |
return e3; | |
const n3 = new Headers(e3); | |
for (const e4 of r3) | |
for (const [t4, r4] of Object.entries(e4)) | |
void 0 !== r4 && n3.set(t4, r4); | |
return n3; | |
}(getProxyRequestHeaders(e2), r2.fetchOptions?.headers, r2.headers); | |
return async function(e3, t3, r3 = {}) { | |
const n3 = await _getFetch(r3.fetch)(t3, { headers: r3.headers, ignoreResponseError: true, ...r3.fetchOptions }); | |
e3.node.res.statusCode = sanitizeStatusCode(n3.status, e3.node.res.statusCode), e3.node.res.statusMessage = sanitizeStatusMessage(n3.statusText); | |
const i3 = []; | |
for (const [t4, r4] of n3.headers.entries()) | |
"content-encoding" !== t4 && "content-length" !== t4 && ("set-cookie" !== t4 ? e3.node.res.setHeader(t4, r4) : i3.push(...splitCookiesString(r4))); | |
i3.length > 0 && e3.node.res.setHeader("set-cookie", i3.map((e4) => (r3.cookieDomainRewrite && (e4 = rewriteCookieProperty(e4, r3.cookieDomainRewrite, "domain")), r3.cookiePathRewrite && (e4 = rewriteCookieProperty(e4, r3.cookiePathRewrite, "path")), e4))); | |
r3.onResponse && await r3.onResponse(e3, n3); | |
if (void 0 !== n3._data) | |
return n3._data; | |
if (e3.handled) | |
return; | |
if (false === r3.sendStream) { | |
const t4 = new Uint8Array(await n3.arrayBuffer()); | |
return e3.node.res.end(t4); | |
} | |
if (n3.body) | |
for await (const t4 of n3.body) | |
e3.node.res.write(t4); | |
return e3.node.res.end(); | |
}(e2, t2, { ...r2, fetchOptions: { method: a2, body: n2, duplex: i2, ...r2.fetchOptions, headers: c2 } }); | |
} | |
function getProxyRequestHeaders(e2) { | |
const t2 = /* @__PURE__ */ Object.create(null), r2 = getRequestHeaders(e2); | |
for (const e3 in r2) | |
Gt.has(e3) || (t2[e3] = r2[e3]); | |
return t2; | |
} | |
function fetchWithEvent(e2, t2, r2, n2) { | |
return _getFetch(n2?.fetch)(t2, { ...r2, context: r2?.context || e2.context, headers: { ...getProxyRequestHeaders(e2), ...r2?.headers } }); | |
} | |
function _getFetch(e2) { | |
if (e2) | |
return e2; | |
if (globalThis.fetch) | |
return globalThis.fetch; | |
throw new Error("fetch is not available. Try importing `node-fetch-native/polyfill` for Node.js."); | |
} | |
function rewriteCookieProperty(e2, t2, r2) { | |
const n2 = "string" == typeof t2 ? { "*": t2 } : t2; | |
return e2.replace(new RegExp(`(;\\s*${r2}=)([^;]+)`, "gi"), (e3, t3, r3) => { | |
let i2; | |
if (r3 in n2) | |
i2 = n2[r3]; | |
else { | |
if (!("*" in n2)) | |
return e3; | |
i2 = n2["*"]; | |
} | |
return i2 ? t3 + i2 : ""; | |
}); | |
} | |
const Zt = /* @__PURE__ */ new Set(["PATCH", "POST", "PUT", "DELETE"]); | |
class H3Event { | |
constructor(e2, t2) { | |
this.__is_event__ = true, this.context = {}, this._handled = false, this.node = { req: e2, res: t2 }; | |
} | |
get _originalPath() { | |
return this.node.req.originalUrl || this.node.req.url || "/"; | |
} | |
get _hasBody() { | |
return Zt.has(this.method); | |
} | |
get path() { | |
return this._path || this.node.req.url || "/"; | |
} | |
get url() { | |
return this._url || (this._url = getRequestURL(this)), this._url; | |
} | |
get handled() { | |
return this._handled || this.node.res.writableEnded || this.node.res.headersSent; | |
} | |
get method() { | |
return this._method || (this._method = (this.node.req.method || "GET").toUpperCase()), this._method; | |
} | |
get headers() { | |
return this._headers || (this._headers = function(e2) { | |
const t2 = new Headers(); | |
for (const [r2, n2] of Object.entries(e2)) | |
if (Array.isArray(n2)) | |
for (const e3 of n2) | |
t2.append(r2, e3); | |
else | |
n2 && t2.set(r2, n2); | |
return t2; | |
}(this.node.req.headers)), this._headers; | |
} | |
get req() { | |
return this.node.req; | |
} | |
get res() { | |
return this.node.res; | |
} | |
get body() { | |
if (this._hasBody) | |
return void 0 === this._body && (this._body = new ReadableStream({ start: (e2) => { | |
this.node.req.on("data", (t2) => { | |
e2.enqueue(t2); | |
}), this.node.req.on("end", () => { | |
e2.close(); | |
}), this.node.req.on("error", (t2) => { | |
e2.error(t2); | |
}); | |
} })), this._body; | |
} | |
get request() { | |
return this._request || (this._request = new Request(this.url, { duplex: "half", method: this.method, headers: this.headers, body: this.body })), this._request; | |
} | |
respondWith(e2) { | |
return Promise.resolve(e2).then((e3) => sendWebResponse(this, e3)); | |
} | |
toString() { | |
return `[${this.method}] ${this.url}`; | |
} | |
toJSON() { | |
return this.toString(); | |
} | |
} | |
function createEvent(e2, t2) { | |
return new H3Event(e2, t2); | |
} | |
function defineEventHandler(e2) { | |
if ("function" == typeof e2) | |
return Object.assign(e2, { __is_handler__: true }); | |
return Object.assign((t2) => async function(e3, t3) { | |
if (t3.before) { | |
for (const r3 of t3.before) | |
if (await r3(e3), e3.handled) | |
return; | |
} | |
const r2 = await t3.handler(e3), n2 = { body: r2 }; | |
if (t3.after) | |
for (const r3 of t3.after) | |
await r3(e3, n2); | |
return n2.body; | |
}(t2, e2), { __is_handler__: true }); | |
} | |
const Yt = defineEventHandler; | |
function isEventHandler(e2) { | |
return "__is_handler__" in e2; | |
} | |
function toEventHandler(e2, t2, r2) { | |
return isEventHandler(e2) || console.warn("[h3] Implicit event handler conversion is deprecated. Use `eventHandler()` or `fromNodeMiddleware()` to define event handlers.", r2 && "/" !== r2 ? ` | |
Route: ${r2}` : "", ` | |
Handler: ${e2}`), e2; | |
} | |
const lazyEventHandler = function(e2) { | |
let t2, r2; | |
return Yt((n2) => r2 ? r2(n2) : (r2 ? Promise.resolve(r2) : (t2 || (t2 = Promise.resolve(e2()).then((e3) => { | |
const t3 = e3.default || e3; | |
if ("function" != typeof t3) | |
throw new TypeError("Invalid lazy handler result. It should be a function:", t3); | |
return r2 = toEventHandler(e3.default || e3), r2; | |
})), t2)).then((e3) => e3(n2))); | |
}; | |
function createApp(e2 = {}) { | |
const t2 = [], r2 = function(e3, t3) { | |
const r3 = t3.debug ? 2 : void 0; | |
return Yt(async (n3) => { | |
n3.node.req.originalUrl = n3.node.req.originalUrl || n3.node.req.url || "/"; | |
const i2 = n3._path || n3.node.req.url || "/"; | |
let a2; | |
t3.onRequest && await t3.onRequest(n3); | |
for (const c2 of e3) { | |
if (c2.route.length > 1) { | |
if (!i2.startsWith(c2.route)) | |
continue; | |
a2 = i2.slice(c2.route.length) || "/"; | |
} else | |
a2 = i2; | |
if (c2.match && !c2.match(a2, n3)) | |
continue; | |
n3._path = a2, n3.node.req.url = a2; | |
const e4 = await c2.handler(n3), u2 = void 0 === e4 ? void 0 : await e4; | |
if (void 0 !== u2) { | |
const e5 = { body: u2 }; | |
return t3.onBeforeResponse && await t3.onBeforeResponse(n3, e5), await handleHandlerResponse(n3, e5.body, r3), void (t3.onAfterResponse && await t3.onAfterResponse(n3, e5)); | |
} | |
if (n3.handled) | |
return void (t3.onAfterResponse && await t3.onAfterResponse(n3, void 0)); | |
} | |
if (!n3.handled) | |
throw createError$1({ statusCode: 404, statusMessage: `Cannot find any path matching ${n3.path || "/"}.` }); | |
t3.onAfterResponse && await t3.onAfterResponse(n3, void 0); | |
}); | |
}(t2, e2), n2 = { use: (e3, t3, r3) => use(n2, e3, t3, r3), handler: r2, stack: t2, options: e2 }; | |
return n2; | |
} | |
function use(e2, t2, r2, n2) { | |
if (Array.isArray(t2)) | |
for (const i2 of t2) | |
use(e2, i2, r2, n2); | |
else if (Array.isArray(r2)) | |
for (const i2 of r2) | |
use(e2, t2, i2, n2); | |
else | |
"string" == typeof t2 ? e2.stack.push(normalizeLayer({ ...n2, route: t2, handler: r2 })) : "function" == typeof t2 ? e2.stack.push(normalizeLayer({ ...r2, route: "/", handler: t2 })) : e2.stack.push(normalizeLayer({ ...t2 })); | |
return e2; | |
} | |
function normalizeLayer(e2) { | |
let t2 = e2.handler; | |
return t2.handler && (t2 = t2.handler), e2.lazy ? t2 = lazyEventHandler(t2) : isEventHandler(t2) || (t2 = toEventHandler(t2, 0, e2.route)), { route: withoutTrailingSlash(e2.route), match: e2.match, handler: t2 }; | |
} | |
function handleHandlerResponse(e2, t2, r2) { | |
if (null === t2) | |
return e2.node.res.statusCode = 204, send$1(e2); | |
if (t2) { | |
if (n2 = t2, "undefined" != typeof Response && n2 instanceof Response) | |
return sendWebResponse(e2, t2); | |
if (function(e3) { | |
if (!e3 || "object" != typeof e3) | |
return false; | |
if ("function" == typeof e3.pipe) { | |
if ("function" == typeof e3._read) | |
return true; | |
if ("function" == typeof e3.abort) | |
return true; | |
} | |
return "function" == typeof e3.pipeTo; | |
}(t2)) | |
return sendStream(e2, t2); | |
if (t2.buffer) | |
return send$1(e2, t2); | |
if (t2.arrayBuffer && "function" == typeof t2.arrayBuffer) | |
return t2.arrayBuffer().then((r3) => send$1(e2, b.from(r3), t2.type)); | |
if (t2 instanceof Error) | |
throw createError$1(t2); | |
if ("function" == typeof t2.end) | |
return true; | |
} | |
var n2; | |
const i2 = typeof t2; | |
if ("string" === i2) | |
return send$1(e2, t2, qt.html); | |
if ("object" === i2 || "boolean" === i2 || "number" === i2) | |
return send$1(e2, JSON.stringify(t2, void 0, r2), qt.json); | |
if ("bigint" === i2) | |
return send$1(e2, t2.toString(), qt.json); | |
throw createError$1({ statusCode: 500, statusMessage: `[h3] Cannot send ${i2} as response.` }); | |
} | |
const Xt = ["connect", "delete", "get", "head", "options", "post", "put", "trace", "patch"]; | |
function toNodeListener(e2) { | |
return async function(t2, r2) { | |
const n2 = createEvent(t2, r2); | |
try { | |
await e2.handler(n2); | |
} catch (t3) { | |
const r3 = createError$1(t3); | |
if (isError(t3) || (r3.unhandled = true), e2.options.onError && await e2.options.onError(r3, n2), n2.handled) | |
return; | |
(r3.unhandled || r3.fatal) && console.error("[h3]", r3.fatal ? "[fatal]" : "[unhandled]", r3), await function(e3, t4, r4) { | |
if (e3.handled) | |
return; | |
const n3 = isError(t4) ? t4 : createError$1(t4), i2 = { statusCode: n3.statusCode, statusMessage: n3.statusMessage, stack: [], data: n3.data }; | |
if (r4 && (i2.stack = (n3.stack || "").split("\n").map((e4) => e4.trim())), e3.handled) | |
return; | |
setResponseStatus(e3, Number.parseInt(n3.statusCode), n3.statusMessage), e3.node.res.setHeader("content-type", qt.json), e3.node.res.end(JSON.stringify(i2, void 0, 2)); | |
}(n2, r3, !!e2.options.debug); | |
} | |
}; | |
} | |
const Qt = /post|put|patch/i; | |
function hasReqHeader(e2, t2, r2) { | |
const n2 = function(e3, t3) { | |
return getRequestHeaders(e3)[t3.toLowerCase()]; | |
}(e2, t2); | |
return n2 && "string" == typeof n2 && n2.toLowerCase().includes(r2); | |
} | |
const fn = function() { | |
}; | |
const er = function createMock(e2, t2 = {}) { | |
fn.prototype.name = e2; | |
const r2 = {}; | |
return new Proxy(fn, { get: (n2, i2) => "caller" === i2 ? null : "__createMock__" === i2 ? createMock : "__unenv__" === i2 || (i2 in t2 ? t2[i2] : r2[i2] = r2[i2] || createMock(`${e2}.${i2.toString()}`)), apply: (t3, r3, n2) => createMock(`${e2}()`), construct: (t3, r3, n2) => createMock(`[${e2}]`), enumerate: () => [] }); | |
}("mock"), tr = Object.freeze(Object.defineProperty({ __proto__: null, METHODS: ["ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "M-SEARCH", "MERGE", "MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PRI", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK", "UNSUBSCRIBE"], STATUS_CODES: { 100: "Continue", 101: "Switching Protocols", 102: "Processing", 103: "Early Hints", 200: "OK", 201: "Created", 202: "Accepted", 203: "Non-Authoritative Information", 204: "No Content", 205: "Reset Content", 206: "Partial Content", 207: "Multi-Status", 208: "Already Reported", 226: "IM Used", 300: "Multiple Choices", 301: "Moved Permanently", 302: "Found", 303: "See Other", 304: "Not Modified", 305: "Use Proxy", 307: "Temporary Redirect", 308: "Permanent Redirect", 400: "Bad Request", 401: "Unauthorized", 402: "Payment Required", 403: "Forbidden", 404: "Not Found", 405: "Method Not Allowed", 406: "Not Acceptable", 407: "Proxy Authentication Required", 408: "Request Timeout", 409: "Conflict", 410: "Gone", 411: "Length Required", 412: "Precondition Failed", 413: "Payload Too Large", 414: "URI Too Long", 415: "Unsupported Media Type", 416: "Range Not Satisfiable", 417: "Expectation Failed", 418: "I'm a Teapot", 421: "Misdirected Request", 422: "Unprocessable Entity", 423: "Locked", 424: "Failed Dependency", 425: "Too Early", 426: "Upgrade Required", 428: "Precondition Required", 429: "Too Many Requests", 431: "Request Header Fields Too Large", 451: "Unavailable For Legal Reasons", 500: "Internal Server Error", 501: "Not Implemented", 502: "Bad Gateway", 503: "Service Unavailable", 504: "Gateway Timeout", 505: "HTTP Version Not Supported", 506: "Variant Also Negotiates", 507: "Insufficient Storage", 508: "Loop Detected", 509: "Bandwidth Limit Exceeded", 510: "Not Extended", 511: "Network Authentication Required" }, maxHeaderSize: 16384 }, Symbol.toStringTag, { value: "Module" })), rr = notImplemented("http.createServer"), nr = notImplemented("http.request"), sr = notImplemented("http.get"), ir = er.__createMock__("http.Server"), or = er.__createMock__("http.OutgoingMessage"), ar = er.__createMock__("http.ClientRequest"), cr = er.__createMock__("http.Agent"), lr = new cr(), pr = notImplemented("http.validateHeaderName"), ur = notImplemented("http.validateHeaderValue"), dr = notImplemented("http.setMaxIdleHTTPParsers"), hr = { ...tr, IncomingMessage, ServerResponse, createServer: rr, request: nr, get: sr, Server: ir, OutgoingMessage: or, ClientRequest: ar, Agent: cr, globalAgent: lr, validateHeaderName: pr, validateHeaderValue: ur, setMaxIdleHTTPParsers: dr }, fetch$2 = (...e2) => globalThis.fetch(...e2), fr = globalThis.Headers, mr = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]); | |
fetch$2.Promise = globalThis.Promise, fetch$2.isRedirect = (e2) => mr.has(e2); | |
const gr = fetch$2; | |
class FetchError extends Error { | |
constructor() { | |
super(...arguments), this.name = "FetchError"; | |
} | |
} | |
const yr = new Set(Object.freeze(["PATCH", "POST", "PUT", "DELETE"])); | |
function isPayloadMethod(e2 = "GET") { | |
return yr.has(e2.toUpperCase()); | |
} | |
const br = /* @__PURE__ */ new Set(["image/svg", "application/xml", "application/xhtml", "application/html"]), vr = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i; | |
function mergeFetchOptions(e2, t2, r2 = globalThis.Headers) { | |
const n2 = { ...t2, ...e2 }; | |
if (t2?.params && e2?.params && (n2.params = { ...t2?.params, ...e2?.params }), t2?.query && e2?.query && (n2.query = { ...t2?.query, ...e2?.query }), t2?.headers && e2?.headers) { | |
n2.headers = new r2(t2?.headers || {}); | |
for (const [t3, i2] of new r2(e2?.headers || {})) | |
n2.headers.set(t3, i2); | |
} | |
return n2; | |
} | |
const xr = /* @__PURE__ */ new Set([408, 409, 425, 429, 500, 502, 503, 504]); | |
function createFetch$1(e2) { | |
const { fetch: t2, Headers: r2 } = e2; | |
function onError(e3) { | |
const t3 = e3.error && "AbortError" === e3.error.name || false; | |
if (false !== e3.options.retry && !t3) { | |
let t4; | |
t4 = "number" == typeof e3.options.retry ? e3.options.retry : isPayloadMethod(e3.options.method) ? 0 : 1; | |
const r4 = e3.response && e3.response.status || 500; | |
if (t4 > 0 && xr.has(r4)) | |
return $fetchRaw(e3.request, { ...e3.options, retry: t4 - 1 }); | |
} | |
const r3 = function(e4, t4, r4) { | |
let n2 = ""; | |
t4 && (n2 = t4.message), e4 && r4 ? n2 = `${n2} (${r4.status} ${r4.statusText} (${e4.toString()}))` : e4 && (n2 = `${n2} (${e4.toString()})`); | |
const i2 = new FetchError(n2); | |
return Object.defineProperty(i2, "request", { get: () => e4 }), Object.defineProperty(i2, "response", { get: () => r4 }), Object.defineProperty(i2, "data", { get: () => r4 && r4._data }), Object.defineProperty(i2, "status", { get: () => r4 && r4.status }), Object.defineProperty(i2, "statusText", { get: () => r4 && r4.statusText }), Object.defineProperty(i2, "statusCode", { get: () => r4 && r4.status }), Object.defineProperty(i2, "statusMessage", { get: () => r4 && r4.statusText }), i2; | |
}(e3.request, e3.error, e3.response); | |
throw Error.captureStackTrace && Error.captureStackTrace(r3, $fetchRaw), r3; | |
} | |
const $fetchRaw = async function(n2, i2 = {}) { | |
const a2 = { request: n2, options: mergeFetchOptions(i2, e2.defaults, r2), response: void 0, error: void 0 }; | |
a2.options.onRequest && await a2.options.onRequest(a2), "string" == typeof a2.request && (a2.options.baseURL && (a2.request = function(e3, t3) { | |
if (isEmptyURL(t3) || hasProtocol(e3)) | |
return e3; | |
const r3 = withoutTrailingSlash(t3); | |
return e3.startsWith(r3) ? e3 : joinURL(r3, e3); | |
}(a2.request, a2.options.baseURL)), (a2.options.query || a2.options.params) && (a2.request = withQuery(a2.request, { ...a2.options.params, ...a2.options.query })), a2.options.body && isPayloadMethod(a2.options.method) && function(e3) { | |
if (void 0 === e3) | |
return false; | |
const t3 = typeof e3; | |
return "string" === t3 || "number" === t3 || "boolean" === t3 || null === t3 || "object" === t3 && (!!Array.isArray(e3) || e3.constructor && "Object" === e3.constructor.name || "function" == typeof e3.toJSON); | |
}(a2.options.body) && (a2.options.body = "string" == typeof a2.options.body ? a2.options.body : JSON.stringify(a2.options.body), a2.options.headers = new r2(a2.options.headers || {}), a2.options.headers.has("content-type") || a2.options.headers.set("content-type", "application/json"), a2.options.headers.has("accept") || a2.options.headers.set("accept", "application/json"))); | |
try { | |
a2.response = await t2(a2.request, a2.options); | |
} catch (e3) { | |
return a2.error = e3, a2.options.onRequestError && await a2.options.onRequestError(a2), await onError(a2); | |
} | |
const c2 = (a2.options.parseResponse ? "json" : a2.options.responseType) || function(e3 = "") { | |
if (!e3) | |
return "json"; | |
const t3 = e3.split(";").shift() || ""; | |
return vr.test(t3) ? "json" : br.has(t3) || t3.startsWith("text/") ? "text" : "blob"; | |
}(a2.response.headers.get("content-type") || ""); | |
if ("json" === c2) { | |
const e3 = await a2.response.text(), t3 = a2.options.parseResponse || destr; | |
a2.response._data = t3(e3); | |
} else | |
a2.response._data = "stream" === c2 ? a2.response.body : await a2.response[c2](); | |
return a2.options.onResponse && await a2.options.onResponse(a2), !a2.options.ignoreResponseError && a2.response.status >= 400 && a2.response.status < 600 ? (a2.options.onResponseError && await a2.options.onResponseError(a2), await onError(a2)) : a2.response; | |
}, $fetch2 = async function(e3, t3) { | |
return (await $fetchRaw(e3, t3))._data; | |
}; | |
return $fetch2.raw = $fetchRaw, $fetch2.native = t2, $fetch2.create = (t3 = {}) => createFetch$1({ ...e2, defaults: { ...e2.defaults, ...t3 } }), $fetch2; | |
} | |
const wr = globalThis.fetch || function() { | |
if (!JSON.parse(R.env.FETCH_KEEP_ALIVE || "false")) | |
return gr; | |
const e2 = { keepAlive: true }, t2 = new hr.Agent(e2), r2 = new H.Agent(e2), n2 = { agent: (e3) => "http:" === e3.protocol ? t2 : r2 }; | |
return function(e3, t3) { | |
return gr(e3, { ...n2, ...t3 }); | |
}; | |
}(), Cr = globalThis.Headers || fr, Er = createFetch$1({ fetch: wr, Headers: Cr }), Sr = /* @__PURE__ */ new Set([101, 204, 205, 304]); | |
function flatHooks(e2, t2 = {}, r2) { | |
for (const n2 in e2) { | |
const i2 = e2[n2], a2 = r2 ? `${r2}:${n2}` : n2; | |
"object" == typeof i2 && null !== i2 ? flatHooks(i2, t2, a2) : "function" == typeof i2 && (t2[a2] = i2); | |
} | |
return t2; | |
} | |
const Ar = { run: (e2) => e2() }, kr = void 0 !== console.createTask ? console.createTask : () => Ar; | |
function serialTaskCaller(e2, t2) { | |
const r2 = t2.shift(), n2 = kr(r2); | |
return e2.reduce((e3, r3) => e3.then(() => n2.run(() => r3(...t2))), Promise.resolve()); | |
} | |
function parallelTaskCaller(e2, t2) { | |
const r2 = t2.shift(), n2 = kr(r2); | |
return Promise.all(e2.map((e3) => n2.run(() => e3(...t2)))); | |
} | |
function callEachWith(e2, t2) { | |
for (const r2 of [...e2]) | |
r2(t2); | |
} | |
class Hookable { | |
constructor() { | |
this._hooks = {}, this._before = void 0, this._after = void 0, this._deprecatedMessages = void 0, this._deprecatedHooks = {}, this.hook = this.hook.bind(this), this.callHook = this.callHook.bind(this), this.callHookWith = this.callHookWith.bind(this); | |
} | |
hook(e2, t2, r2 = {}) { | |
if (!e2 || "function" != typeof t2) | |
return () => { | |
}; | |
const n2 = e2; | |
let i2; | |
for (; this._deprecatedHooks[e2]; ) | |
i2 = this._deprecatedHooks[e2], e2 = i2.to; | |
if (i2 && !r2.allowDeprecated) { | |
let e3 = i2.message; | |
e3 || (e3 = `${n2} hook has been deprecated` + (i2.to ? `, please use ${i2.to}` : "")), this._deprecatedMessages || (this._deprecatedMessages = /* @__PURE__ */ new Set()), this._deprecatedMessages.has(e3) || (console.warn(e3), this._deprecatedMessages.add(e3)); | |
} | |
if (!t2.name) | |
try { | |
Object.defineProperty(t2, "name", { get: () => "_" + e2.replace(/\W+/g, "_") + "_hook_cb", configurable: true }); | |
} catch { | |
} | |
return this._hooks[e2] = this._hooks[e2] || [], this._hooks[e2].push(t2), () => { | |
t2 && (this.removeHook(e2, t2), t2 = void 0); | |
}; | |
} | |
hookOnce(e2, t2) { | |
let r2, _function = (...e3) => ("function" == typeof r2 && r2(), r2 = void 0, _function = void 0, t2(...e3)); | |
return r2 = this.hook(e2, _function), r2; | |
} | |
removeHook(e2, t2) { | |
if (this._hooks[e2]) { | |
const r2 = this._hooks[e2].indexOf(t2); | |
-1 !== r2 && this._hooks[e2].splice(r2, 1), 0 === this._hooks[e2].length && delete this._hooks[e2]; | |
} | |
} | |
deprecateHook(e2, t2) { | |
this._deprecatedHooks[e2] = "string" == typeof t2 ? { to: t2 } : t2; | |
const r2 = this._hooks[e2] || []; | |
delete this._hooks[e2]; | |
for (const t3 of r2) | |
this.hook(e2, t3); | |
} | |
deprecateHooks(e2) { | |
Object.assign(this._deprecatedHooks, e2); | |
for (const t2 in e2) | |
this.deprecateHook(t2, e2[t2]); | |
} | |
addHooks(e2) { | |
const t2 = flatHooks(e2), r2 = Object.keys(t2).map((e3) => this.hook(e3, t2[e3])); | |
return () => { | |
for (const e3 of r2.splice(0, r2.length)) | |
e3(); | |
}; | |
} | |
removeHooks(e2) { | |
const t2 = flatHooks(e2); | |
for (const e3 in t2) | |
this.removeHook(e3, t2[e3]); | |
} | |
removeAllHooks() { | |
for (const e2 in this._hooks) | |
delete this._hooks[e2]; | |
} | |
callHook(e2, ...t2) { | |
return t2.unshift(e2), this.callHookWith(serialTaskCaller, e2, ...t2); | |
} | |
callHookParallel(e2, ...t2) { | |
return t2.unshift(e2), this.callHookWith(parallelTaskCaller, e2, ...t2); | |
} | |
callHookWith(e2, t2, ...r2) { | |
const n2 = this._before || this._after ? { name: t2, args: r2, context: {} } : void 0; | |
this._before && callEachWith(this._before, n2); | |
const i2 = e2(t2 in this._hooks ? [...this._hooks[t2]] : [], r2); | |
return i2 instanceof Promise ? i2.finally(() => { | |
this._after && n2 && callEachWith(this._after, n2); | |
}) : (this._after && n2 && callEachWith(this._after, n2), i2); | |
} | |
beforeEach(e2) { | |
return this._before = this._before || [], this._before.push(e2), () => { | |
if (void 0 !== this._before) { | |
const t2 = this._before.indexOf(e2); | |
-1 !== t2 && this._before.splice(t2, 1); | |
} | |
}; | |
} | |
afterEach(e2) { | |
return this._after = this._after || [], this._after.push(e2), () => { | |
if (void 0 !== this._after) { | |
const t2 = this._after.indexOf(e2); | |
-1 !== t2 && this._after.splice(t2, 1); | |
} | |
}; | |
} | |
} | |
function createHooks() { | |
return new Hookable(); | |
} | |
const Pr = /\d/, Tr = ["-", "_", "/", "."]; | |
function isUppercase(e2 = "") { | |
if (!Pr.test(e2)) | |
return e2.toUpperCase() === e2; | |
} | |
function kebabCase(e2, t2) { | |
return e2 ? (Array.isArray(e2) ? e2 : function(e3, t3) { | |
const r2 = t3 ?? Tr, n2 = []; | |
if (!e3 || "string" != typeof e3) | |
return n2; | |
let i2, a2, c2 = ""; | |
for (const t4 of e3) { | |
const e4 = r2.includes(t4); | |
if (true === e4) { | |
n2.push(c2), c2 = "", i2 = void 0; | |
continue; | |
} | |
const u2 = isUppercase(t4); | |
if (false === a2) { | |
if (false === i2 && true === u2) { | |
n2.push(c2), c2 = t4, i2 = u2; | |
continue; | |
} | |
if (true === i2 && false === u2 && c2.length > 1) { | |
const e5 = c2[c2.length - 1]; | |
n2.push(c2.slice(0, Math.max(0, c2.length - 1))), c2 = e5 + t4, i2 = u2; | |
continue; | |
} | |
} | |
c2 += t4, i2 = u2, a2 = e4; | |
} | |
return n2.push(c2), n2; | |
}(e2)).map((e3) => e3.toLowerCase()).join(t2 ?? "-") : ""; | |
} | |
function klona(e2) { | |
if ("object" != typeof e2) | |
return e2; | |
var t2, r2, n2 = Object.prototype.toString.call(e2); | |
if ("[object Object]" === n2) { | |
if (e2.constructor !== Object && "function" == typeof e2.constructor) | |
for (t2 in r2 = new e2.constructor(), e2) | |
e2.hasOwnProperty(t2) && r2[t2] !== e2[t2] && (r2[t2] = klona(e2[t2])); | |
else | |
for (t2 in r2 = {}, e2) | |
"__proto__" === t2 ? Object.defineProperty(r2, t2, { value: klona(e2[t2]), configurable: true, enumerable: true, writable: true }) : r2[t2] = klona(e2[t2]); | |
return r2; | |
} | |
if ("[object Array]" === n2) { | |
for (t2 = e2.length, r2 = Array(t2); t2--; ) | |
r2[t2] = klona(e2[t2]); | |
return r2; | |
} | |
return "[object Set]" === n2 ? (r2 = /* @__PURE__ */ new Set(), e2.forEach(function(e3) { | |
r2.add(klona(e3)); | |
}), r2) : "[object Map]" === n2 ? (r2 = /* @__PURE__ */ new Map(), e2.forEach(function(e3, t3) { | |
r2.set(klona(t3), klona(e3)); | |
}), r2) : "[object Date]" === n2 ? new Date(+e2) : "[object RegExp]" === n2 ? ((r2 = new RegExp(e2.source, e2.flags)).lastIndex = e2.lastIndex, r2) : "[object DataView]" === n2 ? new e2.constructor(klona(e2.buffer)) : "[object ArrayBuffer]" === n2 ? e2.slice(0) : "Array]" === n2.slice(-6) ? new e2.constructor(e2) : e2; | |
} | |
const _r = be({}), Ir = { app: { baseURL: "/", buildAssetsDir: "/_nuxt/", cdnURL: "" }, nitro: { envPrefix: "NUXT_", routeRules: { "/__nuxt_error": { cache: false }, "/_nuxt/**": { headers: { "cache-control": "public, max-age=31536000, immutable" } } } }, public: { authJs: { verifyClientOnEveryRequest: true, guestRedirectTo: "/", authenticatedRedirectTo: "/", baseUrl: "" } }, authJs: { secret: "" }, github: { clientId: "", clientSecret: "" } }, Dr = "NITRO_", Nr = Ir.nitro.envPrefix ?? R.env.NITRO_ENV_PREFIX ?? "_", Or = _deepFreeze(_applyEnv(klona(Ir))); | |
function useRuntimeConfig$1(e2) { | |
if (!e2) | |
return Or; | |
if (e2.context.nitro.runtimeConfig) | |
return e2.context.nitro.runtimeConfig; | |
const t2 = klona(Ir); | |
return _applyEnv(t2), e2.context.nitro.runtimeConfig = t2, t2; | |
} | |
function _getEnv(e2) { | |
const t2 = (r2 = e2, kebabCase(r2, "_")).toUpperCase(); | |
var r2; | |
return destr(R.env[Dr + t2] ?? R.env[Nr + t2]); | |
} | |
function _isObject(e2) { | |
return "object" == typeof e2 && !Array.isArray(e2); | |
} | |
function _applyEnv(e2, t2 = "") { | |
for (const r2 in e2) { | |
const n2 = t2 ? `${t2}_${r2}` : r2, i2 = _getEnv(n2); | |
_isObject(e2[r2]) ? (_isObject(i2) && (e2[r2] = { ...e2[r2], ...i2 }), _applyEnv(e2[r2], n2)) : e2[r2] = i2 ?? e2[r2]; | |
} | |
return e2; | |
} | |
function _deepFreeze(e2) { | |
const t2 = Object.getOwnPropertyNames(e2); | |
for (const r2 of t2) { | |
const t3 = e2[r2]; | |
t3 && "object" == typeof t3 && _deepFreeze(t3); | |
} | |
return Object.freeze(e2); | |
} | |
_deepFreeze(klona(_r)), new Proxy(/* @__PURE__ */ Object.create(null), { get: (e2, t2) => { | |
console.warn("Please use `useRuntimeConfig()` instead of accessing config directly."); | |
const r2 = useRuntimeConfig$1(); | |
if (t2 in r2) | |
return r2[t2]; | |
} }); | |
const Lr = Object.freeze({ ignoreUnknown: false, respectType: false, respectFunctionNames: false, respectFunctionProperties: false, unorderedObjects: true, unorderedArrays: false, unorderedSets: false, excludeKeys: void 0, excludeValues: void 0, replacer: void 0 }); | |
function objectHash(e2, t2) { | |
const r2 = createHasher(t2 = t2 ? { ...Lr, ...t2 } : Lr); | |
return r2.dispatch(e2), r2.toString(); | |
} | |
const Rr = Object.freeze(["prototype", "__proto__", "constructor"]); | |
function createHasher(e2) { | |
let t2 = "", r2 = /* @__PURE__ */ new Map(); | |
const write2 = (e3) => { | |
t2 += e3; | |
}; | |
return { toString: () => t2, getContext: () => r2, dispatch(t3) { | |
e2.replacer && (t3 = e2.replacer(t3)); | |
return this[null === t3 ? "null" : typeof t3](t3); | |
}, object(t3) { | |
if (t3 && "function" == typeof t3.toJSON) | |
return this.object(t3.toJSON()); | |
const n2 = Object.prototype.toString.call(t3); | |
let i2 = ""; | |
const a2 = n2.length; | |
i2 = a2 < 10 ? "unknown:[" + n2 + "]" : n2.slice(8, a2 - 1), i2 = i2.toLowerCase(); | |
let c2 = null; | |
if (void 0 !== (c2 = r2.get(t3))) | |
return this.dispatch("[CIRCULAR:" + c2 + "]"); | |
if (r2.set(t3, r2.size), void 0 !== b && b.isBuffer && b.isBuffer(t3)) | |
return write2("buffer:"), write2(t3.toString("utf8")); | |
if ("object" !== i2 && "function" !== i2 && "asyncfunction" !== i2) | |
this[i2] ? this[i2](t3) : e2.ignoreUnknown || this.unkown(t3, i2); | |
else { | |
let r3 = Object.keys(t3); | |
e2.unorderedObjects && (r3 = r3.sort()); | |
let n3 = []; | |
false === e2.respectType || isNativeFunction(t3) || (n3 = Rr), e2.excludeKeys && (r3 = r3.filter((t4) => !e2.excludeKeys(t4)), n3 = n3.filter((t4) => !e2.excludeKeys(t4))), write2("object:" + (r3.length + n3.length) + ":"); | |
const dispatchForKey = (r4) => { | |
this.dispatch(r4), write2(":"), e2.excludeValues || this.dispatch(t3[r4]), write2(","); | |
}; | |
for (const e3 of r3) | |
dispatchForKey(e3); | |
for (const e3 of n3) | |
dispatchForKey(e3); | |
} | |
}, array(t3, n2) { | |
if (n2 = void 0 === n2 ? false !== e2.unorderedArrays : n2, write2("array:" + t3.length + ":"), !n2 || t3.length <= 1) { | |
for (const e3 of t3) | |
this.dispatch(e3); | |
return; | |
} | |
const i2 = /* @__PURE__ */ new Map(), a2 = t3.map((t4) => { | |
const r3 = createHasher(e2); | |
r3.dispatch(t4); | |
for (const [e3, t5] of r3.getContext()) | |
i2.set(e3, t5); | |
return r3.toString(); | |
}); | |
return r2 = i2, a2.sort(), this.array(a2, false); | |
}, date: (e3) => write2("date:" + e3.toJSON()), symbol: (e3) => write2("symbol:" + e3.toString()), unkown(e3, t3) { | |
if (write2(t3), e3) | |
return write2(":"), e3 && "function" == typeof e3.entries ? this.array(Array.from(e3.entries()), true) : void 0; | |
}, error: (e3) => write2("error:" + e3.toString()), boolean: (e3) => write2("bool:" + e3), string(e3) { | |
write2("string:" + e3.length + ":"), write2(e3); | |
}, function(t3) { | |
write2("fn:"), isNativeFunction(t3) ? this.dispatch("[native]") : this.dispatch(t3.toString()), false !== e2.respectFunctionNames && this.dispatch("function-name:" + String(t3.name)), e2.respectFunctionProperties && this.object(t3); | |
}, number: (e3) => write2("number:" + e3), xml: (e3) => write2("xml:" + e3.toString()), null: () => write2("Null"), undefined: () => write2("Undefined"), regexp: (e3) => write2("regex:" + e3.toString()), uint8array(e3) { | |
return write2("uint8array:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, uint8clampedarray(e3) { | |
return write2("uint8clampedarray:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, int8array(e3) { | |
return write2("int8array:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, uint16array(e3) { | |
return write2("uint16array:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, int16array(e3) { | |
return write2("int16array:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, uint32array(e3) { | |
return write2("uint32array:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, int32array(e3) { | |
return write2("int32array:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, float32array(e3) { | |
return write2("float32array:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, float64array(e3) { | |
return write2("float64array:"), this.dispatch(Array.prototype.slice.call(e3)); | |
}, arraybuffer(e3) { | |
return write2("arraybuffer:"), this.dispatch(new Uint8Array(e3)); | |
}, url: (e3) => write2("url:" + e3.toString()), map(t3) { | |
write2("map:"); | |
const r3 = [...t3]; | |
return this.array(r3, false !== e2.unorderedSets); | |
}, set(t3) { | |
write2("set:"); | |
const r3 = [...t3]; | |
return this.array(r3, false !== e2.unorderedSets); | |
}, file(e3) { | |
return write2("file:"), this.dispatch([e3.name, e3.size, e3.type, e3.lastModfied]); | |
}, blob() { | |
if (e2.ignoreUnknown) | |
return write2("[blob]"); | |
throw new Error('Hashing Blob objects is currently not supported\nUse "options.replacer" or "options.ignoreUnknown"\n'); | |
}, domwindow: () => write2("domwindow"), bigint: (e3) => write2("bigint:" + e3.toString()), process: () => write2("process"), timer: () => write2("timer"), pipe: () => write2("pipe"), tcp: () => write2("tcp"), udp: () => write2("udp"), tty: () => write2("tty"), statwatcher: () => write2("statwatcher"), securecontext: () => write2("securecontext"), connection: () => write2("connection"), zlib: () => write2("zlib"), context: () => write2("context"), nodescript: () => write2("nodescript"), httpparser: () => write2("httpparser"), dataview: () => write2("dataview"), signal: () => write2("signal"), fsevent: () => write2("fsevent"), tlswrap: () => write2("tlswrap") }; | |
} | |
const Mr = "[native code] }", Fr = Mr.length; | |
function isNativeFunction(e2) { | |
return "function" == typeof e2 && Function.prototype.toString.call(e2).slice(-Fr) === Mr; | |
} | |
class WordArray { | |
constructor(e2, t2) { | |
e2 = this.words = e2 || [], this.sigBytes = void 0 === t2 ? 4 * e2.length : t2; | |
} | |
toString(e2) { | |
return (e2 || Br).stringify(this); | |
} | |
concat(e2) { | |
if (this.clamp(), this.sigBytes % 4) | |
for (let t2 = 0; t2 < e2.sigBytes; t2++) { | |
const r2 = e2.words[t2 >>> 2] >>> 24 - t2 % 4 * 8 & 255; | |
this.words[this.sigBytes + t2 >>> 2] |= r2 << 24 - (this.sigBytes + t2) % 4 * 8; | |
} | |
else | |
for (let t2 = 0; t2 < e2.sigBytes; t2 += 4) | |
this.words[this.sigBytes + t2 >>> 2] = e2.words[t2 >>> 2]; | |
return this.sigBytes += e2.sigBytes, this; | |
} | |
clamp() { | |
this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8, this.words.length = Math.ceil(this.sigBytes / 4); | |
} | |
clone() { | |
return new WordArray([...this.words]); | |
} | |
} | |
const Br = { stringify(e2) { | |
const t2 = []; | |
for (let r2 = 0; r2 < e2.sigBytes; r2++) { | |
const n2 = e2.words[r2 >>> 2] >>> 24 - r2 % 4 * 8 & 255; | |
t2.push((n2 >>> 4).toString(16), (15 & n2).toString(16)); | |
} | |
return t2.join(""); | |
} }, jr = { stringify(e2) { | |
const t2 = []; | |
for (let r2 = 0; r2 < e2.sigBytes; r2 += 3) { | |
const n2 = (e2.words[r2 >>> 2] >>> 24 - r2 % 4 * 8 & 255) << 16 | (e2.words[r2 + 1 >>> 2] >>> 24 - (r2 + 1) % 4 * 8 & 255) << 8 | e2.words[r2 + 2 >>> 2] >>> 24 - (r2 + 2) % 4 * 8 & 255; | |
for (let i2 = 0; i2 < 4 && 8 * r2 + 6 * i2 < 8 * e2.sigBytes; i2++) | |
t2.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n2 >>> 6 * (3 - i2) & 63)); | |
} | |
return t2.join(""); | |
} }, $r = { parse(e2) { | |
const t2 = e2.length, r2 = []; | |
for (let n2 = 0; n2 < t2; n2++) | |
r2[n2 >>> 2] |= (255 & e2.charCodeAt(n2)) << 24 - n2 % 4 * 8; | |
return new WordArray(r2, t2); | |
} }, Ur = { parse: (e2) => $r.parse(unescape(encodeURIComponent(e2))) }; | |
class BufferedBlockAlgorithm { | |
constructor() { | |
this._data = new WordArray(), this._nDataBytes = 0, this._minBufferSize = 0, this.blockSize = 16; | |
} | |
reset() { | |
this._data = new WordArray(), this._nDataBytes = 0; | |
} | |
_append(e2) { | |
"string" == typeof e2 && (e2 = Ur.parse(e2)), this._data.concat(e2), this._nDataBytes += e2.sigBytes; | |
} | |
_doProcessBlock(e2, t2) { | |
} | |
_process(e2) { | |
let t2, r2 = this._data.sigBytes / (4 * this.blockSize); | |
r2 = e2 ? Math.ceil(r2) : Math.max((0 | r2) - this._minBufferSize, 0); | |
const n2 = r2 * this.blockSize, i2 = Math.min(4 * n2, this._data.sigBytes); | |
if (n2) { | |
for (let e3 = 0; e3 < n2; e3 += this.blockSize) | |
this._doProcessBlock(this._data.words, e3); | |
t2 = this._data.words.splice(0, n2), this._data.sigBytes -= i2; | |
} | |
return new WordArray(t2, i2); | |
} | |
} | |
class Hasher extends BufferedBlockAlgorithm { | |
update(e2) { | |
return this._append(e2), this._process(), this; | |
} | |
finalize(e2) { | |
e2 && this._append(e2); | |
} | |
} | |
const Hr = [1779033703, -1150833019, 1013904242, -1521486534, 1359893119, -1694144372, 528734635, 1541459225], Vr = [1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998], zr = []; | |
class SHA256 extends Hasher { | |
constructor() { | |
super(...arguments), this._hash = new WordArray([...Hr]); | |
} | |
reset() { | |
super.reset(), this._hash = new WordArray([...Hr]); | |
} | |
_doProcessBlock(e2, t2) { | |
const r2 = this._hash.words; | |
let n2 = r2[0], i2 = r2[1], a2 = r2[2], c2 = r2[3], u2 = r2[4], m2 = r2[5], g2 = r2[6], b2 = r2[7]; | |
for (let r3 = 0; r3 < 64; r3++) { | |
if (r3 < 16) | |
zr[r3] = 0 | e2[t2 + r3]; | |
else { | |
const e3 = zr[r3 - 15], t3 = (e3 << 25 | e3 >>> 7) ^ (e3 << 14 | e3 >>> 18) ^ e3 >>> 3, n3 = zr[r3 - 2], i3 = (n3 << 15 | n3 >>> 17) ^ (n3 << 13 | n3 >>> 19) ^ n3 >>> 10; | |
zr[r3] = t3 + zr[r3 - 7] + i3 + zr[r3 - 16]; | |
} | |
const x2 = n2 & i2 ^ n2 & a2 ^ i2 & a2, C2 = (n2 << 30 | n2 >>> 2) ^ (n2 << 19 | n2 >>> 13) ^ (n2 << 10 | n2 >>> 22), A2 = b2 + ((u2 << 26 | u2 >>> 6) ^ (u2 << 21 | u2 >>> 11) ^ (u2 << 7 | u2 >>> 25)) + (u2 & m2 ^ ~u2 & g2) + Vr[r3] + zr[r3]; | |
b2 = g2, g2 = m2, m2 = u2, u2 = c2 + A2 | 0, c2 = a2, a2 = i2, i2 = n2, n2 = A2 + (C2 + x2) | 0; | |
} | |
r2[0] = r2[0] + n2 | 0, r2[1] = r2[1] + i2 | 0, r2[2] = r2[2] + a2 | 0, r2[3] = r2[3] + c2 | 0, r2[4] = r2[4] + u2 | 0, r2[5] = r2[5] + m2 | 0, r2[6] = r2[6] + g2 | 0, r2[7] = r2[7] + b2 | 0; | |
} | |
finalize(e2) { | |
super.finalize(e2); | |
const t2 = 8 * this._nDataBytes, r2 = 8 * this._data.sigBytes; | |
return this._data.words[r2 >>> 5] |= 128 << 24 - r2 % 32, this._data.words[14 + (r2 + 64 >>> 9 << 4)] = Math.floor(t2 / 4294967296), this._data.words[15 + (r2 + 64 >>> 9 << 4)] = t2, this._data.sigBytes = 4 * this._data.words.length, this._process(), this._hash; | |
} | |
} | |
function hash(e2, t2 = {}) { | |
return function(e3) { | |
return new SHA256().finalize(e3).toString(jr); | |
}("string" == typeof e2 ? e2 : objectHash(e2, t2)).slice(0, 10); | |
} | |
function asyncCall(e2, ...t2) { | |
try { | |
return (r2 = e2(...t2)) && "function" == typeof r2.then ? r2 : Promise.resolve(r2); | |
} catch (e3) { | |
return Promise.reject(e3); | |
} | |
var r2; | |
} | |
function stringify$1(e2) { | |
if (function(e3) { | |
const t2 = typeof e3; | |
return null === e3 || "object" !== t2 && "function" !== t2; | |
}(e2)) | |
return String(e2); | |
if (function(e3) { | |
const t2 = Object.getPrototypeOf(e3); | |
return !t2 || t2.isPrototypeOf(Object); | |
}(e2) || Array.isArray(e2)) | |
return JSON.stringify(e2); | |
if ("function" == typeof e2.toJSON) | |
return stringify$1(e2.toJSON()); | |
throw new Error("[unstorage] Cannot stringify value!"); | |
} | |
function checkBufferSupport() { | |
if (void 0 === typeof b) | |
throw new TypeError("[unstorage] Buffer is not supported!"); | |
} | |
const qr = "base64:"; | |
const Wr = ["hasItem", "getItem", "getItemRaw", "setItem", "setItemRaw", "removeItem", "getMeta", "setMeta", "removeMeta", "getKeys", "clear", "mount", "unmount"]; | |
function normalizeKey$1(e2) { | |
return e2 ? e2.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") : ""; | |
} | |
function joinKeys(...e2) { | |
return normalizeKey$1(e2.join(":")); | |
} | |
function normalizeBaseKey(e2) { | |
return (e2 = normalizeKey$1(e2)) ? e2 + ":" : ""; | |
} | |
const memory = () => { | |
const e2 = /* @__PURE__ */ new Map(); | |
return { name: "memory", options: {}, hasItem: (t2) => e2.has(t2), getItem: (t2) => e2.get(t2) || null, getItemRaw: (t2) => e2.get(t2) || null, setItem(t2, r2) { | |
e2.set(t2, r2); | |
}, setItemRaw(t2, r2) { | |
e2.set(t2, r2); | |
}, removeItem(t2) { | |
e2.delete(t2); | |
}, getKeys: () => Array.from(e2.keys()), clear() { | |
e2.clear(); | |
}, dispose() { | |
e2.clear(); | |
} }; | |
}; | |
function watch(e2, t2, r2) { | |
return e2.watch ? e2.watch((e3, n2) => t2(e3, r2 + n2)) : () => { | |
}; | |
} | |
async function dispose(e2) { | |
"function" == typeof e2.dispose && await asyncCall(e2.dispose); | |
} | |
const Kr = {}; | |
function normalizeKey(e2) { | |
return e2 ? e2.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") : ""; | |
} | |
const Jr = { getKeys: () => Promise.resolve(Object.keys(Kr)), hasItem: (e2) => (e2 = normalizeKey(e2), Promise.resolve(e2 in Kr)), getItem: (e2) => (e2 = normalizeKey(e2), Promise.resolve(Kr[e2] ? Kr[e2].import() : null)), getMeta: (e2) => (e2 = normalizeKey(e2), Promise.resolve(Kr[e2] ? Kr[e2].meta : {})) }, Gr = function(e2 = {}) { | |
const t2 = { mounts: { "": e2.driver || memory() }, mountpoints: [""], watching: false, watchListeners: [], unwatch: {} }, getMount = (e3) => { | |
for (const r3 of t2.mountpoints) | |
if (e3.startsWith(r3)) | |
return { base: r3, relativeKey: e3.slice(r3.length), driver: t2.mounts[r3] }; | |
return { base: "", relativeKey: e3, driver: t2.mounts[""] }; | |
}, getMounts = (e3, r3) => t2.mountpoints.filter((t3) => t3.startsWith(e3) || r3 && e3.startsWith(t3)).map((r4) => ({ relativeBase: e3.length > r4.length ? e3.slice(r4.length) : void 0, mountpoint: r4, driver: t2.mounts[r4] })), onChange = (e3, r3) => { | |
if (t2.watching) { | |
r3 = normalizeKey$1(r3); | |
for (const n2 of t2.watchListeners) | |
n2(e3, r3); | |
} | |
}, stopWatch = async () => { | |
if (t2.watching) { | |
for (const e3 in t2.unwatch) | |
await t2.unwatch[e3](); | |
t2.unwatch = {}, t2.watching = false; | |
} | |
}, runBatch = (e3, t3, r3) => { | |
const n2 = /* @__PURE__ */ new Map(), getBatch = (e4) => { | |
let t4 = n2.get(e4.base); | |
return t4 || (t4 = { driver: e4.driver, base: e4.base, items: [] }, n2.set(e4.base, t4)), t4; | |
}; | |
for (const r4 of e3) { | |
const e4 = "string" == typeof r4, n3 = normalizeKey$1(e4 ? r4 : r4.key), i2 = e4 ? void 0 : r4.value, a2 = e4 || !r4.options ? t3 : { ...t3, ...r4.options }, c2 = getMount(n3); | |
getBatch(c2).items.push({ key: n3, value: i2, relativeKey: c2.relativeKey, options: a2 }); | |
} | |
return Promise.all([...n2.values()].map((e4) => r3(e4))).then((e4) => e4.flat()); | |
}, r2 = { hasItem(e3, t3 = {}) { | |
e3 = normalizeKey$1(e3); | |
const { relativeKey: r3, driver: n2 } = getMount(e3); | |
return asyncCall(n2.hasItem, r3, t3); | |
}, getItem(e3, t3 = {}) { | |
e3 = normalizeKey$1(e3); | |
const { relativeKey: r3, driver: n2 } = getMount(e3); | |
return asyncCall(n2.getItem, r3, t3).then((e4) => destr(e4)); | |
}, getItems: (e3, t3) => runBatch(e3, t3, (e4) => e4.driver.getItems ? asyncCall(e4.driver.getItems, e4.items.map((e5) => ({ key: e5.relativeKey, options: e5.options })), t3).then((t4) => t4.map((t5) => ({ key: joinKeys(e4.base, t5.key), value: destr(t5.value) }))) : Promise.all(e4.items.map((t4) => asyncCall(e4.driver.getItem, t4.relativeKey, t4.options).then((e5) => ({ key: t4.key, value: destr(e5) }))))), getItemRaw(e3, t3 = {}) { | |
e3 = normalizeKey$1(e3); | |
const { relativeKey: r3, driver: n2 } = getMount(e3); | |
return n2.getItemRaw ? asyncCall(n2.getItemRaw, r3, t3) : asyncCall(n2.getItem, r3, t3).then((e4) => function(e5) { | |
return "string" != typeof e5 ? e5 : e5.startsWith(qr) ? (checkBufferSupport(), b.from(e5.slice(qr.length), "base64")) : e5; | |
}(e4)); | |
}, async setItem(e3, t3, n2 = {}) { | |
if (void 0 === t3) | |
return r2.removeItem(e3); | |
e3 = normalizeKey$1(e3); | |
const { relativeKey: i2, driver: a2 } = getMount(e3); | |
a2.setItem && (await asyncCall(a2.setItem, i2, stringify$1(t3), n2), a2.watch || onChange("update", e3)); | |
}, async setItems(e3, t3) { | |
await runBatch(e3, t3, async (e4) => { | |
e4.driver.setItems && await asyncCall(e4.driver.setItems, e4.items.map((e5) => ({ key: e5.relativeKey, value: stringify$1(e5.value), options: e5.options })), t3), e4.driver.setItem && await Promise.all(e4.items.map((t4) => asyncCall(e4.driver.setItem, t4.relativeKey, stringify$1(t4.value), t4.options))); | |
}); | |
}, async setItemRaw(e3, t3, n2 = {}) { | |
if (void 0 === t3) | |
return r2.removeItem(e3, n2); | |
e3 = normalizeKey$1(e3); | |
const { relativeKey: i2, driver: a2 } = getMount(e3); | |
if (a2.setItemRaw) | |
await asyncCall(a2.setItemRaw, i2, t3, n2); | |
else { | |
if (!a2.setItem) | |
return; | |
await asyncCall(a2.setItem, i2, function(e4) { | |
if ("string" == typeof e4) | |
return e4; | |
checkBufferSupport(); | |
const t4 = b.from(e4).toString("base64"); | |
return qr + t4; | |
}(t3), n2); | |
} | |
a2.watch || onChange("update", e3); | |
}, async removeItem(e3, t3 = {}) { | |
"boolean" == typeof t3 && (t3 = { removeMeta: t3 }), e3 = normalizeKey$1(e3); | |
const { relativeKey: r3, driver: n2 } = getMount(e3); | |
n2.removeItem && (await asyncCall(n2.removeItem, r3, t3), (t3.removeMeta || t3.removeMata) && await asyncCall(n2.removeItem, r3 + "$", t3), n2.watch || onChange("remove", e3)); | |
}, async getMeta(e3, t3 = {}) { | |
"boolean" == typeof t3 && (t3 = { nativeOnly: t3 }), e3 = normalizeKey$1(e3); | |
const { relativeKey: r3, driver: n2 } = getMount(e3), i2 = /* @__PURE__ */ Object.create(null); | |
if (n2.getMeta && Object.assign(i2, await asyncCall(n2.getMeta, r3, t3)), !t3.nativeOnly) { | |
const e4 = await asyncCall(n2.getItem, r3 + "$", t3).then((e5) => destr(e5)); | |
e4 && "object" == typeof e4 && ("string" == typeof e4.atime && (e4.atime = new Date(e4.atime)), "string" == typeof e4.mtime && (e4.mtime = new Date(e4.mtime)), Object.assign(i2, e4)); | |
} | |
return i2; | |
}, setMeta(e3, t3, r3 = {}) { | |
return this.setItem(e3 + "$", t3, r3); | |
}, removeMeta(e3, t3 = {}) { | |
return this.removeItem(e3 + "$", t3); | |
}, async getKeys(e3, t3 = {}) { | |
e3 = normalizeBaseKey(e3); | |
const r3 = getMounts(e3, true); | |
let n2 = []; | |
const i2 = []; | |
for (const e4 of r3) { | |
const r4 = (await asyncCall(e4.driver.getKeys, e4.relativeBase, t3)).map((t4) => e4.mountpoint + normalizeKey$1(t4)).filter((e5) => !n2.some((t4) => e5.startsWith(t4))); | |
i2.push(...r4), n2 = [e4.mountpoint, ...n2.filter((t4) => !t4.startsWith(e4.mountpoint))]; | |
} | |
return e3 ? i2.filter((t4) => t4.startsWith(e3) && !t4.endsWith("$")) : i2.filter((e4) => !e4.endsWith("$")); | |
}, async clear(e3, t3 = {}) { | |
e3 = normalizeBaseKey(e3), await Promise.all(getMounts(e3, false).map(async (e4) => { | |
if (e4.driver.clear) | |
return asyncCall(e4.driver.clear, e4.relativeBase, t3); | |
if (e4.driver.removeItem) { | |
const r3 = await e4.driver.getKeys(e4.relativeBase || "", t3); | |
return Promise.all(r3.map((r4) => e4.driver.removeItem(r4, t3))); | |
} | |
})); | |
}, async dispose() { | |
await Promise.all(Object.values(t2.mounts).map((e3) => dispose(e3))); | |
}, watch: async (e3) => (await (async () => { | |
if (!t2.watching) { | |
t2.watching = true; | |
for (const e4 in t2.mounts) | |
t2.unwatch[e4] = await watch(t2.mounts[e4], onChange, e4); | |
} | |
})(), t2.watchListeners.push(e3), async () => { | |
t2.watchListeners = t2.watchListeners.filter((t3) => t3 !== e3), 0 === t2.watchListeners.length && await stopWatch(); | |
}), async unwatch() { | |
t2.watchListeners = [], await stopWatch(); | |
}, mount(e3, n2) { | |
if ((e3 = normalizeBaseKey(e3)) && t2.mounts[e3]) | |
throw new Error(`already mounted at ${e3}`); | |
return e3 && (t2.mountpoints.push(e3), t2.mountpoints.sort((e4, t3) => t3.length - e4.length)), t2.mounts[e3] = n2, t2.watching && Promise.resolve(watch(n2, onChange, e3)).then((r3) => { | |
t2.unwatch[e3] = r3; | |
}).catch(console.error), r2; | |
}, async unmount(e3, r3 = true) { | |
(e3 = normalizeBaseKey(e3)) && t2.mounts[e3] && (t2.watching && e3 in t2.unwatch && (t2.unwatch[e3](), delete t2.unwatch[e3]), r3 && await dispose(t2.mounts[e3]), t2.mountpoints = t2.mountpoints.filter((t3) => t3 !== e3), delete t2.mounts[e3]); | |
}, getMount(e3 = "") { | |
e3 = normalizeKey$1(e3) + ":"; | |
const t3 = getMount(e3); | |
return { driver: t3.driver, base: t3.base }; | |
}, getMounts(e3 = "", t3 = {}) { | |
e3 = normalizeKey$1(e3); | |
return getMounts(e3, t3.parents).map((e4) => ({ driver: e4.driver, base: e4.mountpoint })); | |
} }; | |
return r2; | |
}({}); | |
function useStorage(e2 = "") { | |
return e2 ? function(e3, t2) { | |
if (!(t2 = normalizeBaseKey(t2))) | |
return e3; | |
const r2 = { ...e3 }; | |
for (const n2 of Wr) | |
r2[n2] = (r3 = "", ...i2) => e3[n2](t2 + r3, ...i2); | |
return r2.getKeys = (r3 = "", ...n2) => e3.getKeys(t2 + r3, ...n2).then((e4) => e4.map((e5) => e5.slice(t2.length))), r2; | |
}(Gr, e2) : Gr; | |
} | |
Gr.mount("/assets", Jr); | |
const Zr = { name: "_", base: "/cache", swr: true, maxAge: 1 }; | |
const cachedFunction = function(e2, t2 = {}) { | |
t2 = { ...Zr, ...t2 }; | |
const r2 = {}, n2 = t2.group || "nitro/functions", i2 = t2.name || e2.name || "_", a2 = hash([t2.integrity, e2, t2]), c2 = t2.validate || (() => true); | |
return async (...u2) => { | |
const m2 = t2.shouldBypassCache?.(...u2); | |
if (m2) | |
return e2(...u2); | |
const g2 = await (t2.getKey || getKey)(...u2), b2 = t2.shouldInvalidateCache?.(...u2), x2 = await async function(e3, u3, m3) { | |
const g3 = [t2.base, n2, i2, e3 + ".json"].filter(Boolean).join(":").replace(/:\/$/, ":index"), b3 = await useStorage().getItem(g3) || {}, x3 = 1e3 * (t2.maxAge ?? t2.maxAge ?? 0); | |
x3 && (b3.expires = Date.now() + x3); | |
const C3 = m3 || b3.integrity !== a2 || x3 && Date.now() - (b3.mtime || 0) > x3 || !c2(b3) ? (async () => { | |
const n3 = r2[e3]; | |
n3 || (void 0 !== b3.value && (t2.staleMaxAge || 0) >= 0 && false === t2.swr && (b3.value = void 0, b3.integrity = void 0, b3.mtime = void 0, b3.expires = void 0), r2[e3] = Promise.resolve(u3())); | |
try { | |
b3.value = await r2[e3]; | |
} catch (t3) { | |
throw n3 || delete r2[e3], t3; | |
} | |
n3 || (b3.mtime = Date.now(), b3.integrity = a2, delete r2[e3], c2(b3) && useStorage().setItem(g3, b3).catch((e4) => console.error("[nitro] [cache]", e4))); | |
})() : Promise.resolve(); | |
return t2.swr && b3.value ? (C3.catch(console.error), b3) : C3.then(() => b3); | |
}(g2, () => e2(...u2), b2); | |
let C2 = x2.value; | |
return t2.transform && (C2 = await t2.transform(x2, ...u2) || C2), C2; | |
}; | |
}; | |
function getKey(...e2) { | |
return e2.length > 0 ? hash(e2, {}) : ""; | |
} | |
function escapeKey(e2) { | |
return e2.replace(/[^\dA-Za-z]/g, ""); | |
} | |
function cloneWithProxy(e2, t2) { | |
return new Proxy(e2, { get: (e3, r2, n2) => r2 in t2 ? t2[r2] : Reflect.get(e3, r2, n2), set: (e3, r2, n2, i2) => r2 in t2 ? (t2[r2] = n2, true) : Reflect.set(e3, r2, n2, i2) }); | |
} | |
const cachedEventHandler = function(e2, t2 = Zr) { | |
const r2 = { ...t2, getKey: async (e3) => { | |
const r3 = await t2.getKey?.(e3); | |
if (r3) | |
return escapeKey(r3); | |
const n3 = e3.node.req.originalUrl || e3.node.req.url; | |
return `${escapeKey(decodeURI(parseURL$1(n3).pathname)).slice(0, 16)}.${hash(n3)}`; | |
}, validate: (e3) => !(e3.value.code >= 400) && void 0 !== e3.value.body, group: t2.group || "nitro/handlers", integrity: [t2.integrity, e2] }, n2 = cachedFunction(async (r3) => { | |
const n3 = cloneWithProxy(r3.node.req, { headers: {} }), i2 = {}; | |
let a2; | |
const c2 = createEvent(n3, cloneWithProxy(r3.node.res, { statusCode: 200, writableEnded: false, writableFinished: false, headersSent: false, closed: false, getHeader: (e3) => i2[e3], setHeader(e3, t3) { | |
return i2[e3] = t3, this; | |
}, getHeaderNames: () => Object.keys(i2), hasHeader: (e3) => e3 in i2, removeHeader(e3) { | |
delete i2[e3]; | |
}, getHeaders: () => i2, end(e3, t3, r4) { | |
return "string" == typeof e3 && (a2 = e3), "function" == typeof t3 && t3(), "function" == typeof r4 && r4(), this; | |
}, write(e3, t3, r4) { | |
return "string" == typeof e3 && (a2 = e3), "function" == typeof t3 && t3(), "function" == typeof r4 && r4(), this; | |
}, writeHead(e3, t3) { | |
if (this.statusCode = e3, t3) | |
for (const e4 in t3) | |
this.setHeader(e4, t3[e4]); | |
return this; | |
} })); | |
c2.context = r3.context; | |
const u2 = await e2(c2) || a2, m2 = c2.node.res.getHeaders(); | |
m2.etag = m2.Etag || m2.etag || `W/"${hash(u2)}"`, m2["last-modified"] = m2["Last-Modified"] || m2["last-modified"] || new Date().toUTCString(); | |
const g2 = []; | |
t2.swr ? (t2.maxAge && g2.push(`s-maxage=${t2.maxAge}`), t2.staleMaxAge ? g2.push(`stale-while-revalidate=${t2.staleMaxAge}`) : g2.push("stale-while-revalidate")) : t2.maxAge && g2.push(`max-age=${t2.maxAge}`), g2.length > 0 && (m2["cache-control"] = g2.join(", ")); | |
return { code: c2.node.res.statusCode, headers: m2, body: u2 }; | |
}, r2); | |
return defineEventHandler(async (r3) => { | |
if (t2.headersOnly) { | |
if (handleCacheHeaders(r3, { maxAge: t2.maxAge })) | |
return; | |
return e2(r3); | |
} | |
const i2 = await n2(r3); | |
if (r3.node.res.headersSent || r3.node.res.writableEnded) | |
return i2.body; | |
if (!handleCacheHeaders(r3, { modifiedTime: new Date(i2.headers["last-modified"]), etag: i2.headers.etag, maxAge: t2.maxAge })) { | |
r3.node.res.statusCode = i2.code; | |
for (const e3 in i2.headers) | |
r3.node.res.setHeader(e3, i2.headers[e3]); | |
return i2.body; | |
} | |
}); | |
}, Yr = toRouteMatcher(createRouter$2({ routes: useRuntimeConfig$1().nitro.routeRules })); | |
function createRouteRulesHandler() { | |
return Yt((e2) => { | |
const t2 = getRouteRules(e2); | |
if (t2.headers && setHeaders(e2, t2.headers), t2.redirect) | |
return function(e3, t3, r2 = 302) { | |
return e3.node.res.statusCode = sanitizeStatusCode(r2, e3.node.res.statusCode), e3.node.res.setHeader("location", t3), send$1(e3, `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${t3.replace(/"/g, "%22")}"></head></html>`, qt.html); | |
}(e2, t2.redirect.to, t2.redirect.statusCode); | |
if (t2.proxy) { | |
let r2 = t2.proxy.to; | |
if (r2.endsWith("/**")) { | |
let n2 = e2.path; | |
const i2 = t2.proxy._proxyStripBase; | |
i2 && (n2 = withoutBase(n2, i2)), r2 = joinURL(r2.slice(0, -3), n2); | |
} else if (e2.path.includes("?")) { | |
r2 = withQuery(r2, getQuery$1(e2.path)); | |
} | |
return proxyRequest(e2, r2, { fetch: $fetch.raw, ...t2.proxy }); | |
} | |
}); | |
} | |
function getRouteRules(e2) { | |
if (e2.context._nitro = e2.context._nitro || {}, !e2.context._nitro.routeRules) { | |
const t2 = new URL(e2.node.req.url, "http://localhost").pathname; | |
e2.context._nitro.routeRules = getRouteRulesForPath(withoutBase(t2, useRuntimeConfig$1().app.baseURL)); | |
} | |
return e2.context._nitro.routeRules; | |
} | |
function getRouteRulesForPath(e2) { | |
return ye({}, ...Yr.matchAll(e2).reverse()); | |
} | |
const Xr = []; | |
const errorHandler = async function(e2, t2) { | |
const { stack: r2, statusCode: n2, statusMessage: i2, message: a2 } = function(e3) { | |
const t3 = "function" == typeof R.cwd ? R.cwd() : "/", r3 = (e3.stack || "").split("\n").splice(1).filter((e4) => e4.includes("at ")).map((e4) => ({ text: e4.replace(t3 + "/", "./").replace("webpack:/", "").replace("file://", "").trim(), internal: e4.includes("node_modules") && !e4.includes(".cache") || e4.includes("internal") || e4.includes("new Promise") })), n3 = e3.statusCode || 500; | |
return { stack: r3, statusCode: n3, statusMessage: e3.statusMessage ?? (404 === n3 ? "Not Found" : ""), message: e3.message || e3.toString() }; | |
}(e2), c2 = { url: t2.node.req.url, statusCode: n2, statusMessage: i2, message: a2, stack: "", data: e2.data }; | |
if (e2.unhandled || e2.fatal) { | |
const t3 = ["[nuxt]", "[request error]", e2.unhandled && "[unhandled]", e2.fatal && "[fatal]", 200 !== Number(c2.statusCode) && `[${c2.statusCode}]`].filter(Boolean).join(" "); | |
console.error(t3, c2.message + "\n" + r2.map((e3) => " " + e3.text).join(" \n")); | |
} | |
if (t2.handled) | |
return; | |
if (setResponseStatus(t2, 200 !== c2.statusCode && c2.statusCode || 500, c2.statusMessage), function(e3) { | |
return hasReqHeader(e3, "accept", "application/json") || hasReqHeader(e3, "user-agent", "curl/") || hasReqHeader(e3, "user-agent", "httpie/") || hasReqHeader(e3, "sec-fetch-mode", "cors") || e3.path.startsWith("/api/") || e3.path.endsWith(".json"); | |
}(t2)) | |
return setResponseHeader(t2, "Content-Type", "application/json"), void t2.node.res.end(JSON.stringify(c2)); | |
const u2 = t2.node.req.url?.startsWith("/__nuxt_error"), m2 = u2 ? null : await useNitroApp().localFetch(withQuery(joinURL(useRuntimeConfig$1().app.baseURL, "/__nuxt_error"), c2), { headers: getRequestHeaders(t2), redirect: "manual" }).catch(() => null); | |
if (!m2) { | |
const { template: e3 } = await Promise.resolve().then(function() { | |
return nn; | |
}); | |
if (t2.handled) | |
return; | |
return setResponseHeader(t2, "Content-Type", "text/html;charset=UTF-8"), void t2.node.res.end(e3(c2)); | |
} | |
const g2 = await m2.text(); | |
if (!t2.handled) { | |
for (const [e3, r3] of m2.headers.entries()) | |
setResponseHeader(t2, e3, r3); | |
setResponseStatus(t2, m2.status && 200 !== m2.status ? m2.status : void 0, m2.statusText), t2.node.res.end(g2); | |
} | |
}, _lazy_I6R8nf = () => Promise.resolve().then(function() { | |
return bd; | |
}), Qr = [{ route: "/api/auth/**", handler: () => Promise.resolve().then(function() { | |
return Ti; | |
}), lazy: true, middleware: false, method: void 0 }, { route: "/__nuxt_error", handler: _lazy_I6R8nf, lazy: true, middleware: false, method: void 0 }, { route: "/**", handler: _lazy_I6R8nf, lazy: true, middleware: false, method: void 0 }]; | |
const en = function() { | |
const e2 = useRuntimeConfig$1(), t2 = createHooks(), r2 = createApp({ debug: destr(false), onError: errorHandler }), n2 = function(e3 = {}) { | |
const t3 = createRouter$2({}), r3 = {}; | |
let n3; | |
const i3 = {}, addRoute = (e4, n4, a3) => { | |
let c3 = r3[e4]; | |
if (c3 || (r3[e4] = c3 = { handlers: {} }, t3.insert(e4, c3)), Array.isArray(a3)) | |
for (const t4 of a3) | |
addRoute(e4, n4, t4); | |
else | |
c3.handlers[a3] = toEventHandler(n4, 0, e4); | |
return i3; | |
}; | |
i3.use = i3.add = (e4, t4, r4) => addRoute(e4, t4, r4 || "all"); | |
for (const e4 of Xt) | |
i3[e4] = (t4, r4) => i3.add(t4, r4, e4); | |
return i3.handler = Yt((r4) => { | |
let i4 = r4.path || "/"; | |
const a3 = i4.indexOf("?"); | |
-1 !== a3 && (i4 = i4.slice(0, Math.max(0, a3))); | |
const c3 = t3.lookup(i4); | |
if (!c3 || !c3.handlers) { | |
if (e3.preemptive || e3.preemtive) | |
throw createError$1({ statusCode: 404, name: "Not Found", statusMessage: `Cannot find any route matching ${r4.path || "/"}.` }); | |
return; | |
} | |
const u3 = (r4.node.req.method || "get").toLowerCase(); | |
let m3 = c3.handlers[u3] || c3.handlers.all; | |
if (!m3) { | |
n3 || (n3 = toRouteMatcher(t3)); | |
const e4 = n3.matchAll(i4).reverse(); | |
for (const t4 of e4) { | |
if (t4.handlers[u3]) { | |
m3 = t4.handlers[u3], c3.handlers[u3] = c3.handlers[u3] || m3; | |
break; | |
} | |
if (t4.handlers.all) { | |
m3 = t4.handlers.all, c3.handlers.all = c3.handlers.all || m3; | |
break; | |
} | |
} | |
} | |
if (!m3) { | |
if (e3.preemptive || e3.preemtive) | |
throw createError$1({ statusCode: 405, name: "Method Not Allowed", statusMessage: `Method ${u3} is not allowed on this route.` }); | |
return; | |
} | |
const g2 = c3.params || {}; | |
return r4.context.params = g2, Promise.resolve(m3(r4)).then((t4) => void 0 === t4 && (e3.preemptive || e3.preemtive) ? (setResponseStatus(r4, 204), "") : t4); | |
}), i3; | |
}(); | |
r2.use(createRouteRulesHandler()); | |
const i2 = (a2 = toNodeListener(r2), function(e3) { | |
const t3 = new IncomingMessage(), r3 = new ServerResponse(t3); | |
if (t3.url = e3.url || "/", t3.method = e3.method || "GET", t3.headers = {}, e3.headers) { | |
const r4 = "function" == typeof e3.headers.entries ? e3.headers.entries() : Object.entries(e3.headers); | |
for (const [e4, n3] of r4) | |
n3 && (t3.headers[e4.toLowerCase()] = n3); | |
} | |
return t3.headers.host = t3.headers.host || e3.host || "localhost", t3.connection.encrypted = t3.connection.encrypted || "https" === e3.protocol, t3.body = e3.body || null, t3.__unenv__ = e3.context, a2(t3, r3).then(() => { | |
let e4 = r3._data; | |
(Sr.has(r3.statusCode) || "HEAD" === t3.method.toUpperCase()) && (e4 = null, delete r3._headers["content-length"]); | |
const n3 = { body: e4, headers: r3._headers, status: r3.statusCode, statusText: r3.statusMessage }; | |
return t3.destroy(), r3.destroy(), n3; | |
}); | |
}); | |
var a2; | |
const c2 = function(e3, t3 = global.fetch) { | |
return async function(r3, n3) { | |
const i3 = r3.toString(); | |
if (!i3.startsWith("/")) | |
return t3(i3, n3); | |
try { | |
const t4 = await e3({ url: i3, ...n3 }); | |
return new Response(t4.body, { status: t4.status, statusText: t4.statusText, headers: Object.fromEntries(Object.entries(t4.headers).map(([e4, t5]) => [e4, Array.isArray(t5) ? t5.join(",") : String(t5) || ""])) }); | |
} catch (e4) { | |
return new Response(e4.toString(), { status: Number.parseInt(e4.statusCode || e4.code) || 500, statusText: e4.statusText }); | |
} | |
}; | |
}(i2, globalThis.fetch), u2 = createFetch$1({ fetch: c2, Headers: Cr, defaults: { baseURL: e2.app.baseURL } }); | |
globalThis.$fetch = u2, r2.use(Yt((e3) => { | |
e3.context.nitro = e3.context.nitro || {}; | |
const t3 = e3.node.req.__unenv__; | |
t3 && Object.assign(e3.context, t3), e3.fetch = (t4, r3) => fetchWithEvent(e3, t4, r3, { fetch: c2 }), e3.$fetch = (t4, r3) => fetchWithEvent(e3, t4, r3, { fetch: u2 }); | |
})); | |
for (const t3 of Qr) { | |
let i3 = t3.lazy ? lazyEventHandler(t3.handler) : t3.handler; | |
if (t3.middleware || !t3.route) { | |
const n3 = (e2.app.baseURL + (t3.route || "/")).replace(/\/+/g, "/"); | |
r2.use(n3, i3); | |
} else { | |
const e3 = getRouteRulesForPath(t3.route.replace(/:\w+|\*\*/g, "_")); | |
e3.cache && (i3 = cachedEventHandler(i3, { group: "nitro/routes", ...e3.cache })), n2.use(t3.route, i3, t3.method); | |
} | |
} | |
r2.use(e2.app.baseURL, n2.handler); | |
const m2 = { hooks: t2, h3App: r2, router: n2, localCall: i2, localFetch: c2 }; | |
for (const e3 of Xr) | |
e3(m2); | |
return m2; | |
}(), useNitroApp = () => en, tn = { "/_nuxt": { maxAge: 31536e3 } }; | |
function assetsCacheControl(e2) { | |
const t2 = function(e3 = "") { | |
for (const t3 in tn) | |
if (e3.startsWith(t3)) | |
return tn[t3]; | |
return {}; | |
}(new URL(e2.url).pathname); | |
return t2.maxAge ? { browserTTL: t2.maxAge, edgeTTL: t2.maxAge } : {}; | |
} | |
addEventListener("fetch", (e2) => { | |
e2.respondWith(async function(e3) { | |
try { | |
return await q.getAssetFromKV(e3, { cacheControl: assetsCacheControl, mapRequestToAsset: baseURLModifier }); | |
} catch { | |
} | |
const t2 = new URL(e3.request.url); | |
let r2; | |
(function(e4) { | |
return Qt.test(e4.method); | |
})(e3.request) && (r2 = b.from(await e3.request.arrayBuffer())); | |
const n2 = await en.localCall({ event: e3, context: { cf: e3.request.cf }, url: t2.pathname + t2.search, host: t2.hostname, protocol: t2.protocol, headers: Object.fromEntries(e3.request.headers.entries()), method: e3.request.method, redirect: e3.request.redirect, body: r2 }); | |
return new Response(n2.body, { headers: normalizeOutgoingHeaders(n2.headers), status: n2.status, statusText: n2.statusText }); | |
}(e2)); | |
}); | |
const baseURLModifier = (e2) => { | |
const t2 = withoutBase(e2.url, useRuntimeConfig$1().app.baseURL); | |
return q.mapRequestToAsset(new Request(t2, e2)); | |
}; | |
function normalizeOutgoingHeaders(e2) { | |
return Object.entries(e2).map(([e3, t2]) => [e3, Array.isArray(t2) ? t2.join(",") : t2]); | |
} | |
const rn = { appName: "Nuxt", version: "", statusCode: 500, statusMessage: "Server error", description: "This page is temporarily unavailable." }, template$1 = (e2) => function({ messages: e3 }) { | |
var t2, r2 = ""; | |
return r2 + "<!DOCTYPE html><html><head><title>" + (null == (t2 = e3.statusCode) ? "" : t2) + " - " + (null == (t2 = e3.statusMessage) ? "" : t2) + " | " + (null == (t2 = e3.appName) ? "" : t2) + `</title><meta charset="utf-8"><meta content="width=device-width,initial-scale=1,minimum-scale=1" name="viewport"><style>.spotlight{background:linear-gradient(45deg, #00DC82 0%, #36E4DA 50%, #0047E1 100%);filter:blur(20vh)}*,:before,:after{-webkit-box-sizing:border-box;box-sizing:border-box;border-width:0;border-style:solid;border-color:#e0e0e0}*{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(14, 165, 233, .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}:root{-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{margin:0;font-family:inherit;line-height:inherit}html{-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";line-height:1.5}h1,p{margin:0}h1{font-size:inherit;font-weight:inherit}.bg-white{--tw-bg-opacity:1;background-color:rgba(255,255,255,var(--tw-bg-opacity))}.grid{display:-ms-grid;display:grid}.place-content-center{place-content:center}.font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.font-medium{font-weight:500}.font-light{font-weight:300}.h-1\\/2{height:50%}.text-8xl{font-size:6rem;line-height:1}.text-xl{font-size:1.25rem;line-height:1.75rem}.leading-tight{line-height:1.25}.mb-8{margin-bottom:2rem}.mb-16{margin-bottom:4rem}.max-w-520px{max-width:520px}.min-h-screen{min-height:100vh}.overflow-hidden{overflow:hidden}.px-8{padding-left:2rem;padding-right:2rem}.fixed{position:fixed}.left-0{left:0}.right-0{right:0}.-bottom-1\\/2{bottom:-50%}.text-center{text-align:center}.text-black{--tw-text-opacity:1;color:rgba(0,0,0,var(--tw-text-opacity))}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (min-width: 640px){.sm\\:text-4xl{font-size:2.25rem;line-height:2.5rem}.sm\\:text-10xl{font-size:10rem;line-height:1}.sm\\:px-0{padding-left:0;padding-right:0}}@media (prefers-color-scheme: dark){.dark\\:bg-black{--tw-bg-opacity:1;background-color:rgba(0,0,0,var(--tw-bg-opacity))}.dark\\:text-white{--tw-text-opacity:1;color:rgba(255,255,255,var(--tw-text-opacity))}}</style><script>(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))i(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function s(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?r.credentials="include":e.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(e){if(e.ep)return;e.ep=!0;const r=s(e);fetch(e.href,r)}})();</script></head><body class="font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"><div class="fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"></div><div class="max-w-520px text-center"><h1 class="text-8xl sm:text-10xl font-medium mb-8">` + (null == (t2 = e3.statusCode) ? "" : t2) + '</h1><p class="text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight">' + (null == (t2 = e3.description) ? "" : t2) + "</p></div></body></html>"; | |
}({ messages: { ...rn, ...e2 } }), nn = Object.freeze(Object.defineProperty({ __proto__: null, template: template$1 }, Symbol.toStringTag, { value: "Module" })); | |
var sn, on, an, cn, ln, pn, __classPrivateFieldSet = function(e2, t2, r2, n2, i2) { | |
if ("m" === n2) | |
throw new TypeError("Private method is not writable"); | |
if ("a" === n2 && !i2) | |
throw new TypeError("Private accessor was defined without a setter"); | |
if ("function" == typeof t2 ? e2 !== t2 || !i2 : !t2.has(e2)) | |
throw new TypeError("Cannot write private member to an object whose class did not declare it"); | |
return "a" === n2 ? i2.call(e2, r2) : i2 ? i2.value = r2 : t2.set(e2, r2), r2; | |
}, __classPrivateFieldGet = function(e2, t2, r2, n2) { | |
if ("a" === r2 && !n2) | |
throw new TypeError("Private accessor was defined without a getter"); | |
if ("function" == typeof t2 ? e2 !== t2 || !n2 : !t2.has(e2)) | |
throw new TypeError("Cannot read private member from an object whose class did not declare it"); | |
return "m" === r2 ? n2 : "a" === r2 ? n2.call(e2) : n2 ? n2.value : t2.get(e2); | |
}; | |
const un = 3933; | |
function defaultCookies(e2) { | |
const t2 = e2 ? "__Secure-" : ""; | |
return { sessionToken: { name: `${t2}next-auth.session-token`, options: { httpOnly: true, sameSite: "lax", path: "/", secure: e2 } }, callbackUrl: { name: `${t2}next-auth.callback-url`, options: { httpOnly: true, sameSite: "lax", path: "/", secure: e2 } }, csrfToken: { name: (e2 ? "__Host-" : "") + "next-auth.csrf-token", options: { httpOnly: true, sameSite: "lax", path: "/", secure: e2 } }, pkceCodeVerifier: { name: `${t2}next-auth.pkce.code_verifier`, options: { httpOnly: true, sameSite: "lax", path: "/", secure: e2, maxAge: 900 } }, state: { name: `${t2}next-auth.state`, options: { httpOnly: true, sameSite: "lax", path: "/", secure: e2, maxAge: 900 } }, nonce: { name: `${t2}next-auth.nonce`, options: { httpOnly: true, sameSite: "lax", path: "/", secure: e2 } } }; | |
} | |
class SessionStore { | |
constructor(e2, t2, r2) { | |
sn.add(this), on.set(this, {}), an.set(this, void 0), cn.set(this, void 0), __classPrivateFieldSet(this, cn, r2, "f"), __classPrivateFieldSet(this, an, e2, "f"); | |
const { cookies: n2 } = t2, { name: i2 } = e2; | |
if ("function" == typeof n2?.getAll) | |
for (const { name: e3, value: t3 } of n2.getAll()) | |
e3.startsWith(i2) && (__classPrivateFieldGet(this, on, "f")[e3] = t3); | |
else if (n2 instanceof Map) | |
for (const e3 of n2.keys()) | |
e3.startsWith(i2) && (__classPrivateFieldGet(this, on, "f")[e3] = n2.get(e3)); | |
else | |
for (const e3 in n2) | |
e3.startsWith(i2) && (__classPrivateFieldGet(this, on, "f")[e3] = n2[e3]); | |
} | |
get value() { | |
const e2 = Object.keys(__classPrivateFieldGet(this, on, "f")).sort((e3, t2) => parseInt(e3.split(".").pop() || "0") - parseInt(t2.split(".").pop() || "0")); | |
return e2.map((e3) => __classPrivateFieldGet(this, on, "f")[e3]).join(""); | |
} | |
chunk(e2, t2) { | |
const r2 = __classPrivateFieldGet(this, sn, "m", pn).call(this), n2 = __classPrivateFieldGet(this, sn, "m", ln).call(this, { name: __classPrivateFieldGet(this, an, "f").name, value: e2, options: { ...__classPrivateFieldGet(this, an, "f").options, ...t2 } }); | |
for (const e3 of n2) | |
r2[e3.name] = e3; | |
return Object.values(r2); | |
} | |
clean() { | |
return Object.values(__classPrivateFieldGet(this, sn, "m", pn).call(this)); | |
} | |
} | |
on = /* @__PURE__ */ new WeakMap(), an = /* @__PURE__ */ new WeakMap(), cn = /* @__PURE__ */ new WeakMap(), sn = /* @__PURE__ */ new WeakSet(), ln = function(e2) { | |
const t2 = Math.ceil(e2.value.length / un); | |
if (1 === t2) | |
return __classPrivateFieldGet(this, on, "f")[e2.name] = e2.value, [e2]; | |
const r2 = []; | |
for (let n2 = 0; n2 < t2; n2++) { | |
const t3 = `${e2.name}.${n2}`, i2 = e2.value.substr(n2 * un, un); | |
r2.push({ ...e2, name: t3, value: i2 }), __classPrivateFieldGet(this, on, "f")[t3] = i2; | |
} | |
return __classPrivateFieldGet(this, cn, "f").debug("CHUNKING_SESSION_COOKIE", { message: "Session cookie exceeds allowed 4096 bytes.", emptyCookieSize: 163, valueSize: e2.value.length, chunks: r2.map((e3) => e3.value.length + 163) }), r2; | |
}, pn = function() { | |
const e2 = {}; | |
for (const t2 in __classPrivateFieldGet(this, on, "f")) | |
delete __classPrivateFieldGet(this, on, "f")?.[t2], e2[t2] = { name: t2, value: "", options: { ...__classPrivateFieldGet(this, an, "f").options, maxAge: 0 } }; | |
return e2; | |
}; | |
class AuthError extends Error { | |
constructor(e2, t2) { | |
e2 instanceof Error ? super(void 0, { cause: { err: e2, ...e2.cause, ...t2 } }) : "string" == typeof e2 ? (t2 instanceof Error && (t2 = { err: t2, ...t2.cause }), super(e2, t2)) : super(void 0, e2), Error.captureStackTrace?.(this, this.constructor), this.name = e2 instanceof AuthError ? e2.name : this.constructor.name; | |
} | |
} | |
class AdapterError extends AuthError { | |
} | |
class AuthorizedCallbackError extends AuthError { | |
} | |
class CallbackRouteError extends AuthError { | |
} | |
class ErrorPageLoop extends AuthError { | |
} | |
class EventError extends AuthError { | |
} | |
class InvalidCallbackUrl extends AuthError { | |
} | |
class InvalidEndpoints extends AuthError { | |
} | |
class InvalidCheck extends AuthError { | |
} | |
class JWTSessionError extends AuthError { | |
} | |
class MissingAdapter extends AuthError { | |
} | |
class MissingAdapterMethods extends AuthError { | |
} | |
class MissingAuthorize extends AuthError { | |
} | |
class MissingSecret extends AuthError { | |
} | |
class OAuthAccountNotLinked extends AuthError { | |
} | |
class OAuthCallbackError extends AuthError { | |
} | |
class OAuthProfileParseError extends AuthError { | |
} | |
class SessionTokenError extends AuthError { | |
} | |
class SignInError extends AuthError { | |
} | |
class SignOutError extends AuthError { | |
} | |
class UnknownAction extends AuthError { | |
} | |
class UnsupportedStrategy extends AuthError { | |
} | |
class UntrustedHost extends AuthError { | |
} | |
class Verification extends AuthError { | |
} | |
let dn = false; | |
function isValidHttpUrl(e2, t2) { | |
try { | |
return /^https?:/.test(new URL(e2, e2.startsWith("/") ? t2 : void 0).protocol); | |
} catch { | |
return false; | |
} | |
} | |
let hn = false, mn = false; | |
const gn = ["createVerificationToken", "useVerificationToken", "getUserByEmail"], yn = ["createUser", "getUser", "getUserByEmail", "getUserByAccount", "updateUser", "linkAccount", "createSession", "getSessionAndUser", "updateSession", "deleteSession"]; | |
const fallback = (e2, t2, r2, n2, i2) => { | |
const a2 = parseInt(e2.substr(3), 10) >> 3 || 20, c2 = Le(e2, r2.byteLength ? r2 : new Uint8Array(a2)).update(t2).digest(), u2 = Math.ceil(i2 / a2), m2 = new Uint8Array(a2 * u2 + n2.byteLength + 1); | |
let g2 = 0, b2 = 0; | |
for (let t3 = 1; t3 <= u2; t3++) | |
m2.set(n2, b2), m2[b2 + n2.byteLength] = t3, m2.set(Le(e2, c2).update(m2.subarray(g2, b2 + n2.byteLength + 1)).digest(), b2), g2 = b2, b2 += a2; | |
return m2.slice(0, i2); | |
}; | |
let bn; | |
"function" != typeof Je || R.versions.electron || (bn = async (...e2) => new Promise((t2, r2) => { | |
Je(...e2, (e3, n2) => { | |
e3 ? r2(e3) : t2(new Uint8Array(n2)); | |
}); | |
})); | |
const derive = async (e2, t2, r2, n2, i2) => (bn || fallback)(e2, t2, r2, n2, i2); | |
function normalizeUint8Array(e2, t2) { | |
if ("string" == typeof e2) | |
return new TextEncoder().encode(e2); | |
if (!(e2 instanceof Uint8Array)) | |
throw new TypeError(`"${t2}"" must be an instance of Uint8Array or a string`); | |
return e2; | |
} | |
async function hkdf(e2, t2, r2, n2, i2) { | |
return derive(function(e3) { | |
switch (e3) { | |
case "sha256": | |
case "sha384": | |
case "sha512": | |
case "sha1": | |
return e3; | |
default: | |
throw new TypeError('unsupported "digest" value'); | |
} | |
}(e2), function(e3) { | |
const t3 = normalizeUint8Array(e3, "ikm"); | |
if (!t3.byteLength) | |
throw new TypeError('"ikm" must be at least one byte in length'); | |
return t3; | |
}(t2), normalizeUint8Array(r2, "salt"), function(e3) { | |
const t3 = normalizeUint8Array(e3, "info"); | |
if (t3.byteLength > 1024) | |
throw TypeError('"info" must not contain more than 1024 bytes'); | |
return t3; | |
}(n2), function(e3, t3) { | |
if ("number" != typeof e3 || !Number.isInteger(e3) || e3 < 1) | |
throw new TypeError('"keylen" must be a positive integer'); | |
if (e3 > 255 * (parseInt(t3.substr(3), 10) >> 3 || 20)) | |
throw new TypeError('"keylen" too large'); | |
return e3; | |
}(i2, e2)); | |
} | |
const digest$1 = (e2, t2) => Oe(e2).update(t2).digest(), vn = new TextEncoder(), xn = new TextDecoder(), wn = 2 ** 32; | |
function concat(...e2) { | |
const t2 = e2.reduce((e3, { length: t3 }) => e3 + t3, 0), r2 = new Uint8Array(t2); | |
let n2 = 0; | |
return e2.forEach((e3) => { | |
r2.set(e3, n2), n2 += e3.length; | |
}), r2; | |
} | |
function p2s(e2, t2) { | |
return concat(vn.encode(e2), new Uint8Array([0]), t2); | |
} | |
function writeUInt32BE(e2, t2, r2) { | |
if (t2 < 0 || t2 >= wn) | |
throw new RangeError(`value must be >= 0 and <= ${wn - 1}. Received ${t2}`); | |
e2.set([t2 >>> 24, t2 >>> 16, t2 >>> 8, 255 & t2], r2); | |
} | |
function uint32be(e2) { | |
const t2 = new Uint8Array(4); | |
return writeUInt32BE(t2, e2), t2; | |
} | |
function lengthAndInput(e2) { | |
return concat(uint32be(e2.length), e2); | |
} | |
let Cn; | |
Cn = b.isEncoding("base64url") ? (e2) => b.from(e2).toString("base64url") : (e2) => b.from(e2).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); | |
const decode$4 = (e2) => b.from(function(e3) { | |
let t2 = e3; | |
return t2 instanceof Uint8Array && (t2 = xn.decode(t2)), t2; | |
}(e2), "base64"); | |
class JOSEError extends Error { | |
static get code() { | |
return "ERR_JOSE_GENERIC"; | |
} | |
constructor(e2) { | |
var t2; | |
super(e2), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, null === (t2 = Error.captureStackTrace) || void 0 === t2 || t2.call(Error, this, this.constructor); | |
} | |
} | |
class JWTClaimValidationFailed extends JOSEError { | |
static get code() { | |
return "ERR_JWT_CLAIM_VALIDATION_FAILED"; | |
} | |
constructor(e2, t2 = "unspecified", r2 = "unspecified") { | |
super(e2), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = t2, this.reason = r2; | |
} | |
} | |
class JWTExpired extends JOSEError { | |
static get code() { | |
return "ERR_JWT_EXPIRED"; | |
} | |
constructor(e2, t2 = "unspecified", r2 = "unspecified") { | |
super(e2), this.code = "ERR_JWT_EXPIRED", this.claim = t2, this.reason = r2; | |
} | |
} | |
class JOSEAlgNotAllowed extends JOSEError { | |
constructor() { | |
super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED"; | |
} | |
static get code() { | |
return "ERR_JOSE_ALG_NOT_ALLOWED"; | |
} | |
} | |
class JOSENotSupported extends JOSEError { | |
constructor() { | |
super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED"; | |
} | |
static get code() { | |
return "ERR_JOSE_NOT_SUPPORTED"; | |
} | |
} | |
class JWEDecryptionFailed extends JOSEError { | |
constructor() { | |
super(...arguments), this.code = "ERR_JWE_DECRYPTION_FAILED", this.message = "decryption operation failed"; | |
} | |
static get code() { | |
return "ERR_JWE_DECRYPTION_FAILED"; | |
} | |
} | |
class JWEInvalid extends JOSEError { | |
constructor() { | |
super(...arguments), this.code = "ERR_JWE_INVALID"; | |
} | |
static get code() { | |
return "ERR_JWE_INVALID"; | |
} | |
} | |
class JWTInvalid extends JOSEError { | |
constructor() { | |
super(...arguments), this.code = "ERR_JWT_INVALID"; | |
} | |
static get code() { | |
return "ERR_JWT_INVALID"; | |
} | |
} | |
function bitLength$1(e2) { | |
switch (e2) { | |
case "A128GCM": | |
case "A128GCMKW": | |
case "A192GCM": | |
case "A192GCMKW": | |
case "A256GCM": | |
case "A256GCMKW": | |
return 96; | |
case "A128CBC-HS256": | |
case "A192CBC-HS384": | |
case "A256CBC-HS512": | |
return 128; | |
default: | |
throw new JOSENotSupported(`Unsupported JWE Algorithm: ${e2}`); | |
} | |
} | |
const generateIv = (e2) => at(new Uint8Array(bitLength$1(e2) >> 3)), checkIvLength$1 = (e2, t2) => { | |
if (t2.length << 3 !== bitLength$1(e2)) | |
throw new JWEInvalid("Invalid Initialization Vector length"); | |
}, En = notImplemented("util.types.isExternal"), Sn = notImplemented("util.types.isArgumentsObject"), An = notImplemented("util.types.isNativeError"), kn = notImplemented("util.types.isAsyncFunction"), Pn = notImplemented("util.types.isGeneratorFunction"), Tn = notImplemented("util.types.isGeneratorObject"), _n = notImplemented("util.types.isMapIterator"), In = notImplemented("util.types.isSetIterator"), Dn = notImplemented("util.types.isProxy"), Nn = notImplemented("util.types.isModuleNamespaceObject"), On = notImplemented("util.types.isAnyArrayBuffer"), Ln = notImplemented("util.types.isBoxedPrimitive"), Rn = notImplemented("util.types.isArrayBufferView"), Mn = notImplemented("util.types.isTypedArray"), Fn = notImplemented("util.types.isUint8Array"), Bn = notImplemented("util.types.isUint8ClampedArray"), jn = notImplemented("util.types.isUint16Array"), $n = notImplemented("util.types.isUint32Array"), Un = notImplemented("util.types.isInt8Array"), Hn = notImplemented("util.types.isInt16Array"), Vn = notImplemented("util.types.isInt32Array"), zn = notImplemented("util.types.isFloat32Array"), qn = notImplemented("util.types.isFloat64Array"), Wn = notImplemented("util.types.isBigInt64Array"), Kn = notImplemented("util.types.isBigUint64Array"), Jn = notImplemented("util.types.isKeyObject"), Gn = notImplemented("util.types.isCryptoKey"), Zn = Object.freeze(Object.defineProperty({ __proto__: null, isAnyArrayBuffer: On, isArgumentsObject: Sn, isArrayBuffer: (e2) => e2 instanceof ArrayBuffer, isArrayBufferView: Rn, isAsyncFunction: kn, isBigInt64Array: Wn, isBigIntObject: (e2) => e2 instanceof BigInt, isBigUint64Array: Kn, isBooleanObject: (e2) => e2 instanceof Boolean, isBoxedPrimitive: Ln, isCryptoKey: Gn, isDataView: (e2) => e2 instanceof DataView, isDate: (e2) => e2 instanceof Date, isExternal: En, isFloat32Array: zn, isFloat64Array: qn, isGeneratorFunction: Pn, isGeneratorObject: Tn, isInt16Array: Hn, isInt32Array: Vn, isInt8Array: Un, isKeyObject: Jn, isMap: (e2) => e2 instanceof Map, isMapIterator: _n, isModuleNamespaceObject: Nn, isNativeError: An, isNumberObject: (e2) => e2 instanceof Number, isPromise: (e2) => e2 instanceof Promise, isProxy: Dn, isRegExp: (e2) => e2 instanceof RegExp, isSet: (e2) => e2 instanceof Set, isSetIterator: In, isSharedArrayBuffer: (e2) => e2 instanceof SharedArrayBuffer, isStringObject: (e2) => e2 instanceof String, isSymbolObject: (e2) => e2 instanceof Symbol, isTypedArray: Mn, isUint16Array: jn, isUint32Array: $n, isUint8Array: Fn, isUint8ClampedArray: Bn, isWeakMap: (e2) => e2 instanceof WeakMap, isWeakSet: (e2) => e2 instanceof WeakSet }, Symbol.toStringTag, { value: "Module" })), Yn = Symbol("customPromisify"); | |
function _promisify(e2) { | |
return e2[Yn] ? e2[Yn] : function(...t2) { | |
return new Promise((r2, n2) => { | |
try { | |
e2.call(this, ...t2, (e3, t3) => { | |
if (e3) | |
return n2(e3); | |
r2(t3); | |
}); | |
} catch (e3) { | |
n2(e3); | |
} | |
}); | |
}; | |
} | |
_promisify.custom = Yn; | |
const Xn = _promisify, Qn = Zn.isKeyObject ? (e2) => Zn.isKeyObject(e2) : (e2) => null != e2 && e2 instanceof Tt, checkCekLength$1 = (e2, t2) => { | |
let r2; | |
switch (e2) { | |
case "A128CBC-HS256": | |
case "A192CBC-HS384": | |
case "A256CBC-HS512": | |
r2 = parseInt(e2.slice(-3), 10); | |
break; | |
case "A128GCM": | |
case "A192GCM": | |
case "A256GCM": | |
r2 = parseInt(e2.slice(1, 4), 10); | |
break; | |
default: | |
throw new JOSENotSupported(`Content Encryption Algorithm ${e2} is not supported either by JOSE or your javascript runtime`); | |
} | |
if (t2 instanceof Uint8Array) { | |
const e3 = t2.byteLength << 3; | |
if (e3 !== r2) | |
throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${r2} bits, got ${e3} bits`); | |
} else { | |
if (!Qn(t2) || "secret" !== t2.type) | |
throw new TypeError("Invalid Content Encryption Key type"); | |
{ | |
const e3 = t2.symmetricKeySize << 3; | |
if (e3 !== r2) | |
throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${r2} bits, got ${e3} bits`); | |
} | |
} | |
}, es = ht; | |
function cbcTag(e2, t2, r2, n2, i2, a2) { | |
const c2 = concat(e2, t2, r2, function(e3) { | |
const t3 = Math.floor(e3 / wn), r3 = e3 % wn, n3 = new Uint8Array(8); | |
return writeUInt32BE(n3, t3, 0), writeUInt32BE(n3, r3, 4), n3; | |
}(e2.length << 3)), u2 = Le(`sha${n2}`, i2); | |
return u2.update(c2), u2.digest().slice(0, a2 >> 3); | |
} | |
const ts = we, rs = Zn.isCryptoKey ? (e2) => Zn.isCryptoKey(e2) : (e2) => false; | |
function unusable(e2, t2 = "algorithm.name") { | |
return new TypeError(`CryptoKey does not support this operation, its ${t2} must be ${e2}`); | |
} | |
function isAlgorithm(e2, t2) { | |
return e2.name === t2; | |
} | |
function checkEncCryptoKey(e2, t2, ...r2) { | |
switch (t2) { | |
case "A128GCM": | |
case "A192GCM": | |
case "A256GCM": { | |
if (!isAlgorithm(e2.algorithm, "AES-GCM")) | |
throw unusable("AES-GCM"); | |
const r3 = parseInt(t2.slice(1, 4), 10); | |
if (e2.algorithm.length !== r3) | |
throw unusable(r3, "algorithm.length"); | |
break; | |
} | |
case "A128KW": | |
case "A192KW": | |
case "A256KW": { | |
if (!isAlgorithm(e2.algorithm, "AES-KW")) | |
throw unusable("AES-KW"); | |
const r3 = parseInt(t2.slice(1, 4), 10); | |
if (e2.algorithm.length !== r3) | |
throw unusable(r3, "algorithm.length"); | |
break; | |
} | |
case "ECDH": | |
switch (e2.algorithm.name) { | |
case "ECDH": | |
case "X25519": | |
case "X448": | |
break; | |
default: | |
throw unusable("ECDH, X25519, or X448"); | |
} | |
break; | |
case "PBES2-HS256+A128KW": | |
case "PBES2-HS384+A192KW": | |
case "PBES2-HS512+A256KW": | |
if (!isAlgorithm(e2.algorithm, "PBKDF2")) | |
throw unusable("PBKDF2"); | |
break; | |
case "RSA-OAEP": | |
case "RSA-OAEP-256": | |
case "RSA-OAEP-384": | |
case "RSA-OAEP-512": { | |
if (!isAlgorithm(e2.algorithm, "RSA-OAEP")) | |
throw unusable("RSA-OAEP"); | |
const r3 = parseInt(t2.slice(9), 10) || 1, n2 = function(e3) { | |
return parseInt(e3.name.slice(4), 10); | |
}(e2.algorithm.hash); | |
if (n2 !== r3) | |
throw unusable(`SHA-${r3}`, "algorithm.hash"); | |
break; | |
} | |
default: | |
throw new TypeError("CryptoKey does not support this operation"); | |
} | |
!function(e3, t3) { | |
if (t3.length && !t3.some((t4) => e3.usages.includes(t4))) { | |
let e4 = "CryptoKey does not support this operation, its usages must include "; | |
if (t3.length > 2) { | |
const r3 = t3.pop(); | |
e4 += `one of ${t3.join(", ")}, or ${r3}.`; | |
} else | |
2 === t3.length ? e4 += `one of ${t3[0]} or ${t3[1]}.` : e4 += `${t3[0]}.`; | |
throw new TypeError(e4); | |
} | |
}(e2, r2); | |
} | |
function message(e2, t2, ...r2) { | |
if (r2.length > 2) { | |
const t3 = r2.pop(); | |
e2 += `one of type ${r2.join(", ")}, or ${t3}.`; | |
} else | |
2 === r2.length ? e2 += `one of type ${r2[0]} or ${r2[1]}.` : e2 += `of type ${r2[0]}.`; | |
return null == t2 ? e2 += ` Received ${t2}` : "function" == typeof t2 && t2.name ? e2 += ` Received function ${t2.name}` : "object" == typeof t2 && null != t2 && t2.constructor && t2.constructor.name && (e2 += ` Received an instance of ${t2.constructor.name}`), e2; | |
} | |
const invalidKeyInput = (e2, ...t2) => message("Key must be ", e2, ...t2); | |
function withAlg(e2, t2, ...r2) { | |
return message(`Key for the ${e2} algorithm must be `, t2, ...r2); | |
} | |
let ns; | |
const supported = (e2) => (ns || (ns = new Set(Ve())), ns.has(e2)), isKeyLike = (e2) => Qn(e2) || rs(e2), ss = ["KeyObject"]; | |
(globalThis.CryptoKey || (null == ts ? void 0 : ts.CryptoKey)) && ss.push("CryptoKey"); | |
const decrypt$3 = (e2, t2, r2, n2, i2, a2) => { | |
let c2; | |
if (rs(t2)) | |
checkEncCryptoKey(t2, e2, "decrypt"), c2 = Tt.from(t2); | |
else { | |
if (!(t2 instanceof Uint8Array || Qn(t2))) | |
throw new TypeError(invalidKeyInput(t2, ...ss, "Uint8Array")); | |
c2 = t2; | |
} | |
switch (checkCekLength$1(e2, c2), checkIvLength$1(e2, n2), e2) { | |
case "A128CBC-HS256": | |
case "A192CBC-HS384": | |
case "A256CBC-HS512": | |
return function(e3, t3, r3, n3, i3, a3) { | |
const c3 = parseInt(e3.slice(1, 4), 10); | |
Qn(t3) && (t3 = t3.export()); | |
const u2 = t3.subarray(c3 >> 3), m2 = t3.subarray(0, c3 >> 3), g2 = parseInt(e3.slice(-3), 10), b2 = `aes-${c3}-cbc`; | |
if (!supported(b2)) | |
throw new JOSENotSupported(`alg ${e3} is not supported by your javascript runtime`); | |
const x2 = cbcTag(a3, n3, r3, g2, m2, c3); | |
let C2, A2; | |
try { | |
C2 = es(i3, x2); | |
} catch { | |
} | |
if (!C2) | |
throw new JWEDecryptionFailed(); | |
try { | |
const e4 = _e(b2, u2, n3); | |
A2 = concat(e4.update(r3), e4.final()); | |
} catch { | |
} | |
if (!A2) | |
throw new JWEDecryptionFailed(); | |
return A2; | |
}(e2, c2, r2, n2, i2, a2); | |
case "A128GCM": | |
case "A192GCM": | |
case "A256GCM": | |
return function(e3, t3, r3, n3, i3, a3) { | |
const c3 = `aes-${parseInt(e3.slice(1, 4), 10)}-gcm`; | |
if (!supported(c3)) | |
throw new JOSENotSupported(`alg ${e3} is not supported by your javascript runtime`); | |
try { | |
const e4 = _e(c3, t3, n3, { authTagLength: 16 }); | |
e4.setAuthTag(i3), a3.byteLength && e4.setAAD(a3, { plaintextLength: r3.length }); | |
const u2 = e4.update(r3); | |
return e4.final(), u2; | |
} catch { | |
throw new JWEDecryptionFailed(); | |
} | |
}(e2, c2, r2, n2, i2, a2); | |
default: | |
throw new JOSENotSupported("Unsupported JWE Content Encryption Algorithm"); | |
} | |
}, is = Xn(U.inflateRaw), os = Xn(U.deflateRaw), inflate = (e2) => is(e2), deflate = (e2) => os(e2), isDisjoint$1 = (...e2) => { | |
const t2 = e2.filter(Boolean); | |
if (0 === t2.length || 1 === t2.length) | |
return true; | |
let r2; | |
for (const e3 of t2) { | |
const t3 = Object.keys(e3); | |
if (r2 && 0 !== r2.size) | |
for (const e4 of t3) { | |
if (r2.has(e4)) | |
return false; | |
r2.add(e4); | |
} | |
else | |
r2 = new Set(t3); | |
} | |
return true; | |
}; | |
function isObject$2(e2) { | |
if ("object" != typeof (t2 = e2) || null === t2 || "[object Object]" !== Object.prototype.toString.call(e2)) | |
return false; | |
var t2; | |
if (null === Object.getPrototypeOf(e2)) | |
return true; | |
let r2 = e2; | |
for (; null !== Object.getPrototypeOf(r2); ) | |
r2 = Object.getPrototypeOf(r2); | |
return Object.getPrototypeOf(e2) === r2; | |
} | |
function checkKeySize(e2, t2) { | |
if (e2.symmetricKeySize << 3 !== parseInt(t2.slice(1, 4), 10)) | |
throw new TypeError(`Invalid key size for alg: ${t2}`); | |
} | |
function ensureKeyObject$1(e2, t2, r2) { | |
if (Qn(e2)) | |
return e2; | |
if (e2 instanceof Uint8Array) | |
return Fe(e2); | |
if (rs(e2)) | |
return checkEncCryptoKey(e2, t2, r2), Tt.from(e2); | |
throw new TypeError(invalidKeyInput(e2, ...ss, "Uint8Array")); | |
} | |
const wrap$1 = (e2, t2, r2) => { | |
const n2 = `aes${parseInt(e2.slice(1, 4), 10)}-wrap`; | |
if (!supported(n2)) | |
throw new JOSENotSupported(`alg ${e2} is not supported either by JOSE or your javascript runtime`); | |
const i2 = ensureKeyObject$1(t2, e2, "wrapKey"); | |
checkKeySize(i2, e2); | |
const a2 = Te(n2, i2, b.alloc(8, 166)); | |
return concat(a2.update(r2), a2.final()); | |
}, unwrap$1 = (e2, t2, r2) => { | |
const n2 = `aes${parseInt(e2.slice(1, 4), 10)}-wrap`; | |
if (!supported(n2)) | |
throw new JOSENotSupported(`alg ${e2} is not supported either by JOSE or your javascript runtime`); | |
const i2 = ensureKeyObject$1(t2, e2, "unwrapKey"); | |
checkKeySize(i2, e2); | |
const a2 = _e(n2, i2, b.alloc(8, 166)); | |
return concat(a2.update(r2), a2.final()); | |
}, as = b.from([42, 134, 72, 206, 61, 3, 1, 7]), cs = b.from([43, 129, 4, 0, 34]), ls = b.from([43, 129, 4, 0, 35]), ps = b.from([43, 129, 4, 0, 10]), us = /* @__PURE__ */ new WeakMap(), getNamedCurve = (e2, t2) => { | |
var r2; | |
let n2; | |
if (rs(e2)) | |
n2 = Tt.from(e2); | |
else { | |
if (!Qn(e2)) | |
throw new TypeError(invalidKeyInput(e2, ...ss)); | |
n2 = e2; | |
} | |
if ("secret" === n2.type) | |
throw new TypeError('only "private" or "public" type keys can be used for this operation'); | |
switch (n2.asymmetricKeyType) { | |
case "ed25519": | |
case "ed448": | |
return `Ed${n2.asymmetricKeyType.slice(2)}`; | |
case "x25519": | |
case "x448": | |
return `X${n2.asymmetricKeyType.slice(1)}`; | |
case "ec": { | |
if (us.has(n2)) | |
return us.get(n2); | |
let e3 = null === (r2 = n2.asymmetricKeyDetails) || void 0 === r2 ? void 0 : r2.namedCurve; | |
if (e3 || "private" !== n2.type) { | |
if (!e3) { | |
const t3 = n2.export({ format: "der", type: "spki" }), r3 = t3[1] < 128 ? 14 : 15, i3 = t3[r3], a2 = t3.slice(r3 + 1, r3 + 1 + i3); | |
if (a2.equals(as)) | |
e3 = "prime256v1"; | |
else if (a2.equals(cs)) | |
e3 = "secp384r1"; | |
else if (a2.equals(ls)) | |
e3 = "secp521r1"; | |
else { | |
if (!a2.equals(ps)) | |
throw new JOSENotSupported("Unsupported key curve for this operation"); | |
e3 = "secp256k1"; | |
} | |
} | |
} else | |
e3 = getNamedCurve(Me(n2), true); | |
if (t2) | |
return e3; | |
const i2 = ((e4) => { | |
switch (e4) { | |
case "prime256v1": | |
return "P-256"; | |
case "secp384r1": | |
return "P-384"; | |
case "secp521r1": | |
return "P-521"; | |
case "secp256k1": | |
return "secp256k1"; | |
default: | |
throw new JOSENotSupported("Unsupported key curve for this operation"); | |
} | |
})(e3); | |
return us.set(n2, i2), i2; | |
} | |
default: | |
throw new TypeError("Invalid asymmetric key type for this operation"); | |
} | |
}; | |
function setCurve(e2, t2) { | |
us.set(e2, t2); | |
} | |
const ds = getNamedCurve, hs = Xn(Xe); | |
async function deriveKey(e2, t2, r2, n2, i2 = new Uint8Array(0), a2 = new Uint8Array(0)) { | |
let c2, u2; | |
if (rs(e2)) | |
checkEncCryptoKey(e2, "ECDH"), c2 = Tt.from(e2); | |
else { | |
if (!Qn(e2)) | |
throw new TypeError(invalidKeyInput(e2, ...ss)); | |
c2 = e2; | |
} | |
if (rs(t2)) | |
checkEncCryptoKey(t2, "ECDH", "deriveBits"), u2 = Tt.from(t2); | |
else { | |
if (!Qn(t2)) | |
throw new TypeError(invalidKeyInput(t2, ...ss)); | |
u2 = t2; | |
} | |
const m2 = concat(lengthAndInput(vn.encode(r2)), lengthAndInput(i2), lengthAndInput(a2), uint32be(n2)); | |
return async function(e3, t3, r3) { | |
const n3 = Math.ceil((t3 >> 3) / 32), i3 = new Uint8Array(32 * n3); | |
for (let t4 = 0; t4 < n3; t4++) { | |
const n4 = new Uint8Array(4 + e3.length + r3.length); | |
n4.set(uint32be(t4 + 1)), n4.set(e3, 4), n4.set(r3, 4 + e3.length), i3.set(await digest$1("sha256", n4), 32 * t4); | |
} | |
return i3.slice(0, t3 >> 3); | |
}($e({ privateKey: u2, publicKey: c2 }), n2, m2); | |
} | |
const ecdhAllowed = (e2) => ["P-256", "P-384", "P-521", "X25519", "X448"].includes(ds(e2)); | |
function checkP2s(e2) { | |
if (!(e2 instanceof Uint8Array) || e2.length < 8) | |
throw new JWEInvalid("PBES2 Salt Input must be 8 or more octets"); | |
} | |
const fs = Xn(Ze); | |
function getPassword(e2, t2) { | |
if (Qn(e2)) | |
return e2.export(); | |
if (e2 instanceof Uint8Array) | |
return e2; | |
if (rs(e2)) | |
return checkEncCryptoKey(e2, t2, "deriveBits", "deriveKey"), Tt.from(e2).export(); | |
throw new TypeError(invalidKeyInput(e2, ...ss, "Uint8Array")); | |
} | |
const encrypt$3 = async (e2, t2, r2, n2 = 2048, i2 = at(new Uint8Array(16))) => { | |
checkP2s(i2); | |
const a2 = p2s(e2, i2), c2 = parseInt(e2.slice(13, 16), 10) >> 3, u2 = getPassword(t2, e2), m2 = await fs(u2, a2, n2, c2, `sha${e2.slice(8, 11)}`); | |
return { encryptedKey: await wrap$1(e2.slice(-6), m2, r2), p2c: n2, p2s: Cn(i2) }; | |
}, decrypt$1 = async (e2, t2, r2, n2, i2) => { | |
checkP2s(i2); | |
const a2 = p2s(e2, i2), c2 = parseInt(e2.slice(13, 16), 10) >> 3, u2 = getPassword(t2, e2), m2 = await fs(u2, a2, n2, c2, `sha${e2.slice(8, 11)}`); | |
return unwrap$1(e2.slice(-6), m2, r2); | |
}, ms = /* @__PURE__ */ new WeakMap(), getLength = (e2, t2) => { | |
let r2 = e2.readUInt8(1); | |
if (0 == (128 & r2)) | |
return 0 === t2 ? r2 : getLength(e2.subarray(2 + r2), t2 - 1); | |
const n2 = 127 & r2; | |
r2 = 0; | |
for (let t3 = 0; t3 < n2; t3++) { | |
r2 <<= 8; | |
r2 |= e2.readUInt8(2 + t3); | |
} | |
return 0 === t2 ? r2 : getLength(e2.subarray(2 + r2), t2 - 1); | |
}, getModulusLength = (e2) => { | |
var t2, r2; | |
if (ms.has(e2)) | |
return ms.get(e2); | |
const n2 = null !== (r2 = null === (t2 = e2.asymmetricKeyDetails) || void 0 === t2 ? void 0 : t2.modulusLength) && void 0 !== r2 ? r2 : ((e3, t3) => { | |
const r3 = e3.readUInt8(1); | |
if (0 == (128 & r3)) | |
return getLength(e3.subarray(2), t3); | |
const n3 = 127 & r3; | |
return getLength(e3.subarray(2 + n3), t3); | |
})(e2.export({ format: "der", type: "pkcs1" }), "private" === e2.type ? 1 : 0) - 1 << 3; | |
return ms.set(e2, n2), n2; | |
}, checkKey = (e2, t2) => { | |
if ("rsa" !== e2.asymmetricKeyType) | |
throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be rsa"); | |
((e3, t3) => { | |
if (getModulusLength(e3) < 2048) | |
throw new TypeError(`${t3} requires key modulusLength to be 2048 bits or larger`); | |
})(e2, t2); | |
}, resolvePadding = (e2) => { | |
switch (e2) { | |
case "RSA-OAEP": | |
case "RSA-OAEP-256": | |
case "RSA-OAEP-384": | |
case "RSA-OAEP-512": | |
return Ce.RSA_PKCS1_OAEP_PADDING; | |
case "RSA1_5": | |
return Ce.RSA_PKCS1_PADDING; | |
default: | |
return; | |
} | |
}, resolveOaepHash = (e2) => { | |
switch (e2) { | |
case "RSA-OAEP": | |
return "sha1"; | |
case "RSA-OAEP-256": | |
return "sha256"; | |
case "RSA-OAEP-384": | |
return "sha384"; | |
case "RSA-OAEP-512": | |
return "sha512"; | |
default: | |
return; | |
} | |
}; | |
function ensureKeyObject(e2, t2, ...r2) { | |
if (Qn(e2)) | |
return e2; | |
if (rs(e2)) | |
return checkEncCryptoKey(e2, t2, ...r2), Tt.from(e2); | |
throw new TypeError(invalidKeyInput(e2, ...ss)); | |
} | |
const decrypt = (e2, t2, r2) => { | |
const n2 = resolvePadding(e2), i2 = resolveOaepHash(e2), a2 = ensureKeyObject(t2, e2, "unwrapKey", "decrypt"); | |
return checkKey(a2, e2), rt({ key: a2, oaepHash: i2, padding: n2 }, r2); | |
}; | |
function bitLength(e2) { | |
switch (e2) { | |
case "A128GCM": | |
return 128; | |
case "A192GCM": | |
return 192; | |
case "A256GCM": | |
case "A128CBC-HS256": | |
return 256; | |
case "A192CBC-HS384": | |
return 384; | |
case "A256CBC-HS512": | |
return 512; | |
default: | |
throw new JOSENotSupported(`Unsupported JWE Algorithm: ${e2}`); | |
} | |
} | |
const generateCek = (e2) => at(new Uint8Array(bitLength(e2) >> 3)), gs = b.from([0]), ys = b.from([2]), bs = b.from([3]), vs = b.from([48]), xs = b.from([4]), encodeLength = (e2) => { | |
if (e2 < 128) | |
return b.from([e2]); | |
const t2 = b.alloc(5); | |
t2.writeUInt32BE(e2, 1); | |
let r2 = 1; | |
for (; 0 === t2[r2]; ) | |
r2++; | |
return t2[r2 - 1] = 128 | 5 - r2, t2.slice(r2 - 1); | |
}, ws = /* @__PURE__ */ new Map([["P-256", b.from("06 08 2A 86 48 CE 3D 03 01 07".replace(/ /g, ""), "hex")], ["secp256k1", b.from("06 05 2B 81 04 00 0A".replace(/ /g, ""), "hex")], ["P-384", b.from("06 05 2B 81 04 00 22".replace(/ /g, ""), "hex")], ["P-521", b.from("06 05 2B 81 04 00 23".replace(/ /g, ""), "hex")], ["ecPublicKey", b.from("06 07 2A 86 48 CE 3D 02 01".replace(/ /g, ""), "hex")], ["X25519", b.from("06 03 2B 65 6E".replace(/ /g, ""), "hex")], ["X448", b.from("06 03 2B 65 6F".replace(/ /g, ""), "hex")], ["Ed25519", b.from("06 03 2B 65 70".replace(/ /g, ""), "hex")], ["Ed448", b.from("06 03 2B 65 71".replace(/ /g, ""), "hex")]]); | |
class DumbAsn1Encoder { | |
constructor() { | |
this.length = 0, this.elements = []; | |
} | |
oidFor(e2) { | |
const t2 = ws.get(e2); | |
if (!t2) | |
throw new JOSENotSupported("Invalid or unsupported OID"); | |
this.elements.push(t2), this.length += t2.length; | |
} | |
zero() { | |
this.elements.push(ys, b.from([1]), gs), this.length += 3; | |
} | |
one() { | |
this.elements.push(ys, b.from([1]), b.from([1])), this.length += 3; | |
} | |
unsignedInteger(e2) { | |
if (128 & e2[0]) { | |
const t2 = encodeLength(e2.length + 1); | |
this.elements.push(ys, t2, gs, e2), this.length += 2 + t2.length + e2.length; | |
} else { | |
let t2 = 0; | |
for (; 0 === e2[t2] && 0 == (128 & e2[t2 + 1]); ) | |
t2++; | |
const r2 = encodeLength(e2.length - t2); | |
this.elements.push(ys, encodeLength(e2.length - t2), e2.slice(t2)), this.length += 1 + r2.length + e2.length - t2; | |
} | |
} | |
octStr(e2) { | |
const t2 = encodeLength(e2.length); | |
this.elements.push(xs, encodeLength(e2.length), e2), this.length += 1 + t2.length + e2.length; | |
} | |
bitStr(e2) { | |
const t2 = encodeLength(e2.length + 1); | |
this.elements.push(bs, encodeLength(e2.length + 1), gs, e2), this.length += 1 + t2.length + e2.length + 1; | |
} | |
add(e2) { | |
this.elements.push(e2), this.length += e2.length; | |
} | |
end(e2 = vs) { | |
const t2 = encodeLength(this.length); | |
return b.concat([e2, t2, ...this.elements], 1 + t2.length + this.length); | |
} | |
} | |
const [Cs, Es] = R.versions.node.split(".").map((e2) => parseInt(e2, 10)); | |
R.versions; | |
const Ss = Cs >= 16 || 15 === Cs && Es >= 9, As = Cs >= 16 || 15 === Cs && Es >= 12, asKeyObject = (e2) => { | |
if (As && "oct" !== e2.kty) | |
return e2.d ? Re({ format: "jwk", key: e2 }) : Me({ format: "jwk", key: e2 }); | |
switch (e2.kty) { | |
case "oct": | |
return Fe(decode$4(e2.k)); | |
case "RSA": { | |
const t2 = new DumbAsn1Encoder(), r2 = void 0 !== e2.d, n2 = b.from(e2.n, "base64"), i2 = b.from(e2.e, "base64"); | |
r2 ? (t2.zero(), t2.unsignedInteger(n2), t2.unsignedInteger(i2), t2.unsignedInteger(b.from(e2.d, "base64")), t2.unsignedInteger(b.from(e2.p, "base64")), t2.unsignedInteger(b.from(e2.q, "base64")), t2.unsignedInteger(b.from(e2.dp, "base64")), t2.unsignedInteger(b.from(e2.dq, "base64")), t2.unsignedInteger(b.from(e2.qi, "base64"))) : (t2.unsignedInteger(n2), t2.unsignedInteger(i2)); | |
const a2 = { key: t2.end(), format: "der", type: "pkcs1" }, c2 = r2 ? Re(a2) : Me(a2); | |
return ((e3, t3) => { | |
ms.set(e3, t3); | |
})(c2, n2.length << 3), c2; | |
} | |
case "EC": { | |
const t2 = new DumbAsn1Encoder(), r2 = void 0 !== e2.d, n2 = b.concat([b.alloc(1, 4), b.from(e2.x, "base64"), b.from(e2.y, "base64")]); | |
if (r2) { | |
t2.zero(); | |
const r3 = new DumbAsn1Encoder(); | |
r3.oidFor("ecPublicKey"), r3.oidFor(e2.crv), t2.add(r3.end()); | |
const i3 = new DumbAsn1Encoder(); | |
i3.one(), i3.octStr(b.from(e2.d, "base64")); | |
const a3 = new DumbAsn1Encoder(); | |
a3.bitStr(n2); | |
const c3 = a3.end(b.from([161])); | |
i3.add(c3); | |
const u2 = i3.end(), m2 = new DumbAsn1Encoder(); | |
m2.add(u2); | |
const g2 = m2.end(b.from([4])); | |
t2.add(g2); | |
const x2 = t2.end(), C2 = Re({ key: x2, format: "der", type: "pkcs8" }); | |
return setCurve(C2, e2.crv), C2; | |
} | |
const i2 = new DumbAsn1Encoder(); | |
i2.oidFor("ecPublicKey"), i2.oidFor(e2.crv), t2.add(i2.end()), t2.bitStr(n2); | |
const a2 = t2.end(), c2 = Me({ key: a2, format: "der", type: "spki" }); | |
return setCurve(c2, e2.crv), c2; | |
} | |
case "OKP": { | |
const t2 = new DumbAsn1Encoder(); | |
if (void 0 !== e2.d) { | |
t2.zero(); | |
const r3 = new DumbAsn1Encoder(); | |
r3.oidFor(e2.crv), t2.add(r3.end()); | |
const n3 = new DumbAsn1Encoder(); | |
n3.octStr(b.from(e2.d, "base64")); | |
const i2 = n3.end(b.from([4])); | |
t2.add(i2); | |
const a2 = t2.end(); | |
return Re({ key: a2, format: "der", type: "pkcs8" }); | |
} | |
const r2 = new DumbAsn1Encoder(); | |
r2.oidFor(e2.crv), t2.add(r2.end()), t2.bitStr(b.from(e2.x, "base64")); | |
const n2 = t2.end(); | |
return Me({ key: n2, format: "der", type: "spki" }); | |
} | |
default: | |
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value'); | |
} | |
}; | |
const checkKeyType$1 = (e2, t2, r2) => { | |
e2.startsWith("HS") || "dir" === e2 || e2.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e2) ? ((e3, t3) => { | |
if (!(t3 instanceof Uint8Array)) { | |
if (!isKeyLike(t3)) | |
throw new TypeError(withAlg(e3, t3, ...ss, "Uint8Array")); | |
if ("secret" !== t3.type) | |
throw new TypeError(`${ss.join(" or ")} instances for symmetric algorithms must be of type "secret"`); | |
} | |
})(e2, t2) : ((e3, t3, r3) => { | |
if (!isKeyLike(t3)) | |
throw new TypeError(withAlg(e3, t3, ...ss)); | |
if ("secret" === t3.type) | |
throw new TypeError(`${ss.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`); | |
if ("sign" === r3 && "public" === t3.type) | |
throw new TypeError(`${ss.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`); | |
if ("decrypt" === r3 && "public" === t3.type) | |
throw new TypeError(`${ss.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`); | |
if (t3.algorithm && "verify" === r3 && "private" === t3.type) | |
throw new TypeError(`${ss.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`); | |
if (t3.algorithm && "encrypt" === r3 && "private" === t3.type) | |
throw new TypeError(`${ss.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`); | |
})(e2, t2, r2); | |
}; | |
const encrypt$1 = (e2, t2, r2, n2, i2) => { | |
let a2; | |
if (rs(r2)) | |
checkEncCryptoKey(r2, e2, "encrypt"), a2 = Tt.from(r2); | |
else { | |
if (!(r2 instanceof Uint8Array || Qn(r2))) | |
throw new TypeError(invalidKeyInput(r2, ...ss, "Uint8Array")); | |
a2 = r2; | |
} | |
switch (checkCekLength$1(e2, a2), checkIvLength$1(e2, n2), e2) { | |
case "A128CBC-HS256": | |
case "A192CBC-HS384": | |
case "A256CBC-HS512": | |
return function(e3, t3, r3, n3, i3) { | |
const a3 = parseInt(e3.slice(1, 4), 10); | |
Qn(r3) && (r3 = r3.export()); | |
const c2 = r3.subarray(a3 >> 3), u2 = r3.subarray(0, a3 >> 3), m2 = `aes-${a3}-cbc`; | |
if (!supported(m2)) | |
throw new JOSENotSupported(`alg ${e3} is not supported by your javascript runtime`); | |
const g2 = Te(m2, c2, n3), b2 = concat(g2.update(t3), g2.final()); | |
return { ciphertext: b2, tag: cbcTag(i3, n3, b2, parseInt(e3.slice(-3), 10), u2, a3) }; | |
}(e2, t2, a2, n2, i2); | |
case "A128GCM": | |
case "A192GCM": | |
case "A256GCM": | |
return function(e3, t3, r3, n3, i3) { | |
const a3 = `aes-${parseInt(e3.slice(1, 4), 10)}-gcm`; | |
if (!supported(a3)) | |
throw new JOSENotSupported(`alg ${e3} is not supported by your javascript runtime`); | |
const c2 = Te(a3, r3, n3, { authTagLength: 16 }); | |
i3.byteLength && c2.setAAD(i3, { plaintextLength: t3.length }); | |
const u2 = c2.update(t3); | |
return c2.final(), { ciphertext: u2, tag: c2.getAuthTag() }; | |
}(e2, t2, a2, n2, i2); | |
default: | |
throw new JOSENotSupported("Unsupported JWE Content Encryption Algorithm"); | |
} | |
}; | |
async function decryptKeyManagement(e2, t2, r2, n2, i2) { | |
switch (checkKeyType$1(e2, t2, "decrypt"), e2) { | |
case "dir": | |
if (void 0 !== r2) | |
throw new JWEInvalid("Encountered unexpected JWE Encrypted Key"); | |
return t2; | |
case "ECDH-ES": | |
if (void 0 !== r2) | |
throw new JWEInvalid("Encountered unexpected JWE Encrypted Key"); | |
case "ECDH-ES+A128KW": | |
case "ECDH-ES+A192KW": | |
case "ECDH-ES+A256KW": { | |
if (!isObject$2(n2.epk)) | |
throw new JWEInvalid('JOSE Header "epk" (Ephemeral Public Key) missing or invalid'); | |
if (!ecdhAllowed(t2)) | |
throw new JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime"); | |
const i3 = await async function(e3, t3, r3) { | |
var n3; | |
if (!isObject$2(e3)) | |
throw new TypeError("JWK must be an object"); | |
switch (t3 || (t3 = e3.alg), e3.kty) { | |
case "oct": | |
if ("string" != typeof e3.k || !e3.k) | |
throw new TypeError('missing "k" (Key Value) Parameter value'); | |
return null != r3 || (r3 = true !== e3.ext), r3 ? asKeyObject({ ...e3, alg: t3, ext: null !== (n3 = e3.ext) && void 0 !== n3 && n3 }) : decode$4(e3.k); | |
case "RSA": | |
if (void 0 !== e3.oth) | |
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported'); | |
case "EC": | |
case "OKP": | |
return asKeyObject({ ...e3, alg: t3 }); | |
default: | |
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value'); | |
} | |
}(n2.epk, e2); | |
let a2, c2; | |
if (void 0 !== n2.apu) { | |
if ("string" != typeof n2.apu) | |
throw new JWEInvalid('JOSE Header "apu" (Agreement PartyUInfo) invalid'); | |
a2 = decode$4(n2.apu); | |
} | |
if (void 0 !== n2.apv) { | |
if ("string" != typeof n2.apv) | |
throw new JWEInvalid('JOSE Header "apv" (Agreement PartyVInfo) invalid'); | |
c2 = decode$4(n2.apv); | |
} | |
const u2 = await deriveKey(i3, t2, "ECDH-ES" === e2 ? n2.enc : e2, "ECDH-ES" === e2 ? bitLength(n2.enc) : parseInt(e2.slice(-5, -2), 10), a2, c2); | |
if ("ECDH-ES" === e2) | |
return u2; | |
if (void 0 === r2) | |
throw new JWEInvalid("JWE Encrypted Key missing"); | |
return unwrap$1(e2.slice(-6), u2, r2); | |
} | |
case "RSA1_5": | |
case "RSA-OAEP": | |
case "RSA-OAEP-256": | |
case "RSA-OAEP-384": | |
case "RSA-OAEP-512": | |
if (void 0 === r2) | |
throw new JWEInvalid("JWE Encrypted Key missing"); | |
return decrypt(e2, t2, r2); | |
case "PBES2-HS256+A128KW": | |
case "PBES2-HS384+A192KW": | |
case "PBES2-HS512+A256KW": { | |
if (void 0 === r2) | |
throw new JWEInvalid("JWE Encrypted Key missing"); | |
if ("number" != typeof n2.p2c) | |
throw new JWEInvalid('JOSE Header "p2c" (PBES2 Count) missing or invalid'); | |
const a2 = (null == i2 ? void 0 : i2.maxPBES2Count) || 1e4; | |
if (n2.p2c > a2) | |
throw new JWEInvalid('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds'); | |
if ("string" != typeof n2.p2s) | |
throw new JWEInvalid('JOSE Header "p2s" (PBES2 Salt) missing or invalid'); | |
return decrypt$1(e2, t2, r2, n2.p2c, decode$4(n2.p2s)); | |
} | |
case "A128KW": | |
case "A192KW": | |
case "A256KW": | |
if (void 0 === r2) | |
throw new JWEInvalid("JWE Encrypted Key missing"); | |
return unwrap$1(e2, t2, r2); | |
case "A128GCMKW": | |
case "A192GCMKW": | |
case "A256GCMKW": | |
if (void 0 === r2) | |
throw new JWEInvalid("JWE Encrypted Key missing"); | |
if ("string" != typeof n2.iv) | |
throw new JWEInvalid('JOSE Header "iv" (Initialization Vector) missing or invalid'); | |
if ("string" != typeof n2.tag) | |
throw new JWEInvalid('JOSE Header "tag" (Authentication Tag) missing or invalid'); | |
return async function(e3, t3, r3, n3, i3) { | |
const a2 = e3.slice(0, 7); | |
return decrypt$3(a2, t3, r3, n3, i3, new Uint8Array(0)); | |
}(e2, t2, r2, decode$4(n2.iv), decode$4(n2.tag)); | |
default: | |
throw new JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value'); | |
} | |
} | |
function validateCrit(e2, t2, r2, n2, i2) { | |
if (void 0 !== i2.crit && void 0 === n2.crit) | |
throw new e2('"crit" (Critical) Header Parameter MUST be integrity protected'); | |
if (!n2 || void 0 === n2.crit) | |
return /* @__PURE__ */ new Set(); | |
if (!Array.isArray(n2.crit) || 0 === n2.crit.length || n2.crit.some((e3) => "string" != typeof e3 || 0 === e3.length)) | |
throw new e2('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present'); | |
let a2; | |
a2 = void 0 !== r2 ? new Map([...Object.entries(r2), ...t2.entries()]) : t2; | |
for (const t3 of n2.crit) { | |
if (!a2.has(t3)) | |
throw new JOSENotSupported(`Extension Header Parameter "${t3}" is not recognized`); | |
if (void 0 === i2[t3]) | |
throw new e2(`Extension Header Parameter "${t3}" is missing`); | |
if (a2.get(t3) && void 0 === n2[t3]) | |
throw new e2(`Extension Header Parameter "${t3}" MUST be integrity protected`); | |
} | |
return new Set(n2.crit); | |
} | |
const validateAlgorithms$1 = (e2, t2) => { | |
if (void 0 !== t2 && (!Array.isArray(t2) || t2.some((e3) => "string" != typeof e3))) | |
throw new TypeError(`"${e2}" option must be an array of strings`); | |
if (t2) | |
return new Set(t2); | |
}; | |
async function compactDecrypt(e2, t2, r2) { | |
if (e2 instanceof Uint8Array && (e2 = xn.decode(e2)), "string" != typeof e2) | |
throw new JWEInvalid("Compact JWE must be a string or Uint8Array"); | |
const { 0: n2, 1: i2, 2: a2, 3: c2, 4: u2, length: m2 } = e2.split("."); | |
if (5 !== m2) | |
throw new JWEInvalid("Invalid Compact JWE"); | |
const g2 = await async function(e3, t3, r3) { | |
var n3; | |
if (!isObject$2(e3)) | |
throw new JWEInvalid("Flattened JWE must be an object"); | |
if (void 0 === e3.protected && void 0 === e3.header && void 0 === e3.unprotected) | |
throw new JWEInvalid("JOSE Header missing"); | |
if ("string" != typeof e3.iv) | |
throw new JWEInvalid("JWE Initialization Vector missing or incorrect type"); | |
if ("string" != typeof e3.ciphertext) | |
throw new JWEInvalid("JWE Ciphertext missing or incorrect type"); | |
if ("string" != typeof e3.tag) | |
throw new JWEInvalid("JWE Authentication Tag missing or incorrect type"); | |
if (void 0 !== e3.protected && "string" != typeof e3.protected) | |
throw new JWEInvalid("JWE Protected Header incorrect type"); | |
if (void 0 !== e3.encrypted_key && "string" != typeof e3.encrypted_key) | |
throw new JWEInvalid("JWE Encrypted Key incorrect type"); | |
if (void 0 !== e3.aad && "string" != typeof e3.aad) | |
throw new JWEInvalid("JWE AAD incorrect type"); | |
if (void 0 !== e3.header && !isObject$2(e3.header)) | |
throw new JWEInvalid("JWE Shared Unprotected Header incorrect type"); | |
if (void 0 !== e3.unprotected && !isObject$2(e3.unprotected)) | |
throw new JWEInvalid("JWE Per-Recipient Unprotected Header incorrect type"); | |
let i3; | |
if (e3.protected) | |
try { | |
const t4 = decode$4(e3.protected); | |
i3 = JSON.parse(xn.decode(t4)); | |
} catch { | |
throw new JWEInvalid("JWE Protected Header is invalid"); | |
} | |
if (!isDisjoint$1(i3, e3.header, e3.unprotected)) | |
throw new JWEInvalid("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint"); | |
const a3 = { ...i3, ...e3.header, ...e3.unprotected }; | |
if (validateCrit(JWEInvalid, /* @__PURE__ */ new Map(), null == r3 ? void 0 : r3.crit, i3, a3), void 0 !== a3.zip) { | |
if (!i3 || !i3.zip) | |
throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header MUST be integrity protected'); | |
if ("DEF" !== a3.zip) | |
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value'); | |
} | |
const { alg: c3, enc: u3 } = a3; | |
if ("string" != typeof c3 || !c3) | |
throw new JWEInvalid("missing JWE Algorithm (alg) in JWE Header"); | |
if ("string" != typeof u3 || !u3) | |
throw new JWEInvalid("missing JWE Encryption Algorithm (enc) in JWE Header"); | |
const m3 = r3 && validateAlgorithms$1("keyManagementAlgorithms", r3.keyManagementAlgorithms), g3 = r3 && validateAlgorithms$1("contentEncryptionAlgorithms", r3.contentEncryptionAlgorithms); | |
if (m3 && !m3.has(c3)) | |
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter not allowed'); | |
if (g3 && !g3.has(u3)) | |
throw new JOSEAlgNotAllowed('"enc" (Encryption Algorithm) Header Parameter not allowed'); | |
let b3; | |
void 0 !== e3.encrypted_key && (b3 = decode$4(e3.encrypted_key)); | |
let x2, C2 = false; | |
"function" == typeof t3 && (t3 = await t3(i3, e3), C2 = true); | |
try { | |
x2 = await decryptKeyManagement(c3, t3, b3, a3, r3); | |
} catch (e4) { | |
if (e4 instanceof TypeError || e4 instanceof JWEInvalid || e4 instanceof JOSENotSupported) | |
throw e4; | |
x2 = generateCek(u3); | |
} | |
const A2 = decode$4(e3.iv), P2 = decode$4(e3.tag), T2 = vn.encode(null !== (n3 = e3.protected) && void 0 !== n3 ? n3 : ""); | |
let _2; | |
_2 = void 0 !== e3.aad ? concat(T2, vn.encode("."), vn.encode(e3.aad)) : T2; | |
let I2 = await decrypt$3(u3, x2, decode$4(e3.ciphertext), A2, P2, _2); | |
"DEF" === a3.zip && (I2 = await ((null == r3 ? void 0 : r3.inflateRaw) || inflate)(I2)); | |
const D2 = { plaintext: I2 }; | |
return void 0 !== e3.protected && (D2.protectedHeader = i3), void 0 !== e3.aad && (D2.additionalAuthenticatedData = decode$4(e3.aad)), void 0 !== e3.unprotected && (D2.sharedUnprotectedHeader = e3.unprotected), void 0 !== e3.header && (D2.unprotectedHeader = e3.header), C2 ? { ...D2, key: t3 } : D2; | |
}({ ciphertext: c2, iv: a2 || void 0, protected: n2 || void 0, tag: u2 || void 0, encrypted_key: i2 || void 0 }, t2, r2), b2 = { plaintext: g2.plaintext, protectedHeader: g2.protectedHeader }; | |
return "function" == typeof t2 ? { ...b2, key: g2.key } : b2; | |
} | |
class Asn1SequenceDecoder { | |
constructor(e2) { | |
if (48 !== e2[0]) | |
throw new TypeError(); | |
this.buffer = e2, this.offset = 1; | |
if (this.decodeLength() !== e2.length - this.offset) | |
throw new TypeError(); | |
} | |
decodeLength() { | |
let e2 = this.buffer[this.offset++]; | |
if (128 & e2) { | |
const t2 = -129 & e2; | |
e2 = 0; | |
for (let r2 = 0; r2 < t2; r2++) | |
e2 = e2 << 8 | this.buffer[this.offset + r2]; | |
this.offset += t2; | |
} | |
return e2; | |
} | |
unsignedInteger() { | |
if (2 !== this.buffer[this.offset++]) | |
throw new TypeError(); | |
let e2 = this.decodeLength(); | |
0 === this.buffer[this.offset] && (this.offset++, e2--); | |
const t2 = this.buffer.slice(this.offset, this.offset + e2); | |
return this.offset += e2, t2; | |
} | |
end() { | |
if (this.offset !== this.buffer.length) | |
throw new TypeError(); | |
} | |
} | |
const keyToJWK = (e2) => { | |
let t2; | |
if (rs(e2)) { | |
if (!e2.extractable) | |
throw new TypeError("CryptoKey is not extractable"); | |
t2 = Tt.from(e2); | |
} else { | |
if (!Qn(e2)) { | |
if (e2 instanceof Uint8Array) | |
return { kty: "oct", k: Cn(e2) }; | |
throw new TypeError(invalidKeyInput(e2, ...ss, "Uint8Array")); | |
} | |
t2 = e2; | |
} | |
if (Ss) { | |
if ("secret" !== t2.type && !["rsa", "ec", "ed25519", "x25519", "ed448", "x448"].includes(t2.asymmetricKeyType)) | |
throw new JOSENotSupported("Unsupported key asymmetricKeyType"); | |
return t2.export({ format: "jwk" }); | |
} | |
switch (t2.type) { | |
case "secret": | |
return { kty: "oct", k: Cn(t2.export()) }; | |
case "private": | |
case "public": | |
switch (t2.asymmetricKeyType) { | |
case "rsa": { | |
const e3 = t2.export({ format: "der", type: "pkcs1" }), r2 = new Asn1SequenceDecoder(e3); | |
"private" === t2.type && r2.unsignedInteger(); | |
const n2 = Cn(r2.unsignedInteger()), i2 = Cn(r2.unsignedInteger()); | |
let a2; | |
return "private" === t2.type && (a2 = { d: Cn(r2.unsignedInteger()), p: Cn(r2.unsignedInteger()), q: Cn(r2.unsignedInteger()), dp: Cn(r2.unsignedInteger()), dq: Cn(r2.unsignedInteger()), qi: Cn(r2.unsignedInteger()) }), r2.end(), { kty: "RSA", n: n2, e: i2, ...a2 }; | |
} | |
case "ec": { | |
const e3 = ds(t2); | |
let r2, n2, i2; | |
switch (e3) { | |
case "secp256k1": | |
r2 = 64, n2 = 33, i2 = -1; | |
break; | |
case "P-256": | |
r2 = 64, n2 = 36, i2 = -1; | |
break; | |
case "P-384": | |
r2 = 96, n2 = 35, i2 = -3; | |
break; | |
case "P-521": | |
r2 = 132, n2 = 35, i2 = -3; | |
break; | |
default: | |
throw new JOSENotSupported("Unsupported curve"); | |
} | |
if ("public" === t2.type) { | |
const n3 = t2.export({ type: "spki", format: "der" }); | |
return { kty: "EC", crv: e3, x: Cn(n3.subarray(-r2, -r2 / 2)), y: Cn(n3.subarray(-r2 / 2)) }; | |
} | |
const a2 = t2.export({ type: "pkcs8", format: "der" }); | |
return a2.length < 100 && (n2 += i2), { ...keyToJWK(Me(t2)), d: Cn(a2.subarray(n2, n2 + r2 / 2)) }; | |
} | |
case "ed25519": | |
case "x25519": { | |
const e3 = ds(t2); | |
if ("public" === t2.type) { | |
const r3 = t2.export({ type: "spki", format: "der" }); | |
return { kty: "OKP", crv: e3, x: Cn(r3.subarray(-32)) }; | |
} | |
const r2 = t2.export({ type: "pkcs8", format: "der" }); | |
return { ...keyToJWK(Me(t2)), d: Cn(r2.subarray(-32)) }; | |
} | |
case "ed448": | |
case "x448": { | |
const e3 = ds(t2); | |
if ("public" === t2.type) { | |
const r3 = t2.export({ type: "spki", format: "der" }); | |
return { kty: "OKP", crv: e3, x: Cn(r3.subarray("Ed448" === e3 ? -57 : -56)) }; | |
} | |
const r2 = t2.export({ type: "pkcs8", format: "der" }); | |
return { ...keyToJWK(Me(t2)), d: Cn(r2.subarray("Ed448" === e3 ? -57 : -56)) }; | |
} | |
default: | |
throw new JOSENotSupported("Unsupported key asymmetricKeyType"); | |
} | |
default: | |
throw new JOSENotSupported("Unsupported key type"); | |
} | |
}, ks = keyToJWK; | |
async function encryptKeyManagement(e2, t2, r2, n2, i2 = {}) { | |
let a2, c2, u2; | |
switch (checkKeyType$1(e2, r2, "encrypt"), e2) { | |
case "dir": | |
u2 = r2; | |
break; | |
case "ECDH-ES": | |
case "ECDH-ES+A128KW": | |
case "ECDH-ES+A192KW": | |
case "ECDH-ES+A256KW": { | |
if (!ecdhAllowed(r2)) | |
throw new JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime"); | |
const { apu: m2, apv: g2 } = i2; | |
let { epk: b2 } = i2; | |
b2 || (b2 = (await async function(e3) { | |
let t3; | |
if (rs(e3)) | |
t3 = Tt.from(e3); | |
else { | |
if (!Qn(e3)) | |
throw new TypeError(invalidKeyInput(e3, ...ss)); | |
t3 = e3; | |
} | |
switch (t3.asymmetricKeyType) { | |
case "x25519": | |
return hs("x25519"); | |
case "x448": | |
return hs("x448"); | |
case "ec": { | |
const e4 = ds(t3); | |
return hs("ec", { namedCurve: e4 }); | |
} | |
default: | |
throw new JOSENotSupported("Invalid or unsupported EPK"); | |
} | |
}(r2)).privateKey); | |
const { x: x2, y: C2, crv: A2, kty: P2 } = await async function(e3) { | |
return ks(e3); | |
}(b2), T2 = await deriveKey(r2, b2, "ECDH-ES" === e2 ? t2 : e2, "ECDH-ES" === e2 ? bitLength(t2) : parseInt(e2.slice(-5, -2), 10), m2, g2); | |
if (c2 = { epk: { x: x2, crv: A2, kty: P2 } }, "EC" === P2 && (c2.epk.y = C2), m2 && (c2.apu = Cn(m2)), g2 && (c2.apv = Cn(g2)), "ECDH-ES" === e2) { | |
u2 = T2; | |
break; | |
} | |
u2 = n2 || generateCek(t2); | |
const _2 = e2.slice(-6); | |
a2 = await wrap$1(_2, T2, u2); | |
break; | |
} | |
case "RSA1_5": | |
case "RSA-OAEP": | |
case "RSA-OAEP-256": | |
case "RSA-OAEP-384": | |
case "RSA-OAEP-512": | |
u2 = n2 || generateCek(t2), a2 = await ((e3, t3, r3) => { | |
const n3 = resolvePadding(e3), i3 = resolveOaepHash(e3), a3 = ensureKeyObject(t3, e3, "wrapKey", "encrypt"); | |
return checkKey(a3, e3), it({ key: a3, oaepHash: i3, padding: n3 }, r3); | |
})(e2, r2, u2); | |
break; | |
case "PBES2-HS256+A128KW": | |
case "PBES2-HS384+A192KW": | |
case "PBES2-HS512+A256KW": { | |
u2 = n2 || generateCek(t2); | |
const { p2c: m2, p2s: g2 } = i2; | |
({ encryptedKey: a2, ...c2 } = await encrypt$3(e2, r2, u2, m2, g2)); | |
break; | |
} | |
case "A128KW": | |
case "A192KW": | |
case "A256KW": | |
u2 = n2 || generateCek(t2), a2 = await wrap$1(e2, r2, u2); | |
break; | |
case "A128GCMKW": | |
case "A192GCMKW": | |
case "A256GCMKW": { | |
u2 = n2 || generateCek(t2); | |
const { iv: m2 } = i2; | |
({ encryptedKey: a2, ...c2 } = await async function(e3, t3, r3, n3) { | |
const i3 = e3.slice(0, 7); | |
n3 || (n3 = generateIv(i3)); | |
const { ciphertext: a3, tag: c3 } = await encrypt$1(i3, r3, t3, n3, new Uint8Array(0)); | |
return { encryptedKey: a3, iv: Cn(n3), tag: Cn(c3) }; | |
}(e2, r2, u2, m2)); | |
break; | |
} | |
default: | |
throw new JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value'); | |
} | |
return { cek: u2, encryptedKey: a2, parameters: c2 }; | |
} | |
const Ps = Symbol(); | |
class FlattenedEncrypt { | |
constructor(e2) { | |
if (!(e2 instanceof Uint8Array)) | |
throw new TypeError("plaintext must be an instance of Uint8Array"); | |
this._plaintext = e2; | |
} | |
setKeyManagementParameters(e2) { | |
if (this._keyManagementParameters) | |
throw new TypeError("setKeyManagementParameters can only be called once"); | |
return this._keyManagementParameters = e2, this; | |
} | |
setProtectedHeader(e2) { | |
if (this._protectedHeader) | |
throw new TypeError("setProtectedHeader can only be called once"); | |
return this._protectedHeader = e2, this; | |
} | |
setSharedUnprotectedHeader(e2) { | |
if (this._sharedUnprotectedHeader) | |
throw new TypeError("setSharedUnprotectedHeader can only be called once"); | |
return this._sharedUnprotectedHeader = e2, this; | |
} | |
setUnprotectedHeader(e2) { | |
if (this._unprotectedHeader) | |
throw new TypeError("setUnprotectedHeader can only be called once"); | |
return this._unprotectedHeader = e2, this; | |
} | |
setAdditionalAuthenticatedData(e2) { | |
return this._aad = e2, this; | |
} | |
setContentEncryptionKey(e2) { | |
if (this._cek) | |
throw new TypeError("setContentEncryptionKey can only be called once"); | |
return this._cek = e2, this; | |
} | |
setInitializationVector(e2) { | |
if (this._iv) | |
throw new TypeError("setInitializationVector can only be called once"); | |
return this._iv = e2, this; | |
} | |
async encrypt(e2, t2) { | |
if (!this._protectedHeader && !this._unprotectedHeader && !this._sharedUnprotectedHeader) | |
throw new JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()"); | |
if (!isDisjoint$1(this._protectedHeader, this._unprotectedHeader, this._sharedUnprotectedHeader)) | |
throw new JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint"); | |
const r2 = { ...this._protectedHeader, ...this._unprotectedHeader, ...this._sharedUnprotectedHeader }; | |
if (validateCrit(JWEInvalid, /* @__PURE__ */ new Map(), null == t2 ? void 0 : t2.crit, this._protectedHeader, r2), void 0 !== r2.zip) { | |
if (!this._protectedHeader || !this._protectedHeader.zip) | |
throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header MUST be integrity protected'); | |
if ("DEF" !== r2.zip) | |
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value'); | |
} | |
const { alg: n2, enc: i2 } = r2; | |
if ("string" != typeof n2 || !n2) | |
throw new JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid'); | |
if ("string" != typeof i2 || !i2) | |
throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid'); | |
let a2, c2, u2, m2, g2, b2, x2; | |
if ("dir" === n2) { | |
if (this._cek) | |
throw new TypeError("setContentEncryptionKey cannot be called when using Direct Encryption"); | |
} else if ("ECDH-ES" === n2 && this._cek) | |
throw new TypeError("setContentEncryptionKey cannot be called when using Direct Key Agreement"); | |
{ | |
let r3; | |
({ cek: c2, encryptedKey: a2, parameters: r3 } = await encryptKeyManagement(n2, i2, e2, this._cek, this._keyManagementParameters)), r3 && (t2 && Ps in t2 ? this._unprotectedHeader ? this._unprotectedHeader = { ...this._unprotectedHeader, ...r3 } : this.setUnprotectedHeader(r3) : this._protectedHeader ? this._protectedHeader = { ...this._protectedHeader, ...r3 } : this.setProtectedHeader(r3)); | |
} | |
if (this._iv || (this._iv = generateIv(i2)), m2 = this._protectedHeader ? vn.encode(Cn(JSON.stringify(this._protectedHeader))) : vn.encode(""), this._aad ? (g2 = Cn(this._aad), u2 = concat(m2, vn.encode("."), vn.encode(g2))) : u2 = m2, "DEF" === r2.zip) { | |
const e3 = await ((null == t2 ? void 0 : t2.deflateRaw) || deflate)(this._plaintext); | |
({ ciphertext: b2, tag: x2 } = await encrypt$1(i2, e3, c2, this._iv, u2)); | |
} else | |
({ ciphertext: b2, tag: x2 } = await encrypt$1(i2, this._plaintext, c2, this._iv, u2)); | |
const C2 = { ciphertext: Cn(b2), iv: Cn(this._iv), tag: Cn(x2) }; | |
return a2 && (C2.encrypted_key = Cn(a2)), g2 && (C2.aad = g2), this._protectedHeader && (C2.protected = xn.decode(m2)), this._sharedUnprotectedHeader && (C2.unprotected = this._sharedUnprotectedHeader), this._unprotectedHeader && (C2.header = this._unprotectedHeader), C2; | |
} | |
} | |
const epoch = (e2) => Math.floor(e2.getTime() / 1e3), Ts = 86400, _s = /^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i, secs = (e2) => { | |
const t2 = _s.exec(e2); | |
if (!t2) | |
throw new TypeError("Invalid time period format"); | |
const r2 = parseFloat(t2[1]); | |
switch (t2[2].toLowerCase()) { | |
case "sec": | |
case "secs": | |
case "second": | |
case "seconds": | |
case "s": | |
return Math.round(r2); | |
case "minute": | |
case "minutes": | |
case "min": | |
case "mins": | |
case "m": | |
return Math.round(60 * r2); | |
case "hour": | |
case "hours": | |
case "hr": | |
case "hrs": | |
case "h": | |
return Math.round(3600 * r2); | |
case "day": | |
case "days": | |
case "d": | |
return Math.round(r2 * Ts); | |
case "week": | |
case "weeks": | |
case "w": | |
return Math.round(604800 * r2); | |
default: | |
return Math.round(31557600 * r2); | |
} | |
}, normalizeTyp = (e2) => e2.toLowerCase().replace(/^application\//, ""), jwtPayload = (e2, t2, r2 = {}) => { | |
const { typ: n2 } = r2; | |
if (n2 && ("string" != typeof e2.typ || normalizeTyp(e2.typ) !== normalizeTyp(n2))) | |
throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', "typ", "check_failed"); | |
let i2; | |
try { | |
i2 = JSON.parse(xn.decode(t2)); | |
} catch { | |
} | |
if (!isObject$2(i2)) | |
throw new JWTInvalid("JWT Claims Set must be a top-level JSON object"); | |
const { requiredClaims: a2 = [], issuer: c2, subject: u2, audience: m2, maxTokenAge: g2 } = r2; | |
void 0 !== g2 && a2.push("iat"), void 0 !== m2 && a2.push("aud"), void 0 !== u2 && a2.push("sub"), void 0 !== c2 && a2.push("iss"); | |
for (const e3 of new Set(a2.reverse())) | |
if (!(e3 in i2)) | |
throw new JWTClaimValidationFailed(`missing required "${e3}" claim`, e3, "missing"); | |
if (c2 && !(Array.isArray(c2) ? c2 : [c2]).includes(i2.iss)) | |
throw new JWTClaimValidationFailed('unexpected "iss" claim value', "iss", "check_failed"); | |
if (u2 && i2.sub !== u2) | |
throw new JWTClaimValidationFailed('unexpected "sub" claim value', "sub", "check_failed"); | |
if (m2 && (b2 = i2.aud, x2 = "string" == typeof m2 ? [m2] : m2, !("string" == typeof b2 ? x2.includes(b2) : Array.isArray(b2) && x2.some(Set.prototype.has.bind(new Set(b2)))))) | |
throw new JWTClaimValidationFailed('unexpected "aud" claim value', "aud", "check_failed"); | |
var b2, x2; | |
let C2; | |
switch (typeof r2.clockTolerance) { | |
case "string": | |
C2 = secs(r2.clockTolerance); | |
break; | |
case "number": | |
C2 = r2.clockTolerance; | |
break; | |
case "undefined": | |
C2 = 0; | |
break; | |
default: | |
throw new TypeError("Invalid clockTolerance option type"); | |
} | |
const { currentDate: A2 } = r2, P2 = epoch(A2 || new Date()); | |
if ((void 0 !== i2.iat || g2) && "number" != typeof i2.iat) | |
throw new JWTClaimValidationFailed('"iat" claim must be a number', "iat", "invalid"); | |
if (void 0 !== i2.nbf) { | |
if ("number" != typeof i2.nbf) | |
throw new JWTClaimValidationFailed('"nbf" claim must be a number', "nbf", "invalid"); | |
if (i2.nbf > P2 + C2) | |
throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', "nbf", "check_failed"); | |
} | |
if (void 0 !== i2.exp) { | |
if ("number" != typeof i2.exp) | |
throw new JWTClaimValidationFailed('"exp" claim must be a number', "exp", "invalid"); | |
if (i2.exp <= P2 - C2) | |
throw new JWTExpired('"exp" claim timestamp check failed', "exp", "check_failed"); | |
} | |
if (g2) { | |
const e3 = P2 - i2.iat; | |
if (e3 - C2 > ("number" == typeof g2 ? g2 : secs(g2))) | |
throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', "iat", "check_failed"); | |
if (e3 < 0 - C2) | |
throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', "iat", "check_failed"); | |
} | |
return i2; | |
}; | |
class CompactEncrypt { | |
constructor(e2) { | |
this._flattened = new FlattenedEncrypt(e2); | |
} | |
setContentEncryptionKey(e2) { | |
return this._flattened.setContentEncryptionKey(e2), this; | |
} | |
setInitializationVector(e2) { | |
return this._flattened.setInitializationVector(e2), this; | |
} | |
setProtectedHeader(e2) { | |
return this._flattened.setProtectedHeader(e2), this; | |
} | |
setKeyManagementParameters(e2) { | |
return this._flattened.setKeyManagementParameters(e2), this; | |
} | |
async encrypt(e2, t2) { | |
const r2 = await this._flattened.encrypt(e2, t2); | |
return [r2.protected, r2.encrypted_key, r2.iv, r2.ciphertext, r2.tag].join("."); | |
} | |
} | |
class ProduceJWT { | |
constructor(e2) { | |
if (!isObject$2(e2)) | |
throw new TypeError("JWT Claims Set MUST be an object"); | |
this._payload = e2; | |
} | |
setIssuer(e2) { | |
return this._payload = { ...this._payload, iss: e2 }, this; | |
} | |
setSubject(e2) { | |
return this._payload = { ...this._payload, sub: e2 }, this; | |
} | |
setAudience(e2) { | |
return this._payload = { ...this._payload, aud: e2 }, this; | |
} | |
setJti(e2) { | |
return this._payload = { ...this._payload, jti: e2 }, this; | |
} | |
setNotBefore(e2) { | |
return this._payload = "number" == typeof e2 ? { ...this._payload, nbf: e2 } : { ...this._payload, nbf: epoch(new Date()) + secs(e2) }, this; | |
} | |
setExpirationTime(e2) { | |
return this._payload = "number" == typeof e2 ? { ...this._payload, exp: e2 } : { ...this._payload, exp: epoch(new Date()) + secs(e2) }, this; | |
} | |
setIssuedAt(e2) { | |
return this._payload = void 0 === e2 ? { ...this._payload, iat: epoch(new Date()) } : { ...this._payload, iat: e2 }, this; | |
} | |
} | |
class EncryptJWT extends ProduceJWT { | |
setProtectedHeader(e2) { | |
if (this._protectedHeader) | |
throw new TypeError("setProtectedHeader can only be called once"); | |
return this._protectedHeader = e2, this; | |
} | |
setKeyManagementParameters(e2) { | |
if (this._keyManagementParameters) | |
throw new TypeError("setKeyManagementParameters can only be called once"); | |
return this._keyManagementParameters = e2, this; | |
} | |
setContentEncryptionKey(e2) { | |
if (this._cek) | |
throw new TypeError("setContentEncryptionKey can only be called once"); | |
return this._cek = e2, this; | |
} | |
setInitializationVector(e2) { | |
if (this._iv) | |
throw new TypeError("setInitializationVector can only be called once"); | |
return this._iv = e2, this; | |
} | |
replicateIssuerAsHeader() { | |
return this._replicateIssuerAsHeader = true, this; | |
} | |
replicateSubjectAsHeader() { | |
return this._replicateSubjectAsHeader = true, this; | |
} | |
replicateAudienceAsHeader() { | |
return this._replicateAudienceAsHeader = true, this; | |
} | |
async encrypt(e2, t2) { | |
const r2 = new CompactEncrypt(vn.encode(JSON.stringify(this._payload))); | |
return this._replicateIssuerAsHeader && (this._protectedHeader = { ...this._protectedHeader, iss: this._payload.iss }), this._replicateSubjectAsHeader && (this._protectedHeader = { ...this._protectedHeader, sub: this._payload.sub }), this._replicateAudienceAsHeader && (this._protectedHeader = { ...this._protectedHeader, aud: this._payload.aud }), r2.setProtectedHeader(this._protectedHeader), this._iv && r2.setInitializationVector(this._iv), this._cek && r2.setContentEncryptionKey(this._cek), this._keyManagementParameters && r2.setKeyManagementParameters(this._keyManagementParameters), r2.encrypt(e2, t2); | |
} | |
} | |
const Is = Cn, Ds = decode$4, Ns = 2592e3, now = () => Date.now() / 1e3 | 0; | |
async function encode$1(e2) { | |
const { token: t2 = {}, secret: r2, maxAge: n2 = Ns } = e2, i2 = await getDerivedEncryptionKey(r2); | |
return await new EncryptJWT(t2).setProtectedHeader({ alg: "dir", enc: "A256GCM" }).setIssuedAt().setExpirationTime(now() + n2).setJti(crypto.randomUUID()).encrypt(i2); | |
} | |
async function decode$2(e2) { | |
const { token: t2, secret: r2 } = e2; | |
if (!t2) | |
return null; | |
const n2 = await getDerivedEncryptionKey(r2), { payload: i2 } = await async function(e3, t3, r3) { | |
const n3 = await compactDecrypt(e3, t3, r3), i3 = jwtPayload(n3.protectedHeader, n3.plaintext, r3), { protectedHeader: a2 } = n3; | |
if (void 0 !== a2.iss && a2.iss !== i3.iss) | |
throw new JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch', "iss", "mismatch"); | |
if (void 0 !== a2.sub && a2.sub !== i3.sub) | |
throw new JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch', "sub", "mismatch"); | |
if (void 0 !== a2.aud && JSON.stringify(a2.aud) !== JSON.stringify(i3.aud)) | |
throw new JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch', "aud", "mismatch"); | |
const c2 = { payload: i3, protectedHeader: a2 }; | |
return "function" == typeof t3 ? { ...c2, key: n3.key } : c2; | |
}(t2, n2, { clockTolerance: 15 }); | |
return i2; | |
} | |
async function getDerivedEncryptionKey(e2) { | |
return await hkdf("sha256", e2, "", "Auth.js Generated Encryption Key", 32); | |
} | |
var parse_1 = function(e2, t2) { | |
if ("string" != typeof e2) | |
throw new TypeError("argument str must be a string"); | |
var r2 = {}, n2 = (t2 || {}).decode || decode$1, i2 = 0; | |
for (; i2 < e2.length; ) { | |
var a2 = e2.indexOf("=", i2); | |
if (-1 === a2) | |
break; | |
var c2 = e2.indexOf(";", i2); | |
if (-1 === c2) | |
c2 = e2.length; | |
else if (c2 < a2) { | |
i2 = e2.lastIndexOf(";", a2 - 1) + 1; | |
continue; | |
} | |
var u2 = e2.slice(i2, a2).trim(); | |
if (void 0 === r2[u2]) { | |
var m2 = e2.slice(a2 + 1, c2).trim(); | |
34 === m2.charCodeAt(0) && (m2 = m2.slice(1, -1)), r2[u2] = tryDecode(m2, n2); | |
} | |
i2 = c2 + 1; | |
} | |
return r2; | |
}, serialize_1 = function(e2, t2, r2) { | |
var n2 = r2 || {}, i2 = n2.encode || encode; | |
if ("function" != typeof i2) | |
throw new TypeError("option encode is invalid"); | |
if (!Ls.test(e2)) | |
throw new TypeError("argument name is invalid"); | |
var a2 = i2(t2); | |
if (a2 && !Ls.test(a2)) | |
throw new TypeError("argument val is invalid"); | |
var c2 = e2 + "=" + a2; | |
if (null != n2.maxAge) { | |
var u2 = n2.maxAge - 0; | |
if (isNaN(u2) || !isFinite(u2)) | |
throw new TypeError("option maxAge is invalid"); | |
c2 += "; Max-Age=" + Math.floor(u2); | |
} | |
if (n2.domain) { | |
if (!Ls.test(n2.domain)) | |
throw new TypeError("option domain is invalid"); | |
c2 += "; Domain=" + n2.domain; | |
} | |
if (n2.path) { | |
if (!Ls.test(n2.path)) | |
throw new TypeError("option path is invalid"); | |
c2 += "; Path=" + n2.path; | |
} | |
if (n2.expires) { | |
var m2 = n2.expires; | |
if (!function(e3) { | |
return "[object Date]" === Os.call(e3) || e3 instanceof Date; | |
}(m2) || isNaN(m2.valueOf())) | |
throw new TypeError("option expires is invalid"); | |
c2 += "; Expires=" + m2.toUTCString(); | |
} | |
n2.httpOnly && (c2 += "; HttpOnly"); | |
n2.secure && (c2 += "; Secure"); | |
if (n2.priority) { | |
switch ("string" == typeof n2.priority ? n2.priority.toLowerCase() : n2.priority) { | |
case "low": | |
c2 += "; Priority=Low"; | |
break; | |
case "medium": | |
c2 += "; Priority=Medium"; | |
break; | |
case "high": | |
c2 += "; Priority=High"; | |
break; | |
default: | |
throw new TypeError("option priority is invalid"); | |
} | |
} | |
if (n2.sameSite) { | |
switch ("string" == typeof n2.sameSite ? n2.sameSite.toLowerCase() : n2.sameSite) { | |
case true: | |
c2 += "; SameSite=Strict"; | |
break; | |
case "lax": | |
c2 += "; SameSite=Lax"; | |
break; | |
case "strict": | |
c2 += "; SameSite=Strict"; | |
break; | |
case "none": | |
c2 += "; SameSite=None"; | |
break; | |
default: | |
throw new TypeError("option sameSite is invalid"); | |
} | |
} | |
return c2; | |
}, Os = Object.prototype.toString, Ls = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/; | |
function decode$1(e2) { | |
return -1 !== e2.indexOf("%") ? decodeURIComponent(e2) : e2; | |
} | |
function encode(e2) { | |
return encodeURIComponent(e2); | |
} | |
function tryDecode(e2, t2) { | |
try { | |
return t2(e2); | |
} catch (t3) { | |
return e2; | |
} | |
} | |
async function getBody(e2) { | |
if (!("body" in e2) || !e2.body || "POST" !== e2.method) | |
return; | |
const t2 = e2.headers.get("content-type"); | |
if (t2?.includes("application/json")) | |
return await e2.json(); | |
if (t2?.includes("application/x-www-form-urlencoded")) { | |
const t3 = new URLSearchParams(await e2.text()); | |
return Object.fromEntries(t3); | |
} | |
} | |
const Rs = ["providers", "session", "csrf", "signin", "signout", "callback", "verify-request", "error"]; | |
function toRequest(e2) { | |
return new Request(e2.url, { headers: e2.headers, method: e2.method, body: "POST" === e2.method ? JSON.stringify(e2.body ?? {}) : void 0 }); | |
} | |
function toResponse(e2) { | |
const t2 = new Headers(e2.headers); | |
e2.cookies?.forEach((e3) => { | |
const { name: r3, value: n3, options: i3 } = e3, a2 = serialize_1(r3, n3, i3); | |
t2.has("Set-Cookie") ? t2.append("Set-Cookie", a2) : t2.set("Set-Cookie", a2); | |
}); | |
let r2 = e2.body; | |
"application/json" === t2.get("content-type") ? r2 = JSON.stringify(e2.body) : "application/x-www-form-urlencoded" === t2.get("content-type") && (r2 = new URLSearchParams(e2.body).toString()); | |
const n2 = e2.redirect ? 302 : e2.status ?? 200, i2 = new Response(r2, { headers: t2, status: n2 }); | |
return e2.redirect && i2.headers.set("Location", e2.redirect), i2; | |
} | |
async function createHash(e2) { | |
const t2 = new TextEncoder().encode(e2), r2 = await crypto.subtle.digest("SHA-256", t2); | |
return Array.from(new Uint8Array(r2)).map((e3) => e3.toString(16).padStart(2, "0")).join("").toString(); | |
} | |
function randomString(e2) { | |
const t2 = crypto.getRandomValues(new Uint8Array(e2)); | |
return Array.from(t2).reduce((e3, t3) => e3 + ((e4) => ("0" + e4.toString(16)).slice(-2))(t3), ""); | |
} | |
const Ms = { signIn: () => true, redirect: ({ url: e2, baseUrl: t2 }) => e2.startsWith("/") ? `${t2}${e2}` : new URL(e2).origin === t2 ? e2 : t2, session: ({ session: e2 }) => e2, jwt: ({ token: e2 }) => e2 }; | |
function isObject$1(e2) { | |
return e2 && "object" == typeof e2 && !Array.isArray(e2); | |
} | |
function merge(e2, ...t2) { | |
if (!t2.length) | |
return e2; | |
const r2 = t2.shift(); | |
if (isObject$1(e2) && isObject$1(r2)) | |
for (const t3 in r2) | |
isObject$1(r2[t3]) ? (e2[t3] || Object.assign(e2, { [t3]: {} }), merge(e2[t3], r2[t3])) : Object.assign(e2, { [t3]: r2[t3] }); | |
return merge(e2, ...t2); | |
} | |
function parseProviders(e2) { | |
const { url: t2, providerId: r2, options: n2 } = e2, i2 = e2.providers.map((e3) => { | |
const r3 = "function" == typeof e3 ? e3() : e3, { options: i3, ...a2 } = r3, c2 = i3?.id ?? a2.id, u2 = merge(a2, i3, { signinUrl: `${t2}/signin/${c2}`, callbackUrl: `${t2}/callback/${c2}` }); | |
return "oauth" === r3.type || "oidc" === r3.type ? (u2.redirectProxyUrl ?? (u2.redirectProxyUrl = n2.redirectProxyUrl), function(e4) { | |
e4.issuer && (e4.wellKnown ?? (e4.wellKnown = `${e4.issuer}/.well-known/openid-configuration`)); | |
const t3 = normalizeEndpoint(e4.authorization, e4.issuer); | |
t3 && !t3.url?.searchParams.has("scope") && t3.url.searchParams.set("scope", "openid profile email"); | |
const r4 = normalizeEndpoint(e4.token, e4.issuer), n3 = normalizeEndpoint(e4.userinfo, e4.issuer), i4 = e4.checks ?? ["pkce"]; | |
e4.redirectProxyUrl && (i4.includes("state") || i4.push("state"), e4.redirectProxyUrl = `${e4.redirectProxyUrl}/callback/${e4.id}`); | |
return { ...e4, authorization: t3, token: r4, checks: i4, userinfo: n3, profile: e4.profile ?? defaultProfile, account: e4.account ?? defaultAccount }; | |
}(u2)) : u2; | |
}); | |
return { providers: i2, provider: i2.find(({ id: e3 }) => e3 === r2) }; | |
} | |
const defaultProfile = (e2) => { | |
const t2 = e2.sub ?? e2.id; | |
if (!t2) | |
throw new OAuthProfileParseError("Missing user id"); | |
return stripUndefined({ id: t2.toString(), name: e2.name ?? e2.nickname ?? e2.preferred_username, email: e2.email, image: e2.picture }); | |
}, defaultAccount = (e2) => stripUndefined({ access_token: e2.access_token, id_token: e2.id_token, refresh_token: e2.refresh_token, expires_at: e2.expires_at, scope: e2.scope, token_type: e2.token_type, session_state: e2.session_state }); | |
function stripUndefined(e2) { | |
const t2 = {}; | |
for (let [r2, n2] of Object.entries(e2)) | |
void 0 !== n2 && (t2[r2] = n2); | |
return t2; | |
} | |
function normalizeEndpoint(e2, t2) { | |
if (!e2 && t2) | |
return; | |
if ("string" == typeof e2) | |
return { url: new URL(e2) }; | |
const r2 = new URL(e2?.url ?? "https://authjs.dev"); | |
if (null != e2?.params) | |
for (let [t3, n2] of Object.entries(e2.params)) | |
"claims" === t3 && (n2 = JSON.stringify(n2)), r2.searchParams.set(t3, String(n2)); | |
return { url: r2, request: e2?.request, conform: e2?.conform }; | |
} | |
const Fs = "\x1B[31m", Bs = "\x1B[0m", js = { error(e2) { | |
const t2 = `https://errors.authjs.dev#${e2.name.toLowerCase()}`; | |
if (console.error(`${Fs}[auth][error][${e2.name}]${Bs}:${e2.message ? ` ${e2.message}.` : ""} Read more at ${t2}`), e2.cause) { | |
const { err: t3, ...r2 } = e2.cause; | |
console.error(`${Fs}[auth][cause]${Bs}:`, t3.stack), console.error(`${Fs}[auth][details]${Bs}:`, JSON.stringify(r2, null, 2)); | |
} else | |
e2.stack && console.error(e2.stack.replace(/.*/, "").substring(1)); | |
}, warn(e2) { | |
const t2 = `https://warnings.authjs.dev#${e2}`; | |
console.warn(`\x1B[33m[auth][warn][${e2}]${Bs}`, `Read more: ${t2}`); | |
}, debug(e2, t2) { | |
console.log(`\x1B[90m[auth][debug]:${Bs} ${e2}`, JSON.stringify(t2, null, 2)); | |
} }; | |
async function init({ authOptions: e2, providerId: t2, action: r2, url: n2, cookies: i2, callbackUrl: a2, csrfToken: c2, csrfDisabled: u2, isPost: m2 }) { | |
const g2 = function(e3) { | |
const t3 = new URL("http://localhost:3000/api/auth"); | |
e3 && !e3.toString().startsWith("http") && (e3 = `https://${e3}`); | |
const r3 = new URL(e3 ?? t3), n3 = ("/" === r3.pathname ? t3.pathname : r3.pathname).replace(/\/$/, ""), i3 = `${r3.origin}${n3}`; | |
return { origin: r3.origin, host: r3.host, path: n3, base: i3, toString: () => i3 }; | |
}(n2.origin + n2.pathname.replace(`/${r2}`, "").replace(`/${t2}`, "")), b2 = new URL(g2.toString()), { providers: x2, provider: C2 } = parseProviders({ providers: e2.providers, url: b2, providerId: t2, options: e2 }), A2 = 2592e3; | |
let P2 = false; | |
if (("oauth" === C2?.type || "oidc" === C2?.type) && C2.redirectProxyUrl) | |
try { | |
P2 = new URL(C2.redirectProxyUrl).origin === b2.origin; | |
} catch { | |
throw new TypeError(`redirectProxyUrl must be a valid URL. Received: ${C2.redirectProxyUrl}`); | |
} | |
const T2 = { debug: false, pages: {}, theme: { colorScheme: "auto", logo: "", brandColor: "", buttonText: "" }, ...e2, url: b2, action: r2, provider: C2, cookies: { ...defaultCookies(e2.useSecureCookies ?? "https:" === b2.protocol), ...e2.cookies }, providers: x2, session: { strategy: e2.adapter ? "database" : "jwt", maxAge: A2, updateAge: 86400, generateSessionToken: () => crypto.randomUUID(), ...e2.session }, jwt: { secret: e2.secret, maxAge: e2.session?.maxAge ?? A2, encode: encode$1, decode: decode$2, ...e2.jwt }, events: eventsErrorHandler(e2.events ?? {}, js), adapter: adapterErrorHandler(e2.adapter, js), callbacks: { ...Ms, ...e2.callbacks }, logger: js, callbackUrl: b2.origin, isOnRedirectProxy: P2 }, _2 = []; | |
if (!u2) { | |
const { csrfToken: e3, cookie: t3, csrfTokenVerified: r3 } = await async function({ options: e4, cookieValue: t4, isPost: r4, bodyValue: n3 }) { | |
if (t4) { | |
const [i4, a3] = t4.split("|"); | |
if (a3 === await createHash(`${i4}${e4.secret}`)) | |
return { csrfTokenVerified: r4 && i4 === n3, csrfToken: i4 }; | |
} | |
const i3 = randomString(32); | |
return { cookie: `${i3}|${await createHash(`${i3}${e4.secret}`)}`, csrfToken: i3 }; | |
}({ options: T2, cookieValue: i2?.[T2.cookies.csrfToken.name], isPost: m2, bodyValue: c2 }); | |
T2.csrfToken = e3, T2.csrfTokenVerified = r3, t3 && _2.push({ name: T2.cookies.csrfToken.name, value: t3, options: T2.cookies.csrfToken.options }); | |
} | |
const { callbackUrl: I2, callbackUrlCookie: D2 } = await async function({ options: e3, paramValue: t3, cookieValue: r3 }) { | |
const { url: n3, callbacks: i3 } = e3; | |
let a3 = n3.origin; | |
return t3 ? a3 = await i3.redirect({ url: t3, baseUrl: n3.origin }) : r3 && (a3 = await i3.redirect({ url: r3, baseUrl: n3.origin })), { callbackUrl: a3, callbackUrlCookie: a3 !== r3 ? a3 : void 0 }; | |
}({ options: T2, cookieValue: i2?.[T2.cookies.callbackUrl.name], paramValue: a2 }); | |
return T2.callbackUrl = I2, D2 && _2.push({ name: T2.cookies.callbackUrl.name, value: D2, options: T2.cookies.callbackUrl.options }), { options: T2, cookies: _2 }; | |
} | |
function eventsErrorHandler(e2, t2) { | |
return Object.keys(e2).reduce((r2, n2) => (r2[n2] = async (...r3) => { | |
try { | |
const t3 = e2[n2]; | |
return await t3(...r3); | |
} catch (e3) { | |
t2.error(new EventError(e3)); | |
} | |
}, r2), {}); | |
} | |
function adapterErrorHandler(e2, t2) { | |
if (e2) | |
return Object.keys(e2).reduce((r2, n2) => (r2[n2] = async (...r3) => { | |
try { | |
t2.debug(`adapter_${n2}`, { args: r3 }); | |
const i2 = e2[n2]; | |
return await i2(...r3); | |
} catch (e3) { | |
const r4 = new AdapterError(e3); | |
throw t2.error(r4), r4; | |
} | |
}, r2), {}); | |
} | |
var $s; | |
function p$1(e2) { | |
return e2.children; | |
} | |
$s = { __e: function(e2, t2, r2, n2) { | |
for (var i2, a2, c2; t2 = t2.__; ) | |
if ((i2 = t2.__c) && !i2.__) | |
try { | |
if ((a2 = i2.constructor) && null != a2.getDerivedStateFromError && (i2.setState(a2.getDerivedStateFromError(e2)), c2 = i2.__d), null != i2.componentDidCatch && (i2.componentDidCatch(e2, n2 || {}), c2 = i2.__d), c2) | |
return i2.__E = i2; | |
} catch (t3) { | |
e2 = t3; | |
} | |
throw e2; | |
} }; | |
var Us = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i, Hs = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/, Vs = /[\s\n\\/='"\0<>]/, zs = /^xlink:?./, qs = /["&<]/; | |
function l(e2) { | |
if (false === qs.test(e2 += "")) | |
return e2; | |
for (var t2 = 0, r2 = 0, n2 = "", i2 = ""; r2 < e2.length; r2++) { | |
switch (e2.charCodeAt(r2)) { | |
case 34: | |
i2 = """; | |
break; | |
case 38: | |
i2 = "&"; | |
break; | |
case 60: | |
i2 = "<"; | |
break; | |
default: | |
continue; | |
} | |
r2 !== t2 && (n2 += e2.slice(t2, r2)), n2 += i2, t2 = r2 + 1; | |
} | |
return r2 !== t2 && (n2 += e2.slice(t2, r2)), n2; | |
} | |
var s = function(e2, t2) { | |
return String(e2).replace(/(\n+)/g, "$1" + (t2 || " ")); | |
}, f = function(e2, t2, r2) { | |
return String(e2).length > (t2 || 40) || !r2 && -1 !== String(e2).indexOf("\n") || -1 !== String(e2).indexOf("<"); | |
}, Ws = {}, Ks = /([A-Z])/g; | |
function p(e2) { | |
var t2 = ""; | |
for (var r2 in e2) { | |
var n2 = e2[r2]; | |
null != n2 && "" !== n2 && (t2 && (t2 += " "), t2 += "-" == r2[0] ? r2 : Ws[r2] || (Ws[r2] = r2.replace(Ks, "-$1").toLowerCase()), t2 = "number" == typeof n2 && false === Us.test(r2) ? t2 + ": " + n2 + "px;" : t2 + ": " + n2 + ";"); | |
} | |
return t2 || void 0; | |
} | |
function _$1(e2, t2) { | |
return Array.isArray(t2) ? t2.reduce(_$1, e2) : null != t2 && false !== t2 && e2.push(t2), e2; | |
} | |
function d() { | |
this.__d = true; | |
} | |
function v(e2, t2) { | |
return { __v: e2, context: t2, props: e2.props, setState: d, forceUpdate: d, __d: true, __h: [] }; | |
} | |
function h(e2, t2) { | |
var r2 = e2.contextType, n2 = r2 && t2[r2.__c]; | |
return null != r2 ? n2 ? n2.props.value : r2.__ : t2; | |
} | |
var Js = []; | |
function y(e2, t2, r2, n2, i2, a2) { | |
if (null == e2 || "boolean" == typeof e2) | |
return ""; | |
if ("object" != typeof e2) | |
return l(e2); | |
var c2 = r2.pretty, u2 = c2 && "string" == typeof c2 ? c2 : " "; | |
if (Array.isArray(e2)) { | |
for (var m2 = "", g2 = 0; g2 < e2.length; g2++) | |
c2 && g2 > 0 && (m2 += "\n"), m2 += y(e2[g2], t2, r2, n2, i2, a2); | |
return m2; | |
} | |
var b2, x2 = e2.type, C2 = e2.props, A2 = false; | |
if ("function" == typeof x2) { | |
if (A2 = true, !r2.shallow || !n2 && false !== r2.renderRootComponent) { | |
if (x2 === p$1) { | |
var P2 = []; | |
return _$1(P2, e2.props.children), y(P2, t2, r2, false !== r2.shallowHighOrder, i2, a2); | |
} | |
var T2, _2 = e2.__c = v(e2, t2); | |
$s.__b && $s.__b(e2); | |
var I2 = $s.__r; | |
if (x2.prototype && "function" == typeof x2.prototype.render) { | |
var D2 = h(x2, t2); | |
(_2 = e2.__c = new x2(C2, D2)).__v = e2, _2._dirty = _2.__d = true, _2.props = C2, null == _2.state && (_2.state = {}), null == _2._nextState && null == _2.__s && (_2._nextState = _2.__s = _2.state), _2.context = D2, x2.getDerivedStateFromProps ? _2.state = Object.assign({}, _2.state, x2.getDerivedStateFromProps(_2.props, _2.state)) : _2.componentWillMount && (_2.componentWillMount(), _2.state = _2._nextState !== _2.state ? _2._nextState : _2.__s !== _2.state ? _2.__s : _2.state), I2 && I2(e2), T2 = _2.render(_2.props, _2.state, _2.context); | |
} else | |
for (var N2 = h(x2, t2), O2 = 0; _2.__d && O2++ < 25; ) | |
_2.__d = false, I2 && I2(e2), T2 = x2.call(e2.__c, C2, N2); | |
return _2.getChildContext && (t2 = Object.assign({}, t2, _2.getChildContext())), $s.diffed && $s.diffed(e2), y(T2, t2, r2, false !== r2.shallowHighOrder, i2, a2); | |
} | |
x2 = (b2 = x2).displayName || b2 !== Function && b2.name || function(e3) { | |
var t3 = (Function.prototype.toString.call(e3).match(/^\s*function\s+([^( ]+)/) || "")[1]; | |
if (!t3) { | |
for (var r3 = -1, n3 = Js.length; n3--; ) | |
if (Js[n3] === e3) { | |
r3 = n3; | |
break; | |
} | |
r3 < 0 && (r3 = Js.push(e3) - 1), t3 = "UnnamedComponent" + r3; | |
} | |
return t3; | |
}(b2); | |
} | |
var L2, R2, M2 = "<" + x2; | |
if (C2) { | |
var F2 = Object.keys(C2); | |
r2 && true === r2.sortAttributes && F2.sort(); | |
for (var B2 = 0; B2 < F2.length; B2++) { | |
var $2 = F2[B2], U2 = C2[$2]; | |
if ("children" !== $2) { | |
if (!Vs.test($2) && (r2 && r2.allAttributes || "key" !== $2 && "ref" !== $2 && "__self" !== $2 && "__source" !== $2)) { | |
if ("defaultValue" === $2) | |
$2 = "value"; | |
else if ("defaultChecked" === $2) | |
$2 = "checked"; | |
else if ("defaultSelected" === $2) | |
$2 = "selected"; | |
else if ("className" === $2) { | |
if (void 0 !== C2.class) | |
continue; | |
$2 = "class"; | |
} else | |
i2 && zs.test($2) && ($2 = $2.toLowerCase().replace(/^xlink:?/, "xlink:")); | |
if ("htmlFor" === $2) { | |
if (C2.for) | |
continue; | |
$2 = "for"; | |
} | |
"style" === $2 && U2 && "object" == typeof U2 && (U2 = p(U2)), "a" === $2[0] && "r" === $2[1] && "boolean" == typeof U2 && (U2 = String(U2)); | |
var H2 = r2.attributeHook && r2.attributeHook($2, U2, t2, r2, A2); | |
if (H2 || "" === H2) | |
M2 += H2; | |
else if ("dangerouslySetInnerHTML" === $2) | |
R2 = U2 && U2.__html; | |
else if ("textarea" === x2 && "value" === $2) | |
L2 = U2; | |
else if ((U2 || 0 === U2 || "" === U2) && "function" != typeof U2) { | |
if (!(true !== U2 && "" !== U2 || (U2 = $2, r2 && r2.xml))) { | |
M2 = M2 + " " + $2; | |
continue; | |
} | |
if ("value" === $2) { | |
if ("select" === x2) { | |
a2 = U2; | |
continue; | |
} | |
"option" === x2 && a2 == U2 && void 0 === C2.selected && (M2 += " selected"); | |
} | |
M2 = M2 + " " + $2 + '="' + l(U2) + '"'; | |
} | |
} | |
} else | |
L2 = U2; | |
} | |
} | |
if (c2) { | |
var V2 = M2.replace(/\n\s*/, " "); | |
V2 === M2 || ~V2.indexOf("\n") ? c2 && ~M2.indexOf("\n") && (M2 += "\n") : M2 = V2; | |
} | |
if (M2 += ">", Vs.test(x2)) | |
throw new Error(x2 + " is not a valid HTML tag name in " + M2); | |
var z2, q2 = Hs.test(x2) || r2.voidElements && r2.voidElements.test(x2), W2 = []; | |
if (R2) | |
c2 && f(R2) && (R2 = "\n" + u2 + s(R2, u2)), M2 += R2; | |
else if (null != L2 && _$1(z2 = [], L2).length) { | |
for (var K2 = c2 && ~M2.indexOf("\n"), J2 = false, G2 = 0; G2 < z2.length; G2++) { | |
var Z2 = z2[G2]; | |
if (null != Z2 && false !== Z2) { | |
var Y2 = y(Z2, t2, r2, true, "svg" === x2 || "foreignObject" !== x2 && i2, a2); | |
if (c2 && !K2 && f(Y2) && (K2 = true), Y2) | |
if (c2) { | |
var X2 = Y2.length > 0 && "<" != Y2[0]; | |
J2 && X2 ? W2[W2.length - 1] += Y2 : W2.push(Y2), J2 = X2; | |
} else | |
W2.push(Y2); | |
} | |
} | |
if (c2 && K2) | |
for (var Q2 = W2.length; Q2--; ) | |
W2[Q2] = "\n" + u2 + s(W2[Q2], u2); | |
} | |
if (W2.length || R2) | |
M2 += W2.join(""); | |
else if (r2 && r2.xml) | |
return M2.substring(0, M2.length - 1) + " />"; | |
return !q2 || z2 || R2 ? (c2 && ~M2.indexOf("\n") && (M2 += "\n"), M2 = M2 + "</" + x2 + ">") : M2 = M2.replace(/>$/, " />"), M2; | |
} | |
var Gs = { shallow: true }; | |
k.render = k; | |
var Zs = []; | |
function k(e2, t2, r2) { | |
t2 = t2 || {}; | |
var n2, i2 = $s.__s; | |
return $s.__s = true, n2 = r2 && (r2.pretty || r2.voidElements || r2.sortAttributes || r2.shallow || r2.allAttributes || r2.xml || r2.attributeHook) ? y(e2, t2, r2) : j(e2, t2, false, void 0), $s.__c && $s.__c(e2, Zs), $s.__s = i2, Zs.length = 0, n2; | |
} | |
function S(e2, t2) { | |
return "className" === e2 ? "class" : "htmlFor" === e2 ? "for" : "defaultValue" === e2 ? "value" : "defaultChecked" === e2 ? "checked" : "defaultSelected" === e2 ? "selected" : t2 && zs.test(e2) ? e2.toLowerCase().replace(/^xlink:?/, "xlink:") : e2; | |
} | |
function w(e2, t2) { | |
return "style" === e2 && null != t2 && "object" == typeof t2 ? p(t2) : "a" === e2[0] && "r" === e2[1] && "boolean" == typeof t2 ? String(t2) : t2; | |
} | |
var Ys = Array.isArray, Xs = Object.assign; | |
function j(e2, t2, r2, n2) { | |
if (null == e2 || true === e2 || false === e2 || "" === e2) | |
return ""; | |
if ("object" != typeof e2) | |
return l(e2); | |
if (Ys(e2)) { | |
for (var i2 = "", a2 = 0; a2 < e2.length; a2++) | |
i2 += j(e2[a2], t2, r2, n2); | |
return i2; | |
} | |
$s.__b && $s.__b(e2); | |
var c2 = e2.type, u2 = e2.props; | |
if ("function" == typeof c2) { | |
if (c2 === p$1) | |
return j(e2.props.children, t2, r2, n2); | |
var m2; | |
m2 = c2.prototype && "function" == typeof c2.prototype.render ? function(e3, t3) { | |
var r3 = e3.type, n3 = h(r3, t3), i3 = new r3(e3.props, n3); | |
e3.__c = i3, i3.__v = e3, i3.__d = true, i3.props = e3.props, null == i3.state && (i3.state = {}), null == i3.__s && (i3.__s = i3.state), i3.context = n3, r3.getDerivedStateFromProps ? i3.state = Xs({}, i3.state, r3.getDerivedStateFromProps(i3.props, i3.state)) : i3.componentWillMount && (i3.componentWillMount(), i3.state = i3.__s !== i3.state ? i3.__s : i3.state); | |
var a3 = $s.__r; | |
return a3 && a3(e3), i3.render(i3.props, i3.state, i3.context); | |
}(e2, t2) : function(e3, t3) { | |
var r3, n3 = v(e3, t3), i3 = h(e3.type, t3); | |
e3.__c = n3; | |
for (var a3 = $s.__r, c3 = 0; n3.__d && c3++ < 25; ) | |
n3.__d = false, a3 && a3(e3), r3 = e3.type.call(n3, e3.props, i3); | |
return r3; | |
}(e2, t2); | |
var g2 = e2.__c; | |
g2.getChildContext && (t2 = Xs({}, t2, g2.getChildContext())); | |
var b2 = j(m2, t2, r2, n2); | |
return $s.diffed && $s.diffed(e2), b2; | |
} | |
var x2, C2, A2 = "<"; | |
if (A2 += c2, u2) | |
for (var P2 in x2 = u2.children, u2) { | |
var T2 = u2[P2]; | |
if (!("key" === P2 || "ref" === P2 || "__self" === P2 || "__source" === P2 || "children" === P2 || "className" === P2 && "class" in u2 || "htmlFor" === P2 && "for" in u2 || Vs.test(P2))) { | |
if (T2 = w(P2 = S(P2, r2), T2), "dangerouslySetInnerHTML" === P2) | |
C2 = T2 && T2.__html; | |
else if ("textarea" === c2 && "value" === P2) | |
x2 = T2; | |
else if ((T2 || 0 === T2 || "" === T2) && "function" != typeof T2) { | |
if (true === T2 || "" === T2) { | |
T2 = P2, A2 = A2 + " " + P2; | |
continue; | |
} | |
if ("value" === P2) { | |
if ("select" === c2) { | |
n2 = T2; | |
continue; | |
} | |
"option" !== c2 || n2 != T2 || "selected" in u2 || (A2 += " selected"); | |
} | |
A2 = A2 + " " + P2 + '="' + l(T2) + '"'; | |
} | |
} | |
} | |
var _2 = A2; | |
if (A2 += ">", Vs.test(c2)) | |
throw new Error(c2 + " is not a valid HTML tag name in " + A2); | |
var I2 = "", D2 = false; | |
if (C2) | |
I2 += C2, D2 = true; | |
else if ("string" == typeof x2) | |
I2 += l(x2), D2 = true; | |
else if (Ys(x2)) | |
for (var N2 = 0; N2 < x2.length; N2++) { | |
var O2 = x2[N2]; | |
if (null != O2 && false !== O2) { | |
var L2 = j(O2, t2, "svg" === c2 || "foreignObject" !== c2 && r2, n2); | |
L2 && (I2 += L2, D2 = true); | |
} | |
} | |
else if (null != x2 && false !== x2 && true !== x2) { | |
var R2 = j(x2, t2, "svg" === c2 || "foreignObject" !== c2 && r2, n2); | |
R2 && (I2 += R2, D2 = true); | |
} | |
if ($s.diffed && $s.diffed(e2), D2) | |
A2 += I2; | |
else if (Hs.test(c2)) | |
return _2 + " />"; | |
return A2 + "</" + c2 + ">"; | |
} | |
k.shallowRender = function(e2, t2) { | |
return k(e2, t2, Gs); | |
}; | |
var Qs = 0; | |
function o(e2, t2, r2, n2, i2) { | |
var a2, c2, u2 = {}; | |
for (c2 in t2) | |
"ref" == c2 ? a2 = t2[c2] : u2[c2] = t2[c2]; | |
var m2 = { type: e2, props: u2, key: r2, ref: a2, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, __h: null, constructor: void 0, __v: --Qs, __source: i2, __self: n2 }; | |
if ("function" == typeof e2 && (a2 = e2.defaultProps)) | |
for (c2 in a2) | |
void 0 === u2[c2] && (u2[c2] = a2[c2]); | |
return $s.vnode && $s.vnode(m2), m2; | |
} | |
function ErrorPage(e2) { | |
const { url: t2, error: r2 = "default", theme: n2 } = e2, i2 = `${t2}/signin`, a2 = { default: { status: 200, heading: "Error", message: o("p", { children: o("a", { className: "site", href: t2?.origin, children: t2?.host }) }) }, configuration: { status: 500, heading: "Server error", message: o("div", { children: [o("p", { children: "There is a problem with the server configuration." }), o("p", { children: "Check the server logs for more information." })] }) }, accessdenied: { status: 403, heading: "Access Denied", message: o("div", { children: [o("p", { children: "You do not have permission to sign in." }), o("p", { children: o("a", { className: "button", href: i2, children: "Sign in" }) })] }) }, verification: { status: 403, heading: "Unable to sign in", message: o("div", { children: [o("p", { children: "The sign in link is no longer valid." }), o("p", { children: "It may have been used already or it may have expired." })] }), signin: o("p", { children: o("a", { className: "button", href: i2, children: "Sign in" }) }) } }, { status: c2, heading: u2, message: m2, signin: g2 } = a2[r2.toLowerCase()] ?? a2.default; | |
return { status: c2, html: o("div", { className: "error", children: [n2?.brandColor && o("style", { dangerouslySetInnerHTML: { __html: ` | |
:root { | |
--brand-color: ${n2?.brandColor} | |
} | |
` } }), o("div", { className: "card", children: [n2?.logo && o("img", { src: n2?.logo, alt: "Logo", className: "logo" }), o("h1", { children: u2 }), o("div", { className: "message", children: m2 }), g2] })] }) }; | |
} | |
const ei = { default: "Unable to sign in.", signin: "Try signing in with a different account.", oauthsignin: "Try signing in with a different account.", oauthcallbackerror: "Try signing in with a different account.", oauthcreateaccount: "Try signing in with a different account.", emailcreateaccount: "Try signing in with a different account.", callback: "Try signing in with a different account.", oauthaccountnotlinked: "To confirm your identity, sign in with the same account you used originally.", emailsignin: "The e-mail could not be sent.", credentialssignin: "Sign in failed. Check the details you provided are correct.", sessionrequired: "Please sign in to access this page." }; | |
function SigninPage(e2) { | |
const { csrfToken: t2, providers: r2 = [], callbackUrl: n2, theme: i2, email: a2, error: c2 } = e2; | |
"undefined" != typeof document && i2.brandColor && document.documentElement.style.setProperty("--brand-color", i2.brandColor), "undefined" != typeof document && i2.buttonText && document.documentElement.style.setProperty("--button-text-color", i2.buttonText); | |
const u2 = c2 && (ei[c2.toLowerCase()] ?? ei.default), m2 = "https://authjs.dev/img/providers"; | |
return o("div", { className: "signin", children: [i2.brandColor && o("style", { dangerouslySetInnerHTML: { __html: `:root {--brand-color: ${i2.brandColor}}` } }), i2.buttonText && o("style", { dangerouslySetInnerHTML: { __html: ` | |
:root { | |
--button-text-color: ${i2.buttonText} | |
} | |
` } }), o("div", { className: "card", children: [u2 && o("div", { className: "error", children: o("p", { children: u2 }) }), r2.map((e3, i3) => o("div", { className: "provider", children: ["oauth" === e3.type || "oidc" === e3.type ? o("form", { action: e3.signinUrl, method: "POST", children: [o("input", { type: "hidden", name: "csrfToken", value: t2 }), n2 && o("input", { type: "hidden", name: "callbackUrl", value: n2 }), o("button", { type: "submit", className: "button", style: { "--provider-bg": e3.style?.bg ?? "", "--provider-dark-bg": e3.style?.bgDark ?? "", "--provider-color": e3.style?.text ?? "", "--provider-dark-color": e3.style?.textDark ?? "", gap: 8 }, children: [e3.style?.logo && o("img", { loading: "lazy", height: 24, width: 24, id: "provider-logo", src: `${e3.style.logo.startsWith("/") ? m2 : ""}${e3.style.logo}` }), e3.style?.logoDark && o("img", { loading: "lazy", height: 24, width: 24, id: "provider-logo-dark", src: `${e3.style.logo.startsWith("/") ? m2 : ""}${e3.style.logoDark}` }), o("span", { children: ["Sign in with ", e3.name] })] })] }) : null, ("email" === e3.type || "credentials" === e3.type) && i3 > 0 && "email" !== r2[i3 - 1].type && "credentials" !== r2[i3 - 1].type && o("hr", {}), "email" === e3.type && o("form", { action: e3.signinUrl, method: "POST", children: [o("input", { type: "hidden", name: "csrfToken", value: t2 }), o("label", { className: "section-header", htmlFor: `input-email-for-${e3.id}-provider`, children: "Email" }), o("input", { id: `input-email-for-${e3.id}-provider`, autoFocus: true, type: "email", name: "email", value: a2, placeholder: "email@example.com", required: true }), o("button", { type: "submit", children: ["Sign in with ", e3.name] })] }), "credentials" === e3.type && o("form", { action: e3.callbackUrl, method: "POST", children: [o("input", { type: "hidden", name: "csrfToken", value: t2 }), Object.keys(e3.credentials).map((t3) => o("div", { children: [o("label", { className: "section-header", htmlFor: `input-${t3}-for-${e3.id}-provider`, children: e3.credentials[t3].label ?? t3 }), o("input", { name: t3, id: `input-${t3}-for-${e3.id}-provider`, type: e3.credentials[t3].type ?? "text", placeholder: e3.credentials[t3].placeholder ?? "", ...e3.credentials[t3] })] }, `input-group-${e3.id}`)), o("button", { id: "submitButton", type: "submit", children: ["Sign in with ", e3.name] })] }), ("email" === e3.type || "credentials" === e3.type) && i3 + 1 < r2.length && o("hr", {})] }, e3.id))] })] }); | |
} | |
function SignoutPage(e2) { | |
const { url: t2, csrfToken: r2, theme: n2 } = e2; | |
return o("div", { className: "signout", children: [n2.brandColor && o("style", { dangerouslySetInnerHTML: { __html: ` | |
:root { | |
--brand-color: ${n2.brandColor} | |
} | |
` } }), n2.buttonText && o("style", { dangerouslySetInnerHTML: { __html: ` | |
:root { | |
--button-text-color: ${n2.buttonText} | |
} | |
` } }), o("div", { className: "card", children: [n2.logo && o("img", { src: n2.logo, alt: "Logo", className: "logo" }), o("h1", { children: "Signout" }), o("p", { children: "Are you sure you want to sign out?" }), o("form", { action: `${t2}/signout`, method: "POST", children: [o("input", { type: "hidden", name: "csrfToken", value: r2 }), o("button", { id: "submitButton", type: "submit", children: "Sign out" })] })] })] }); | |
} | |
const ti = ':root {\n --border-width: 1px;\n --border-radius: 0.5rem;\n --color-error: #c94b4b;\n --color-info: #157efb;\n --color-info-text: #fff;\n}\n\n.__next-auth-theme-auto,\n.__next-auth-theme-light {\n --color-background: #ececec;\n --color-background-card: #fff;\n --color-text: #000;\n --color-primary: #444;\n --color-control-border: #bbb;\n --color-button-active-background: #f9f9f9;\n --color-button-active-border: #aaa;\n --color-separator: #ccc;\n}\n\n.__next-auth-theme-dark {\n --color-background: #161b22;\n --color-background-card: #0d1117;\n --color-text: #fff;\n --color-primary: #ccc;\n --color-control-border: #555;\n --color-button-active-background: #060606;\n --color-button-active-border: #666;\n --color-separator: #444;\n}\n\n@media (prefers-color-scheme: dark) {\n .__next-auth-theme-auto {\n --color-background: #161b22;\n --color-background-card: #0d1117;\n --color-text: #fff;\n --color-primary: #ccc;\n --color-control-border: #555;\n --color-button-active-background: #060606;\n --color-button-active-border: #666;\n --color-separator: #444;\n }\n}\n\nbody {\n background-color: var(--color-background);\n margin: 0;\n padding: 0;\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,\n "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,\n "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";\n}\n\nh1 {\n font-weight: 400;\n margin-bottom: 1.5rem;\n padding: 0 1rem;\n color: var(--color-text);\n}\n\np {\n color: var(--color-text);\n}\n\nform {\n margin: 0;\n padding: 0;\n}\n\nlabel {\n font-weight: 500;\n text-align: left;\n margin-bottom: 0.25rem;\n display: block;\n color: var(--color-text);\n}\n\ninput[type] {\n box-sizing: border-box;\n display: block;\n width: 100%;\n padding: 0.5rem 1rem;\n border: var(--border-width) solid var(--color-control-border);\n background: var(--color-background-card);\n font-size: 1rem;\n border-radius: var(--border-radius);\n color: var(--color-text);\n}\n\ninput[type]:focus {\n box-shadow: none;\n }\n\np {\n margin: 0 0 1.5rem 0;\n padding: 0 1rem;\n font-size: 1.1rem;\n line-height: 2rem;\n}\n\na.button {\n text-decoration: none;\n line-height: 1rem;\n}\n\na.button:link,\n a.button:visited {\n background-color: var(--color-background);\n color: var(--color-primary);\n }\n\nbutton span {\n flex-grow: 1;\n}\n\nbutton,\na.button {\n margin: 0 0 0.75rem 0;\n padding: 0.75rem 1rem;\n color: var(--provider-color, var(--color-primary));\n background-color: var(--provider-bg, var(--color-background-card));\n font-size: 1.1rem;\n min-height: 62px;\n border-color: rgba(0, 0, 0, 0.1);\n border-radius: var(--border-radius);\n transition: all 0.1s ease-in-out;\n font-weight: 500;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n@media (max-width: 450px) {\n\nbutton,\na.button {\n font-size: 0.9rem\n}\n }\n\nbutton:hover, a.button:hover {\n cursor: pointer;\n }\n\nbutton:active, a.button:active {\n cursor: pointer;\n }\n\nbutton #provider-logo, a.button #provider-logo {\n width: 25px;\n display: block;\n }\n\nbutton #provider-logo-dark, a.button #provider-logo-dark {\n display: none;\n }\n\n#submitButton {\n color: var(--button-text-color, var(--color-info-text));\n background-color: var(--brand-color, var(--color-info));\n width: 100%;\n}\n\n@media (prefers-color-scheme: dark) {\n button,\n a.button {\n color: var(--provider-dark-color, var(--color-primary));\n background-color: var(--provider-dark-bg, var(--color-background));\n }\n #provider-logo {\n display: none !important;\n }\n #provider-logo-dark {\n width: 25px;\n display: block !important;\n }\n}\n\na.site {\n color: var(--color-primary);\n text-decoration: none;\n font-size: 1rem;\n line-height: 2rem;\n}\n\na.site:hover {\n text-decoration: underline;\n }\n\n.page {\n position: absolute;\n width: 100%;\n height: 100%;\n display: grid;\n place-items: center;\n margin: 0;\n padding: 0;\n}\n\n.page > div {\n text-align: center;\n }\n\n.error a.button {\n display: inline-block;\n padding-left: 2rem;\n padding-right: 2rem;\n margin-top: 0.5rem;\n }\n\n.error .message {\n margin-bottom: 1.5rem;\n }\n\n.signin input[type="text"] {\n margin-left: auto;\n margin-right: auto;\n display: block;\n }\n\n.signin hr {\n display: block;\n border: 0;\n border-top: 1px solid var(--color-separator);\n margin: 2rem auto 1rem auto;\n overflow: visible;\n }\n\n.signin hr::before {\n content: "or";\n background: var(--color-background-card);\n color: #888;\n padding: 0 0.4rem;\n position: relative;\n top: -0.7rem;\n }\n\n.signin .error {\n background: #f5f5f5;\n font-weight: 500;\n border-radius: 0.3rem;\n background: var(--color-error);\n }\n\n.signin .error p {\n text-align: left;\n padding: 0.5rem 1rem;\n font-size: 0.9rem;\n line-height: 1.2rem;\n color: var(--color-info-text);\n }\n\n.signin > div,\n .signin form {\n display: block;\n }\n\n.signin > div input[type], .signin form input[type] {\n margin-bottom: 0.5rem;\n }\n\n.signin > div button, .signin form button {\n width: 100%;\n }\n\n.signin > div,\n .signin form {\n\n max-width: 300px;\n}\n\n.logo {\n display: inline-block;\n max-width: 150px;\n margin-top: 20px;\n margin-bottom: 25px;\n max-height: 70px;\n}\n\n@media screen and (min-width: 450px) {\n\n.card {\n width: 350px\n}\n }\n\n@media screen and (max-width: 450px) {\n\n.card {\n width: 200px\n}\n }\n\n.card {\n margin: 20px 0 20px 0;\n background-color: var(--color-background-card);\n border-radius: 30px;\n padding: 20px 50px;\n}\n\n.card .header {\n color: var(--color-primary);\n }\n\n.section-header {\n color: var(--color-text);\n}\n'; | |
function VerifyRequestPage(e2) { | |
const { url: t2, theme: r2 } = e2; | |
return o("div", { className: "verify-request", children: [r2.brandColor && o("style", { dangerouslySetInnerHTML: { __html: ` | |
:root { | |
--brand-color: ${r2.brandColor} | |
} | |
` } }), o("div", { className: "card", children: [r2.logo && o("img", { src: r2.logo, alt: "Logo", className: "logo" }), o("h1", { children: "Check your email" }), o("p", { children: "A sign in link has been sent to your email address." }), o("p", { children: o("a", { className: "site", href: t2.origin, children: t2.host }) })] })] }); | |
} | |
function send({ html: e2, title: t2, status: r2, cookies: n2, theme: i2 }) { | |
return { cookies: n2, status: r2, headers: { "Content-Type": "text/html" }, body: `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><style>${ti}</style><title>${t2}</title></head><body class="__next-auth-theme-${i2?.colorScheme ?? "auto"}"><div class="page">${k(e2)}</div></body></html>` }; | |
} | |
function renderPage(e2) { | |
const { url: t2, theme: r2, query: n2, cookies: i2 } = e2; | |
return { signin: (t3) => send({ cookies: i2, theme: r2, html: SigninPage({ csrfToken: e2.csrfToken, providers: e2.providers?.filter((e3) => ["email", "oauth", "oidc"].includes(e3.type) || "credentials" === e3.type && e3.credentials || false), callbackUrl: e2.callbackUrl, theme: r2, ...n2, ...t3 }), title: "Sign In" }), signout: (n3) => send({ cookies: i2, theme: r2, html: SignoutPage({ csrfToken: e2.csrfToken, url: t2, theme: r2, ...n3 }), title: "Sign Out" }), verifyRequest: (e3) => send({ cookies: i2, theme: r2, html: VerifyRequestPage({ url: t2, theme: r2, ...e3 }), title: "Verify Request" }), error: (e3) => send({ cookies: i2, theme: r2, ...ErrorPage({ url: t2, theme: r2, ...e3 }), title: "Error" }) }; | |
} | |
function fromDate(e2, t2 = Date.now()) { | |
return new Date(t2 + 1e3 * e2); | |
} | |
async function handleLogin(e2, t2, r2, n2) { | |
if (!r2?.providerAccountId || !r2.type) | |
throw new Error("Missing or invalid provider account"); | |
if (!["email", "oauth", "oidc"].includes(r2.type)) | |
throw new Error("Provider not supported"); | |
const { adapter: i2, jwt: a2, events: c2, session: { strategy: u2, generateSessionToken: m2 } } = n2; | |
if (!i2) | |
return { user: t2, account: r2 }; | |
const g2 = t2; | |
let b2 = r2; | |
const { createUser: x2, updateUser: C2, getUser: A2, getUserByAccount: P2, getUserByEmail: T2, linkAccount: _2, createSession: I2, getSessionAndUser: D2, deleteSession: N2 } = i2; | |
let O2 = null, L2 = null, R2 = false; | |
const M2 = "jwt" === u2; | |
if (e2) | |
if (M2) | |
try { | |
O2 = await a2.decode({ ...a2, token: e2 }), O2 && "sub" in O2 && O2.sub && (L2 = await A2(O2.sub)); | |
} catch { | |
} | |
else { | |
const t3 = await D2(e2); | |
t3 && (O2 = t3.session, L2 = t3.user); | |
} | |
if ("email" === b2.type) { | |
const t3 = await T2(g2.email); | |
if (t3) | |
L2?.id !== t3.id && !M2 && e2 && await N2(e2), L2 = await C2({ id: t3.id, emailVerified: new Date() }), await c2.updateUser?.({ user: L2 }); | |
else { | |
const { id: e3, ...t4 } = { ...g2, emailVerified: new Date() }; | |
L2 = await x2(t4), await c2.createUser?.({ user: L2 }), R2 = true; | |
} | |
return O2 = M2 ? {} : await I2({ sessionToken: m2(), userId: L2.id, expires: fromDate(n2.session.maxAge) }), { session: O2, user: L2, isNewUser: R2 }; | |
} | |
const F2 = await P2({ providerAccountId: b2.providerAccountId, provider: b2.provider }); | |
if (F2) { | |
if (L2) { | |
if (F2.id === L2.id) | |
return { session: O2, user: L2, isNewUser: R2 }; | |
throw new OAuthAccountNotLinked("The account is already associated with another user", { provider: b2.provider }); | |
} | |
return O2 = M2 ? {} : await I2({ sessionToken: m2(), userId: F2.id, expires: fromDate(n2.session.maxAge) }), { session: O2, user: F2, isNewUser: R2 }; | |
} | |
{ | |
const { provider: e3 } = n2, { type: t3, provider: r3, providerAccountId: i3, userId: a3, ...u3 } = b2, C3 = { providerAccountId: i3, provider: r3, type: t3, userId: a3 }; | |
if (b2 = Object.assign(e3.account(u3) ?? {}, C3), L2) | |
return await _2({ ...b2, userId: L2.id }), await c2.linkAccount?.({ user: L2, account: b2, profile: g2 }), { session: O2, user: L2, isNewUser: R2 }; | |
const A3 = g2.email ? await T2(g2.email) : null; | |
if (A3) { | |
const e4 = n2.provider; | |
if (!e4?.allowDangerousEmailAccountLinking) | |
throw new OAuthAccountNotLinked("Another account already exists with the same e-mail address", { provider: b2.provider }); | |
L2 = A3; | |
} else { | |
const { id: e4, ...t4 } = { ...g2, emailVerified: null }; | |
L2 = await x2(t4); | |
} | |
return await c2.createUser?.({ user: L2 }), await _2({ ...b2, userId: L2.id }), await c2.linkAccount?.({ user: L2, account: b2, profile: g2 }), O2 = M2 ? {} : await I2({ sessionToken: m2(), userId: L2.id, expires: fromDate(n2.session.maxAge) }), { session: O2, user: L2, isNewUser: true }; | |
} | |
} | |
let ri; | |
if ("undefined" == typeof navigator || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) { | |
ri = `${"oauth4webapi"}/${"v2.3.0"}`; | |
} | |
const ni = Symbol(), si = Symbol(), ii = new TextEncoder(), oi = new TextDecoder(); | |
function buf(e2) { | |
return "string" == typeof e2 ? ii.encode(e2) : oi.decode(e2); | |
} | |
const ai = 32768; | |
function b64u(e2) { | |
return "string" == typeof e2 ? function(e3) { | |
try { | |
const t2 = atob(e3.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")), r2 = new Uint8Array(t2.length); | |
for (let e4 = 0; e4 < t2.length; e4++) | |
r2[e4] = t2.charCodeAt(e4); | |
return r2; | |
} catch { | |
throw new TypeError("The input to be decoded is not correctly encoded."); | |
} | |
}(e2) : function(e3) { | |
e3 instanceof ArrayBuffer && (e3 = new Uint8Array(e3)); | |
const t2 = []; | |
for (let r2 = 0; r2 < e3.byteLength; r2 += ai) | |
t2.push(String.fromCharCode.apply(null, e3.subarray(r2, r2 + ai))); | |
return btoa(t2.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); | |
}(e2); | |
} | |
class UnsupportedOperationError extends Error { | |
constructor(e2) { | |
super(e2 ?? "operation not supported"), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor); | |
} | |
} | |
class OperationProcessingError extends Error { | |
constructor(e2) { | |
super(e2), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor); | |
} | |
} | |
const ci = OperationProcessingError, li = new class { | |
constructor(e2) { | |
this.cache = /* @__PURE__ */ new Map(), this._cache = /* @__PURE__ */ new Map(), this.maxSize = e2; | |
} | |
get(e2) { | |
let t2 = this.cache.get(e2); | |
return t2 || ((t2 = this._cache.get(e2)) ? (this.update(e2, t2), t2) : void 0); | |
} | |
has(e2) { | |
return this.cache.has(e2) || this._cache.has(e2); | |
} | |
set(e2, t2) { | |
return this.cache.has(e2) ? this.cache.set(e2, t2) : this.update(e2, t2), this; | |
} | |
delete(e2) { | |
return this.cache.has(e2) ? this.cache.delete(e2) : !!this._cache.has(e2) && this._cache.delete(e2); | |
} | |
update(e2, t2) { | |
this.cache.set(e2, t2), this.cache.size >= this.maxSize && (this._cache = this.cache, this.cache = /* @__PURE__ */ new Map()); | |
} | |
}(100); | |
function isCryptoKey(e2) { | |
return e2 instanceof CryptoKey; | |
} | |
function isPrivateKey(e2) { | |
return isCryptoKey(e2) && "private" === e2.type; | |
} | |
function processDpopNonce(e2) { | |
const t2 = new URL(e2.url); | |
return e2.headers.has("dpop-nonce") && li.set(t2.origin, e2.headers.get("dpop-nonce")), e2; | |
} | |
function isJsonObject(e2) { | |
return null !== e2 && "object" == typeof e2 && !Array.isArray(e2); | |
} | |
function prepareHeaders(e2) { | |
if (void 0 !== e2 && !(e2 instanceof Headers)) | |
throw new TypeError('"options.headers" must be an instance of Headers'); | |
const t2 = new Headers(e2); | |
if (ri && !t2.has("user-agent") && t2.set("user-agent", ri), t2.has("authorization")) | |
throw new TypeError('"options.headers" must not include the "authorization" header name'); | |
if (t2.has("dpop")) | |
throw new TypeError('"options.headers" must not include the "dpop" header name'); | |
return t2; | |
} | |
function signal(e2) { | |
if ("function" == typeof e2 && (e2 = e2()), !(e2 instanceof AbortSignal)) | |
throw new TypeError('"options.signal" must return or be an instance of AbortSignal'); | |
return e2; | |
} | |
async function discoveryRequest(e2, t2) { | |
if (!(e2 instanceof URL)) | |
throw new TypeError('"issuerIdentifier" must be an instance of URL'); | |
if ("https:" !== e2.protocol && "http:" !== e2.protocol) | |
throw new TypeError('"issuer.protocol" must be "https:" or "http:"'); | |
const r2 = new URL(e2.href); | |
switch (t2?.algorithm) { | |
case void 0: | |
case "oidc": | |
r2.pathname = `${r2.pathname}/.well-known/openid-configuration`.replace("//", "/"); | |
break; | |
case "oauth2": | |
"/" === r2.pathname ? r2.pathname = ".well-known/oauth-authorization-server" : r2.pathname = `.well-known/oauth-authorization-server/${r2.pathname}`.replace("//", "/"); | |
break; | |
default: | |
throw new TypeError('"options.algorithm" must be "oidc" (default), or "oauth2"'); | |
} | |
const n2 = prepareHeaders(t2?.headers); | |
return n2.set("accept", "application/json"), fetch(r2.href, { headers: n2, method: "GET", redirect: "manual", signal: t2?.signal ? signal(t2.signal) : null }).then(processDpopNonce); | |
} | |
function validateString(e2) { | |
return "string" == typeof e2 && 0 !== e2.length; | |
} | |
async function processDiscoveryResponse(e2, t2) { | |
if (!(e2 instanceof URL)) | |
throw new TypeError('"expectedIssuer" must be an instance of URL'); | |
if (!(t2 instanceof Response)) | |
throw new TypeError('"response" must be an instance of Response'); | |
if (200 !== t2.status) | |
throw new ci('"response" is not a conform Authorization Server Metadata response'); | |
let r2; | |
assertReadableResponse(t2); | |
try { | |
r2 = await t2.json(); | |
} catch { | |
throw new ci('failed to parse "response" body as JSON'); | |
} | |
if (!isJsonObject(r2)) | |
throw new ci('"response" body must be a top level object'); | |
if (!validateString(r2.issuer)) | |
throw new ci('"response" body "issuer" property must be a non-empty string'); | |
if (new URL(r2.issuer).href !== e2.href) | |
throw new ci('"response" body "issuer" does not match "expectedIssuer"'); | |
return r2; | |
} | |
function randomBytes() { | |
return b64u(crypto.getRandomValues(new Uint8Array(32))); | |
} | |
function formUrlEncode(e2) { | |
return encodeURIComponent(e2).replace(/%20/g, "+"); | |
} | |
function keyToJws(e2) { | |
switch (e2.algorithm.name) { | |
case "RSA-PSS": | |
return function(e3) { | |
switch (e3.algorithm.hash.name) { | |
case "SHA-256": | |
return "PS256"; | |
case "SHA-384": | |
return "PS384"; | |
case "SHA-512": | |
return "PS512"; | |
default: | |
throw new UnsupportedOperationError("unsupported RsaHashedKeyAlgorithm hash name"); | |
} | |
}(e2); | |
case "RSASSA-PKCS1-v1_5": | |
return function(e3) { | |
switch (e3.algorithm.hash.name) { | |
case "SHA-256": | |
return "RS256"; | |
case "SHA-384": | |
return "RS384"; | |
case "SHA-512": | |
return "RS512"; | |
default: | |
throw new UnsupportedOperationError("unsupported RsaHashedKeyAlgorithm hash name"); | |
} | |
}(e2); | |
case "ECDSA": | |
return function(e3) { | |
switch (e3.algorithm.namedCurve) { | |
case "P-256": | |
return "ES256"; | |
case "P-384": | |
return "ES384"; | |
case "P-521": | |
return "ES512"; | |
default: | |
throw new UnsupportedOperationError("unsupported EcKeyAlgorithm namedCurve"); | |
} | |
}(e2); | |
case "Ed25519": | |
case "Ed448": | |
return "EdDSA"; | |
default: | |
throw new UnsupportedOperationError("unsupported CryptoKey algorithm name"); | |
} | |
} | |
function getClockSkew(e2) { | |
return Number.isFinite(e2[ni]) ? e2[ni] : 0; | |
} | |
function getClockTolerance(e2) { | |
const t2 = e2[si]; | |
return Number.isFinite(t2) && -1 !== Math.sign(t2) ? t2 : 30; | |
} | |
function epochTime() { | |
return Math.floor(Date.now() / 1e3); | |
} | |
async function privateKeyJwt(e2, t2, r2, n2) { | |
return jwt({ alg: keyToJws(r2), kid: n2 }, function(e3, t3) { | |
const r3 = epochTime() + getClockSkew(t3); | |
return { jti: randomBytes(), aud: [e3.issuer, e3.token_endpoint], exp: r3 + 60, iat: r3, nbf: r3, iss: t3.client_id, sub: t3.client_id }; | |
}(e2, t2), r2); | |
} | |
function assertAs(e2) { | |
if ("object" != typeof e2 || null === e2) | |
throw new TypeError('"as" must be an object'); | |
if (!validateString(e2.issuer)) | |
throw new TypeError('"as.issuer" property must be a non-empty string'); | |
return true; | |
} | |
function assertClient(e2) { | |
if ("object" != typeof e2 || null === e2) | |
throw new TypeError('"client" must be an object'); | |
if (!validateString(e2.client_id)) | |
throw new TypeError('"client.client_id" property must be a non-empty string'); | |
return true; | |
} | |
function assertClientSecret(e2) { | |
if (!validateString(e2)) | |
throw new TypeError('"client.client_secret" property must be a non-empty string'); | |
return e2; | |
} | |
function assertNoClientPrivateKey(e2, t2) { | |
if (void 0 !== t2) | |
throw new TypeError(`"options.clientPrivateKey" property must not be provided when ${e2} client authentication method is used.`); | |
} | |
function assertNoClientSecret(e2, t2) { | |
if (void 0 !== t2) | |
throw new TypeError(`"client.client_secret" property must not be provided when ${e2} client authentication method is used.`); | |
} | |
async function clientAuthentication(e2, t2, r2, n2, i2) { | |
switch (r2.delete("client_secret"), r2.delete("client_assertion_type"), r2.delete("client_assertion"), t2.token_endpoint_auth_method) { | |
case void 0: | |
case "client_secret_basic": | |
assertNoClientPrivateKey("client_secret_basic", i2), n2.set("authorization", function(e3, t3) { | |
const r3 = formUrlEncode(e3), n3 = formUrlEncode(t3); | |
return `Basic ${btoa(`${r3}:${n3}`)}`; | |
}(t2.client_id, assertClientSecret(t2.client_secret))); | |
break; | |
case "client_secret_post": | |
assertNoClientPrivateKey("client_secret_post", i2), r2.set("client_id", t2.client_id), r2.set("client_secret", assertClientSecret(t2.client_secret)); | |
break; | |
case "private_key_jwt": { | |
if (assertNoClientSecret("private_key_jwt", t2.client_secret), void 0 === i2) | |
throw new TypeError('"options.clientPrivateKey" must be provided when "client.token_endpoint_auth_method" is "private_key_jwt"'); | |
const { key: n3, kid: a2 } = function(e3) { | |
if (e3 instanceof CryptoKey) | |
return { key: e3 }; | |
if (!(e3?.key instanceof CryptoKey)) | |
return {}; | |
if (void 0 !== e3.kid && !validateString(e3.kid)) | |
throw new TypeError('"kid" must be a non-empty string'); | |
return { key: e3.key, kid: e3.kid }; | |
}(i2); | |
if (!isPrivateKey(n3)) | |
throw new TypeError('"options.clientPrivateKey.key" must be a private CryptoKey'); | |
r2.set("client_id", t2.client_id), r2.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), r2.set("client_assertion", await privateKeyJwt(e2, t2, n3, a2)); | |
break; | |
} | |
case "none": | |
assertNoClientSecret("none", t2.client_secret), assertNoClientPrivateKey("none", i2), r2.set("client_id", t2.client_id); | |
break; | |
default: | |
throw new UnsupportedOperationError("unsupported client token_endpoint_auth_method"); | |
} | |
} | |
async function jwt(e2, t2, r2) { | |
if (!r2.usages.includes("sign")) | |
throw new TypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"'); | |
const n2 = `${b64u(buf(JSON.stringify(e2)))}.${b64u(buf(JSON.stringify(t2)))}`; | |
return `${n2}.${b64u(await crypto.subtle.sign(keyToSubtle(r2), r2, buf(n2)))}`; | |
} | |
async function dpopProofJwt(e2, t2, r2, n2, i2, a2) { | |
const { privateKey: c2, publicKey: u2, nonce: m2 = li.get(r2.origin) } = t2; | |
if (!isPrivateKey(c2)) | |
throw new TypeError('"DPoP.privateKey" must be a private CryptoKey'); | |
if (!isCryptoKey(g2 = u2) || "public" !== g2.type) | |
throw new TypeError('"DPoP.publicKey" must be a public CryptoKey'); | |
var g2; | |
if (void 0 !== m2 && !validateString(m2)) | |
throw new TypeError('"DPoP.nonce" must be a non-empty string or undefined'); | |
if (!u2.extractable) | |
throw new TypeError('"DPoP.publicKey.extractable" must be true'); | |
const b2 = epochTime() + i2, x2 = await jwt({ alg: keyToJws(c2), typ: "dpop+jwt", jwk: await publicJwk(u2) }, { iat: b2, jti: randomBytes(), htm: n2, nonce: m2, htu: `${r2.origin}${r2.pathname}`, ath: a2 ? b64u(await crypto.subtle.digest({ name: "SHA-256" }, buf(a2))) : void 0 }, c2); | |
e2.set("dpop", x2); | |
} | |
let pi; | |
async function publicJwk(e2) { | |
if (pi || (pi = /* @__PURE__ */ new WeakMap()), pi.has(e2)) | |
return pi.get(e2); | |
const { kty: t2, e: r2, n: n2, x: i2, y: a2, crv: c2 } = await crypto.subtle.exportKey("jwk", e2), u2 = { kty: t2, e: r2, n: n2, x: i2, y: a2, crv: c2 }; | |
return pi.set(e2, u2), u2; | |
} | |
function isOAuth2Error(e2) { | |
const t2 = e2; | |
return "object" == typeof t2 && !Array.isArray(t2) && null !== t2 && void 0 !== t2.error; | |
} | |
const ui = /((?:,|, )?[0-9a-zA-Z!#$%&'*+-.^_`|~]+=)/, di = /(?:^|, ?)([0-9a-zA-Z!#$%&'*+\-.^_`|~]+)(?=$|[ ,])/g; | |
function parseWwwAuthenticateChallenges(e2) { | |
if (!(e2 instanceof Response)) | |
throw new TypeError('"response" must be an instance of Response'); | |
if (!e2.headers.has("www-authenticate")) | |
return; | |
const t2 = e2.headers.get("www-authenticate"), r2 = []; | |
for (const { 1: e3, index: n3 } of t2.matchAll(di)) | |
r2.push([e3, n3]); | |
if (!r2.length) | |
return; | |
const n2 = r2.map(([e3, r3], n3, i2) => { | |
const a2 = i2[n3 + 1]; | |
let c2; | |
return c2 = a2 ? t2.slice(r3, a2[1]) : t2.slice(r3), function(e4, t3) { | |
const r4 = t3.split(ui).slice(1); | |
if (!r4.length) | |
return { scheme: e4.toLowerCase(), parameters: {} }; | |
r4[r4.length - 1] = r4[r4.length - 1].replace(/,$/, ""); | |
const n4 = {}; | |
for (let e5 = 1; e5 < r4.length; e5 += 2) { | |
const t4 = e5; | |
if ('"' === r4[t4][0]) | |
for (; '"' !== r4[t4].slice(-1) && ++e5 < r4.length; ) | |
r4[t4] += r4[e5]; | |
n4[r4[t4 - 1].replace(/^(?:, ?)|=$/g, "").toLowerCase()] = (i3 = r4[t4]).length >= 2 && '"' === i3[0] && '"' === i3[i3.length - 1] ? i3.slice(1, -1) : i3; | |
} | |
var i3; | |
return { scheme: e4.toLowerCase(), parameters: n4 }; | |
}(e3, c2); | |
}); | |
return n2; | |
} | |
async function userInfoRequest(e2, t2, r2, n2) { | |
if (assertAs(e2), assertClient(t2), "string" != typeof e2.userinfo_endpoint) | |
throw new TypeError('"as.userinfo_endpoint" must be a string'); | |
const i2 = new URL(e2.userinfo_endpoint), a2 = prepareHeaders(n2?.headers); | |
return t2.userinfo_signed_response_alg ? a2.set("accept", "application/jwt") : (a2.set("accept", "application/json"), a2.append("accept", "application/jwt")), async function(e3, t3, r3, n3, i3, a3) { | |
if (!validateString(e3)) | |
throw new TypeError('"accessToken" must be a non-empty string'); | |
if (!(r3 instanceof URL)) | |
throw new TypeError('"url" must be an instance of URL'); | |
return n3 = prepareHeaders(n3), void 0 === a3?.DPoP ? n3.set("authorization", `Bearer ${e3}`) : (await dpopProofJwt(n3, a3.DPoP, r3, "GET", getClockSkew({ [ni]: a3?.clockSkew }), e3), n3.set("authorization", `DPoP ${e3}`)), fetch(r3.href, { body: i3, headers: n3, method: t3, redirect: "manual", signal: a3?.signal ? signal(a3.signal) : null }).then(processDpopNonce); | |
}(r2, "GET", i2, a2, null, { ...n2, clockSkew: getClockSkew(t2) }); | |
} | |
async function tokenEndpointRequest(e2, t2, r2, n2, i2) { | |
if ("string" != typeof e2.token_endpoint) | |
throw new TypeError('"as.token_endpoint" must be a string'); | |
const a2 = new URL(e2.token_endpoint); | |
n2.set("grant_type", r2); | |
const c2 = prepareHeaders(i2?.headers); | |
return c2.set("accept", "application/json"), void 0 !== i2?.DPoP && await dpopProofJwt(c2, i2.DPoP, a2, "POST", getClockSkew(t2)), async function(e3, t3, r3, n3, i3, a3, c3) { | |
return await clientAuthentication(e3, t3, i3, a3, c3?.clientPrivateKey), a3.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"), fetch(n3.href, { body: i3, headers: a3, method: r3, redirect: "manual", signal: c3?.signal ? signal(c3.signal) : null }).then(processDpopNonce); | |
}(e2, t2, "POST", a2, n2, c2, i2); | |
} | |
const hi = /* @__PURE__ */ new WeakMap(); | |
function getValidatedIdTokenClaims(e2) { | |
if (!e2.id_token) | |
return; | |
const t2 = hi.get(e2); | |
if (!t2) | |
throw new TypeError('"ref" was already garbage collected or did not resolve from the proper sources'); | |
return t2; | |
} | |
async function processGenericAccessTokenResponse(e2, t2, r2, n2 = false, i2 = false) { | |
if (assertAs(e2), assertClient(t2), !(r2 instanceof Response)) | |
throw new TypeError('"response" must be an instance of Response'); | |
if (200 !== r2.status) { | |
let e3; | |
if (e3 = await async function(e4) { | |
if (e4.status > 399 && e4.status < 500) { | |
assertReadableResponse(e4); | |
try { | |
const t3 = await e4.json(); | |
if (isJsonObject(t3) && "string" == typeof t3.error && t3.error.length) | |
return void 0 !== t3.error_description && "string" != typeof t3.error_description && delete t3.error_description, void 0 !== t3.error_uri && "string" != typeof t3.error_uri && delete t3.error_uri, void 0 !== t3.algs && "string" != typeof t3.algs && delete t3.algs, void 0 !== t3.scope && "string" != typeof t3.scope && delete t3.scope, t3; | |
} catch { | |
} | |
} | |
return; | |
}(r2)) | |
return e3; | |
throw new ci('"response" is not a conform Token Endpoint response'); | |
} | |
let a2; | |
assertReadableResponse(r2); | |
try { | |
a2 = await r2.json(); | |
} catch { | |
throw new ci('failed to parse "response" body as JSON'); | |
} | |
if (!isJsonObject(a2)) | |
throw new ci('"response" body must be a top level object'); | |
if (!validateString(a2.access_token)) | |
throw new ci('"response" body "access_token" property must be a non-empty string'); | |
if (!validateString(a2.token_type)) | |
throw new ci('"response" body "token_type" property must be a non-empty string'); | |
if (a2.token_type = a2.token_type.toLowerCase(), "dpop" !== a2.token_type && "bearer" !== a2.token_type) | |
throw new UnsupportedOperationError("unsupported `token_type` value"); | |
if (void 0 !== a2.expires_in && ("number" != typeof a2.expires_in || a2.expires_in <= 0)) | |
throw new ci('"response" body "expires_in" property must be a positive number'); | |
if (!i2 && void 0 !== a2.refresh_token && !validateString(a2.refresh_token)) | |
throw new ci('"response" body "refresh_token" property must be a non-empty string'); | |
if (void 0 !== a2.scope && "string" != typeof a2.scope) | |
throw new ci('"response" body "scope" property must be a string'); | |
if (!n2) { | |
if (void 0 !== a2.id_token && !validateString(a2.id_token)) | |
throw new ci('"response" body "id_token" property must be a non-empty string'); | |
if (a2.id_token) { | |
const { claims: r3 } = await async function(e3, t3, r4, n3, i3) { | |
const { 0: a3, 1: c2, 2: u2, length: m2 } = e3.split("."); | |
if (5 === m2) | |
throw new UnsupportedOperationError("JWE structure JWTs are not supported"); | |
if (3 !== m2) | |
throw new ci("Invalid JWT"); | |
let g2; | |
try { | |
g2 = JSON.parse(buf(b64u(a3))); | |
} catch { | |
throw new ci("failed to parse JWT Header body as base64url encoded JSON"); | |
} | |
if (!isJsonObject(g2)) | |
throw new ci("JWT Header must be a top level object"); | |
if (t3(g2), void 0 !== g2.crit) | |
throw new ci('unexpected JWT "crit" header parameter'); | |
const b2 = b64u(u2); | |
if (r4 !== bi) { | |
const e4 = await r4(g2), t4 = `${a3}.${c2}`; | |
if (!await crypto.subtle.verify(keyToSubtle(e4), e4, b2, buf(t4))) | |
throw new ci("JWT signature verification failed"); | |
} | |
let x2; | |
try { | |
x2 = JSON.parse(buf(b64u(c2))); | |
} catch { | |
throw new ci("failed to parse JWT Payload body as base64url encoded JSON"); | |
} | |
if (!isJsonObject(x2)) | |
throw new ci("JWT Payload must be a top level object"); | |
const C2 = epochTime() + n3; | |
if (void 0 !== x2.exp) { | |
if ("number" != typeof x2.exp) | |
throw new ci('unexpected JWT "exp" (expiration time) claim type'); | |
if (x2.exp <= C2 - i3) | |
throw new ci('unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()'); | |
} | |
if (void 0 !== x2.iat && "number" != typeof x2.iat) | |
throw new ci('unexpected JWT "iat" (issued at) claim type'); | |
if (void 0 !== x2.iss && "string" != typeof x2.iss) | |
throw new ci('unexpected JWT "iss" (issuer) claim type'); | |
if (void 0 !== x2.nbf) { | |
if ("number" != typeof x2.nbf) | |
throw new ci('unexpected JWT "nbf" (not before) claim type'); | |
if (x2.nbf > C2 + i3) | |
throw new ci('unexpected JWT "nbf" (not before) claim value, timestamp is > now()'); | |
} | |
if (void 0 !== x2.aud && "string" != typeof x2.aud && !Array.isArray(x2.aud)) | |
throw new ci('unexpected JWT "aud" (audience) claim type'); | |
return { header: g2, claims: x2, signature: b2 }; | |
}(a2.id_token, checkSigningAlgorithm.bind(void 0, t2.id_token_signed_response_alg, e2.id_token_signing_alg_values_supported), bi, getClockSkew(t2), getClockTolerance(t2)).then(validatePresence.bind(void 0, ["aud", "exp", "iat", "iss", "sub"])).then(validateIssuer.bind(void 0, e2.issuer)).then(validateAudience.bind(void 0, t2.client_id)); | |
if (Array.isArray(r3.aud) && 1 !== r3.aud.length && r3.azp !== t2.client_id) | |
throw new ci('unexpected ID Token "azp" (authorized party) claim value'); | |
if (t2.require_auth_time && "number" != typeof r3.auth_time) | |
throw new ci('unexpected ID Token "auth_time" (authentication time) claim value'); | |
hi.set(a2, r3); | |
} | |
} | |
return a2; | |
} | |
function validateAudience(e2, t2) { | |
if (Array.isArray(t2.claims.aud)) { | |
if (!t2.claims.aud.includes(e2)) | |
throw new ci('unexpected JWT "aud" (audience) claim value'); | |
} else if (t2.claims.aud !== e2) | |
throw new ci('unexpected JWT "aud" (audience) claim value'); | |
return t2; | |
} | |
function validateIssuer(e2, t2) { | |
if (t2.claims.iss !== e2) | |
throw new ci('unexpected JWT "iss" (issuer) claim value'); | |
return t2; | |
} | |
const fi = /* @__PURE__ */ new WeakSet(); | |
const mi = { aud: "audience", exp: "expiration time", iat: "issued at", iss: "issuer", sub: "subject" }; | |
function validatePresence(e2, t2) { | |
for (const r2 of e2) | |
if (void 0 === t2.claims[r2]) | |
throw new ci(`JWT "${r2}" (${mi[r2]}) claim missing`); | |
return t2; | |
} | |
const gi = Symbol(), yi = Symbol(); | |
function assertReadableResponse(e2) { | |
if (e2.bodyUsed) | |
throw new TypeError('"response" body has been used already'); | |
} | |
function checkRsaKeyAlgorithm(e2) { | |
if ("number" != typeof e2.modulusLength || e2.modulusLength < 2048) | |
throw new ci(`${e2.name} modulusLength must be at least 2048 bits`); | |
} | |
function ecdsaHashName(e2) { | |
switch (e2) { | |
case "P-256": | |
return "SHA-256"; | |
case "P-384": | |
return "SHA-384"; | |
case "P-521": | |
return "SHA-512"; | |
default: | |
throw new UnsupportedOperationError(); | |
} | |
} | |
function keyToSubtle(e2) { | |
switch (e2.algorithm.name) { | |
case "ECDSA": | |
return { name: e2.algorithm.name, hash: { name: ecdsaHashName(e2.algorithm.namedCurve) } }; | |
case "RSA-PSS": | |
switch (checkRsaKeyAlgorithm(e2.algorithm), e2.algorithm.hash.name) { | |
case "SHA-256": | |
case "SHA-384": | |
case "SHA-512": | |
return { name: e2.algorithm.name, saltLength: parseInt(e2.algorithm.hash.name.slice(-3), 10) >> 3 }; | |
default: | |
throw new UnsupportedOperationError(); | |
} | |
case "RSASSA-PKCS1-v1_5": | |
return checkRsaKeyAlgorithm(e2.algorithm), { name: e2.algorithm.name }; | |
case "Ed448": | |
case "Ed25519": | |
return { name: e2.algorithm.name }; | |
} | |
throw new UnsupportedOperationError(); | |
} | |
const bi = Symbol(); | |
function checkSigningAlgorithm(e2, t2, r2) { | |
if (void 0 === e2) { | |
if (Array.isArray(t2)) { | |
if (!t2.includes(r2.alg)) | |
throw new ci('unexpected JWT "alg" header parameter'); | |
} else if ("RS256" !== r2.alg) | |
throw new ci('unexpected JWT "alg" header parameter'); | |
} else if (r2.alg !== e2) | |
throw new ci('unexpected JWT "alg" header parameter'); | |
} | |
function getURLSearchParameter(e2, t2) { | |
const { 0: r2, length: n2 } = e2.getAll(t2); | |
if (n2 > 1) | |
throw new ci(`"${t2}" parameter must be provided only once`); | |
return r2; | |
} | |
const vi = Symbol(), xi = Symbol(); | |
function validateAuthResponse(e2, t2, r2, n2) { | |
if (assertAs(e2), assertClient(t2), r2 instanceof URL && (r2 = r2.searchParams), !(r2 instanceof URLSearchParams)) | |
throw new TypeError('"parameters" must be an instance of URLSearchParams, or URL'); | |
if (getURLSearchParameter(r2, "response")) | |
throw new ci('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()'); | |
const i2 = getURLSearchParameter(r2, "iss"), a2 = getURLSearchParameter(r2, "state"); | |
if (!i2 && e2.authorization_response_iss_parameter_supported) | |
throw new ci('response parameter "iss" (issuer) missing'); | |
if (i2 && i2 !== e2.issuer) | |
throw new ci('unexpected "iss" (issuer) response parameter value'); | |
switch (n2) { | |
case void 0: | |
case xi: | |
if (void 0 !== a2) | |
throw new ci('unexpected "state" response parameter encountered'); | |
break; | |
case vi: | |
break; | |
default: | |
if (!validateString(n2)) | |
throw new ci('"expectedState" must be a non-empty string'); | |
if (void 0 === a2) | |
throw new ci('response parameter "state" missing'); | |
if (a2 !== n2) | |
throw new ci('unexpected "state" response parameter value'); | |
} | |
const c2 = getURLSearchParameter(r2, "error"); | |
if (c2) | |
return { error: c2, error_description: getURLSearchParameter(r2, "error_description"), error_uri: getURLSearchParameter(r2, "error_uri") }; | |
const u2 = getURLSearchParameter(r2, "id_token"), m2 = getURLSearchParameter(r2, "token"); | |
if (void 0 !== u2 || void 0 !== m2) | |
throw new UnsupportedOperationError("implicit and hybrid flows are not supported"); | |
return g2 = new URLSearchParams(r2), fi.add(g2), g2; | |
var g2; | |
} | |
async function signCookie(e2, t2, r2, n2, i2) { | |
const { cookies: a2, logger: c2 } = n2; | |
c2.debug(`CREATE_${e2.toUpperCase()}`, { value: t2, maxAge: r2 }); | |
const u2 = new Date(); | |
u2.setTime(u2.getTime() + 1e3 * r2); | |
const m2 = { value: t2 }; | |
return "state" === e2 && i2 && (m2.data = i2), { name: a2[e2].name, value: await encode$1({ ...n2.jwt, maxAge: r2, token: m2 }), options: { ...a2[e2].options, expires: u2 } }; | |
} | |
const wi = { async create(e2) { | |
const t2 = randomBytes(), r2 = await async function(e3) { | |
if (!validateString(e3)) | |
throw new TypeError('"codeVerifier" must be a non-empty string'); | |
return b64u(await crypto.subtle.digest({ name: "SHA-256" }, buf(e3))); | |
}(t2); | |
return { cookie: await signCookie("pkceCodeVerifier", t2, 900, e2), value: r2 }; | |
}, async use(e2, t2, r2) { | |
const { provider: n2 } = r2; | |
if (!n2?.checks?.includes("pkce")) | |
return; | |
const i2 = e2?.[r2.cookies.pkceCodeVerifier.name]; | |
if (!i2) | |
throw new InvalidCheck("PKCE code_verifier cookie was missing."); | |
const a2 = await decode$2({ ...r2.jwt, token: i2 }); | |
if (!a2?.value) | |
throw new InvalidCheck("PKCE code_verifier value could not be parsed."); | |
return t2.push({ name: r2.cookies.pkceCodeVerifier.name, value: "", options: { ...r2.cookies.pkceCodeVerifier.options, maxAge: 0 } }), a2.value; | |
} }; | |
function decodeState(e2) { | |
try { | |
const t2 = new TextDecoder(); | |
return JSON.parse(t2.decode(Ds(e2))); | |
} catch { | |
} | |
} | |
const Ci = { async create(e2, t2) { | |
const { provider: r2 } = e2; | |
if (!r2.checks.includes("state")) { | |
if (t2) | |
throw new InvalidCheck("State data was provided but the provider is not configured to use state."); | |
return; | |
} | |
const n2 = Is(JSON.stringify({ ...t2, random: randomBytes() })); | |
return { cookie: await signCookie("state", n2, 900, e2, t2), value: n2 }; | |
}, async use(e2, t2, r2, n2) { | |
const { provider: i2 } = r2; | |
if (!i2.checks.includes("state")) | |
return; | |
const a2 = e2?.[r2.cookies.state.name]; | |
if (!a2) | |
throw new InvalidCheck("State cookie was missing."); | |
const c2 = await decode$2({ ...r2.jwt, token: a2 }); | |
if (!c2?.value) | |
throw new InvalidCheck("State (cookie) value could not be parsed."); | |
const u2 = decodeState(c2.value); | |
if (!u2) | |
throw new InvalidCheck("State (encoded) value could not be parsed."); | |
if (u2.random !== n2) | |
throw new InvalidCheck(`Random state values did not match. Expected: ${u2.random}. Got: ${n2}`); | |
return t2.push({ name: r2.cookies.state.name, value: "", options: { ...r2.cookies.state.options, maxAge: 0 } }), c2.value; | |
} }, Ei = { async create(e2) { | |
if (!e2.provider.checks.includes("nonce")) | |
return; | |
const t2 = randomBytes(); | |
return { cookie: await signCookie("nonce", t2, 900, e2), value: t2 }; | |
}, async use(e2, t2, r2) { | |
const { provider: n2 } = r2; | |
if (!n2?.checks?.includes("nonce")) | |
return; | |
const i2 = e2?.[r2.cookies.nonce.name]; | |
if (!i2) | |
throw new InvalidCheck("Nonce cookie was missing."); | |
const a2 = await decode$2({ ...r2.jwt, token: i2 }); | |
if (!a2?.value) | |
throw new InvalidCheck("Nonce value could not be parsed."); | |
return t2.push({ name: r2.cookies.nonce.name, value: "", options: { ...r2.cookies.nonce.options, maxAge: 0 } }), a2.value; | |
} }; | |
async function handleOAuth(e2, t2, r2, n2) { | |
const { logger: i2, provider: a2 } = r2; | |
let c2; | |
const { token: u2, userinfo: m2 } = a2; | |
if (u2?.url && "authjs.dev" !== u2.url.host || m2?.url && "authjs.dev" !== m2.url.host) | |
c2 = { issuer: a2.issuer ?? "https://authjs.dev", token_endpoint: u2?.url.toString(), userinfo_endpoint: m2?.url.toString() }; | |
else { | |
const e3 = new URL(a2.issuer), t3 = await discoveryRequest(e3), r3 = await processDiscoveryResponse(e3, t3); | |
if (!r3.token_endpoint) | |
throw new TypeError("TODO: Authorization server did not provide a token endpoint."); | |
if (!r3.userinfo_endpoint) | |
throw new TypeError("TODO: Authorization server did not provide a userinfo endpoint."); | |
c2 = r3; | |
} | |
const g2 = { client_id: a2.clientId, client_secret: a2.clientSecret, ...a2.client }, b2 = [], x2 = await Ci.use(t2, b2, r2, n2), C2 = validateAuthResponse(c2, g2, new URLSearchParams(e2), a2.checks.includes("state") ? x2 : vi); | |
if (isOAuth2Error(C2)) { | |
const e3 = { providerId: a2.id, ...C2 }; | |
throw i2.debug("OAuthCallbackError", e3), new OAuthCallbackError("OAuth Provider returned an error", e3); | |
} | |
const A2 = await wi.use(t2, b2, r2); | |
let P2 = a2.callbackUrl; | |
!r2.isOnRedirectProxy && a2.redirectProxyUrl && (P2 = a2.redirectProxyUrl); | |
let T2, _2 = await async function(e3, t3, r3, n3, i3, a3) { | |
if (assertAs(e3), assertClient(t3), !fi.has(r3)) | |
throw new TypeError('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()'); | |
if (!validateString(n3)) | |
throw new TypeError('"redirectUri" must be a non-empty string'); | |
if (!validateString(i3)) | |
throw new TypeError('"codeVerifier" must be a non-empty string'); | |
const c3 = getURLSearchParameter(r3, "code"); | |
if (!c3) | |
throw new ci('no authorization code in "callbackParameters"'); | |
const u3 = new URLSearchParams(a3?.additionalParameters); | |
return u3.set("redirect_uri", n3), u3.set("code_verifier", i3), u3.set("code", c3), tokenEndpointRequest(e3, t3, "authorization_code", u3, a3); | |
}(c2, g2, C2, P2, A2 ?? "auth"); | |
if (a2.token?.conform && (_2 = await a2.token.conform(_2.clone()) ?? _2), T2 = parseWwwAuthenticateChallenges(_2)) { | |
for (const e3 of T2) | |
console.log("challenge", e3); | |
throw new Error("TODO: Handle www-authenticate challenges as needed"); | |
} | |
let I2, D2 = {}; | |
if ("oidc" === a2.type) { | |
const e3 = await Ei.use(t2, b2, r2), n3 = await async function(e4, t3, r3, n4, i3) { | |
const a3 = await processGenericAccessTokenResponse(e4, t3, r3); | |
if (isOAuth2Error(a3)) | |
return a3; | |
if (!validateString(a3.id_token)) | |
throw new ci('"response" body "id_token" property must be a non-empty string'); | |
i3 ?? (i3 = t3.default_max_age ?? yi); | |
const c3 = getValidatedIdTokenClaims(a3); | |
if ((t3.require_auth_time || i3 !== yi) && void 0 === c3.auth_time) | |
throw new ci('ID Token "auth_time" (authentication time) claim missing'); | |
if (i3 !== yi) { | |
if ("number" != typeof i3 || i3 < 0) | |
throw new TypeError('"options.max_age" must be a non-negative number'); | |
const e5 = epochTime() + getClockSkew(t3), r4 = getClockTolerance(t3); | |
if (c3.auth_time + i3 < e5 - r4) | |
throw new ci("too much time has elapsed since the last End-User authentication"); | |
} | |
switch (n4) { | |
case void 0: | |
case gi: | |
if (void 0 !== c3.nonce) | |
throw new ci('unexpected ID Token "nonce" claim value'); | |
break; | |
default: | |
if (!validateString(n4)) | |
throw new TypeError('"expectedNonce" must be a non-empty string'); | |
if (void 0 === c3.nonce) | |
throw new ci('ID Token "nonce" claim missing'); | |
if (c3.nonce !== n4) | |
throw new ci('unexpected ID Token "nonce" claim value'); | |
} | |
return a3; | |
}(c2, g2, _2, e3 ?? gi); | |
if (isOAuth2Error(n3)) | |
throw console.log("error", n3), new Error("TODO: Handle OIDC response body error"); | |
D2 = getValidatedIdTokenClaims(n3), I2 = n3; | |
} else { | |
if (I2 = await async function(e3, t3, r3) { | |
const n3 = await processGenericAccessTokenResponse(e3, t3, r3, true); | |
if (isOAuth2Error(n3)) | |
return n3; | |
if (void 0 !== n3.id_token) { | |
if ("string" == typeof n3.id_token && n3.id_token.length) | |
throw new ci("Unexpected ID Token returned, use processAuthorizationCodeOpenIDResponse() for OpenID Connect callback processing"); | |
delete n3.id_token; | |
} | |
return n3; | |
}(c2, g2, _2), isOAuth2Error(I2)) | |
throw console.log("error", I2), new Error("TODO: Handle OAuth 2.0 response body error"); | |
if (m2?.request) { | |
const e3 = await m2.request({ tokens: I2, provider: a2 }); | |
e3 instanceof Object && (D2 = e3); | |
} else { | |
if (!m2?.url) | |
throw new TypeError("No userinfo endpoint configured"); | |
{ | |
const e3 = await userInfoRequest(c2, g2, I2.access_token); | |
D2 = await e3.json(); | |
} | |
} | |
} | |
I2.expires_in && (I2.expires_at = Math.floor(Date.now() / 1e3) + Number(I2.expires_in)); | |
const N2 = await async function(e3, t3, r3, n3) { | |
try { | |
const n4 = await t3.profile(e3, r3); | |
if (n4.email = n4.email?.toLowerCase(), !n4.id) | |
throw new TypeError(`User id is missing in ${t3.name} OAuth profile response`); | |
return { user: n4, account: { provider: t3.id, type: t3.type, providerAccountId: n4.id.toString(), ...r3 } }; | |
} catch (r4) { | |
n3.debug("getProfile error details", e3), n3.error(new OAuthProfileParseError(r4, { provider: t3.id })); | |
} | |
}(D2, a2, I2, i2); | |
return { ...N2, profile: D2, cookies: b2 }; | |
} | |
async function handleAuthorized(e2, { url: t2, logger: r2, callbacks: { signIn: n2 } }) { | |
try { | |
if (!await n2(e2)) | |
return t2.pathname += "/error", r2.debug("User not authorized", e2), t2.searchParams.set("error", "AccessDenied"), { status: 403, redirect: t2.toString() }; | |
} catch (e3) { | |
t2.pathname += "/error"; | |
const n3 = new AuthorizedCallbackError(e3); | |
return r2.error(n3), t2.searchParams.set("error", "Configuration"), { status: 500, redirect: t2.toString() }; | |
} | |
} | |
async function callback(e2) { | |
const { options: t2, query: r2, body: n2, method: i2, headers: a2, sessionStore: c2 } = e2, { provider: u2, adapter: m2, url: g2, callbackUrl: b2, pages: x2, jwt: C2, events: A2, callbacks: P2, session: { strategy: T2, maxAge: _2 }, logger: I2 } = t2, D2 = [], N2 = "jwt" === T2; | |
try { | |
if ("oauth" === u2.type || "oidc" === u2.type) { | |
const { proxyRedirect: n3, randomState: i3 } = function(e3, t3, r3) { | |
let n4, i4; | |
if (t3.redirectProxyUrl && !e3?.state) | |
throw new InvalidCheck("Missing state in query, but required for redirect proxy"); | |
const a4 = decodeState(e3?.state); | |
if (n4 = a4?.random, r3) { | |
if (!a4?.origin) | |
return { randomState: n4 }; | |
i4 = `${a4.origin}?${new URLSearchParams(e3)}`; | |
} | |
return { randomState: n4, proxyRedirect: i4 }; | |
}(r2, u2, t2.isOnRedirectProxy); | |
if (n3) | |
return I2.debug("proxy redirect", { proxyRedirect: n3, randomState: i3 }), { redirect: n3 }; | |
const a3 = await handleOAuth(r2, e2.cookies, t2, i3); | |
a3.cookies.length && D2.push(...a3.cookies), I2.debug("authorization result", a3); | |
const { user: T3, account: O2, profile: L2 } = a3; | |
if (!T3 || !O2 || !L2) | |
return { redirect: `${g2}/signin`, cookies: D2 }; | |
let R2; | |
if (m2) { | |
const { getUserByAccount: e3 } = m2, t3 = await e3({ providerAccountId: O2.providerAccountId, provider: u2.id }); | |
t3 && (R2 = t3); | |
} | |
const M2 = await handleAuthorized({ user: R2, account: O2, profile: L2 }, t2); | |
if (M2) | |
return { ...M2, cookies: D2 }; | |
const { user: F2, session: B2, isNewUser: $2 } = await handleLogin(c2.value, T3, O2, t2); | |
if (N2) { | |
const e3 = { name: F2.name, email: F2.email, picture: F2.image, sub: F2.id?.toString() }, t3 = await P2.jwt({ token: e3, user: F2, account: O2, profile: L2, isNewUser: $2, trigger: $2 ? "signUp" : "signIn" }); | |
if (null === t3) | |
D2.push(...c2.clean()); | |
else { | |
const e4 = await C2.encode({ ...C2, token: t3 }), r3 = new Date(); | |
r3.setTime(r3.getTime() + 1e3 * _2); | |
const n4 = c2.chunk(e4, { expires: r3 }); | |
D2.push(...n4); | |
} | |
} else | |
D2.push({ name: t2.cookies.sessionToken.name, value: B2.sessionToken, options: { ...t2.cookies.sessionToken.options, expires: B2.expires } }); | |
return await A2.signIn?.({ user: F2, account: O2, profile: L2, isNewUser: $2 }), $2 && x2.newUser ? { redirect: `${x2.newUser}${x2.newUser.includes("?") ? "&" : "?"}${new URLSearchParams({ callbackUrl: b2 })}`, cookies: D2 } : { redirect: b2, cookies: D2 }; | |
} | |
if ("email" === u2.type) { | |
const e3 = r2?.token, n3 = r2?.email; | |
if (!e3 || !n3) { | |
const t3 = new TypeError("Missing token or email. The sign-in URL was manually opened without token/identifier or the link was not sent correctly in the email.", { cause: { hasToken: !!e3, hasEmail: !!n3 } }); | |
throw t3.name = "Configuration", t3; | |
} | |
const i3 = u2.secret ?? t2.secret, a3 = await m2.useVerificationToken({ identifier: n3, token: await createHash(`${e3}${i3}`) }), g3 = !!a3, T3 = a3 ? a3.expires.valueOf() < Date.now() : void 0; | |
if (!g3 || T3) | |
throw new Verification({ hasInvite: g3, expired: T3 }); | |
const I3 = await m2.getUserByEmail(n3) ?? { id: n3, email: n3, emailVerified: null }, O2 = { providerAccountId: I3.email, userId: I3.id, type: "email", provider: u2.id }, L2 = await handleAuthorized({ user: I3, account: O2 }, t2); | |
if (L2) | |
return { ...L2, cookies: D2 }; | |
const { user: R2, session: M2, isNewUser: F2 } = await handleLogin(c2.value, I3, O2, t2); | |
if (N2) { | |
const e4 = { name: R2.name, email: R2.email, picture: R2.image, sub: R2.id?.toString() }, t3 = await P2.jwt({ token: e4, user: R2, account: O2, isNewUser: F2, trigger: F2 ? "signUp" : "signIn" }); | |
if (null === t3) | |
D2.push(...c2.clean()); | |
else { | |
const e5 = await C2.encode({ ...C2, token: t3 }), r3 = new Date(); | |
r3.setTime(r3.getTime() + 1e3 * _2); | |
const n4 = c2.chunk(e5, { expires: r3 }); | |
D2.push(...n4); | |
} | |
} else | |
D2.push({ name: t2.cookies.sessionToken.name, value: M2.sessionToken, options: { ...t2.cookies.sessionToken.options, expires: M2.expires } }); | |
return await A2.signIn?.({ user: R2, account: O2, isNewUser: F2 }), F2 && x2.newUser ? { redirect: `${x2.newUser}${x2.newUser.includes("?") ? "&" : "?"}${new URLSearchParams({ callbackUrl: b2 })}`, cookies: D2 } : { redirect: b2, cookies: D2 }; | |
} | |
if ("credentials" === u2.type && "POST" === i2) { | |
const e3 = n2 ?? {}; | |
Object.entries(r2 ?? {}).forEach(([e4, t3]) => g2.searchParams.set(e4, t3)); | |
const m3 = await u2.authorize(e3, new Request(g2, { headers: a2, method: i2, body: JSON.stringify(n2) })); | |
if (!m3) | |
return { status: 401, redirect: `${g2}/error?${new URLSearchParams({ error: "CredentialsSignin", provider: u2.id })}`, cookies: D2 }; | |
const x3 = { providerAccountId: m3.id, type: "credentials", provider: u2.id }, T3 = await handleAuthorized({ user: m3, account: x3, credentials: e3 }, t2); | |
if (T3) | |
return { ...T3, cookies: D2 }; | |
const I3 = { name: m3.name, email: m3.email, picture: m3.image, sub: m3.id?.toString() }, N3 = await P2.jwt({ token: I3, user: m3, account: x3, isNewUser: false, trigger: "signIn" }); | |
if (null === N3) | |
D2.push(...c2.clean()); | |
else { | |
const e4 = await C2.encode({ ...C2, token: N3 }), t3 = new Date(); | |
t3.setTime(t3.getTime() + 1e3 * _2); | |
const r3 = c2.chunk(e4, { expires: t3 }); | |
D2.push(...r3); | |
} | |
return await A2.signIn?.({ user: m3, account: x3 }), { redirect: b2, cookies: D2 }; | |
} | |
return { status: 500, body: `Error: Callback for provider type ${u2.type} not supported`, cookies: D2 }; | |
} catch (e3) { | |
if (e3 instanceof OAuthCallbackError) | |
return I2.error(e3), g2.searchParams.set("error", OAuthCallbackError.name), g2.pathname += "/signin", { redirect: g2.toString(), cookies: D2 }; | |
const t3 = new CallbackRouteError(e3, { provider: u2.id }); | |
return I2.debug("callback route error details", { method: i2, query: r2, body: n2 }), I2.error(t3), g2.searchParams.set("error", CallbackRouteError.name), g2.pathname += "/error", { redirect: g2.toString(), cookies: D2 }; | |
} | |
} | |
async function session(e2) { | |
const { options: t2, sessionStore: r2, newSession: n2, isUpdate: i2 } = e2, { adapter: a2, jwt: c2, events: u2, callbacks: m2, logger: g2, session: { strategy: b2, maxAge: x2 } } = t2, C2 = { body: null, headers: { "Content-Type": "application/json" }, cookies: [] }, A2 = r2.value; | |
if (!A2) | |
return C2; | |
if ("jwt" === b2) { | |
try { | |
const e3 = await c2.decode({ ...c2, token: A2 }); | |
if (!e3) | |
throw new Error("Invalid JWT"); | |
const t3 = await m2.jwt({ token: e3, ...i2 && { trigger: "update" }, session: n2 }), a3 = fromDate(x2); | |
if (null !== t3) { | |
const e4 = { user: { name: t3.name, email: t3.email, image: t3.picture }, expires: a3.toISOString() }, n3 = await m2.session({ session: e4, token: t3 }); | |
C2.body = n3; | |
const i3 = await c2.encode({ ...c2, token: t3 }), g3 = r2.chunk(i3, { expires: a3 }); | |
C2.cookies?.push(...g3), await u2.session?.({ session: n3, token: t3 }); | |
} else | |
C2.cookies?.push(...r2.clean()); | |
} catch (e3) { | |
g2.error(new JWTSessionError(e3)), C2.cookies?.push(...r2.clean()); | |
} | |
return C2; | |
} | |
try { | |
const { getSessionAndUser: e3, deleteSession: c3, updateSession: g3 } = a2; | |
let b3 = await e3(A2); | |
if (b3 && b3.session.expires.valueOf() < Date.now() && (await c3(A2), b3 = null), b3) { | |
const { user: e4, session: r3 } = b3, a3 = t2.session.updateAge, c4 = r3.expires.valueOf() - 1e3 * x2 + 1e3 * a3, P2 = fromDate(x2); | |
c4 <= Date.now() && await g3({ sessionToken: A2, expires: P2 }); | |
const T2 = await m2.session({ session: { user: { name: e4.name, email: e4.email, image: e4.image }, expires: r3.expires.toISOString() }, user: e4, newSession: n2, ...i2 ? { trigger: "update" } : {} }); | |
C2.body = T2, C2.cookies?.push({ name: t2.cookies.sessionToken.name, value: A2, options: { ...t2.cookies.sessionToken.options, expires: P2 } }), await u2.session?.({ session: T2 }); | |
} else | |
A2 && C2.cookies?.push(...r2.clean()); | |
} catch (e3) { | |
g2.error(new SessionTokenError(e3)); | |
} | |
return C2; | |
} | |
async function signin(e2, t2) { | |
const { query: r2, body: n2 } = e2, { url: i2, logger: a2, provider: c2 } = t2; | |
try { | |
if ("oauth" === c2.type || "oidc" === c2.type) | |
return await async function(e3, t3) { | |
const { logger: r3, provider: n3 } = t3; | |
let i3 = n3.authorization?.url; | |
if (!i3 || "authjs.dev" === i3.host) { | |
const e4 = new URL(n3.issuer), t4 = await discoveryRequest(e4), r4 = await processDiscoveryResponse(e4, t4); | |
if (!r4.authorization_endpoint) | |
throw new TypeError("Authorization server did not provide an authorization endpoint."); | |
i3 = new URL(r4.authorization_endpoint); | |
} | |
const a3 = i3.searchParams; | |
let c3, u2 = n3.callbackUrl; | |
!t3.isOnRedirectProxy && n3.redirectProxyUrl && (u2 = n3.redirectProxyUrl, c3 = { origin: n3.callbackUrl }, r3.debug("using redirect proxy", { redirect_uri: u2, data: c3 })); | |
const m2 = Object.assign({ response_type: "code", client_id: n3.clientId, redirect_uri: u2, ...n3.authorization?.params }, Object.fromEntries(n3.authorization?.url.searchParams ?? []), e3); | |
for (const e4 in m2) | |
a3.set(e4, m2[e4]); | |
const g2 = [], b2 = await Ci.create(t3, c3); | |
if (b2 && (a3.set("state", b2.value), g2.push(b2.cookie)), n3.checks?.includes("pkce")) { | |
const { value: e4, cookie: r4 } = await wi.create(t3); | |
a3.set("code_challenge", e4), a3.set("code_challenge_method", "S256"), g2.push(r4); | |
} | |
const x2 = await Ei.create(t3); | |
return x2 && (a3.set("nonce", x2.value), g2.push(x2.cookie)), "oidc" !== n3.type || i3.searchParams.has("scope") || i3.searchParams.set("scope", "openid profile email"), r3.debug("authorization url is ready", { url: i3, cookies: g2, provider: n3 }), { redirect: i3.toString(), cookies: g2 }; | |
}(r2, t2); | |
if ("email" === c2.type) { | |
const r3 = (c2.normalizeIdentifier ?? defaultNormalizer)(n2?.email), i3 = await t2.adapter.getUserByEmail(r3) ?? { id: r3, email: r3, emailVerified: null }, a3 = { providerAccountId: r3, userId: i3.id, type: "email", provider: c2.id }, u2 = await handleAuthorized({ user: i3, account: a3, email: { verificationRequest: true } }, t2); | |
if (u2) | |
return u2; | |
const m2 = await async function(e3, t3, r4) { | |
const { url: n3, adapter: i4, provider: a4, callbackUrl: c3, theme: u3 } = t3, m3 = await a4.generateVerificationToken?.() ?? randomString(32), g2 = new Date(Date.now() + 1e3 * (a4.maxAge ?? 86400)), b2 = new URLSearchParams({ callbackUrl: c3, token: m3, email: e3 }), x2 = `${n3}/callback/${a4.id}?${b2}`, C2 = a4.secret ?? t3.secret; | |
return await Promise.all([a4.sendVerificationRequest({ identifier: e3, token: m3, expires: g2, url: x2, provider: a4, theme: u3, request: toRequest(r4) }), i4.createVerificationToken?.({ identifier: e3, token: await createHash(`${m3}${C2}`), expires: g2 })]), `${n3}/verify-request?${new URLSearchParams({ provider: a4.id, type: a4.type })}`; | |
}(r3, t2, e2); | |
return { redirect: m2 }; | |
} | |
return { redirect: `${i2}/signin` }; | |
} catch (e3) { | |
const t3 = new SignInError(e3, { provider: c2.id }); | |
a2.error(t3); | |
const r3 = "email" === c2.type ? "EmailSignin" : "OAuthSignin"; | |
return i2.searchParams.set("error", r3), i2.pathname += "/signin", { redirect: i2.toString() }; | |
} | |
} | |
function defaultNormalizer(e2) { | |
if (!e2) | |
throw new Error("Missing email from request body."); | |
let [t2, r2] = e2.toLowerCase().trim().split("@"); | |
return r2 = r2.split(",")[0], `${t2}@${r2}`; | |
} | |
async function AuthInternal(e2, t2) { | |
const { action: r2, providerId: n2, error: i2, method: a2 } = e2, c2 = t2.skipCSRFCheck === Si, { options: u2, cookies: m2 } = await init({ authOptions: t2, action: r2, providerId: n2, url: e2.url, callbackUrl: e2.body?.callbackUrl ?? e2.query?.callbackUrl, csrfToken: e2.body?.csrfToken, cookies: e2.cookies, isPost: "POST" === a2, csrfDisabled: c2 }), g2 = new SessionStore(u2.cookies.sessionToken, e2, u2.logger); | |
if ("GET" === a2) { | |
const t3 = renderPage({ ...u2, query: e2.query, cookies: m2 }), { pages: n3 } = u2; | |
switch (r2) { | |
case "providers": | |
return await function(e3) { | |
return { headers: { "Content-Type": "application/json" }, body: e3.reduce((e4, { id: t4, name: r3, type: n4, signinUrl: i3, callbackUrl: a3 }) => (e4[t4] = { id: t4, name: r3, type: n4, signinUrl: i3, callbackUrl: a3 }, e4), {}) }; | |
}(u2.providers); | |
case "session": { | |
const e3 = await session({ sessionStore: g2, options: u2 }); | |
return e3.cookies && m2.push(...e3.cookies), { ...e3, cookies: m2 }; | |
} | |
case "csrf": | |
return c2 ? (u2.logger.warn("csrf-disabled"), m2.push({ name: u2.cookies.csrfToken.name, value: "", options: { ...u2.cookies.csrfToken.options, maxAge: 0 } }), { status: 404, cookies: m2 }) : { headers: { "Content-Type": "application/json" }, body: { csrfToken: u2.csrfToken }, cookies: m2 }; | |
case "signin": | |
if (n3.signIn) { | |
let e3 = `${n3.signIn}${n3.signIn.includes("?") ? "&" : "?"}${new URLSearchParams({ callbackUrl: u2.callbackUrl })}`; | |
return i2 && (e3 = `${e3}&${new URLSearchParams({ error: i2 })}`), { redirect: e3, cookies: m2 }; | |
} | |
return t3.signin(); | |
case "signout": | |
return n3.signOut ? { redirect: n3.signOut, cookies: m2 } : t3.signout(); | |
case "callback": | |
if (u2.provider) { | |
const t4 = await callback({ body: e2.body, query: e2.query, headers: e2.headers, cookies: e2.cookies, method: a2, options: u2, sessionStore: g2 }); | |
return t4.cookies && m2.push(...t4.cookies), { ...t4, cookies: m2 }; | |
} | |
break; | |
case "verify-request": | |
return n3.verifyRequest ? { redirect: n3.verifyRequest, cookies: m2 } : t3.verifyRequest(); | |
case "error": | |
return ["Signin", "OAuthCreateAccount", "EmailCreateAccount", "Callback", "OAuthAccountNotLinked", "SessionRequired"].includes(i2) ? { redirect: `${u2.url}/signin?error=${i2}`, cookies: m2 } : n3.error ? { redirect: `${n3.error}${n3.error.includes("?") ? "&" : "?"}error=${i2}`, cookies: m2 } : t3.error({ error: i2 }); | |
} | |
} else | |
switch (r2) { | |
case "signin": | |
if ((c2 || u2.csrfTokenVerified) && u2.provider) { | |
const t3 = await signin(e2, u2); | |
return t3.cookies && m2.push(...t3.cookies), { ...t3, cookies: m2 }; | |
} | |
return { redirect: `${u2.url}/signin?csrf=true`, cookies: m2 }; | |
case "signout": | |
if (c2 || u2.csrfTokenVerified) { | |
const e3 = await async function(e4, t3) { | |
const { jwt: r3, events: n3, callbackUrl: i3, logger: a3, session: c3 } = t3, u3 = e4.value; | |
if (!u3) | |
return { redirect: i3 }; | |
try { | |
if ("jwt" === c3.strategy) { | |
const e5 = await r3.decode({ ...r3, token: u3 }); | |
await n3.signOut?.({ token: e5 }); | |
} else { | |
const e5 = await t3.adapter?.deleteSession(u3); | |
await n3.signOut?.({ session: e5 }); | |
} | |
} catch (e5) { | |
a3.error(new SignOutError(e5)); | |
} | |
return { redirect: i3, cookies: e4.clean() }; | |
}(g2, u2); | |
return e3.cookies && m2.push(...e3.cookies), { ...e3, cookies: m2 }; | |
} | |
return { redirect: `${u2.url}/signout?csrf=true`, cookies: m2 }; | |
case "callback": | |
if (u2.provider) { | |
if ("credentials" === u2.provider.type && !c2 && !u2.csrfTokenVerified) | |
return { redirect: `${u2.url}/signin?csrf=true`, cookies: m2 }; | |
const t3 = await callback({ body: e2.body, query: e2.query, headers: e2.headers, cookies: e2.cookies, method: a2, options: u2, sessionStore: g2 }); | |
return t3.cookies && m2.push(...t3.cookies), { ...t3, cookies: m2 }; | |
} | |
break; | |
case "session": | |
if (u2.csrfTokenVerified) { | |
const t3 = await session({ options: u2, sessionStore: g2, newSession: e2.body?.data, isUpdate: true }); | |
return t3.cookies && m2.push(...t3.cookies), { ...t3, cookies: m2 }; | |
} | |
return { status: 400, cookies: m2 }; | |
} | |
throw new UnknownAction(`Cannot handle action: ${r2}`); | |
} | |
const Si = Symbol("skip-csrf-check"); | |
async function Auth(e2, t2) { | |
!function(e3 = {}, t3) { | |
t3 || (js.debug = () => { | |
}), e3.error && (js.error = e3.error), e3.warn && (js.warn = e3.warn), e3.debug && (js.debug = e3.debug); | |
}(t2.logger, t2.debug); | |
const r2 = await async function(e3) { | |
try { | |
const t3 = new URL(e3.url.replace(/\/$/, "")); | |
t3.searchParams.delete("nextauth"); | |
const { pathname: r3 } = t3, n3 = Rs.find((e4) => r3.includes(e4)); | |
if (!n3) | |
throw new UnknownAction(`Cannot detect action in pathname (${r3}).`); | |
if ("GET" !== e3.method && "POST" !== e3.method) | |
throw new UnknownAction("Only GET and POST requests are supported."); | |
const i3 = r3.split("/").pop(); | |
let a3; | |
return i3 && !n3.includes(i3) && ["signin", "callback"].includes(n3) && (a3 = i3), { url: t3, action: n3, providerId: a3, method: e3.method, headers: Object.fromEntries(e3.headers), body: e3.body ? await getBody(e3) : void 0, cookies: parse_1(e3.headers.get("cookie") ?? "") ?? {}, error: t3.searchParams.get("error") ?? void 0, query: Object.fromEntries(t3.searchParams) }; | |
} catch (e4) { | |
return e4; | |
} | |
}(e2); | |
if (r2 instanceof Error) | |
return js.error(r2), new Response(`Error: This action with HTTP ${e2.method} is not supported.`, { status: 400 }); | |
const n2 = function(e3, t3) { | |
const { url: r3 } = e3, n3 = []; | |
if (!dn && t3.debug && n3.push("debug-enabled"), !t3.trustHost) | |
return new UntrustedHost(`Host must be trusted. URL was: ${e3.url}`); | |
if (!t3.secret) | |
return new MissingSecret("Please define a `secret`."); | |
const i3 = e3.query?.callbackUrl; | |
if (i3 && !isValidHttpUrl(i3, r3.origin)) | |
return new InvalidCallbackUrl(`Invalid callback URL. Received: ${i3}`); | |
const { callbackUrl: a3 } = defaultCookies(t3.useSecureCookies ?? "https:" === r3.protocol), c3 = e3.cookies?.[t3.cookies?.callbackUrl?.name ?? a3.name]; | |
if (c3 && !isValidHttpUrl(c3, r3.origin)) | |
return new InvalidCallbackUrl(`Invalid callback URL. Received: ${c3}`); | |
for (const e4 of t3.providers) { | |
const t4 = "function" == typeof e4 ? e4() : e4; | |
if (("oauth" === t4.type || "oidc" === t4.type) && !(t4.issuer ?? t4.options?.issuer)) { | |
const { authorization: e5, token: r4, userinfo: n4 } = t4; | |
let i4; | |
if ("string" == typeof e5 || e5?.url ? "string" == typeof r4 || r4?.url ? "string" == typeof n4 || n4?.url || (i4 = "userinfo") : i4 = "token" : i4 = "authorization", i4) | |
return new InvalidEndpoints(`Provider "${t4.id}" is missing both \`issuer\` and \`${i4}\` endpoint config. At least one of them is required.`); | |
} | |
"credentials" === t4.type ? hn = true : "email" === t4.type && (mn = true); | |
} | |
if (hn) { | |
const e4 = "database" === t3.session?.strategy, r4 = !t3.providers.some((e5) => "credentials" !== ("function" == typeof e5 ? e5() : e5).type); | |
if (e4 && r4) | |
return new UnsupportedStrategy("Signin in with credentials only supported if JWT strategy is enabled"); | |
const n4 = t3.providers.some((e5) => { | |
const t4 = "function" == typeof e5 ? e5() : e5; | |
return "credentials" === t4.type && !t4.authorize; | |
}); | |
if (n4) | |
return new MissingAuthorize("Must define an authorize() handler to use credentials authentication provider"); | |
} | |
const { adapter: u2, session: m2 } = t3; | |
if (mn || "database" === m2?.strategy || !m2?.strategy && u2) { | |
let e4; | |
if (mn) { | |
if (!u2) | |
return new MissingAdapter("Email login requires an adapter."); | |
e4 = gn; | |
} else { | |
if (!u2) | |
return new MissingAdapter("Database session requires an adapter."); | |
e4 = yn; | |
} | |
const t4 = e4.filter((e5) => !u2[e5]); | |
if (t4.length) | |
return new MissingAdapterMethods(`Required adapter methods were missing: ${t4.join(", ")}`); | |
} | |
return dn || (dn = true), n3; | |
}(r2, t2); | |
if (Array.isArray(n2)) | |
n2.forEach(js.warn); | |
else if (n2 instanceof Error) { | |
js.error(n2); | |
if (!["signin", "signout", "error", "verify-request"].includes(r2.action) || "GET" !== r2.method) | |
return new Response(JSON.stringify({ message: "There was a problem with the server configuration. Check the server logs for more information.", code: n2.name }), { status: 500, headers: { "Content-Type": "application/json" } }); | |
const { pages: e3, theme: i3 } = t2, a3 = e3?.error && r2.url.searchParams.get("callbackUrl")?.startsWith(e3.error); | |
if (!e3?.error || a3) { | |
a3 && js.error(new ErrorPageLoop(`The error page ${e3?.error} should not require authentication`)); | |
return toResponse(renderPage({ theme: i3 }).error({ error: "Configuration" })); | |
} | |
return Response.redirect(`${e3.error}?error=Configuration`); | |
} | |
const i2 = await AuthInternal(r2, t2), a2 = await toResponse(i2), c2 = a2.headers.get("Location"); | |
return e2.headers.has("X-Auth-Return-Redirect") && c2 ? (a2.headers.delete("Location"), a2.headers.set("Content-Type", "application/json"), new Response(JSON.stringify({ url: c2 }), { headers: a2.headers })) : a2; | |
} | |
globalThis.crypto || (console.log("Polyfilling crypto..."), Promise.resolve().then(function() { | |
return Ot; | |
}).then((e2) => { | |
Object.defineProperty(globalThis, "crypto", { value: e2, writable: false, configurable: true }); | |
})); | |
const Ai = useRuntimeConfig$1(), ki = { secret: Ai.authJs.secret, providers: [function(e2) { | |
return { id: "github", name: "GitHub", type: "oauth", authorization: { url: "https://github.com/login/oauth/authorize", params: { scope: "read:user user:email" } }, token: "https://github.com/login/oauth/access_token", userinfo: { url: "https://api.github.com/user", async request({ tokens: e3, provider: t2 }) { | |
const r2 = await fetch(t2.userinfo?.url, { headers: { Authorization: `Bearer ${e3.access_token}`, "User-Agent": "authjs" } }).then(async (e4) => await e4.json()); | |
if (!r2.email) { | |
const t3 = await fetch("https://api.github.com/user/emails", { headers: { Authorization: `Bearer ${e3.access_token}`, "User-Agent": "authjs" } }); | |
if (t3.ok) { | |
const e4 = await t3.json(); | |
r2.email = (e4.find((e5) => e5.primary) ?? e4[0]).email; | |
} | |
} | |
return r2; | |
} }, profile: (e3) => ({ id: e3.id.toString(), name: e3.name ?? e3.login, email: e3.email, image: e3.avatar_url }), style: { logo: "/github.svg", logoDark: "/github-dark.svg", bg: "#fff", bgDark: "#24292f", text: "#000", textDark: "#fff" }, options: e2 }; | |
}({ clientId: Ai.github.clientId, clientSecret: Ai.github.clientSecret })] }, Pi = function(e2, t2) { | |
return Yt(async (r2) => { | |
e2.trustHost ??= true, e2.skipCSRFCheck = Si; | |
const n2 = await async function(e3) { | |
const t3 = new URL(getRequestURL(e3)), r3 = function(e4, t4 = "GET") { | |
return (e4.node.req.method || t4).toUpperCase(); | |
}(e3), n3 = "POST" === r3 ? await readRawBody(e3) : void 0; | |
return new Request(t3, { headers: getRequestHeaders(e3), method: r3, body: n3 }); | |
}(r2); | |
if (n2.url.includes(".js.map")) | |
return; | |
!function(e3, t3) { | |
if ("POST" !== e3.method) | |
return; | |
const r3 = e3.headers.get("Origin"), n3 = t3.public?.authJs?.baseUrl; | |
if (n3 !== r3) | |
throw new Error("CSRF protected"); | |
}(n2, t2); | |
return await Auth(n2, e2); | |
}); | |
}(ki, Ai), Ti = Object.freeze(Object.defineProperty({ __proto__: null, authOptions: ki, default: Pi }, Symbol.toStringTag, { value: "Module" })), defaultShouldPrefetch = (e2) => "font" !== e2.resourceType, defaultShouldPreload = (e2) => ["module", "script", "style"].includes(e2.resourceType || ""); | |
function getModuleDependencies(e2, t2) { | |
if (t2._dependencies[e2]) | |
return t2._dependencies[e2]; | |
const r2 = t2._dependencies[e2] = { scripts: {}, styles: {}, preload: {}, prefetch: {} }, n2 = t2.manifest[e2]; | |
if (!n2) | |
return r2; | |
n2.file && (r2.preload[e2] = n2, (n2.isEntry || n2.sideEffects) && (r2.scripts[e2] = n2)); | |
for (const e3 of n2.css || []) | |
r2.styles[e3] = r2.preload[e3] = r2.prefetch[e3] = t2.manifest[e3]; | |
for (const e3 of n2.assets || []) | |
r2.preload[e3] = r2.prefetch[e3] = t2.manifest[e3]; | |
for (const e3 of n2.imports || []) { | |
const n3 = getModuleDependencies(e3, t2); | |
Object.assign(r2.styles, n3.styles), Object.assign(r2.preload, n3.preload), Object.assign(r2.prefetch, n3.prefetch); | |
} | |
const i2 = {}; | |
for (const e3 in r2.preload) { | |
const n3 = r2.preload[e3]; | |
t2.shouldPreload(n3) && (i2[e3] = n3); | |
} | |
return r2.preload = i2, r2; | |
} | |
function getRequestDependencies(e2, t2) { | |
if (e2._requestDependencies) | |
return e2._requestDependencies; | |
const r2 = function(e3, t3) { | |
const r3 = Array.from(e3).sort().join(","); | |
if (t3._dependencySets[r3]) | |
return t3._dependencySets[r3]; | |
const n2 = { scripts: {}, styles: {}, preload: {}, prefetch: {} }; | |
for (const r4 of e3) { | |
const e4 = getModuleDependencies(r4, t3); | |
Object.assign(n2.scripts, e4.scripts), Object.assign(n2.styles, e4.styles), Object.assign(n2.preload, e4.preload), Object.assign(n2.prefetch, e4.prefetch); | |
for (const e5 of t3.manifest[r4]?.dynamicImports || []) { | |
const r5 = getModuleDependencies(e5, t3); | |
Object.assign(n2.prefetch, r5.scripts), Object.assign(n2.prefetch, r5.styles), Object.assign(n2.prefetch, r5.preload); | |
} | |
} | |
const i2 = {}; | |
for (const e4 in n2.prefetch) { | |
const r4 = n2.prefetch[e4]; | |
t3.shouldPrefetch(r4) && (i2[e4] = r4); | |
} | |
n2.prefetch = i2; | |
for (const e4 in n2.prefetch) | |
e4 in n2.preload && delete n2.prefetch[e4]; | |
return t3._dependencySets[r3] = n2, n2; | |
}(new Set(Array.from([...t2._entrypoints, ...e2.modules || e2._registeredComponents || []])), t2); | |
return e2._requestDependencies = r2, r2; | |
} | |
function renderStyles(e2, t2) { | |
const { styles: r2 } = getRequestDependencies(e2, t2); | |
return Object.values(r2).map((e3) => renderLinkToString({ rel: "stylesheet", href: t2.buildAssetsURL(e3.file) })).join(""); | |
} | |
function getResources(e2, t2) { | |
return [...getPreloadLinks(e2, t2), ...getPrefetchLinks(e2, t2)]; | |
} | |
function renderResourceHints(e2, t2) { | |
return getResources(e2, t2).map(renderLinkToString).join(""); | |
} | |
function renderResourceHeaders(e2, t2) { | |
return { link: getResources(e2, t2).map(renderLinkToHeader).join(", ") }; | |
} | |
function getPreloadLinks(e2, t2) { | |
const { preload: r2 } = getRequestDependencies(e2, t2); | |
return Object.values(r2).map((e3) => ({ rel: e3.module ? "modulepreload" : "preload", as: e3.resourceType, type: e3.mimeType ?? null, crossorigin: "font" === e3.resourceType || e3.module ? "" : null, href: t2.buildAssetsURL(e3.file) })); | |
} | |
function getPrefetchLinks(e2, t2) { | |
const { prefetch: r2 } = getRequestDependencies(e2, t2); | |
return Object.values(r2).map((e3) => ({ rel: "prefetch", as: e3.resourceType, type: e3.mimeType ?? null, crossorigin: "font" === e3.resourceType || e3.module ? "" : null, href: t2.buildAssetsURL(e3.file) })); | |
} | |
function renderScripts(e2, t2) { | |
const { scripts: r2 } = getRequestDependencies(e2, t2); | |
return Object.values(r2).map((e3) => { | |
return r3 = { type: e3.module ? "module" : null, src: t2.buildAssetsURL(e3.file), defer: e3.module ? null : "", crossorigin: "" }, `<script${Object.entries(r3).map(([e4, t3]) => null === t3 ? "" : t3 ? ` ${e4}="${t3}"` : " " + e4).join("")}></script>`; | |
var r3; | |
}).join(""); | |
} | |
function createRenderer(e2, t2) { | |
const r2 = function({ manifest: e3, buildAssetsURL: t3, shouldPrefetch: r3, shouldPreload: n2 }) { | |
const i2 = { shouldPrefetch: r3 || defaultShouldPrefetch, shouldPreload: n2 || defaultShouldPreload, buildAssetsURL: t3 || withLeadingSlash, manifest: void 0, updateManifest, _dependencies: void 0, _dependencySets: void 0, _entrypoints: void 0 }; | |
function updateManifest(e4) { | |
const t4 = Object.entries(e4); | |
i2.manifest = e4, i2._dependencies = {}, i2._dependencySets = {}, i2._entrypoints = t4.filter((e5) => e5[1].isEntry).map(([e5]) => e5); | |
} | |
return updateManifest(e3), i2; | |
}(t2); | |
return { rendererContext: r2, async renderToString(n2) { | |
n2._registeredComponents = n2._registeredComponents || /* @__PURE__ */ new Set(); | |
const i2 = await Promise.resolve(e2).then((e3) => e3.default || e3), a2 = await i2(n2), wrap = (e3) => () => e3(n2, r2); | |
return { html: await t2.renderToString(a2, n2), renderResourceHeaders: wrap(renderResourceHeaders), renderResourceHints: wrap(renderResourceHints), renderStyles: wrap(renderStyles), renderScripts: wrap(renderScripts) }; | |
} }; | |
} | |
function renderLinkToString(e2) { | |
return `<link${Object.entries(e2).map(([e3, t2]) => null === t2 ? "" : t2 ? ` ${e3}="${t2}"` : " " + e3).join("")}>`; | |
} | |
function renderLinkToHeader(e2) { | |
return `<${e2.href}>${Object.entries(e2).map(([e3, t2]) => "href" === e3 || null === t2 ? "" : t2 ? `; ${e3}="${t2}"` : `; ${e3}`).join("")}`; | |
} | |
const _i = { "<": "\\u003C", "\\": "\\\\", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", " ": "\\t", "\u2028": "\\u2028", "\u2029": "\\u2029" }; | |
class DevalueError extends Error { | |
constructor(e2, t2) { | |
super(e2), this.name = "DevalueError", this.path = t2.join(""); | |
} | |
} | |
function is_primitive(e2) { | |
return Object(e2) !== e2; | |
} | |
const Ii = Object.getOwnPropertyNames(Object.prototype).sort().join("\0"); | |
function is_plain_object(e2) { | |
const t2 = Object.getPrototypeOf(e2); | |
return t2 === Object.prototype || null === t2 || Object.getOwnPropertyNames(t2).sort().join("\0") === Ii; | |
} | |
function get_type(e2) { | |
return Object.prototype.toString.call(e2).slice(8, -1); | |
} | |
function get_escaped_char(e2) { | |
switch (e2) { | |
case '"': | |
return '\\"'; | |
case "<": | |
return "\\u003C"; | |
case "\\": | |
return "\\\\"; | |
case "\n": | |
return "\\n"; | |
case "\r": | |
return "\\r"; | |
case " ": | |
return "\\t"; | |
case "\b": | |
return "\\b"; | |
case "\f": | |
return "\\f"; | |
case "\u2028": | |
return "\\u2028"; | |
case "\u2029": | |
return "\\u2029"; | |
default: | |
return e2 < " " ? `\\u${e2.charCodeAt(0).toString(16).padStart(4, "0")}` : ""; | |
} | |
} | |
function stringify_string(e2) { | |
let t2 = "", r2 = 0; | |
const n2 = e2.length; | |
for (let i2 = 0; i2 < n2; i2 += 1) { | |
const n3 = get_escaped_char(e2[i2]); | |
n3 && (t2 += e2.slice(r2, i2) + n3, r2 = i2 + 1); | |
} | |
return `"${0 === r2 ? e2 : t2 + e2.slice(r2)}"`; | |
} | |
const Di = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$", Ni = /[<\b\f\n\r\t\0\u2028\u2029]/g, Oi = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/; | |
function uneval(e2, t2) { | |
const r2 = /* @__PURE__ */ new Map(), n2 = [], i2 = /* @__PURE__ */ new Map(); | |
!function walk2(e3) { | |
if ("function" == typeof e3) | |
throw new DevalueError("Cannot stringify a function", n2); | |
if (!is_primitive(e3)) { | |
if (r2.has(e3)) | |
return void r2.set(e3, r2.get(e3) + 1); | |
if (r2.set(e3, 1), t2) { | |
const r3 = t2(e3); | |
if ("string" == typeof r3) | |
return void i2.set(e3, r3); | |
} | |
switch (get_type(e3)) { | |
case "Number": | |
case "BigInt": | |
case "String": | |
case "Boolean": | |
case "Date": | |
case "RegExp": | |
return; | |
case "Array": | |
e3.forEach((e4, t3) => { | |
n2.push(`[${t3}]`), walk2(e4), n2.pop(); | |
}); | |
break; | |
case "Set": | |
Array.from(e3).forEach(walk2); | |
break; | |
case "Map": | |
for (const [t3, r3] of e3) | |
n2.push(`.get(${is_primitive(t3) ? stringify_primitive$1(t3) : "..."})`), walk2(r3), n2.pop(); | |
break; | |
default: | |
if (!is_plain_object(e3)) | |
throw new DevalueError("Cannot stringify arbitrary non-POJOs", n2); | |
if (Object.getOwnPropertySymbols(e3).length > 0) | |
throw new DevalueError("Cannot stringify POJOs with symbolic keys", n2); | |
for (const t3 in e3) | |
n2.push(`.${t3}`), walk2(e3[t3]), n2.pop(); | |
} | |
} | |
}(e2); | |
const a2 = /* @__PURE__ */ new Map(); | |
function stringify2(e3) { | |
if (a2.has(e3)) | |
return a2.get(e3); | |
if (is_primitive(e3)) | |
return stringify_primitive$1(e3); | |
if (i2.has(e3)) | |
return i2.get(e3); | |
const t3 = get_type(e3); | |
switch (t3) { | |
case "Number": | |
case "String": | |
case "Boolean": | |
return `Object(${stringify2(e3.valueOf())})`; | |
case "RegExp": | |
return `new RegExp(${stringify_string(e3.source)}, "${e3.flags}")`; | |
case "Date": | |
return `new Date(${e3.getTime()})`; | |
case "Array": | |
const r3 = e3.map((t4, r4) => r4 in e3 ? stringify2(t4) : ""), n3 = 0 === e3.length || e3.length - 1 in e3 ? "" : ","; | |
return `[${r3.join(",")}${n3}]`; | |
case "Set": | |
case "Map": | |
return `new ${t3}([${Array.from(e3).map(stringify2).join(",")}])`; | |
default: | |
const i3 = `{${Object.keys(e3).map((t4) => `${function(e4) { | |
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(e4) ? e4 : escape_unsafe_chars(JSON.stringify(e4)); | |
}(t4)}:${stringify2(e3[t4])}`).join(",")}}`; | |
return null === Object.getPrototypeOf(e3) ? Object.keys(e3).length > 0 ? `Object.assign(Object.create(null),${i3})` : "Object.create(null)" : i3; | |
} | |
} | |
Array.from(r2).filter((e3) => e3[1] > 1).sort((e3, t3) => t3[1] - e3[1]).forEach((e3, t3) => { | |
a2.set(e3[0], function(e4) { | |
let t4 = ""; | |
do { | |
t4 = Di[e4 % Di.length] + t4, e4 = ~~(e4 / Di.length) - 1; | |
} while (e4 >= 0); | |
return Oi.test(t4) ? `${t4}0` : t4; | |
}(t3)); | |
}); | |
const c2 = stringify2(e2); | |
if (a2.size) { | |
const e3 = [], t3 = [], r3 = []; | |
return a2.forEach((n3, a3) => { | |
if (e3.push(n3), i2.has(a3)) | |
return void r3.push(i2.get(a3)); | |
if (is_primitive(a3)) | |
return void r3.push(stringify_primitive$1(a3)); | |
switch (get_type(a3)) { | |
case "Number": | |
case "String": | |
case "Boolean": | |
r3.push(`Object(${stringify2(a3.valueOf())})`); | |
break; | |
case "RegExp": | |
r3.push(a3.toString()); | |
break; | |
case "Date": | |
r3.push(`new Date(${a3.getTime()})`); | |
break; | |
case "Array": | |
r3.push(`Array(${a3.length})`), a3.forEach((e4, r4) => { | |
t3.push(`${n3}[${r4}]=${stringify2(e4)}`); | |
}); | |
break; | |
case "Set": | |
r3.push("new Set"), t3.push(`${n3}.${Array.from(a3).map((e4) => `add(${stringify2(e4)})`).join(".")}`); | |
break; | |
case "Map": | |
r3.push("new Map"), t3.push(`${n3}.${Array.from(a3).map(([e4, t4]) => `set(${stringify2(e4)}, ${stringify2(t4)})`).join(".")}`); | |
break; | |
default: | |
r3.push(null === Object.getPrototypeOf(a3) ? "Object.create(null)" : "{}"), Object.keys(a3).forEach((e4) => { | |
t3.push(`${n3}${function(e5) { | |
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(e5) ? `.${e5}` : `[${escape_unsafe_chars(JSON.stringify(e5))}]`; | |
}(e4)}=${stringify2(a3[e4])}`); | |
}); | |
} | |
}), t3.push(`return ${c2}`), `(function(${e3.join(",")}){${t3.join(";")}}(${r3.join(",")}))`; | |
} | |
return c2; | |
} | |
function escape_unsafe_char(e2) { | |
return _i[e2] || e2; | |
} | |
function escape_unsafe_chars(e2) { | |
return e2.replace(Ni, escape_unsafe_char); | |
} | |
function stringify_primitive$1(e2) { | |
if ("string" == typeof e2) | |
return stringify_string(e2); | |
if (void 0 === e2) | |
return "void 0"; | |
if (0 === e2 && 1 / e2 < 0) | |
return "-0"; | |
const t2 = String(e2); | |
return "number" == typeof e2 ? t2.replace(/^(-)?0\./, "$1.") : "bigint" == typeof e2 ? e2 + "n" : t2; | |
} | |
const Li = -1, Ri = -2, Mi = -3, Fi = -4, Bi = -5, ji = -6; | |
function stringify(e2, t2) { | |
const r2 = [], n2 = /* @__PURE__ */ new Map(), i2 = []; | |
for (const e3 in t2) | |
i2.push({ key: e3, fn: t2[e3] }); | |
const a2 = []; | |
let c2 = 0; | |
const u2 = function flatten(e3) { | |
if ("function" == typeof e3) | |
throw new DevalueError("Cannot stringify a function", a2); | |
if (n2.has(e3)) | |
return n2.get(e3); | |
if (void 0 === e3) | |
return Li; | |
if (Number.isNaN(e3)) | |
return Mi; | |
if (e3 === 1 / 0) | |
return Fi; | |
if (e3 === -1 / 0) | |
return Bi; | |
if (0 === e3 && 1 / e3 < 0) | |
return ji; | |
const t3 = c2++; | |
n2.set(e3, t3); | |
for (const { key: n3, fn: a3 } of i2) { | |
const i3 = a3(e3); | |
if (i3) | |
return r2[t3] = `["${n3}",${flatten(i3)}]`, t3; | |
} | |
let u3 = ""; | |
if (is_primitive(e3)) | |
u3 = stringify_primitive(e3); | |
else { | |
switch (get_type(e3)) { | |
case "Number": | |
case "String": | |
case "Boolean": | |
u3 = `["Object",${stringify_primitive(e3)}]`; | |
break; | |
case "BigInt": | |
u3 = `["BigInt",${e3}]`; | |
break; | |
case "Date": | |
u3 = `["Date","${e3.toISOString()}"]`; | |
break; | |
case "RegExp": | |
const { source: t4, flags: r3 } = e3; | |
u3 = r3 ? `["RegExp",${stringify_string(t4)},"${r3}"]` : `["RegExp",${stringify_string(t4)}]`; | |
break; | |
case "Array": | |
u3 = "["; | |
for (let t5 = 0; t5 < e3.length; t5 += 1) | |
t5 > 0 && (u3 += ","), t5 in e3 ? (a2.push(`[${t5}]`), u3 += flatten(e3[t5]), a2.pop()) : u3 += Ri; | |
u3 += "]"; | |
break; | |
case "Set": | |
u3 = '["Set"'; | |
for (const t5 of e3) | |
u3 += `,${flatten(t5)}`; | |
u3 += "]"; | |
break; | |
case "Map": | |
u3 = '["Map"'; | |
for (const [t5, r4] of e3) | |
a2.push(`.get(${is_primitive(t5) ? stringify_primitive(t5) : "..."})`), u3 += `,${flatten(t5)},${flatten(r4)}`; | |
u3 += "]"; | |
break; | |
default: | |
if (!is_plain_object(e3)) | |
throw new DevalueError("Cannot stringify arbitrary non-POJOs", a2); | |
if (Object.getOwnPropertySymbols(e3).length > 0) | |
throw new DevalueError("Cannot stringify POJOs with symbolic keys", a2); | |
if (null === Object.getPrototypeOf(e3)) { | |
u3 = '["null"'; | |
for (const t5 in e3) | |
a2.push(`.${t5}`), u3 += `,${stringify_string(t5)},${flatten(e3[t5])}`, a2.pop(); | |
u3 += "]"; | |
} else { | |
u3 = "{"; | |
let t5 = false; | |
for (const r4 in e3) | |
t5 && (u3 += ","), t5 = true, a2.push(`.${r4}`), u3 += `${stringify_string(r4)}:${flatten(e3[r4])}`, a2.pop(); | |
u3 += "}"; | |
} | |
} | |
} | |
return r2[t3] = u3, t3; | |
}(e2); | |
return u2 < 0 ? `${u2}` : `[${r2.join(",")}]`; | |
} | |
function stringify_primitive(e2) { | |
const t2 = typeof e2; | |
return "string" === t2 ? stringify_string(e2) : e2 instanceof String ? stringify_string(e2.toString()) : void 0 === e2 ? Li.toString() : 0 === e2 && 1 / e2 < 0 ? ji.toString() : "bigint" === t2 ? `["BigInt","${e2}"]` : String(e2); | |
} | |
var $i = { exports: {} }, Ui = {}, Hi = { exports: {} }, Vi = {}, zi = { exports: {} }, qi = {}, Wi = { exports: {} }, Ki = {}, Ji = { exports: {} }, Gi = {}; | |
function makeMap(e2, t2) { | |
const r2 = /* @__PURE__ */ Object.create(null), n2 = e2.split(","); | |
for (let e3 = 0; e3 < n2.length; e3++) | |
r2[n2[e3]] = true; | |
return t2 ? (e3) => !!r2[e3.toLowerCase()] : (e3) => !!r2[e3]; | |
} | |
Object.defineProperty(Gi, "__esModule", { value: true }); | |
const Zi = /^on[^a-z]/, Yi = Object.assign, Xi = Object.prototype.hasOwnProperty, Qi = Array.isArray, isMap$1 = (e2) => "[object Map]" === toTypeString(e2), isSet$1 = (e2) => "[object Set]" === toTypeString(e2), isDate = (e2) => "[object Date]" === toTypeString(e2), isFunction = (e2) => "function" == typeof e2, isString = (e2) => "string" == typeof e2, isSymbol = (e2) => "symbol" == typeof e2, isObject = (e2) => null !== e2 && "object" == typeof e2, eo = Object.prototype.toString, toTypeString = (e2) => eo.call(e2), isPlainObject$1 = (e2) => "[object Object]" === toTypeString(e2), to = makeMap(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), ro = makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"), cacheStringFunction = (e2) => { | |
const t2 = /* @__PURE__ */ Object.create(null); | |
return (r2) => t2[r2] || (t2[r2] = e2(r2)); | |
}, no = /-(\w)/g, so = cacheStringFunction((e2) => e2.replace(no, (e3, t2) => t2 ? t2.toUpperCase() : "")), io = /\B([A-Z])/g, oo = cacheStringFunction((e2) => e2.replace(io, "-$1").toLowerCase()), ao = cacheStringFunction((e2) => e2.charAt(0).toUpperCase() + e2.slice(1)), co = cacheStringFunction((e2) => e2 ? `on${ao(e2)}` : ""); | |
let lo; | |
const po = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/; | |
const uo = { 1: "TEXT", 2: "CLASS", 4: "STYLE", 8: "PROPS", 16: "FULL_PROPS", 32: "HYDRATE_EVENTS", 64: "STABLE_FRAGMENT", 128: "KEYED_FRAGMENT", 256: "UNKEYED_FRAGMENT", 512: "NEED_PATCH", 1024: "DYNAMIC_SLOTS", 2048: "DEV_ROOT_FRAGMENT", [-1]: "HOISTED", [-2]: "BAIL" }, ho = { 1: "STABLE", 2: "DYNAMIC", 3: "FORWARDED" }, fo = makeMap("Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console"); | |
function normalizeStyle(e2) { | |
if (Qi(e2)) { | |
const t2 = {}; | |
for (let r2 = 0; r2 < e2.length; r2++) { | |
const n2 = e2[r2], i2 = isString(n2) ? parseStringStyle(n2) : normalizeStyle(n2); | |
if (i2) | |
for (const e3 in i2) | |
t2[e3] = i2[e3]; | |
} | |
return t2; | |
} | |
return isString(e2) || isObject(e2) ? e2 : void 0; | |
} | |
const mo = /;(?![^(]*\))/g, yo = /:([^]+)/, bo = /\/\*[^]*?\*\//g; | |
function parseStringStyle(e2) { | |
const t2 = {}; | |
return e2.replace(bo, "").split(mo).forEach((e3) => { | |
if (e3) { | |
const r2 = e3.split(yo); | |
r2.length > 1 && (t2[r2[0].trim()] = r2[1].trim()); | |
} | |
}), t2; | |
} | |
function normalizeClass(e2) { | |
let t2 = ""; | |
if (isString(e2)) | |
t2 = e2; | |
else if (Qi(e2)) | |
for (let r2 = 0; r2 < e2.length; r2++) { | |
const n2 = normalizeClass(e2[r2]); | |
n2 && (t2 += n2 + " "); | |
} | |
else if (isObject(e2)) | |
for (const r2 in e2) | |
e2[r2] && (t2 += r2 + " "); | |
return t2.trim(); | |
} | |
const vo = makeMap("html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot"), xo = makeMap("svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view"), wo = makeMap("area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr"), Co = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly", Eo = makeMap(Co), So = makeMap(Co + ",async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected"); | |
const Ao = /[>/="'\u0009\u000a\u000c\u0020]/, ko = {}; | |
const Po = makeMap("accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap"), To = makeMap("xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan"), _o = /["'&<>]/; | |
const Io = /^-?>|<!--|-->|--!>|<!-$/g; | |
function looseEqual(e2, t2) { | |
if (e2 === t2) | |
return true; | |
let r2 = isDate(e2), n2 = isDate(t2); | |
if (r2 || n2) | |
return !(!r2 || !n2) && e2.getTime() === t2.getTime(); | |
if (r2 = isSymbol(e2), n2 = isSymbol(t2), r2 || n2) | |
return e2 === t2; | |
if (r2 = Qi(e2), n2 = Qi(t2), r2 || n2) | |
return !(!r2 || !n2) && function(e3, t3) { | |
if (e3.length !== t3.length) | |
return false; | |
let r3 = true; | |
for (let n3 = 0; r3 && n3 < e3.length; n3++) | |
r3 = looseEqual(e3[n3], t3[n3]); | |
return r3; | |
}(e2, t2); | |
if (r2 = isObject(e2), n2 = isObject(t2), r2 || n2) { | |
if (!r2 || !n2) | |
return false; | |
if (Object.keys(e2).length !== Object.keys(t2).length) | |
return false; | |
for (const r3 in e2) { | |
const n3 = e2.hasOwnProperty(r3), i2 = t2.hasOwnProperty(r3); | |
if (n3 && !i2 || !n3 && i2 || !looseEqual(e2[r3], t2[r3])) | |
return false; | |
} | |
} | |
return String(e2) === String(t2); | |
} | |
const replacer = (e2, t2) => t2 && t2.__v_isRef ? replacer(e2, t2.value) : isMap$1(t2) ? { [`Map(${t2.size})`]: [...t2.entries()].reduce((e3, [t3, r2]) => (e3[`${t3} =>`] = r2, e3), {}) } : isSet$1(t2) ? { [`Set(${t2.size})`]: [...t2.values()] } : !isObject(t2) || Qi(t2) || isPlainObject$1(t2) ? t2 : String(t2); | |
Gi.EMPTY_ARR = [], Gi.EMPTY_OBJ = {}, Gi.NO = () => false, Gi.NOOP = () => { | |
}, Gi.PatchFlagNames = uo, Gi.camelize = so, Gi.capitalize = ao, Gi.def = (e2, t2, r2) => { | |
Object.defineProperty(e2, t2, { configurable: true, enumerable: false, value: r2 }); | |
}, Gi.escapeHtml = function(e2) { | |
const t2 = "" + e2, r2 = _o.exec(t2); | |
if (!r2) | |
return t2; | |
let n2, i2, a2 = "", c2 = 0; | |
for (i2 = r2.index; i2 < t2.length; i2++) { | |
switch (t2.charCodeAt(i2)) { | |
case 34: | |
n2 = """; | |
break; | |
case 38: | |
n2 = "&"; | |
break; | |
case 39: | |
n2 = "'"; | |
break; | |
case 60: | |
n2 = "<"; | |
break; | |
case 62: | |
n2 = ">"; | |
break; | |
default: | |
continue; | |
} | |
c2 !== i2 && (a2 += t2.slice(c2, i2)), c2 = i2 + 1, a2 += n2; | |
} | |
return c2 !== i2 ? a2 + t2.slice(c2, i2) : a2; | |
}, Gi.escapeHtmlComment = function(e2) { | |
return e2.replace(Io, ""); | |
}, Gi.extend = Yi, Gi.genPropsAccessExp = function(e2) { | |
return po.test(e2) ? `__props.${e2}` : `__props[${JSON.stringify(e2)}]`; | |
}, Gi.generateCodeFrame = function(e2, t2 = 0, r2 = e2.length) { | |
let n2 = e2.split(/(\r?\n)/); | |
const i2 = n2.filter((e3, t3) => t3 % 2 == 1); | |
n2 = n2.filter((e3, t3) => t3 % 2 == 0); | |
let a2 = 0; | |
const c2 = []; | |
for (let e3 = 0; e3 < n2.length; e3++) | |
if (a2 += n2[e3].length + (i2[e3] && i2[e3].length || 0), a2 >= t2) { | |
for (let u2 = e3 - 2; u2 <= e3 + 2 || r2 > a2; u2++) { | |
if (u2 < 0 || u2 >= n2.length) | |
continue; | |
const m2 = u2 + 1; | |
c2.push(`${m2}${" ".repeat(Math.max(3 - String(m2).length, 0))}| ${n2[u2]}`); | |
const g2 = n2[u2].length, b2 = i2[u2] && i2[u2].length || 0; | |
if (u2 === e3) { | |
const e4 = t2 - (a2 - (g2 + b2)), n3 = Math.max(1, r2 > a2 ? g2 - e4 : r2 - t2); | |
c2.push(" | " + " ".repeat(e4) + "^".repeat(n3)); | |
} else if (u2 > e3) { | |
if (r2 > a2) { | |
const e4 = Math.max(Math.min(r2 - a2, g2), 1); | |
c2.push(" | " + "^".repeat(e4)); | |
} | |
a2 += g2 + b2; | |
} | |
} | |
break; | |
} | |
return c2.join("\n"); | |
}, Gi.getGlobalThis = () => lo || (lo = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : void 0 !== M ? M : {}), Gi.hasChanged = (e2, t2) => !Object.is(e2, t2), Gi.hasOwn = (e2, t2) => Xi.call(e2, t2), Gi.hyphenate = oo, Gi.includeBooleanAttr = function(e2) { | |
return !!e2 || "" === e2; | |
}, Gi.invokeArrayFns = (e2, t2) => { | |
for (let r2 = 0; r2 < e2.length; r2++) | |
e2[r2](t2); | |
}, Gi.isArray = Qi, Gi.isBooleanAttr = So, Gi.isBuiltInDirective = ro, Gi.isDate = isDate, Gi.isFunction = isFunction, Gi.isGloballyWhitelisted = fo, Gi.isHTMLTag = vo, Gi.isIntegerKey = (e2) => isString(e2) && "NaN" !== e2 && "-" !== e2[0] && "" + parseInt(e2, 10) === e2, Gi.isKnownHtmlAttr = Po, Gi.isKnownSvgAttr = To, Gi.isMap = isMap$1, Gi.isModelListener = (e2) => e2.startsWith("onUpdate:"), Gi.isObject = isObject, Gi.isOn = (e2) => Zi.test(e2), Gi.isPlainObject = isPlainObject$1, Gi.isPromise = (e2) => isObject(e2) && isFunction(e2.then) && isFunction(e2.catch), Gi.isRegExp = (e2) => "[object RegExp]" === toTypeString(e2), Gi.isReservedProp = to, Gi.isSSRSafeAttrName = function(e2) { | |
if (ko.hasOwnProperty(e2)) | |
return ko[e2]; | |
const t2 = Ao.test(e2); | |
return t2 && console.error(`unsafe attribute name: ${e2}`), ko[e2] = !t2; | |
}, Gi.isSVGTag = xo, Gi.isSet = isSet$1, Gi.isSpecialBooleanAttr = Eo, Gi.isString = isString, Gi.isSymbol = isSymbol, Gi.isVoidTag = wo, Gi.looseEqual = looseEqual, Gi.looseIndexOf = function(e2, t2) { | |
return e2.findIndex((e3) => looseEqual(e3, t2)); | |
}, Gi.looseToNumber = (e2) => { | |
const t2 = parseFloat(e2); | |
return isNaN(t2) ? e2 : t2; | |
}, Gi.makeMap = makeMap, Gi.normalizeClass = normalizeClass, Gi.normalizeProps = function(e2) { | |
if (!e2) | |
return null; | |
let { class: t2, style: r2 } = e2; | |
return t2 && !isString(t2) && (e2.class = normalizeClass(t2)), r2 && (e2.style = normalizeStyle(r2)), e2; | |
}, Gi.normalizeStyle = normalizeStyle, Gi.objectToString = eo, Gi.parseStringStyle = parseStringStyle, Gi.propsToAttrMap = { acceptCharset: "accept-charset", className: "class", htmlFor: "for", httpEquiv: "http-equiv" }, Gi.remove = (e2, t2) => { | |
const r2 = e2.indexOf(t2); | |
r2 > -1 && e2.splice(r2, 1); | |
}, Gi.slotFlagsText = ho, Gi.stringifyStyle = function(e2) { | |
let t2 = ""; | |
if (!e2 || isString(e2)) | |
return t2; | |
for (const r2 in e2) { | |
const n2 = e2[r2], i2 = r2.startsWith("--") ? r2 : oo(r2); | |
(isString(n2) || "number" == typeof n2) && (t2 += `${i2}:${n2};`); | |
} | |
return t2; | |
}, Gi.toDisplayString = (e2) => isString(e2) ? e2 : null == e2 ? "" : Qi(e2) || isObject(e2) && (e2.toString === eo || !isFunction(e2.toString)) ? JSON.stringify(e2, replacer, 2) : String(e2), Gi.toHandlerKey = co, Gi.toNumber = (e2) => { | |
const t2 = isString(e2) ? Number(e2) : NaN; | |
return isNaN(t2) ? e2 : t2; | |
}, Gi.toRawType = (e2) => toTypeString(e2).slice(8, -1), Gi.toTypeString = toTypeString, Ji.exports = Gi; | |
var Do = Ji.exports, No = {}; | |
function _objectWithoutPropertiesLoose(e2, t2) { | |
if (null == e2) | |
return {}; | |
var r2, n2, i2 = {}, a2 = Object.keys(e2); | |
for (n2 = 0; n2 < a2.length; n2++) | |
r2 = a2[n2], t2.indexOf(r2) >= 0 || (i2[r2] = e2[r2]); | |
return i2; | |
} | |
Object.defineProperty(No, "__esModule", { value: true }); | |
class Position { | |
constructor(e2, t2, r2) { | |
this.line = void 0, this.column = void 0, this.index = void 0, this.line = e2, this.column = t2, this.index = r2; | |
} | |
} | |
class SourceLocation { | |
constructor(e2, t2) { | |
this.start = void 0, this.end = void 0, this.filename = void 0, this.identifierName = void 0, this.start = e2, this.end = t2; | |
} | |
} | |
function createPositionWithColumnOffset(e2, t2) { | |
const { line: r2, column: n2, index: i2 } = e2; | |
return new Position(r2, n2 + t2, i2 + t2); | |
} | |
var Oo = "BABEL_PARSER_SYNTAX_ERROR", Lo = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"; | |
const reflect = (e2, t2 = e2.length - 1) => ({ get() { | |
return e2.reduce((e3, t3) => e3[t3], this); | |
}, set(r2) { | |
e2.reduce((e3, n2, i2) => i2 === t2 ? e3[n2] = r2 : e3[n2], this); | |
} }), instantiate = (e2, t2, r2) => Object.keys(r2).map((e3) => [e3, r2[e3]]).filter(([, e3]) => !!e3).map(([e3, t3]) => [e3, "function" == typeof t3 ? { value: t3, enumerable: false } : "string" == typeof t3.reflect ? Object.assign({}, t3, reflect(t3.reflect.split("."))) : t3]).reduce((e3, [t3, r3]) => Object.defineProperty(e3, t3, Object.assign({ configurable: true }, r3)), Object.assign(new e2(), t2)); | |
var Ro = { ImportMetaOutsideModule: { message: `globalThis._importMeta_ may appear only with 'sourceType: "module"'`, code: Lo }, ImportOutsideModule: { message: `'import' and 'export' may appear only with 'sourceType: "module"'`, code: Lo } }; | |
const Mo = { ArrayPattern: "array destructuring pattern", AssignmentExpression: "assignment expression", AssignmentPattern: "assignment expression", ArrowFunctionExpression: "arrow function expression", ConditionalExpression: "conditional expression", CatchClause: "catch clause", ForOfStatement: "for-of statement", ForInStatement: "for-in statement", ForStatement: "for-loop", FormalParameters: "function parameter list", Identifier: "identifier", ImportSpecifier: "import specifier", ImportDefaultSpecifier: "import default specifier", ImportNamespaceSpecifier: "import namespace specifier", ObjectPattern: "object destructuring pattern", ParenthesizedExpression: "parenthesized expression", RestElement: "rest element", UpdateExpression: { true: "prefix operation", false: "postfix operation" }, VariableDeclarator: "variable declaration", YieldExpression: "yield expression" }, toNodeDescription = ({ type: e2, prefix: t2 }) => "UpdateExpression" === e2 ? Mo.UpdateExpression[String(t2)] : Mo[e2]; | |
var Fo = { AccessorIsGenerator: ({ kind: e2 }) => `A ${e2}ter cannot be a generator.`, ArgumentsInClass: "'arguments' is only allowed in functions and class methods.", AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.", AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.", AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.", AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.", AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.", AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.", AwaitNotInAsyncFunction: "'await' is only allowed within async functions.", BadGetterArity: "A 'get' accessor must not have any formal parameters.", BadSetterArity: "A 'set' accessor must have exactly one formal parameter.", BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.", ConstructorClassField: "Classes may not have a field named 'constructor'.", ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.", ConstructorIsAccessor: "Class constructor may not be an accessor.", ConstructorIsAsync: "Constructor can't be an async function.", ConstructorIsGenerator: "Constructor can't be a generator.", DeclarationMissingInitializer: ({ kind: e2 }) => `Missing initializer in ${e2} declaration.`, DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.", DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.", DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.", DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?", DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.", DecoratorSemicolon: "Decorators must not be followed by a semicolon.", DecoratorStaticBlock: "Decorators can't be used with a static block.", DeletePrivateField: "Deleting a private field is not allowed.", DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.", DuplicateConstructor: "Duplicate constructor in the same class.", DuplicateDefaultExport: "Only one default export allowed per module.", DuplicateExport: ({ exportName: e2 }) => `\`${e2}\` has already been exported. Exported identifiers must be unique.`, DuplicateProto: "Redefinition of __proto__ property.", DuplicateRegExpFlags: "Duplicate regular expression flag.", ElementAfterRest: "Rest element must be last element.", EscapedCharNotAnIdentifier: "Invalid Unicode escape.", ExportBindingIsString: ({ localName: e2, exportName: t2 }) => `A string literal cannot be used as an exported binding without \`from\`. | |
- Did you mean \`export { '${e2}' as '${t2}' } from 'some-module'\`?`, ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.", ForInOfLoopInitializer: ({ type: e2 }) => `'${"ForInStatement" === e2 ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`, ForInUsing: "For-in loop may not start with 'using' declaration.", ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.", ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.", GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.", IllegalBreakContinue: ({ type: e2 }) => `Unsyntactic ${"BreakStatement" === e2 ? "break" : "continue"}.`, IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.", IllegalReturn: "'return' outside of function.", ImportAttributesUseAssert: "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.", ImportBindingIsString: ({ importName: e2 }) => `A string literal cannot be used as an imported binding. | |
- Did you mean \`import { "${e2}" as foo }\`?`, ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.", ImportCallArity: ({ maxArgumentCount: e2 }) => `\`import()\` requires exactly ${1 === e2 ? "one argument" : "one or two arguments"}.`, ImportCallNotNewExpression: "Cannot use new with import(...).", ImportCallSpreadArgument: "`...` is not allowed in `import()`.", ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.", ImportReflectionHasAssertion: "`import module x` cannot have assertions.", ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.', IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.", InvalidBigIntLiteral: "Invalid BigIntLiteral.", InvalidCodePoint: "Code point out of bounds.", InvalidCoverInitializedName: "Invalid shorthand property initializer.", InvalidDecimal: "Invalid decimal.", InvalidDigit: ({ radix: e2 }) => `Expected number in radix ${e2}.`, InvalidEscapeSequence: "Bad character escape sequence.", InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.", InvalidEscapedReservedWord: ({ reservedWord: e2 }) => `Escape sequence in keyword ${e2}.`, InvalidIdentifier: ({ identifierName: e2 }) => `Invalid identifier ${e2}.`, InvalidLhs: ({ ancestor: e2 }) => `Invalid left-hand side in ${toNodeDescription(e2)}.`, InvalidLhsBinding: ({ ancestor: e2 }) => `Binding invalid left-hand side in ${toNodeDescription(e2)}.`, InvalidNumber: "Invalid number.", InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.", InvalidOrUnexpectedToken: ({ unexpected: e2 }) => `Unexpected character '${e2}'.`, InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.", InvalidPrivateFieldResolution: ({ identifierName: e2 }) => `Private name #${e2} is not defined.`, InvalidPropertyBindingPattern: "Binding member expression.", InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.", InvalidRestAssignmentPattern: "Invalid rest operator's argument.", LabelRedeclaration: ({ labelName: e2 }) => `Label '${e2}' is already declared.`, LetInLexicalBinding: "'let' is not allowed to be used as a name in 'let' or 'const' declarations.", LineTerminatorBeforeArrow: "No line break is allowed before '=>'.", MalformedRegExpFlags: "Invalid regular expression flag.", MissingClassName: "A class name is required.", MissingEqInAssignment: "Only '=' operator can be used for specifying default value.", MissingSemicolon: "Missing semicolon.", MissingPlugin: ({ missingPlugin: e2 }) => `This experimental syntax requires enabling the parser plugin: ${e2.map((e3) => JSON.stringify(e3)).join(", ")}.`, MissingOneOfPlugins: ({ missingPlugin: e2 }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${e2.map((e3) => JSON.stringify(e3)).join(", ")}.`, MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.", MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.", ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.", ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.", ModuleAttributesWithDuplicateKeys: ({ key: e2 }) => `Duplicate key "${e2}" is not allowed in module attributes.`, ModuleExportNameHasLoneSurrogate: ({ surrogateCharCode: e2 }) => `An export name cannot include a lone surrogate, found '\\u${e2.toString(16)}'.`, ModuleExportUndefined: ({ localName: e2 }) => `Export '${e2}' is not defined.`, MultipleDefaultsInSwitch: "Multiple default clauses.", NewlineAfterThrow: "Illegal newline after throw.", NoCatchOrFinally: "Missing catch or finally clause.", NumberIdentifier: "Identifier directly after number.", NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.", ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.", OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.", OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.", OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.", ParamDupe: "Argument name clash.", PatternHasAccessor: "Object pattern can't contain getter or setter.", PatternHasMethod: "Object pattern can't contain methods.", PrivateInExpectedIn: ({ identifierName: e2 }) => `Private names are only allowed in property accesses (\`obj.#${e2}\`) or in \`in\` expressions (\`#${e2} in obj\`).`, PrivateNameRedeclaration: ({ identifierName: e2 }) => `Duplicate private name #${e2}.`, RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.", RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.", RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.", RecordNoProto: "'__proto__' is not allowed in Record expressions.", RestTrailingComma: "Unexpected trailing comma after rest element.", SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.", SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.", StaticPrototype: "Classes may not have static property named prototype.", SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?", SuperPrivateField: "Private fields can't be accessed on super.", TrailingDecorator: "Decorators must be attached to a class element.", TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.", TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.", TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.", UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.", UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.', UnexpectedDigitAfterHash: "Unexpected digit after hash token.", UnexpectedImportExport: "'import' and 'export' may only appear at the top level.", UnexpectedKeyword: ({ keyword: e2 }) => `Unexpected keyword '${e2}'.`, UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.", UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.", UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.", UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.", UnexpectedPrivateField: "Unexpected private name.", UnexpectedReservedWord: ({ reservedWord: e2 }) => `Unexpected reserved word '${e2}'.`, UnexpectedSuper: "'super' is only allowed in object methods and classes.", UnexpectedToken: ({ expected: e2, unexpected: t2 }) => `Unexpected token${t2 ? ` '${t2}'.` : ""}${e2 ? `, expected "${e2}"` : ""}`, UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.", UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.", UnsupportedBind: "Binding should be performed on object property.", UnsupportedDecoratorExport: "A decorated export must export a class declaration.", UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.", UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.", UnsupportedMetaProperty: ({ target: e2, onlyValidPropertyName: t2 }) => `The only valid meta property for ${e2} is ${e2}.${t2}.`, UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.", UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.", UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).", UnterminatedComment: "Unterminated comment.", UnterminatedRegExp: "Unterminated regular expression.", UnterminatedString: "Unterminated string constant.", UnterminatedTemplate: "Unterminated template.", UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.", VarRedeclaration: ({ identifierName: e2 }) => `Identifier '${e2}' has already been declared.`, YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.", YieldInParameter: "Yield expression is not allowed in formal parameters.", ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0." }; | |
const Bo = /* @__PURE__ */ new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]); | |
var jo = { PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.", PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.', PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.", PipeTopicUnconfiguredToken: ({ token: e2 }) => `Invalid topic token ${e2}. In order to use ${e2} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${e2}" }.`, PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.", PipeUnparenthesizedBody: ({ type: e2 }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({ type: e2 })}; please wrap it in parentheses.`, PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.', PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.", PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.", PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.", PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.", PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.' }; | |
const $o = ["toMessage"], Uo = ["message"]; | |
function toParseErrorConstructor(e2) { | |
let { toMessage: t2 } = e2, r2 = _objectWithoutPropertiesLoose(e2, $o); | |
return function constructor({ loc: e3, details: n2 }) { | |
return instantiate(SyntaxError, Object.assign({}, r2, { loc: e3 }), { clone(e4 = {}) { | |
const t3 = e4.loc || {}; | |
return constructor({ loc: new Position("line" in t3 ? t3.line : this.loc.line, "column" in t3 ? t3.column : this.loc.column, "index" in t3 ? t3.index : this.loc.index), details: Object.assign({}, this.details, e4.details) }); | |
}, details: { value: n2, enumerable: false }, message: { get() { | |
return `${t2(this.details)} (${this.loc.line}:${this.loc.column})`; | |
}, set(e4) { | |
Object.defineProperty(this, "message", { value: e4 }); | |
} }, pos: { reflect: "loc.index", enumerable: true }, missingPlugin: "missingPlugin" in n2 && { reflect: "details.missingPlugin", enumerable: true } }); | |
}; | |
} | |
function ParseErrorEnum(e2, t2) { | |
if (Array.isArray(e2)) | |
return (t3) => ParseErrorEnum(t3, e2[0]); | |
const r2 = {}; | |
for (const n2 of Object.keys(e2)) { | |
const i2 = e2[n2], a2 = "string" == typeof i2 ? { message: () => i2 } : "function" == typeof i2 ? { message: i2 } : i2, { message: c2 } = a2, u2 = _objectWithoutPropertiesLoose(a2, Uo), m2 = "string" == typeof c2 ? () => c2 : c2; | |
r2[n2] = toParseErrorConstructor(Object.assign({ code: Oo, reasonCode: n2, toMessage: m2 }, t2 ? { syntaxPlugin: t2 } : {}, u2)); | |
} | |
return r2; | |
} | |
const Ho = Object.assign({}, ParseErrorEnum(Ro), ParseErrorEnum(Fo), ParseErrorEnum({ StrictDelete: "Deleting local variable in strict mode.", StrictEvalArguments: ({ referenceName: e2 }) => `Assigning to '${e2}' in strict mode.`, StrictEvalArgumentsBinding: ({ bindingName: e2 }) => `Binding '${e2}' in strict mode.`, StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.", StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.", StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.", StrictWith: "'with' in strict mode." }), ParseErrorEnum`pipelineOperator`(jo)), { defineProperty: Vo } = Object, toUnenumerable = (e2, t2) => Vo(e2, t2, { enumerable: false, value: e2[t2] }); | |
function toESTreeLocation(e2) { | |
return e2.loc.start && toUnenumerable(e2.loc.start, "index"), e2.loc.end && toUnenumerable(e2.loc.end, "index"), e2; | |
} | |
class TokContext { | |
constructor(e2, t2) { | |
this.token = void 0, this.preserveSpace = void 0, this.token = e2, this.preserveSpace = !!t2; | |
} | |
} | |
const zo = { brace: new TokContext("{"), j_oTag: new TokContext("<tag"), j_cTag: new TokContext("</tag"), j_expr: new TokContext("<tag>...</tag>", true) }; | |
zo.template = new TokContext("`", true); | |
const qo = true, Wo = true, Ko = true, Jo = true, Go = true; | |
class ExportedTokenType { | |
constructor(e2, t2 = {}) { | |
this.label = void 0, this.keyword = void 0, this.beforeExpr = void 0, this.startsExpr = void 0, this.rightAssociative = void 0, this.isLoop = void 0, this.isAssign = void 0, this.prefix = void 0, this.postfix = void 0, this.binop = void 0, this.label = e2, this.keyword = t2.keyword, this.beforeExpr = !!t2.beforeExpr, this.startsExpr = !!t2.startsExpr, this.rightAssociative = !!t2.rightAssociative, this.isLoop = !!t2.isLoop, this.isAssign = !!t2.isAssign, this.prefix = !!t2.prefix, this.postfix = !!t2.postfix, this.binop = null != t2.binop ? t2.binop : null, this.updateContext = null; | |
} | |
} | |
const Zo = /* @__PURE__ */ new Map(); | |
function createKeyword(e2, t2 = {}) { | |
t2.keyword = e2; | |
const r2 = createToken(e2, t2); | |
return Zo.set(e2, r2), r2; | |
} | |
function createBinop(e2, t2) { | |
return createToken(e2, { beforeExpr: qo, binop: t2 }); | |
} | |
let Yo = -1; | |
const Xo = [], Qo = [], ea = [], ta = [], ra = [], na = []; | |
function createToken(e2, t2 = {}) { | |
var r2, n2, i2, a2; | |
return ++Yo, Qo.push(e2), ea.push(null != (r2 = t2.binop) ? r2 : -1), ta.push(null != (n2 = t2.beforeExpr) && n2), ra.push(null != (i2 = t2.startsExpr) && i2), na.push(null != (a2 = t2.prefix) && a2), Xo.push(new ExportedTokenType(e2, t2)), Yo; | |
} | |
function createKeywordLike(e2, t2 = {}) { | |
var r2, n2, i2, a2; | |
return ++Yo, Zo.set(e2, Yo), Qo.push(e2), ea.push(null != (r2 = t2.binop) ? r2 : -1), ta.push(null != (n2 = t2.beforeExpr) && n2), ra.push(null != (i2 = t2.startsExpr) && i2), na.push(null != (a2 = t2.prefix) && a2), Xo.push(new ExportedTokenType("name", t2)), Yo; | |
} | |
const sa = { bracketL: createToken("[", { beforeExpr: qo, startsExpr: Wo }), bracketHashL: createToken("#[", { beforeExpr: qo, startsExpr: Wo }), bracketBarL: createToken("[|", { beforeExpr: qo, startsExpr: Wo }), bracketR: createToken("]"), bracketBarR: createToken("|]"), braceL: createToken("{", { beforeExpr: qo, startsExpr: Wo }), braceBarL: createToken("{|", { beforeExpr: qo, startsExpr: Wo }), braceHashL: createToken("#{", { beforeExpr: qo, startsExpr: Wo }), braceR: createToken("}"), braceBarR: createToken("|}"), parenL: createToken("(", { beforeExpr: qo, startsExpr: Wo }), parenR: createToken(")"), comma: createToken(",", { beforeExpr: qo }), semi: createToken(";", { beforeExpr: qo }), colon: createToken(":", { beforeExpr: qo }), doubleColon: createToken("::", { beforeExpr: qo }), dot: createToken("."), question: createToken("?", { beforeExpr: qo }), questionDot: createToken("?."), arrow: createToken("=>", { beforeExpr: qo }), template: createToken("template"), ellipsis: createToken("...", { beforeExpr: qo }), backQuote: createToken("`", { startsExpr: Wo }), dollarBraceL: createToken("${", { beforeExpr: qo, startsExpr: Wo }), templateTail: createToken("...`", { startsExpr: Wo }), templateNonTail: createToken("...${", { beforeExpr: qo, startsExpr: Wo }), at: createToken("@"), hash: createToken("#", { startsExpr: Wo }), interpreterDirective: createToken("#!..."), eq: createToken("=", { beforeExpr: qo, isAssign: Jo }), assign: createToken("_=", { beforeExpr: qo, isAssign: Jo }), slashAssign: createToken("_=", { beforeExpr: qo, isAssign: Jo }), xorAssign: createToken("_=", { beforeExpr: qo, isAssign: Jo }), moduloAssign: createToken("_=", { beforeExpr: qo, isAssign: Jo }), incDec: createToken("++/--", { prefix: Go, postfix: true, startsExpr: Wo }), bang: createToken("!", { beforeExpr: qo, prefix: Go, startsExpr: Wo }), tilde: createToken("~", { beforeExpr: qo, prefix: Go, startsExpr: Wo }), doubleCaret: createToken("^^", { startsExpr: Wo }), doubleAt: createToken("@@", { startsExpr: Wo }), pipeline: createBinop("|>", 0), nullishCoalescing: createBinop("??", 1), logicalOR: createBinop("||", 1), logicalAND: createBinop("&&", 2), bitwiseOR: createBinop("|", 3), bitwiseXOR: createBinop("^", 4), bitwiseAND: createBinop("&", 5), equality: createBinop("==/!=/===/!==", 6), lt: createBinop("</>/<=/>=", 7), gt: createBinop("</>/<=/>=", 7), relational: createBinop("</>/<=/>=", 7), bitShift: createBinop("<</>>/>>>", 8), bitShiftL: createBinop("<</>>/>>>", 8), bitShiftR: createBinop("<</>>/>>>", 8), plusMin: createToken("+/-", { beforeExpr: qo, binop: 9, prefix: Go, startsExpr: Wo }), modulo: createToken("%", { binop: 10, startsExpr: Wo }), star: createToken("*", { binop: 10 }), slash: createBinop("/", 10), exponent: createToken("**", { beforeExpr: qo, binop: 11, rightAssociative: true }), _in: createKeyword("in", { beforeExpr: qo, binop: 7 }), _instanceof: createKeyword("instanceof", { beforeExpr: qo, binop: 7 }), _break: createKeyword("break"), _case: createKeyword("case", { beforeExpr: qo }), _catch: createKeyword("catch"), _continue: createKeyword("continue"), _debugger: createKeyword("debugger"), _default: createKeyword("default", { beforeExpr: qo }), _else: createKeyword("else", { beforeExpr: qo }), _finally: createKeyword("finally"), _function: createKeyword("function", { startsExpr: Wo }), _if: createKeyword("if"), _return: createKeyword("return", { beforeExpr: qo }), _switch: createKeyword("switch"), _throw: createKeyword("throw", { beforeExpr: qo, prefix: Go, startsExpr: Wo }), _try: createKeyword("try"), _var: createKeyword("var"), _const: createKeyword("const"), _with: createKeyword("with"), _new: createKeyword("new", { beforeExpr: qo, startsExpr: Wo }), _this: createKeyword("this", { startsExpr: Wo }), _super: createKeyword("super", { startsExpr: Wo }), _class: createKeyword("class", { startsExpr: Wo }), _extends: createKeyword("extends", { beforeExpr: qo }), _export: createKeyword("export"), _import: createKeyword("import", { startsExpr: Wo }), _null: createKeyword("null", { startsExpr: Wo }), _true: createKeyword("true", { startsExpr: Wo }), _false: createKeyword("false", { startsExpr: Wo }), _typeof: createKeyword("typeof", { beforeExpr: qo, prefix: Go, startsExpr: Wo }), _void: createKeyword("void", { beforeExpr: qo, prefix: Go, startsExpr: Wo }), _delete: createKeyword("delete", { beforeExpr: qo, prefix: Go, startsExpr: Wo }), _do: createKeyword("do", { isLoop: Ko, beforeExpr: qo }), _for: createKeyword("for", { isLoop: Ko }), _while: createKeyword("while", { isLoop: Ko }), _as: createKeywordLike("as", { startsExpr: Wo }), _assert: createKeywordLike("assert", { startsExpr: Wo }), _async: createKeywordLike("async", { startsExpr: Wo }), _await: createKeywordLike("await", { startsExpr: Wo }), _from: createKeywordLike("from", { startsExpr: Wo }), _get: createKeywordLike("get", { startsExpr: Wo }), _let: createKeywordLike("let", { startsExpr: Wo }), _meta: createKeywordLike("meta", { startsExpr: Wo }), _of: createKeywordLike("of", { startsExpr: Wo }), _sent: createKeywordLike("sent", { startsExpr: Wo }), _set: createKeywordLike("set", { startsExpr: Wo }), _static: createKeywordLike("static", { startsExpr: Wo }), _using: createKeywordLike("using", { startsExpr: Wo }), _yield: createKeywordLike("yield", { startsExpr: Wo }), _asserts: createKeywordLike("asserts", { startsExpr: Wo }), _checks: createKeywordLike("checks", { startsExpr: Wo }), _exports: createKeywordLike("exports", { startsExpr: Wo }), _global: createKeywordLike("global", { startsExpr: Wo }), _implements: createKeywordLike("implements", { startsExpr: Wo }), _intrinsic: createKeywordLike("intrinsic", { startsExpr: Wo }), _infer: createKeywordLike("infer", { startsExpr: Wo }), _is: createKeywordLike("is", { startsExpr: Wo }), _mixins: createKeywordLike("mixins", { startsExpr: Wo }), _proto: createKeywordLike("proto", { startsExpr: Wo }), _require: createKeywordLike("require", { startsExpr: Wo }), _satisfies: createKeywordLike("satisfies", { startsExpr: Wo }), _keyof: createKeywordLike("keyof", { startsExpr: Wo }), _readonly: createKeywordLike("readonly", { startsExpr: Wo }), _unique: createKeywordLike("unique", { startsExpr: Wo }), _abstract: createKeywordLike("abstract", { startsExpr: Wo }), _declare: createKeywordLike("declare", { startsExpr: Wo }), _enum: createKeywordLike("enum", { startsExpr: Wo }), _module: createKeywordLike("module", { startsExpr: Wo }), _namespace: createKeywordLike("namespace", { startsExpr: Wo }), _interface: createKeywordLike("interface", { startsExpr: Wo }), _type: createKeywordLike("type", { startsExpr: Wo }), _opaque: createKeywordLike("opaque", { startsExpr: Wo }), name: createToken("name", { startsExpr: Wo }), string: createToken("string", { startsExpr: Wo }), num: createToken("num", { startsExpr: Wo }), bigint: createToken("bigint", { startsExpr: Wo }), decimal: createToken("decimal", { startsExpr: Wo }), regexp: createToken("regexp", { startsExpr: Wo }), privateName: createToken("#name", { startsExpr: Wo }), eof: createToken("eof"), jsxName: createToken("jsxName"), jsxText: createToken("jsxText", { beforeExpr: true }), jsxTagStart: createToken("jsxTagStart", { startsExpr: true }), jsxTagEnd: createToken("jsxTagEnd"), placeholder: createToken("%%", { startsExpr: true }) }; | |
function tokenIsIdentifier(e2) { | |
return e2 >= 93 && e2 <= 130; | |
} | |
function tokenIsKeywordOrIdentifier(e2) { | |
return e2 >= 58 && e2 <= 130; | |
} | |
function tokenIsLiteralPropertyName(e2) { | |
return e2 >= 58 && e2 <= 134; | |
} | |
function tokenCanStartExpression(e2) { | |
return ra[e2]; | |
} | |
function tokenIsFlowInterfaceOrTypeOrOpaque(e2) { | |
return e2 >= 127 && e2 <= 129; | |
} | |
function tokenIsKeyword(e2) { | |
return e2 >= 58 && e2 <= 92; | |
} | |
function tokenLabelName(e2) { | |
return Qo[e2]; | |
} | |
function tokenOperatorPrecedence(e2) { | |
return ea[e2]; | |
} | |
function tokenIsTemplate(e2) { | |
return e2 >= 24 && e2 <= 25; | |
} | |
function getExportedToken(e2) { | |
return Xo[e2]; | |
} | |
Xo[8].updateContext = (e2) => { | |
e2.pop(); | |
}, Xo[5].updateContext = Xo[7].updateContext = Xo[23].updateContext = (e2) => { | |
e2.push(zo.brace); | |
}, Xo[22].updateContext = (e2) => { | |
e2[e2.length - 1] === zo.template ? e2.pop() : e2.push(zo.template); | |
}, Xo[140].updateContext = (e2) => { | |
e2.push(zo.j_expr, zo.j_oTag); | |
}; | |
let ia = "\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC", oa = "\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F"; | |
const aa = new RegExp("[" + ia + "]"), ca = new RegExp("[" + ia + oa + "]"); | |
ia = oa = null; | |
const la = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938, 6, 4191], pa = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; | |
function isInAstralSet(e2, t2) { | |
let r2 = 65536; | |
for (let n2 = 0, i2 = t2.length; n2 < i2; n2 += 2) { | |
if (r2 += t2[n2], r2 > e2) | |
return false; | |
if (r2 += t2[n2 + 1], r2 >= e2) | |
return true; | |
} | |
return false; | |
} | |
function isIdentifierStart(e2) { | |
return e2 < 65 ? 36 === e2 : e2 <= 90 || (e2 < 97 ? 95 === e2 : e2 <= 122 || (e2 <= 65535 ? e2 >= 170 && aa.test(String.fromCharCode(e2)) : isInAstralSet(e2, la))); | |
} | |
function isIdentifierChar(e2) { | |
return e2 < 48 ? 36 === e2 : e2 < 58 || !(e2 < 65) && (e2 <= 90 || (e2 < 97 ? 95 === e2 : e2 <= 122 || (e2 <= 65535 ? e2 >= 170 && ca.test(String.fromCharCode(e2)) : isInAstralSet(e2, la) || isInAstralSet(e2, pa)))); | |
} | |
const ua = ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], da = ["eval", "arguments"], ha = /* @__PURE__ */ new Set(["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"]), fa = new Set(ua), ma = new Set(da); | |
function isReservedWord(e2, t2) { | |
return t2 && "await" === e2 || "enum" === e2; | |
} | |
function isStrictReservedWord(e2, t2) { | |
return isReservedWord(e2, t2) || fa.has(e2); | |
} | |
function isStrictBindOnlyReservedWord(e2) { | |
return ma.has(e2); | |
} | |
function isStrictBindReservedWord(e2, t2) { | |
return isStrictReservedWord(e2, t2) || isStrictBindOnlyReservedWord(e2); | |
} | |
const ga = /* @__PURE__ */ new Set(["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "eval", "arguments", "enum", "await"]); | |
class Scope { | |
constructor(e2) { | |
this.var = /* @__PURE__ */ new Set(), this.lexical = /* @__PURE__ */ new Set(), this.functions = /* @__PURE__ */ new Set(), this.flags = e2; | |
} | |
} | |
class ScopeHandler { | |
constructor(e2, t2) { | |
this.parser = void 0, this.scopeStack = [], this.inModule = void 0, this.undefinedExports = /* @__PURE__ */ new Map(), this.parser = e2, this.inModule = t2; | |
} | |
get inTopLevel() { | |
return (1 & this.currentScope().flags) > 0; | |
} | |
get inFunction() { | |
return (2 & this.currentVarScopeFlags()) > 0; | |
} | |
get allowSuper() { | |
return (16 & this.currentThisScopeFlags()) > 0; | |
} | |
get allowDirectSuper() { | |
return (32 & this.currentThisScopeFlags()) > 0; | |
} | |
get inClass() { | |
return (64 & this.currentThisScopeFlags()) > 0; | |
} | |
get inClassAndNotInNonArrowFunction() { | |
const e2 = this.currentThisScopeFlags(); | |
return (64 & e2) > 0 && 0 == (2 & e2); | |
} | |
get inStaticBlock() { | |
for (let e2 = this.scopeStack.length - 1; ; e2--) { | |
const { flags: t2 } = this.scopeStack[e2]; | |
if (128 & t2) | |
return true; | |
if (451 & t2) | |
return false; | |
} | |
} | |
get inNonArrowFunction() { | |
return (2 & this.currentThisScopeFlags()) > 0; | |
} | |
get treatFunctionsAsVar() { | |
return this.treatFunctionsAsVarInScope(this.currentScope()); | |
} | |
createScope(e2) { | |
return new Scope(e2); | |
} | |
enter(e2) { | |
this.scopeStack.push(this.createScope(e2)); | |
} | |
exit() { | |
return this.scopeStack.pop().flags; | |
} | |
treatFunctionsAsVarInScope(e2) { | |
return !!(130 & e2.flags || !this.parser.inModule && 1 & e2.flags); | |
} | |
declareName(e2, t2, r2) { | |
let n2 = this.currentScope(); | |
if (8 & t2 || 16 & t2) | |
this.checkRedeclarationInScope(n2, e2, t2, r2), 16 & t2 ? n2.functions.add(e2) : n2.lexical.add(e2), 8 & t2 && this.maybeExportDefined(n2, e2); | |
else if (4 & t2) | |
for (let i2 = this.scopeStack.length - 1; i2 >= 0 && (n2 = this.scopeStack[i2], this.checkRedeclarationInScope(n2, e2, t2, r2), n2.var.add(e2), this.maybeExportDefined(n2, e2), !(387 & n2.flags)); --i2) | |
; | |
this.parser.inModule && 1 & n2.flags && this.undefinedExports.delete(e2); | |
} | |
maybeExportDefined(e2, t2) { | |
this.parser.inModule && 1 & e2.flags && this.undefinedExports.delete(t2); | |
} | |
checkRedeclarationInScope(e2, t2, r2, n2) { | |
this.isRedeclaredInScope(e2, t2, r2) && this.parser.raise(Ho.VarRedeclaration, { at: n2, identifierName: t2 }); | |
} | |
isRedeclaredInScope(e2, t2, r2) { | |
return !!(1 & r2) && (8 & r2 ? e2.lexical.has(t2) || e2.functions.has(t2) || e2.var.has(t2) : 16 & r2 ? e2.lexical.has(t2) || !this.treatFunctionsAsVarInScope(e2) && e2.var.has(t2) : e2.lexical.has(t2) && !(8 & e2.flags && e2.lexical.values().next().value === t2) || !this.treatFunctionsAsVarInScope(e2) && e2.functions.has(t2)); | |
} | |
checkLocalExport(e2) { | |
const { name: t2 } = e2, r2 = this.scopeStack[0]; | |
r2.lexical.has(t2) || r2.var.has(t2) || r2.functions.has(t2) || this.undefinedExports.set(t2, e2.loc.start); | |
} | |
currentScope() { | |
return this.scopeStack[this.scopeStack.length - 1]; | |
} | |
currentVarScopeFlags() { | |
for (let e2 = this.scopeStack.length - 1; ; e2--) { | |
const { flags: t2 } = this.scopeStack[e2]; | |
if (387 & t2) | |
return t2; | |
} | |
} | |
currentThisScopeFlags() { | |
for (let e2 = this.scopeStack.length - 1; ; e2--) { | |
const { flags: t2 } = this.scopeStack[e2]; | |
if (451 & t2 && !(4 & t2)) | |
return t2; | |
} | |
} | |
} | |
class FlowScope extends Scope { | |
constructor(...e2) { | |
super(...e2), this.declareFunctions = /* @__PURE__ */ new Set(); | |
} | |
} | |
class FlowScopeHandler extends ScopeHandler { | |
createScope(e2) { | |
return new FlowScope(e2); | |
} | |
declareName(e2, t2, r2) { | |
const n2 = this.currentScope(); | |
if (2048 & t2) | |
return this.checkRedeclarationInScope(n2, e2, t2, r2), this.maybeExportDefined(n2, e2), void n2.declareFunctions.add(e2); | |
super.declareName(e2, t2, r2); | |
} | |
isRedeclaredInScope(e2, t2, r2) { | |
return !!super.isRedeclaredInScope(e2, t2, r2) || !!(2048 & r2) && (!e2.declareFunctions.has(t2) && (e2.lexical.has(t2) || e2.functions.has(t2))); | |
} | |
checkLocalExport(e2) { | |
this.scopeStack[0].declareFunctions.has(e2.name) || super.checkLocalExport(e2); | |
} | |
} | |
class BaseParser { | |
constructor() { | |
this.sawUnambiguousESM = false, this.ambiguousScriptDifferentAst = false; | |
} | |
hasPlugin(e2) { | |
if ("string" == typeof e2) | |
return this.plugins.has(e2); | |
{ | |
const [t2, r2] = e2; | |
if (!this.hasPlugin(t2)) | |
return false; | |
const n2 = this.plugins.get(t2); | |
for (const e3 of Object.keys(r2)) | |
if ((null == n2 ? void 0 : n2[e3]) !== r2[e3]) | |
return false; | |
return true; | |
} | |
} | |
getPluginOption(e2, t2) { | |
var r2; | |
return null == (r2 = this.plugins.get(e2)) ? void 0 : r2[t2]; | |
} | |
} | |
function setTrailingComments(e2, t2) { | |
void 0 === e2.trailingComments ? e2.trailingComments = t2 : e2.trailingComments.unshift(...t2); | |
} | |
function setInnerComments(e2, t2) { | |
void 0 === e2.innerComments ? e2.innerComments = t2 : e2.innerComments.unshift(...t2); | |
} | |
function adjustInnerComments(e2, t2, r2) { | |
let n2 = null, i2 = t2.length; | |
for (; null === n2 && i2 > 0; ) | |
n2 = t2[--i2]; | |
null === n2 || n2.start > r2.start ? setInnerComments(e2, r2.comments) : setTrailingComments(n2, r2.comments); | |
} | |
class CommentsParser extends BaseParser { | |
addComment(e2) { | |
this.filename && (e2.loc.filename = this.filename), this.state.comments.push(e2); | |
} | |
processComment(e2) { | |
const { commentStack: t2 } = this.state, r2 = t2.length; | |
if (0 === r2) | |
return; | |
let n2 = r2 - 1; | |
const i2 = t2[n2]; | |
i2.start === e2.end && (i2.leadingNode = e2, n2--); | |
const { start: a2 } = e2; | |
for (; n2 >= 0; n2--) { | |
const r3 = t2[n2], i3 = r3.end; | |
if (!(i3 > a2)) { | |
i3 === a2 && (r3.trailingNode = e2); | |
break; | |
} | |
r3.containingNode = e2, this.finalizeComment(r3), t2.splice(n2, 1); | |
} | |
} | |
finalizeComment(e2) { | |
const { comments: t2 } = e2; | |
if (null !== e2.leadingNode || null !== e2.trailingNode) | |
null !== e2.leadingNode && setTrailingComments(e2.leadingNode, t2), null !== e2.trailingNode && function(e3, t3) { | |
void 0 === e3.leadingComments ? e3.leadingComments = t3 : e3.leadingComments.unshift(...t3); | |
}(e2.trailingNode, t2); | |
else { | |
const { containingNode: r2, start: n2 } = e2; | |
if (44 === this.input.charCodeAt(n2 - 1)) | |
switch (r2.type) { | |
case "ObjectExpression": | |
case "ObjectPattern": | |
case "RecordExpression": | |
adjustInnerComments(r2, r2.properties, e2); | |
break; | |
case "CallExpression": | |
case "OptionalCallExpression": | |
adjustInnerComments(r2, r2.arguments, e2); | |
break; | |
case "FunctionDeclaration": | |
case "FunctionExpression": | |
case "ArrowFunctionExpression": | |
case "ObjectMethod": | |
case "ClassMethod": | |
case "ClassPrivateMethod": | |
adjustInnerComments(r2, r2.params, e2); | |
break; | |
case "ArrayExpression": | |
case "ArrayPattern": | |
case "TupleExpression": | |
adjustInnerComments(r2, r2.elements, e2); | |
break; | |
case "ExportNamedDeclaration": | |
case "ImportDeclaration": | |
adjustInnerComments(r2, r2.specifiers, e2); | |
break; | |
default: | |
setInnerComments(r2, t2); | |
} | |
else | |
setInnerComments(r2, t2); | |
} | |
} | |
finalizeRemainingComments() { | |
const { commentStack: e2 } = this.state; | |
for (let t2 = e2.length - 1; t2 >= 0; t2--) | |
this.finalizeComment(e2[t2]); | |
this.state.commentStack = []; | |
} | |
resetPreviousNodeTrailingComments(e2) { | |
const { commentStack: t2 } = this.state, { length: r2 } = t2; | |
if (0 === r2) | |
return; | |
const n2 = t2[r2 - 1]; | |
n2.leadingNode === e2 && (n2.leadingNode = null); | |
} | |
resetPreviousIdentifierLeadingComments(e2) { | |
const { commentStack: t2 } = this.state, { length: r2 } = t2; | |
0 !== r2 && (t2[r2 - 1].trailingNode === e2 ? t2[r2 - 1].trailingNode = null : r2 >= 2 && t2[r2 - 2].trailingNode === e2 && (t2[r2 - 2].trailingNode = null)); | |
} | |
takeSurroundingComments(e2, t2, r2) { | |
const { commentStack: n2 } = this.state, i2 = n2.length; | |
if (0 === i2) | |
return; | |
let a2 = i2 - 1; | |
for (; a2 >= 0; a2--) { | |
const i3 = n2[a2], c2 = i3.end; | |
if (i3.start === r2) | |
i3.leadingNode = e2; | |
else if (c2 === t2) | |
i3.trailingNode = e2; | |
else if (c2 < t2) | |
break; | |
} | |
} | |
} | |
const ya = /\r\n?|[\n\u2028\u2029]/, ba = new RegExp(ya.source, "g"); | |
function isNewLine(e2) { | |
switch (e2) { | |
case 10: | |
case 13: | |
case 8232: | |
case 8233: | |
return true; | |
default: | |
return false; | |
} | |
} | |
const va = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g, xa = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g, wa = new RegExp("(?=(" + xa.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y"); | |
function isWhitespace(e2) { | |
switch (e2) { | |
case 9: | |
case 11: | |
case 12: | |
case 32: | |
case 160: | |
case 5760: | |
case 8192: | |
case 8193: | |
case 8194: | |
case 8195: | |
case 8196: | |
case 8197: | |
case 8198: | |
case 8199: | |
case 8200: | |
case 8201: | |
case 8202: | |
case 8239: | |
case 8287: | |
case 12288: | |
case 65279: | |
return true; | |
default: | |
return false; | |
} | |
} | |
class State { | |
constructor() { | |
this.strict = void 0, this.curLine = void 0, this.lineStart = void 0, this.startLoc = void 0, this.endLoc = void 0, this.errors = [], this.potentialArrowAt = -1, this.noArrowAt = [], this.noArrowParamsConversionAt = [], this.maybeInArrowParameters = false, this.inType = false, this.noAnonFunctionType = false, this.hasFlowComment = false, this.isAmbientContext = false, this.inAbstractClass = false, this.inDisallowConditionalTypesContext = false, this.topicContext = { maxNumOfResolvableTopics: 0, maxTopicIndex: null }, this.soloAwait = false, this.inFSharpPipelineDirectBody = false, this.labels = [], this.comments = [], this.commentStack = [], this.pos = 0, this.type = 137, this.value = null, this.start = 0, this.end = 0, this.lastTokEndLoc = null, this.lastTokStartLoc = null, this.lastTokStart = 0, this.context = [zo.brace], this.canStartJSXElement = true, this.containsEsc = false, this.firstInvalidTemplateEscapePos = null, this.strictErrors = /* @__PURE__ */ new Map(), this.tokensLength = 0; | |
} | |
init({ strictMode: e2, sourceType: t2, startLine: r2, startColumn: n2 }) { | |
this.strict = false !== e2 && (true === e2 || "module" === t2), this.curLine = r2, this.lineStart = -n2, this.startLoc = this.endLoc = new Position(r2, n2, 0); | |
} | |
curPosition() { | |
return new Position(this.curLine, this.pos - this.lineStart, this.pos); | |
} | |
clone(e2) { | |
const t2 = new State(), r2 = Object.keys(this); | |
for (let n2 = 0, i2 = r2.length; n2 < i2; n2++) { | |
const i3 = r2[n2]; | |
let a2 = this[i3]; | |
!e2 && Array.isArray(a2) && (a2 = a2.slice()), t2[i3] = a2; | |
} | |
return t2; | |
} | |
} | |
var _isDigit = function(e2) { | |
return e2 >= 48 && e2 <= 57; | |
}; | |
const Ca = { decBinOct: /* @__PURE__ */ new Set([46, 66, 69, 79, 95, 98, 101, 111]), hex: /* @__PURE__ */ new Set([46, 88, 95, 120]) }, Ea = { bin: (e2) => 48 === e2 || 49 === e2, oct: (e2) => e2 >= 48 && e2 <= 55, dec: (e2) => e2 >= 48 && e2 <= 57, hex: (e2) => e2 >= 48 && e2 <= 57 || e2 >= 65 && e2 <= 70 || e2 >= 97 && e2 <= 102 }; | |
function readStringContents(e2, t2, r2, n2, i2, a2) { | |
const c2 = r2, u2 = n2, m2 = i2; | |
let g2 = "", b2 = null, x2 = r2; | |
const { length: C2 } = t2; | |
for (; ; ) { | |
if (r2 >= C2) { | |
a2.unterminated(c2, u2, m2), g2 += t2.slice(x2, r2); | |
break; | |
} | |
const A2 = t2.charCodeAt(r2); | |
if (isStringEnd(e2, A2, t2, r2)) { | |
g2 += t2.slice(x2, r2); | |
break; | |
} | |
if (92 === A2) { | |
g2 += t2.slice(x2, r2); | |
const c3 = readEscapedChar(t2, r2, n2, i2, "template" === e2, a2); | |
null !== c3.ch || b2 ? g2 += c3.ch : b2 = { pos: r2, lineStart: n2, curLine: i2 }, { pos: r2, lineStart: n2, curLine: i2 } = c3, x2 = r2; | |
} else | |
8232 === A2 || 8233 === A2 ? (++i2, n2 = ++r2) : 10 === A2 || 13 === A2 ? "template" === e2 ? (g2 += t2.slice(x2, r2) + "\n", ++r2, 13 === A2 && 10 === t2.charCodeAt(r2) && ++r2, ++i2, x2 = n2 = r2) : a2.unterminated(c2, u2, m2) : ++r2; | |
} | |
return { pos: r2, str: g2, firstInvalidLoc: b2, lineStart: n2, curLine: i2, containsInvalid: !!b2 }; | |
} | |
function isStringEnd(e2, t2, r2, n2) { | |
return "template" === e2 ? 96 === t2 || 36 === t2 && 123 === r2.charCodeAt(n2 + 1) : t2 === ("double" === e2 ? 34 : 39); | |
} | |
function readEscapedChar(e2, t2, r2, n2, i2, a2) { | |
const c2 = !i2; | |
t2++; | |
const res = (e3) => ({ pos: t2, ch: e3, lineStart: r2, curLine: n2 }), u2 = e2.charCodeAt(t2++); | |
switch (u2) { | |
case 110: | |
return res("\n"); | |
case 114: | |
return res("\r"); | |
case 120: { | |
let i3; | |
return { code: i3, pos: t2 } = readHexChar(e2, t2, r2, n2, 2, false, c2, a2), res(null === i3 ? null : String.fromCharCode(i3)); | |
} | |
case 117: { | |
let i3; | |
return { code: i3, pos: t2 } = readCodePoint(e2, t2, r2, n2, c2, a2), res(null === i3 ? null : String.fromCodePoint(i3)); | |
} | |
case 116: | |
return res(" "); | |
case 98: | |
return res("\b"); | |
case 118: | |
return res("\v"); | |
case 102: | |
return res("\f"); | |
case 13: | |
10 === e2.charCodeAt(t2) && ++t2; | |
case 10: | |
r2 = t2, ++n2; | |
case 8232: | |
case 8233: | |
return res(""); | |
case 56: | |
case 57: | |
if (i2) | |
return res(null); | |
a2.strictNumericEscape(t2 - 1, r2, n2); | |
default: | |
if (u2 >= 48 && u2 <= 55) { | |
const c3 = t2 - 1; | |
let u3 = e2.slice(c3, t2 + 2).match(/^[0-7]+/)[0], m2 = parseInt(u3, 8); | |
m2 > 255 && (u3 = u3.slice(0, -1), m2 = parseInt(u3, 8)), t2 += u3.length - 1; | |
const g2 = e2.charCodeAt(t2); | |
if ("0" !== u3 || 56 === g2 || 57 === g2) { | |
if (i2) | |
return res(null); | |
a2.strictNumericEscape(c3, r2, n2); | |
} | |
return res(String.fromCharCode(m2)); | |
} | |
return res(String.fromCharCode(u2)); | |
} | |
} | |
function readHexChar(e2, t2, r2, n2, i2, a2, c2, u2) { | |
const m2 = t2; | |
let g2; | |
return { n: g2, pos: t2 } = readInt(e2, t2, r2, n2, 16, i2, a2, false, u2, !c2), null === g2 && (c2 ? u2.invalidEscapeSequence(m2, r2, n2) : t2 = m2 - 1), { code: g2, pos: t2 }; | |
} | |
function readInt(e2, t2, r2, n2, i2, a2, c2, u2, m2, g2) { | |
const b2 = t2, x2 = 16 === i2 ? Ca.hex : Ca.decBinOct, C2 = 16 === i2 ? Ea.hex : 10 === i2 ? Ea.dec : 8 === i2 ? Ea.oct : Ea.bin; | |
let A2 = false, P2 = 0; | |
for (let b3 = 0, T2 = null == a2 ? 1 / 0 : a2; b3 < T2; ++b3) { | |
const a3 = e2.charCodeAt(t2); | |
let b4; | |
if (95 !== a3 || "bail" === u2) { | |
if (b4 = a3 >= 97 ? a3 - 97 + 10 : a3 >= 65 ? a3 - 65 + 10 : _isDigit(a3) ? a3 - 48 : 1 / 0, b4 >= i2) { | |
if (b4 <= 9 && g2) | |
return { n: null, pos: t2 }; | |
if (b4 <= 9 && m2.invalidDigit(t2, r2, n2, i2)) | |
b4 = 0; | |
else { | |
if (!c2) | |
break; | |
b4 = 0, A2 = true; | |
} | |
} | |
++t2, P2 = P2 * i2 + b4; | |
} else { | |
const i3 = e2.charCodeAt(t2 - 1), a4 = e2.charCodeAt(t2 + 1); | |
if (u2) { | |
if (Number.isNaN(a4) || !C2(a4) || x2.has(i3) || x2.has(a4)) { | |
if (g2) | |
return { n: null, pos: t2 }; | |
m2.unexpectedNumericSeparator(t2, r2, n2); | |
} | |
} else { | |
if (g2) | |
return { n: null, pos: t2 }; | |
m2.numericSeparatorInEscapeSequence(t2, r2, n2); | |
} | |
++t2; | |
} | |
} | |
return t2 === b2 || null != a2 && t2 - b2 !== a2 || A2 ? { n: null, pos: t2 } : { n: P2, pos: t2 }; | |
} | |
function readCodePoint(e2, t2, r2, n2, i2, a2) { | |
let c2; | |
if (123 === e2.charCodeAt(t2)) { | |
if (++t2, { code: c2, pos: t2 } = readHexChar(e2, t2, r2, n2, e2.indexOf("}", t2) - t2, true, i2, a2), ++t2, null !== c2 && c2 > 1114111) { | |
if (!i2) | |
return { code: null, pos: t2 }; | |
a2.invalidCodePoint(t2, r2, n2); | |
} | |
} else | |
({ code: c2, pos: t2 } = readHexChar(e2, t2, r2, n2, 4, false, i2, a2)); | |
return { code: c2, pos: t2 }; | |
} | |
const Sa = ["at"], Aa = ["at"]; | |
function buildPosition(e2, t2, r2) { | |
return new Position(r2, e2 - t2, e2); | |
} | |
const ka = /* @__PURE__ */ new Set([103, 109, 115, 105, 121, 117, 100, 118]); | |
class Token { | |
constructor(e2) { | |
this.type = e2.type, this.value = e2.value, this.start = e2.start, this.end = e2.end, this.loc = new SourceLocation(e2.startLoc, e2.endLoc); | |
} | |
} | |
class Tokenizer extends CommentsParser { | |
constructor(e2, t2) { | |
super(), this.isLookahead = void 0, this.tokens = [], this.errorHandlers_readInt = { invalidDigit: (e3, t3, r2, n2) => !!this.options.errorRecovery && (this.raise(Ho.InvalidDigit, { at: buildPosition(e3, t3, r2), radix: n2 }), true), numericSeparatorInEscapeSequence: this.errorBuilder(Ho.NumericSeparatorInEscapeSequence), unexpectedNumericSeparator: this.errorBuilder(Ho.UnexpectedNumericSeparator) }, this.errorHandlers_readCodePoint = Object.assign({}, this.errorHandlers_readInt, { invalidEscapeSequence: this.errorBuilder(Ho.InvalidEscapeSequence), invalidCodePoint: this.errorBuilder(Ho.InvalidCodePoint) }), this.errorHandlers_readStringContents_string = Object.assign({}, this.errorHandlers_readCodePoint, { strictNumericEscape: (e3, t3, r2) => { | |
this.recordStrictModeErrors(Ho.StrictNumericEscape, { at: buildPosition(e3, t3, r2) }); | |
}, unterminated: (e3, t3, r2) => { | |
throw this.raise(Ho.UnterminatedString, { at: buildPosition(e3 - 1, t3, r2) }); | |
} }), this.errorHandlers_readStringContents_template = Object.assign({}, this.errorHandlers_readCodePoint, { strictNumericEscape: this.errorBuilder(Ho.StrictNumericEscape), unterminated: (e3, t3, r2) => { | |
throw this.raise(Ho.UnterminatedTemplate, { at: buildPosition(e3, t3, r2) }); | |
} }), this.state = new State(), this.state.init(e2), this.input = t2, this.length = t2.length, this.isLookahead = false; | |
} | |
pushToken(e2) { | |
this.tokens.length = this.state.tokensLength, this.tokens.push(e2), ++this.state.tokensLength; | |
} | |
next() { | |
this.checkKeywordEscapes(), this.options.tokens && this.pushToken(new Token(this.state)), this.state.lastTokStart = this.state.start, this.state.lastTokEndLoc = this.state.endLoc, this.state.lastTokStartLoc = this.state.startLoc, this.nextToken(); | |
} | |
eat(e2) { | |
return !!this.match(e2) && (this.next(), true); | |
} | |
match(e2) { | |
return this.state.type === e2; | |
} | |
createLookaheadState(e2) { | |
return { pos: e2.pos, value: null, type: e2.type, start: e2.start, end: e2.end, context: [this.curContext()], inType: e2.inType, startLoc: e2.startLoc, lastTokEndLoc: e2.lastTokEndLoc, curLine: e2.curLine, lineStart: e2.lineStart, curPosition: e2.curPosition }; | |
} | |
lookahead() { | |
const e2 = this.state; | |
this.state = this.createLookaheadState(e2), this.isLookahead = true, this.nextToken(), this.isLookahead = false; | |
const t2 = this.state; | |
return this.state = e2, t2; | |
} | |
nextTokenStart() { | |
return this.nextTokenStartSince(this.state.pos); | |
} | |
nextTokenStartSince(e2) { | |
return va.lastIndex = e2, va.test(this.input) ? va.lastIndex : e2; | |
} | |
lookaheadCharCode() { | |
return this.input.charCodeAt(this.nextTokenStart()); | |
} | |
nextTokenInLineStart() { | |
return this.nextTokenInLineStartSince(this.state.pos); | |
} | |
nextTokenInLineStartSince(e2) { | |
return xa.lastIndex = e2, xa.test(this.input) ? xa.lastIndex : e2; | |
} | |
lookaheadInLineCharCode() { | |
return this.input.charCodeAt(this.nextTokenInLineStart()); | |
} | |
codePointAtPos(e2) { | |
let t2 = this.input.charCodeAt(e2); | |
if (55296 == (64512 & t2) && ++e2 < this.input.length) { | |
const r2 = this.input.charCodeAt(e2); | |
56320 == (64512 & r2) && (t2 = 65536 + ((1023 & t2) << 10) + (1023 & r2)); | |
} | |
return t2; | |
} | |
setStrict(e2) { | |
this.state.strict = e2, e2 && (this.state.strictErrors.forEach(([e3, t2]) => this.raise(e3, { at: t2 })), this.state.strictErrors.clear()); | |
} | |
curContext() { | |
return this.state.context[this.state.context.length - 1]; | |
} | |
nextToken() { | |
this.skipSpace(), this.state.start = this.state.pos, this.isLookahead || (this.state.startLoc = this.state.curPosition()), this.state.pos >= this.length ? this.finishToken(137) : this.getTokenFromCode(this.codePointAtPos(this.state.pos)); | |
} | |
skipBlockComment(e2) { | |
let t2; | |
this.isLookahead || (t2 = this.state.curPosition()); | |
const r2 = this.state.pos, n2 = this.input.indexOf(e2, r2 + 2); | |
if (-1 === n2) | |
throw this.raise(Ho.UnterminatedComment, { at: this.state.curPosition() }); | |
for (this.state.pos = n2 + e2.length, ba.lastIndex = r2 + 2; ba.test(this.input) && ba.lastIndex <= n2; ) | |
++this.state.curLine, this.state.lineStart = ba.lastIndex; | |
if (this.isLookahead) | |
return; | |
const i2 = { type: "CommentBlock", value: this.input.slice(r2 + 2, n2), start: r2, end: n2 + e2.length, loc: new SourceLocation(t2, this.state.curPosition()) }; | |
return this.options.tokens && this.pushToken(i2), i2; | |
} | |
skipLineComment(e2) { | |
const t2 = this.state.pos; | |
let r2; | |
this.isLookahead || (r2 = this.state.curPosition()); | |
let n2 = this.input.charCodeAt(this.state.pos += e2); | |
if (this.state.pos < this.length) | |
for (; !isNewLine(n2) && ++this.state.pos < this.length; ) | |
n2 = this.input.charCodeAt(this.state.pos); | |
if (this.isLookahead) | |
return; | |
const i2 = this.state.pos, a2 = { type: "CommentLine", value: this.input.slice(t2 + e2, i2), start: t2, end: i2, loc: new SourceLocation(r2, this.state.curPosition()) }; | |
return this.options.tokens && this.pushToken(a2), a2; | |
} | |
skipSpace() { | |
const e2 = this.state.pos, t2 = []; | |
e: | |
for (; this.state.pos < this.length; ) { | |
const r2 = this.input.charCodeAt(this.state.pos); | |
switch (r2) { | |
case 32: | |
case 160: | |
case 9: | |
++this.state.pos; | |
break; | |
case 13: | |
10 === this.input.charCodeAt(this.state.pos + 1) && ++this.state.pos; | |
case 10: | |
case 8232: | |
case 8233: | |
++this.state.pos, ++this.state.curLine, this.state.lineStart = this.state.pos; | |
break; | |
case 47: | |
switch (this.input.charCodeAt(this.state.pos + 1)) { | |
case 42: { | |
const e3 = this.skipBlockComment("*/"); | |
void 0 !== e3 && (this.addComment(e3), this.options.attachComment && t2.push(e3)); | |
break; | |
} | |
case 47: { | |
const e3 = this.skipLineComment(2); | |
void 0 !== e3 && (this.addComment(e3), this.options.attachComment && t2.push(e3)); | |
break; | |
} | |
default: | |
break e; | |
} | |
break; | |
default: | |
if (isWhitespace(r2)) | |
++this.state.pos; | |
else if (45 === r2 && !this.inModule && this.options.annexB) { | |
const r3 = this.state.pos; | |
if (45 !== this.input.charCodeAt(r3 + 1) || 62 !== this.input.charCodeAt(r3 + 2) || !(0 === e2 || this.state.lineStart > e2)) | |
break e; | |
{ | |
const e3 = this.skipLineComment(3); | |
void 0 !== e3 && (this.addComment(e3), this.options.attachComment && t2.push(e3)); | |
} | |
} else { | |
if (60 !== r2 || this.inModule || !this.options.annexB) | |
break e; | |
{ | |
const e3 = this.state.pos; | |
if (33 !== this.input.charCodeAt(e3 + 1) || 45 !== this.input.charCodeAt(e3 + 2) || 45 !== this.input.charCodeAt(e3 + 3)) | |
break e; | |
{ | |
const e4 = this.skipLineComment(4); | |
void 0 !== e4 && (this.addComment(e4), this.options.attachComment && t2.push(e4)); | |
} | |
} | |
} | |
} | |
} | |
if (t2.length > 0) { | |
const r2 = { start: e2, end: this.state.pos, comments: t2, leadingNode: null, trailingNode: null, containingNode: null }; | |
this.state.commentStack.push(r2); | |
} | |
} | |
finishToken(e2, t2) { | |
this.state.end = this.state.pos, this.state.endLoc = this.state.curPosition(); | |
const r2 = this.state.type; | |
this.state.type = e2, this.state.value = t2, this.isLookahead || this.updateContext(r2); | |
} | |
replaceToken(e2) { | |
this.state.type = e2, this.updateContext(); | |
} | |
readToken_numberSign() { | |
if (0 === this.state.pos && this.readToken_interpreter()) | |
return; | |
const e2 = this.state.pos + 1, t2 = this.codePointAtPos(e2); | |
if (t2 >= 48 && t2 <= 57) | |
throw this.raise(Ho.UnexpectedDigitAfterHash, { at: this.state.curPosition() }); | |
if (123 === t2 || 91 === t2 && this.hasPlugin("recordAndTuple")) { | |
if (this.expectPlugin("recordAndTuple"), "bar" === this.getPluginOption("recordAndTuple", "syntaxType")) | |
throw this.raise(123 === t2 ? Ho.RecordExpressionHashIncorrectStartSyntaxType : Ho.TupleExpressionHashIncorrectStartSyntaxType, { at: this.state.curPosition() }); | |
this.state.pos += 2, 123 === t2 ? this.finishToken(7) : this.finishToken(1); | |
} else | |
isIdentifierStart(t2) ? (++this.state.pos, this.finishToken(136, this.readWord1(t2))) : 92 === t2 ? (++this.state.pos, this.finishToken(136, this.readWord1())) : this.finishOp(27, 1); | |
} | |
readToken_dot() { | |
const e2 = this.input.charCodeAt(this.state.pos + 1); | |
e2 >= 48 && e2 <= 57 ? this.readNumber(true) : 46 === e2 && 46 === this.input.charCodeAt(this.state.pos + 2) ? (this.state.pos += 3, this.finishToken(21)) : (++this.state.pos, this.finishToken(16)); | |
} | |
readToken_slash() { | |
61 === this.input.charCodeAt(this.state.pos + 1) ? this.finishOp(31, 2) : this.finishOp(56, 1); | |
} | |
readToken_interpreter() { | |
if (0 !== this.state.pos || this.length < 2) | |
return false; | |
let e2 = this.input.charCodeAt(this.state.pos + 1); | |
if (33 !== e2) | |
return false; | |
const t2 = this.state.pos; | |
for (this.state.pos += 1; !isNewLine(e2) && ++this.state.pos < this.length; ) | |
e2 = this.input.charCodeAt(this.state.pos); | |
const r2 = this.input.slice(t2 + 2, this.state.pos); | |
return this.finishToken(28, r2), true; | |
} | |
readToken_mult_modulo(e2) { | |
let t2 = 42 === e2 ? 55 : 54, r2 = 1, n2 = this.input.charCodeAt(this.state.pos + 1); | |
42 === e2 && 42 === n2 && (r2++, n2 = this.input.charCodeAt(this.state.pos + 2), t2 = 57), 61 !== n2 || this.state.inType || (r2++, t2 = 37 === e2 ? 33 : 30), this.finishOp(t2, r2); | |
} | |
readToken_pipe_amp(e2) { | |
const t2 = this.input.charCodeAt(this.state.pos + 1); | |
if (t2 !== e2) { | |
if (124 === e2) { | |
if (62 === t2) | |
return void this.finishOp(39, 2); | |
if (this.hasPlugin("recordAndTuple") && 125 === t2) { | |
if ("bar" !== this.getPluginOption("recordAndTuple", "syntaxType")) | |
throw this.raise(Ho.RecordExpressionBarIncorrectEndSyntaxType, { at: this.state.curPosition() }); | |
return this.state.pos += 2, void this.finishToken(9); | |
} | |
if (this.hasPlugin("recordAndTuple") && 93 === t2) { | |
if ("bar" !== this.getPluginOption("recordAndTuple", "syntaxType")) | |
throw this.raise(Ho.TupleExpressionBarIncorrectEndSyntaxType, { at: this.state.curPosition() }); | |
return this.state.pos += 2, void this.finishToken(4); | |
} | |
} | |
61 !== t2 ? this.finishOp(124 === e2 ? 43 : 45, 1) : this.finishOp(30, 2); | |
} else | |
61 === this.input.charCodeAt(this.state.pos + 2) ? this.finishOp(30, 3) : this.finishOp(124 === e2 ? 41 : 42, 2); | |
} | |
readToken_caret() { | |
const e2 = this.input.charCodeAt(this.state.pos + 1); | |
if (61 !== e2 || this.state.inType) | |
if (94 === e2 && this.hasPlugin(["pipelineOperator", { proposal: "hack", topicToken: "^^" }])) { | |
this.finishOp(37, 2); | |
94 === this.input.codePointAt(this.state.pos) && this.unexpected(); | |
} else | |
this.finishOp(44, 1); | |
else | |
this.finishOp(32, 2); | |
} | |
readToken_atSign() { | |
64 === this.input.charCodeAt(this.state.pos + 1) && this.hasPlugin(["pipelineOperator", { proposal: "hack", topicToken: "@@" }]) ? this.finishOp(38, 2) : this.finishOp(26, 1); | |
} | |
readToken_plus_min(e2) { | |
const t2 = this.input.charCodeAt(this.state.pos + 1); | |
t2 !== e2 ? 61 === t2 ? this.finishOp(30, 2) : this.finishOp(53, 1) : this.finishOp(34, 2); | |
} | |
readToken_lt() { | |
const { pos: e2 } = this.state, t2 = this.input.charCodeAt(e2 + 1); | |
if (60 === t2) | |
return 61 === this.input.charCodeAt(e2 + 2) ? void this.finishOp(30, 3) : void this.finishOp(51, 2); | |
61 !== t2 ? this.finishOp(47, 1) : this.finishOp(49, 2); | |
} | |
readToken_gt() { | |
const { pos: e2 } = this.state, t2 = this.input.charCodeAt(e2 + 1); | |
if (62 === t2) { | |
const t3 = 62 === this.input.charCodeAt(e2 + 2) ? 3 : 2; | |
return 61 === this.input.charCodeAt(e2 + t3) ? void this.finishOp(30, t3 + 1) : void this.finishOp(52, t3); | |
} | |
61 !== t2 ? this.finishOp(48, 1) : this.finishOp(49, 2); | |
} | |
readToken_eq_excl(e2) { | |
const t2 = this.input.charCodeAt(this.state.pos + 1); | |
if (61 !== t2) | |
return 61 === e2 && 62 === t2 ? (this.state.pos += 2, void this.finishToken(19)) : void this.finishOp(61 === e2 ? 29 : 35, 1); | |
this.finishOp(46, 61 === this.input.charCodeAt(this.state.pos + 2) ? 3 : 2); | |
} | |
readToken_question() { | |
const e2 = this.input.charCodeAt(this.state.pos + 1), t2 = this.input.charCodeAt(this.state.pos + 2); | |
63 === e2 ? 61 === t2 ? this.finishOp(30, 3) : this.finishOp(40, 2) : 46 !== e2 || t2 >= 48 && t2 <= 57 ? (++this.state.pos, this.finishToken(17)) : (this.state.pos += 2, this.finishToken(18)); | |
} | |
getTokenFromCode(e2) { | |
switch (e2) { | |
case 46: | |
return void this.readToken_dot(); | |
case 40: | |
return ++this.state.pos, void this.finishToken(10); | |
case 41: | |
return ++this.state.pos, void this.finishToken(11); | |
case 59: | |
return ++this.state.pos, void this.finishToken(13); | |
case 44: | |
return ++this.state.pos, void this.finishToken(12); | |
case 91: | |
if (this.hasPlugin("recordAndTuple") && 124 === this.input.charCodeAt(this.state.pos + 1)) { | |
if ("bar" !== this.getPluginOption("recordAndTuple", "syntaxType")) | |
throw this.raise(Ho.TupleExpressionBarIncorrectStartSyntaxType, { at: this.state.curPosition() }); | |
this.state.pos += 2, this.finishToken(2); | |
} else | |
++this.state.pos, this.finishToken(0); | |
return; | |
case 93: | |
return ++this.state.pos, void this.finishToken(3); | |
case 123: | |
if (this.hasPlugin("recordAndTuple") && 124 === this.input.charCodeAt(this.state.pos + 1)) { | |
if ("bar" !== this.getPluginOption("recordAndTuple", "syntaxType")) | |
throw this.raise(Ho.RecordExpressionBarIncorrectStartSyntaxType, { at: this.state.curPosition() }); | |
this.state.pos += 2, this.finishToken(6); | |
} else | |
++this.state.pos, this.finishToken(5); | |
return; | |
case 125: | |
return ++this.state.pos, void this.finishToken(8); | |
case 58: | |
return void (this.hasPlugin("functionBind") && 58 === this.input.charCodeAt(this.state.pos + 1) ? this.finishOp(15, 2) : (++this.state.pos, this.finishToken(14))); | |
case 63: | |
return void this.readToken_question(); | |
case 96: | |
return void this.readTemplateToken(); | |
case 48: { | |
const e3 = this.input.charCodeAt(this.state.pos + 1); | |
if (120 === e3 || 88 === e3) | |
return void this.readRadixNumber(16); | |
if (111 === e3 || 79 === e3) | |
return void this.readRadixNumber(8); | |
if (98 === e3 || 66 === e3) | |
return void this.readRadixNumber(2); | |
} | |
case 49: | |
case 50: | |
case 51: | |
case 52: | |
case 53: | |
case 54: | |
case 55: | |
case 56: | |
case 57: | |
return void this.readNumber(false); | |
case 34: | |
case 39: | |
return void this.readString(e2); | |
case 47: | |
return void this.readToken_slash(); | |
case 37: | |
case 42: | |
return void this.readToken_mult_modulo(e2); | |
case 124: | |
case 38: | |
return void this.readToken_pipe_amp(e2); | |
case 94: | |
return void this.readToken_caret(); | |
case 43: | |
case 45: | |
return void this.readToken_plus_min(e2); | |
case 60: | |
return void this.readToken_lt(); | |
case 62: | |
return void this.readToken_gt(); | |
case 61: | |
case 33: | |
return void this.readToken_eq_excl(e2); | |
case 126: | |
return void this.finishOp(36, 1); | |
case 64: | |
return void this.readToken_atSign(); | |
case 35: | |
return void this.readToken_numberSign(); | |
case 92: | |
return void this.readWord(); | |
default: | |
if (isIdentifierStart(e2)) | |
return void this.readWord(e2); | |
} | |
throw this.raise(Ho.InvalidOrUnexpectedToken, { at: this.state.curPosition(), unexpected: String.fromCodePoint(e2) }); | |
} | |
finishOp(e2, t2) { | |
const r2 = this.input.slice(this.state.pos, this.state.pos + t2); | |
this.state.pos += t2, this.finishToken(e2, r2); | |
} | |
readRegexp() { | |
const e2 = this.state.startLoc, t2 = this.state.start + 1; | |
let r2, n2, { pos: i2 } = this.state; | |
for (; ; ++i2) { | |
if (i2 >= this.length) | |
throw this.raise(Ho.UnterminatedRegExp, { at: createPositionWithColumnOffset(e2, 1) }); | |
const t3 = this.input.charCodeAt(i2); | |
if (isNewLine(t3)) | |
throw this.raise(Ho.UnterminatedRegExp, { at: createPositionWithColumnOffset(e2, 1) }); | |
if (r2) | |
r2 = false; | |
else { | |
if (91 === t3) | |
n2 = true; | |
else if (93 === t3 && n2) | |
n2 = false; | |
else if (47 === t3 && !n2) | |
break; | |
r2 = 92 === t3; | |
} | |
} | |
const a2 = this.input.slice(t2, i2); | |
++i2; | |
let c2 = ""; | |
const nextPos = () => createPositionWithColumnOffset(e2, i2 + 2 - t2); | |
for (; i2 < this.length; ) { | |
const e3 = this.codePointAtPos(i2), t3 = String.fromCharCode(e3); | |
if (ka.has(e3)) | |
118 === e3 ? c2.includes("u") && this.raise(Ho.IncompatibleRegExpUVFlags, { at: nextPos() }) : 117 === e3 && c2.includes("v") && this.raise(Ho.IncompatibleRegExpUVFlags, { at: nextPos() }), c2.includes(t3) && this.raise(Ho.DuplicateRegExpFlags, { at: nextPos() }); | |
else { | |
if (!isIdentifierChar(e3) && 92 !== e3) | |
break; | |
this.raise(Ho.MalformedRegExpFlags, { at: nextPos() }); | |
} | |
++i2, c2 += t3; | |
} | |
this.state.pos = i2, this.finishToken(135, { pattern: a2, flags: c2 }); | |
} | |
readInt(e2, t2, r2 = false, n2 = true) { | |
const { n: i2, pos: a2 } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, e2, t2, r2, n2, this.errorHandlers_readInt, false); | |
return this.state.pos = a2, i2; | |
} | |
readRadixNumber(e2) { | |
const t2 = this.state.curPosition(); | |
let r2 = false; | |
this.state.pos += 2; | |
const n2 = this.readInt(e2); | |
null == n2 && this.raise(Ho.InvalidDigit, { at: createPositionWithColumnOffset(t2, 2), radix: e2 }); | |
const i2 = this.input.charCodeAt(this.state.pos); | |
if (110 === i2) | |
++this.state.pos, r2 = true; | |
else if (109 === i2) | |
throw this.raise(Ho.InvalidDecimal, { at: t2 }); | |
if (isIdentifierStart(this.codePointAtPos(this.state.pos))) | |
throw this.raise(Ho.NumberIdentifier, { at: this.state.curPosition() }); | |
if (r2) { | |
const e3 = this.input.slice(t2.index, this.state.pos).replace(/[_n]/g, ""); | |
this.finishToken(133, e3); | |
} else | |
this.finishToken(132, n2); | |
} | |
readNumber(e2) { | |
const t2 = this.state.pos, r2 = this.state.curPosition(); | |
let n2 = false, i2 = false, a2 = false, c2 = false, u2 = false; | |
e2 || null !== this.readInt(10) || this.raise(Ho.InvalidNumber, { at: this.state.curPosition() }); | |
const m2 = this.state.pos - t2 >= 2 && 48 === this.input.charCodeAt(t2); | |
if (m2) { | |
const e3 = this.input.slice(t2, this.state.pos); | |
if (this.recordStrictModeErrors(Ho.StrictOctalLiteral, { at: r2 }), !this.state.strict) { | |
const t3 = e3.indexOf("_"); | |
t3 > 0 && this.raise(Ho.ZeroDigitNumericSeparator, { at: createPositionWithColumnOffset(r2, t3) }); | |
} | |
u2 = m2 && !/[89]/.test(e3); | |
} | |
let g2 = this.input.charCodeAt(this.state.pos); | |
if (46 !== g2 || u2 || (++this.state.pos, this.readInt(10), n2 = true, g2 = this.input.charCodeAt(this.state.pos)), 69 !== g2 && 101 !== g2 || u2 || (g2 = this.input.charCodeAt(++this.state.pos), 43 !== g2 && 45 !== g2 || ++this.state.pos, null === this.readInt(10) && this.raise(Ho.InvalidOrMissingExponent, { at: r2 }), n2 = true, c2 = true, g2 = this.input.charCodeAt(this.state.pos)), 110 === g2 && ((n2 || m2) && this.raise(Ho.InvalidBigIntLiteral, { at: r2 }), ++this.state.pos, i2 = true), 109 === g2 && (this.expectPlugin("decimal", this.state.curPosition()), (c2 || m2) && this.raise(Ho.InvalidDecimal, { at: r2 }), ++this.state.pos, a2 = true), isIdentifierStart(this.codePointAtPos(this.state.pos))) | |
throw this.raise(Ho.NumberIdentifier, { at: this.state.curPosition() }); | |
const b2 = this.input.slice(t2, this.state.pos).replace(/[_mn]/g, ""); | |
if (i2) | |
return void this.finishToken(133, b2); | |
if (a2) | |
return void this.finishToken(134, b2); | |
const x2 = u2 ? parseInt(b2, 8) : parseFloat(b2); | |
this.finishToken(132, x2); | |
} | |
readCodePoint(e2) { | |
const { code: t2, pos: r2 } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, e2, this.errorHandlers_readCodePoint); | |
return this.state.pos = r2, t2; | |
} | |
readString(e2) { | |
const { str: t2, pos: r2, curLine: n2, lineStart: i2 } = readStringContents(34 === e2 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string); | |
this.state.pos = r2 + 1, this.state.lineStart = i2, this.state.curLine = n2, this.finishToken(131, t2); | |
} | |
readTemplateContinuation() { | |
this.match(8) || this.unexpected(null, 8), this.state.pos--, this.readTemplateToken(); | |
} | |
readTemplateToken() { | |
const e2 = this.input[this.state.pos], { str: t2, firstInvalidLoc: r2, pos: n2, curLine: i2, lineStart: a2 } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template); | |
this.state.pos = n2 + 1, this.state.lineStart = a2, this.state.curLine = i2, r2 && (this.state.firstInvalidTemplateEscapePos = new Position(r2.curLine, r2.pos - r2.lineStart, r2.pos)), 96 === this.input.codePointAt(n2) ? this.finishToken(24, r2 ? null : e2 + t2 + "`") : (this.state.pos++, this.finishToken(25, r2 ? null : e2 + t2 + "${")); | |
} | |
recordStrictModeErrors(e2, { at: t2 }) { | |
const r2 = t2.index; | |
this.state.strict && !this.state.strictErrors.has(r2) ? this.raise(e2, { at: t2 }) : this.state.strictErrors.set(r2, [e2, t2]); | |
} | |
readWord1(e2) { | |
this.state.containsEsc = false; | |
let t2 = ""; | |
const r2 = this.state.pos; | |
let n2 = this.state.pos; | |
for (void 0 !== e2 && (this.state.pos += e2 <= 65535 ? 1 : 2); this.state.pos < this.length; ) { | |
const e3 = this.codePointAtPos(this.state.pos); | |
if (isIdentifierChar(e3)) | |
this.state.pos += e3 <= 65535 ? 1 : 2; | |
else { | |
if (92 !== e3) | |
break; | |
{ | |
this.state.containsEsc = true, t2 += this.input.slice(n2, this.state.pos); | |
const e4 = this.state.curPosition(), i2 = this.state.pos === r2 ? isIdentifierStart : isIdentifierChar; | |
if (117 !== this.input.charCodeAt(++this.state.pos)) { | |
this.raise(Ho.MissingUnicodeEscape, { at: this.state.curPosition() }), n2 = this.state.pos - 1; | |
continue; | |
} | |
++this.state.pos; | |
const a2 = this.readCodePoint(true); | |
null !== a2 && (i2(a2) || this.raise(Ho.EscapedCharNotAnIdentifier, { at: e4 }), t2 += String.fromCodePoint(a2)), n2 = this.state.pos; | |
} | |
} | |
} | |
return t2 + this.input.slice(n2, this.state.pos); | |
} | |
readWord(e2) { | |
const t2 = this.readWord1(e2), r2 = Zo.get(t2); | |
void 0 !== r2 ? this.finishToken(r2, tokenLabelName(r2)) : this.finishToken(130, t2); | |
} | |
checkKeywordEscapes() { | |
const { type: e2 } = this.state; | |
tokenIsKeyword(e2) && this.state.containsEsc && this.raise(Ho.InvalidEscapedReservedWord, { at: this.state.startLoc, reservedWord: tokenLabelName(e2) }); | |
} | |
raise(e2, t2) { | |
const { at: r2 } = t2, n2 = _objectWithoutPropertiesLoose(t2, Sa), i2 = e2({ loc: r2 instanceof Position ? r2 : r2.loc.start, details: n2 }); | |
if (!this.options.errorRecovery) | |
throw i2; | |
return this.isLookahead || this.state.errors.push(i2), i2; | |
} | |
raiseOverwrite(e2, t2) { | |
const { at: r2 } = t2, n2 = _objectWithoutPropertiesLoose(t2, Aa), i2 = r2 instanceof Position ? r2 : r2.loc.start, a2 = i2.index, c2 = this.state.errors; | |
for (let t3 = c2.length - 1; t3 >= 0; t3--) { | |
const r3 = c2[t3]; | |
if (r3.loc.index === a2) | |
return c2[t3] = e2({ loc: i2, details: n2 }); | |
if (r3.loc.index < a2) | |
break; | |
} | |
return this.raise(e2, t2); | |
} | |
updateContext(e2) { | |
} | |
unexpected(e2, t2) { | |
throw this.raise(Ho.UnexpectedToken, { expected: t2 ? tokenLabelName(t2) : null, at: null != e2 ? e2 : this.state.startLoc }); | |
} | |
expectPlugin(e2, t2) { | |
if (this.hasPlugin(e2)) | |
return true; | |
throw this.raise(Ho.MissingPlugin, { at: null != t2 ? t2 : this.state.startLoc, missingPlugin: [e2] }); | |
} | |
expectOnePlugin(e2) { | |
if (!e2.some((e3) => this.hasPlugin(e3))) | |
throw this.raise(Ho.MissingOneOfPlugins, { at: this.state.startLoc, missingPlugin: e2 }); | |
} | |
errorBuilder(e2) { | |
return (t2, r2, n2) => { | |
this.raise(e2, { at: buildPosition(t2, r2, n2) }); | |
}; | |
} | |
} | |
class ClassScope { | |
constructor() { | |
this.privateNames = /* @__PURE__ */ new Set(), this.loneAccessors = /* @__PURE__ */ new Map(), this.undefinedPrivateNames = /* @__PURE__ */ new Map(); | |
} | |
} | |
class ClassScopeHandler { | |
constructor(e2) { | |
this.parser = void 0, this.stack = [], this.undefinedPrivateNames = /* @__PURE__ */ new Map(), this.parser = e2; | |
} | |
current() { | |
return this.stack[this.stack.length - 1]; | |
} | |
enter() { | |
this.stack.push(new ClassScope()); | |
} | |
exit() { | |
const e2 = this.stack.pop(), t2 = this.current(); | |
for (const [r2, n2] of Array.from(e2.undefinedPrivateNames)) | |
t2 ? t2.undefinedPrivateNames.has(r2) || t2.undefinedPrivateNames.set(r2, n2) : this.parser.raise(Ho.InvalidPrivateFieldResolution, { at: n2, identifierName: r2 }); | |
} | |
declarePrivateName(e2, t2, r2) { | |
const { privateNames: n2, loneAccessors: i2, undefinedPrivateNames: a2 } = this.current(); | |
let c2 = n2.has(e2); | |
if (3 & t2) { | |
const r3 = c2 && i2.get(e2); | |
if (r3) { | |
c2 = (3 & r3) === (3 & t2) || (4 & r3) !== (4 & t2), c2 || i2.delete(e2); | |
} else | |
c2 || i2.set(e2, t2); | |
} | |
c2 && this.parser.raise(Ho.PrivateNameRedeclaration, { at: r2, identifierName: e2 }), n2.add(e2), a2.delete(e2); | |
} | |
usePrivateName(e2, t2) { | |
let r2; | |
for (r2 of this.stack) | |
if (r2.privateNames.has(e2)) | |
return; | |
r2 ? r2.undefinedPrivateNames.set(e2, t2) : this.parser.raise(Ho.InvalidPrivateFieldResolution, { at: t2, identifierName: e2 }); | |
} | |
} | |
class ExpressionScope { | |
constructor(e2 = 0) { | |
this.type = e2; | |
} | |
canBeArrowParameterDeclaration() { | |
return 2 === this.type || 1 === this.type; | |
} | |
isCertainlyParameterDeclaration() { | |
return 3 === this.type; | |
} | |
} | |
class ArrowHeadParsingScope extends ExpressionScope { | |
constructor(e2) { | |
super(e2), this.declarationErrors = /* @__PURE__ */ new Map(); | |
} | |
recordDeclarationError(e2, { at: t2 }) { | |
const r2 = t2.index; | |
this.declarationErrors.set(r2, [e2, t2]); | |
} | |
clearDeclarationError(e2) { | |
this.declarationErrors.delete(e2); | |
} | |
iterateErrors(e2) { | |
this.declarationErrors.forEach(e2); | |
} | |
} | |
class ExpressionScopeHandler { | |
constructor(e2) { | |
this.parser = void 0, this.stack = [new ExpressionScope()], this.parser = e2; | |
} | |
enter(e2) { | |
this.stack.push(e2); | |
} | |
exit() { | |
this.stack.pop(); | |
} | |
recordParameterInitializerError(e2, { at: t2 }) { | |
const r2 = { at: t2.loc.start }, { stack: n2 } = this; | |
let i2 = n2.length - 1, a2 = n2[i2]; | |
for (; !a2.isCertainlyParameterDeclaration(); ) { | |
if (!a2.canBeArrowParameterDeclaration()) | |
return; | |
a2.recordDeclarationError(e2, r2), a2 = n2[--i2]; | |
} | |
this.parser.raise(e2, r2); | |
} | |
recordArrowParameterBindingError(e2, { at: t2 }) { | |
const { stack: r2 } = this, n2 = r2[r2.length - 1], i2 = { at: t2.loc.start }; | |
if (n2.isCertainlyParameterDeclaration()) | |
this.parser.raise(e2, i2); | |
else { | |
if (!n2.canBeArrowParameterDeclaration()) | |
return; | |
n2.recordDeclarationError(e2, i2); | |
} | |
} | |
recordAsyncArrowParametersError({ at: e2 }) { | |
const { stack: t2 } = this; | |
let r2 = t2.length - 1, n2 = t2[r2]; | |
for (; n2.canBeArrowParameterDeclaration(); ) | |
2 === n2.type && n2.recordDeclarationError(Ho.AwaitBindingIdentifier, { at: e2 }), n2 = t2[--r2]; | |
} | |
validateAsPattern() { | |
const { stack: e2 } = this, t2 = e2[e2.length - 1]; | |
t2.canBeArrowParameterDeclaration() && t2.iterateErrors(([t3, r2]) => { | |
this.parser.raise(t3, { at: r2 }); | |
let n2 = e2.length - 2, i2 = e2[n2]; | |
for (; i2.canBeArrowParameterDeclaration(); ) | |
i2.clearDeclarationError(r2.index), i2 = e2[--n2]; | |
}); | |
} | |
} | |
function newExpressionScope() { | |
return new ExpressionScope(); | |
} | |
class ProductionParameterHandler { | |
constructor() { | |
this.stacks = []; | |
} | |
enter(e2) { | |
this.stacks.push(e2); | |
} | |
exit() { | |
this.stacks.pop(); | |
} | |
currentFlags() { | |
return this.stacks[this.stacks.length - 1]; | |
} | |
get hasAwait() { | |
return (2 & this.currentFlags()) > 0; | |
} | |
get hasYield() { | |
return (1 & this.currentFlags()) > 0; | |
} | |
get hasReturn() { | |
return (4 & this.currentFlags()) > 0; | |
} | |
get hasIn() { | |
return (8 & this.currentFlags()) > 0; | |
} | |
} | |
function functionFlags(e2, t2) { | |
return (e2 ? 2 : 0) | (t2 ? 1 : 0); | |
} | |
class UtilParser extends Tokenizer { | |
addExtra(e2, t2, r2, n2 = true) { | |
if (!e2) | |
return; | |
const i2 = e2.extra = e2.extra || {}; | |
n2 ? i2[t2] = r2 : Object.defineProperty(i2, t2, { enumerable: n2, value: r2 }); | |
} | |
isContextual(e2) { | |
return this.state.type === e2 && !this.state.containsEsc; | |
} | |
isUnparsedContextual(e2, t2) { | |
const r2 = e2 + t2.length; | |
if (this.input.slice(e2, r2) === t2) { | |
const e3 = this.input.charCodeAt(r2); | |
return !(isIdentifierChar(e3) || 55296 == (64512 & e3)); | |
} | |
return false; | |
} | |
isLookaheadContextual(e2) { | |
const t2 = this.nextTokenStart(); | |
return this.isUnparsedContextual(t2, e2); | |
} | |
eatContextual(e2) { | |
return !!this.isContextual(e2) && (this.next(), true); | |
} | |
expectContextual(e2, t2) { | |
if (!this.eatContextual(e2)) { | |
if (null != t2) | |
throw this.raise(t2, { at: this.state.startLoc }); | |
this.unexpected(null, e2); | |
} | |
} | |
canInsertSemicolon() { | |
return this.match(137) || this.match(8) || this.hasPrecedingLineBreak(); | |
} | |
hasPrecedingLineBreak() { | |
return ya.test(this.input.slice(this.state.lastTokEndLoc.index, this.state.start)); | |
} | |
hasFollowingLineBreak() { | |
return wa.lastIndex = this.state.end, wa.test(this.input); | |
} | |
isLineTerminator() { | |
return this.eat(13) || this.canInsertSemicolon(); | |
} | |
semicolon(e2 = true) { | |
(e2 ? this.isLineTerminator() : this.eat(13)) || this.raise(Ho.MissingSemicolon, { at: this.state.lastTokEndLoc }); | |
} | |
expect(e2, t2) { | |
this.eat(e2) || this.unexpected(t2, e2); | |
} | |
tryParse(e2, t2 = this.state.clone()) { | |
const r2 = { node: null }; | |
try { | |
const n2 = e2((e3 = null) => { | |
throw r2.node = e3, r2; | |
}); | |
if (this.state.errors.length > t2.errors.length) { | |
const e3 = this.state; | |
return this.state = t2, this.state.tokensLength = e3.tokensLength, { node: n2, error: e3.errors[t2.errors.length], thrown: false, aborted: false, failState: e3 }; | |
} | |
return { node: n2, error: null, thrown: false, aborted: false, failState: null }; | |
} catch (e3) { | |
const n2 = this.state; | |
if (this.state = t2, e3 instanceof SyntaxError) | |
return { node: null, error: e3, thrown: true, aborted: false, failState: n2 }; | |
if (e3 === r2) | |
return { node: r2.node, error: null, thrown: false, aborted: true, failState: n2 }; | |
throw e3; | |
} | |
} | |
checkExpressionErrors(e2, t2) { | |
if (!e2) | |
return false; | |
const { shorthandAssignLoc: r2, doubleProtoLoc: n2, privateKeyLoc: i2, optionalParametersLoc: a2 } = e2; | |
if (!t2) | |
return !!(r2 || n2 || a2 || i2); | |
null != r2 && this.raise(Ho.InvalidCoverInitializedName, { at: r2 }), null != n2 && this.raise(Ho.DuplicateProto, { at: n2 }), null != i2 && this.raise(Ho.UnexpectedPrivateField, { at: i2 }), null != a2 && this.unexpected(a2); | |
} | |
isLiteralPropertyName() { | |
return tokenIsLiteralPropertyName(this.state.type); | |
} | |
isPrivateName(e2) { | |
return "PrivateName" === e2.type; | |
} | |
getPrivateNameSV(e2) { | |
return e2.id.name; | |
} | |
hasPropertyAsPrivateName(e2) { | |
return ("MemberExpression" === e2.type || "OptionalMemberExpression" === e2.type) && this.isPrivateName(e2.property); | |
} | |
isObjectProperty(e2) { | |
return "ObjectProperty" === e2.type; | |
} | |
isObjectMethod(e2) { | |
return "ObjectMethod" === e2.type; | |
} | |
initializeScopes(e2 = "module" === this.options.sourceType) { | |
const t2 = this.state.labels; | |
this.state.labels = []; | |
const r2 = this.exportedIdentifiers; | |
this.exportedIdentifiers = /* @__PURE__ */ new Set(); | |
const n2 = this.inModule; | |
this.inModule = e2; | |
const i2 = this.scope, a2 = this.getScopeHandler(); | |
this.scope = new a2(this, e2); | |
const c2 = this.prodParam; | |
this.prodParam = new ProductionParameterHandler(); | |
const u2 = this.classScope; | |
this.classScope = new ClassScopeHandler(this); | |
const m2 = this.expressionScope; | |
return this.expressionScope = new ExpressionScopeHandler(this), () => { | |
this.state.labels = t2, this.exportedIdentifiers = r2, this.inModule = n2, this.scope = i2, this.prodParam = c2, this.classScope = u2, this.expressionScope = m2; | |
}; | |
} | |
enterInitialScopes() { | |
let e2 = 0; | |
this.inModule && (e2 |= 2), this.scope.enter(1), this.prodParam.enter(e2); | |
} | |
checkDestructuringPrivate(e2) { | |
const { privateKeyLoc: t2 } = e2; | |
null !== t2 && this.expectPlugin("destructuringPrivate", t2); | |
} | |
} | |
class ExpressionErrors { | |
constructor() { | |
this.shorthandAssignLoc = null, this.doubleProtoLoc = null, this.privateKeyLoc = null, this.optionalParametersLoc = null; | |
} | |
} | |
class Node { | |
constructor(e2, t2, r2) { | |
this.type = "", this.start = t2, this.end = 0, this.loc = new SourceLocation(r2), null != e2 && e2.options.ranges && (this.range = [t2, 0]), null != e2 && e2.filename && (this.loc.filename = e2.filename); | |
} | |
} | |
const Pa = Node.prototype; | |
function cloneIdentifier(e2) { | |
const { type: t2, start: r2, end: n2, loc: i2, range: a2, extra: c2, name: u2 } = e2, m2 = Object.create(Pa); | |
return m2.type = t2, m2.start = r2, m2.end = n2, m2.loc = i2, m2.range = a2, m2.extra = c2, m2.name = u2, "Placeholder" === t2 && (m2.expectedNode = e2.expectedNode), m2; | |
} | |
function cloneStringLiteral(e2) { | |
const { type: t2, start: r2, end: n2, loc: i2, range: a2, extra: c2 } = e2; | |
if ("Placeholder" === t2) | |
return function(e3) { | |
return cloneIdentifier(e3); | |
}(e2); | |
const u2 = Object.create(Pa); | |
return u2.type = t2, u2.start = r2, u2.end = n2, u2.loc = i2, u2.range = a2, void 0 !== e2.raw ? u2.raw = e2.raw : u2.extra = c2, u2.value = e2.value, u2; | |
} | |
Pa.__clone = function() { | |
const e2 = new Node(void 0, this.start, this.loc.start), t2 = Object.keys(this); | |
for (let r2 = 0, n2 = t2.length; r2 < n2; r2++) { | |
const n3 = t2[r2]; | |
"leadingComments" !== n3 && "trailingComments" !== n3 && "innerComments" !== n3 && (e2[n3] = this[n3]); | |
} | |
return e2; | |
}; | |
class NodeUtils extends UtilParser { | |
startNode() { | |
return new Node(this, this.state.start, this.state.startLoc); | |
} | |
startNodeAt(e2) { | |
return new Node(this, e2.index, e2); | |
} | |
startNodeAtNode(e2) { | |
return this.startNodeAt(e2.loc.start); | |
} | |
finishNode(e2, t2) { | |
return this.finishNodeAt(e2, t2, this.state.lastTokEndLoc); | |
} | |
finishNodeAt(e2, t2, r2) { | |
return e2.type = t2, e2.end = r2.index, e2.loc.end = r2, this.options.ranges && (e2.range[1] = r2.index), this.options.attachComment && this.processComment(e2), e2; | |
} | |
resetStartLocation(e2, t2) { | |
e2.start = t2.index, e2.loc.start = t2, this.options.ranges && (e2.range[0] = t2.index); | |
} | |
resetEndLocation(e2, t2 = this.state.lastTokEndLoc) { | |
e2.end = t2.index, e2.loc.end = t2, this.options.ranges && (e2.range[1] = t2.index); | |
} | |
resetStartLocationFromNode(e2, t2) { | |
this.resetStartLocation(e2, t2.loc.start); | |
} | |
} | |
const Ta = /* @__PURE__ */ new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]), _a = ParseErrorEnum`flow`({ AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.", AmbiguousDeclareModuleKind: "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module.", AssignReservedType: ({ reservedType: e2 }) => `Cannot overwrite reserved type ${e2}.`, DeclareClassElement: "The `declare` modifier can only appear on class fields.", DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.", DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.", EnumBooleanMemberNotInitialized: ({ memberName: e2, enumName: t2 }) => `Boolean enum members need to be initialized. Use either \`${e2} = true,\` or \`${e2} = false,\` in enum \`${t2}\`.`, EnumDuplicateMemberName: ({ memberName: e2, enumName: t2 }) => `Enum member names need to be unique, but the name \`${e2}\` has already been used before in enum \`${t2}\`.`, EnumInconsistentMemberValues: ({ enumName: e2 }) => `Enum \`${e2}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`, EnumInvalidExplicitType: ({ invalidEnumType: e2, enumName: t2 }) => `Enum type \`${e2}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${t2}\`.`, EnumInvalidExplicitTypeUnknownSupplied: ({ enumName: e2 }) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${e2}\`.`, EnumInvalidMemberInitializerPrimaryType: ({ enumName: e2, memberName: t2, explicitType: r2 }) => `Enum \`${e2}\` has type \`${r2}\`, so the initializer of \`${t2}\` needs to be a ${r2} literal.`, EnumInvalidMemberInitializerSymbolType: ({ enumName: e2, memberName: t2 }) => `Symbol enum members cannot be initialized. Use \`${t2},\` in enum \`${e2}\`.`, EnumInvalidMemberInitializerUnknownType: ({ enumName: e2, memberName: t2 }) => `The enum member initializer for \`${t2}\` needs to be a literal (either a boolean, number, or string) in enum \`${e2}\`.`, EnumInvalidMemberName: ({ enumName: e2, memberName: t2, suggestion: r2 }) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${t2}\`, consider using \`${r2}\`, in enum \`${e2}\`.`, EnumNumberMemberNotInitialized: ({ enumName: e2, memberName: t2 }) => `Number enum members need to be initialized, e.g. \`${t2} = 1\` in enum \`${e2}\`.`, EnumStringMemberInconsistentlyInitailized: ({ enumName: e2 }) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${e2}\`.`, GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.", ImportReflectionHasImportType: "An `import module` declaration can not use `type` or `typeof` keyword.", ImportTypeShorthandOnlyInPureImport: "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.", InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.", InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.", InexactVariance: "Explicit inexact syntax cannot have variance.", InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.", MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.", NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.", NestedFlowComment: "Cannot have a flow comment inside another flow comment.", PatternIsOptional: Object.assign({ message: "A binding pattern parameter cannot be optional in an implementation signature." }, { reasonCode: "OptionalBindingPattern" }), SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.", SpreadVariance: "Spread properties cannot have variance.", ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.", ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.", ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.", ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.", ThisParamNoDefault: "The `this` parameter may not have a default value.", TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.", TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.", UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.", UnexpectedReservedType: ({ reservedType: e2 }) => `Unexpected reserved type ${e2}.`, UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.", UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.", UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.", UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".', UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.", UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.", UnsupportedDeclareExportKind: ({ unsupportedExportKind: e2, suggestion: t2 }) => `\`declare export ${e2}\` is not supported. Use \`${t2}\` instead.`, UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.", UnterminatedFlowComment: "Unterminated flow-comment." }); | |
function hasTypeImportKind(e2) { | |
return "type" === e2.importKind || "typeof" === e2.importKind; | |
} | |
const Ia = { const: "declare export var", let: "declare export var", type: "export type", interface: "export interface" }; | |
const Da = /\*?\s*@((?:no)?flow)\b/; | |
const Na = { __proto__: null, quot: '"', amp: "&", apos: "'", lt: "<", gt: ">", nbsp: "\xA0", iexcl: "\xA1", cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", brvbar: "\xA6", sect: "\xA7", uml: "\xA8", copy: "\xA9", ordf: "\xAA", laquo: "\xAB", not: "\xAC", shy: "\xAD", reg: "\xAE", macr: "\xAF", deg: "\xB0", plusmn: "\xB1", sup2: "\xB2", sup3: "\xB3", acute: "\xB4", micro: "\xB5", para: "\xB6", middot: "\xB7", cedil: "\xB8", sup1: "\xB9", ordm: "\xBA", raquo: "\xBB", frac14: "\xBC", frac12: "\xBD", frac34: "\xBE", iquest: "\xBF", Agrave: "\xC0", Aacute: "\xC1", Acirc: "\xC2", Atilde: "\xC3", Auml: "\xC4", Aring: "\xC5", AElig: "\xC6", Ccedil: "\xC7", Egrave: "\xC8", Eacute: "\xC9", Ecirc: "\xCA", Euml: "\xCB", Igrave: "\xCC", Iacute: "\xCD", Icirc: "\xCE", Iuml: "\xCF", ETH: "\xD0", Ntilde: "\xD1", Ograve: "\xD2", Oacute: "\xD3", Ocirc: "\xD4", Otilde: "\xD5", Ouml: "\xD6", times: "\xD7", Oslash: "\xD8", Ugrave: "\xD9", Uacute: "\xDA", Ucirc: "\xDB", Uuml: "\xDC", Yacute: "\xDD", THORN: "\xDE", szlig: "\xDF", agrave: "\xE0", aacute: "\xE1", acirc: "\xE2", atilde: "\xE3", auml: "\xE4", aring: "\xE5", aelig: "\xE6", ccedil: "\xE7", egrave: "\xE8", eacute: "\xE9", ecirc: "\xEA", euml: "\xEB", igrave: "\xEC", iacute: "\xED", icirc: "\xEE", iuml: "\xEF", eth: "\xF0", ntilde: "\xF1", ograve: "\xF2", oacute: "\xF3", ocirc: "\xF4", otilde: "\xF5", ouml: "\xF6", divide: "\xF7", oslash: "\xF8", ugrave: "\xF9", uacute: "\xFA", ucirc: "\xFB", uuml: "\xFC", yacute: "\xFD", thorn: "\xFE", yuml: "\xFF", OElig: "\u0152", oelig: "\u0153", Scaron: "\u0160", scaron: "\u0161", Yuml: "\u0178", fnof: "\u0192", circ: "\u02C6", tilde: "\u02DC", Alpha: "\u0391", Beta: "\u0392", Gamma: "\u0393", Delta: "\u0394", Epsilon: "\u0395", Zeta: "\u0396", Eta: "\u0397", Theta: "\u0398", Iota: "\u0399", Kappa: "\u039A", Lambda: "\u039B", Mu: "\u039C", Nu: "\u039D", Xi: "\u039E", Omicron: "\u039F", Pi: "\u03A0", Rho: "\u03A1", Sigma: "\u03A3", Tau: "\u03A4", Upsilon: "\u03A5", Phi: "\u03A6", Chi: "\u03A7", Psi: "\u03A8", Omega: "\u03A9", alpha: "\u03B1", beta: "\u03B2", gamma: "\u03B3", delta: "\u03B4", epsilon: "\u03B5", zeta: "\u03B6", eta: "\u03B7", theta: "\u03B8", iota: "\u03B9", kappa: "\u03BA", lambda: "\u03BB", mu: "\u03BC", nu: "\u03BD", xi: "\u03BE", omicron: "\u03BF", pi: "\u03C0", rho: "\u03C1", sigmaf: "\u03C2", sigma: "\u03C3", tau: "\u03C4", upsilon: "\u03C5", phi: "\u03C6", chi: "\u03C7", psi: "\u03C8", omega: "\u03C9", thetasym: "\u03D1", upsih: "\u03D2", piv: "\u03D6", ensp: "\u2002", emsp: "\u2003", thinsp: "\u2009", zwnj: "\u200C", zwj: "\u200D", lrm: "\u200E", rlm: "\u200F", ndash: "\u2013", mdash: "\u2014", lsquo: "\u2018", rsquo: "\u2019", sbquo: "\u201A", ldquo: "\u201C", rdquo: "\u201D", bdquo: "\u201E", dagger: "\u2020", Dagger: "\u2021", bull: "\u2022", hellip: "\u2026", permil: "\u2030", prime: "\u2032", Prime: "\u2033", lsaquo: "\u2039", rsaquo: "\u203A", oline: "\u203E", frasl: "\u2044", euro: "\u20AC", image: "\u2111", weierp: "\u2118", real: "\u211C", trade: "\u2122", alefsym: "\u2135", larr: "\u2190", uarr: "\u2191", rarr: "\u2192", darr: "\u2193", harr: "\u2194", crarr: "\u21B5", lArr: "\u21D0", uArr: "\u21D1", rArr: "\u21D2", dArr: "\u21D3", hArr: "\u21D4", forall: "\u2200", part: "\u2202", exist: "\u2203", empty: "\u2205", nabla: "\u2207", isin: "\u2208", notin: "\u2209", ni: "\u220B", prod: "\u220F", sum: "\u2211", minus: "\u2212", lowast: "\u2217", radic: "\u221A", prop: "\u221D", infin: "\u221E", ang: "\u2220", and: "\u2227", or: "\u2228", cap: "\u2229", cup: "\u222A", int: "\u222B", there4: "\u2234", sim: "\u223C", cong: "\u2245", asymp: "\u2248", ne: "\u2260", equiv: "\u2261", le: "\u2264", ge: "\u2265", sub: "\u2282", sup: "\u2283", nsub: "\u2284", sube: "\u2286", supe: "\u2287", oplus: "\u2295", otimes: "\u2297", perp: "\u22A5", sdot: "\u22C5", lceil: "\u2308", rceil: "\u2309", lfloor: "\u230A", rfloor: "\u230B", lang: "\u2329", rang: "\u232A", loz: "\u25CA", spades: "\u2660", clubs: "\u2663", hearts: "\u2665", diams: "\u2666" }, Oa = ParseErrorEnum`jsx`({ AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.", MissingClosingTagElement: ({ openingTagName: e2 }) => `Expected corresponding JSX closing tag for <${e2}>.`, MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.", UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?", UnexpectedToken: ({ unexpected: e2, HTMLEntity: t2 }) => `Unexpected token \`${e2}\`. Did you mean \`${t2}\` or \`{'${e2}'}\`?`, UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.", UnterminatedJsxContent: "Unterminated JSX contents.", UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?" }); | |
function isFragment(e2) { | |
return !!e2 && ("JSXOpeningFragment" === e2.type || "JSXClosingFragment" === e2.type); | |
} | |
function getQualifiedJSXName(e2) { | |
if ("JSXIdentifier" === e2.type) | |
return e2.name; | |
if ("JSXNamespacedName" === e2.type) | |
return e2.namespace.name + ":" + e2.name.name; | |
if ("JSXMemberExpression" === e2.type) | |
return getQualifiedJSXName(e2.object) + "." + getQualifiedJSXName(e2.property); | |
throw new Error("Node had unexpected type: " + e2.type); | |
} | |
class TypeScriptScope extends Scope { | |
constructor(...e2) { | |
super(...e2), this.types = /* @__PURE__ */ new Set(), this.enums = /* @__PURE__ */ new Set(), this.constEnums = /* @__PURE__ */ new Set(), this.classes = /* @__PURE__ */ new Set(), this.exportOnlyBindings = /* @__PURE__ */ new Set(); | |
} | |
} | |
class TypeScriptScopeHandler extends ScopeHandler { | |
constructor(...e2) { | |
super(...e2), this.importsStack = []; | |
} | |
createScope(e2) { | |
return this.importsStack.push(/* @__PURE__ */ new Set()), new TypeScriptScope(e2); | |
} | |
enter(e2) { | |
256 == e2 && this.importsStack.push(/* @__PURE__ */ new Set()), super.enter(e2); | |
} | |
exit() { | |
const e2 = super.exit(); | |
return 256 == e2 && this.importsStack.pop(), e2; | |
} | |
hasImport(e2, t2) { | |
const r2 = this.importsStack.length; | |
if (this.importsStack[r2 - 1].has(e2)) | |
return true; | |
if (!t2 && r2 > 1) { | |
for (let t3 = 0; t3 < r2 - 1; t3++) | |
if (this.importsStack[t3].has(e2)) | |
return true; | |
} | |
return false; | |
} | |
declareName(e2, t2, r2) { | |
if (4096 & t2) | |
return this.hasImport(e2, true) && this.parser.raise(Ho.VarRedeclaration, { at: r2, identifierName: e2 }), void this.importsStack[this.importsStack.length - 1].add(e2); | |
const n2 = this.currentScope(); | |
if (1024 & t2) | |
return this.maybeExportDefined(n2, e2), void n2.exportOnlyBindings.add(e2); | |
super.declareName(e2, t2, r2), 2 & t2 && (1 & t2 || (this.checkRedeclarationInScope(n2, e2, t2, r2), this.maybeExportDefined(n2, e2)), n2.types.add(e2)), 256 & t2 && n2.enums.add(e2), 512 & t2 && n2.constEnums.add(e2), 128 & t2 && n2.classes.add(e2); | |
} | |
isRedeclaredInScope(e2, t2, r2) { | |
if (e2.enums.has(t2)) { | |
if (256 & r2) { | |
return !!(512 & r2) !== e2.constEnums.has(t2); | |
} | |
return true; | |
} | |
return 128 & r2 && e2.classes.has(t2) ? !!e2.lexical.has(t2) && !!(1 & r2) : !!(2 & r2 && e2.types.has(t2)) || super.isRedeclaredInScope(e2, t2, r2); | |
} | |
checkLocalExport(e2) { | |
const { name: t2 } = e2; | |
if (this.hasImport(t2)) | |
return; | |
for (let e3 = this.scopeStack.length - 1; e3 >= 0; e3--) { | |
const r2 = this.scopeStack[e3]; | |
if (r2.types.has(t2) || r2.exportOnlyBindings.has(t2)) | |
return; | |
} | |
super.checkLocalExport(e2); | |
} | |
} | |
const unwrapParenthesizedExpression = (e2) => "ParenthesizedExpression" === e2.type ? unwrapParenthesizedExpression(e2.expression) : e2; | |
class LValParser extends NodeUtils { | |
toAssignable(e2, t2 = false) { | |
var r2, n2; | |
let i2; | |
switch (("ParenthesizedExpression" === e2.type || null != (r2 = e2.extra) && r2.parenthesized) && (i2 = unwrapParenthesizedExpression(e2), t2 ? "Identifier" === i2.type ? this.expressionScope.recordArrowParameterBindingError(Ho.InvalidParenthesizedAssignment, { at: e2 }) : "MemberExpression" !== i2.type && this.raise(Ho.InvalidParenthesizedAssignment, { at: e2 }) : this.raise(Ho.InvalidParenthesizedAssignment, { at: e2 })), e2.type) { | |
case "Identifier": | |
case "ObjectPattern": | |
case "ArrayPattern": | |
case "AssignmentPattern": | |
case "RestElement": | |
break; | |
case "ObjectExpression": | |
e2.type = "ObjectPattern"; | |
for (let r3 = 0, n3 = e2.properties.length, i3 = n3 - 1; r3 < n3; r3++) { | |
var a2; | |
const n4 = e2.properties[r3], c2 = r3 === i3; | |
this.toAssignableObjectExpressionProp(n4, c2, t2), c2 && "RestElement" === n4.type && null != (a2 = e2.extra) && a2.trailingCommaLoc && this.raise(Ho.RestTrailingComma, { at: e2.extra.trailingCommaLoc }); | |
} | |
break; | |
case "ObjectProperty": { | |
const { key: r3, value: n3 } = e2; | |
this.isPrivateName(r3) && this.classScope.usePrivateName(this.getPrivateNameSV(r3), r3.loc.start), this.toAssignable(n3, t2); | |
break; | |
} | |
case "SpreadElement": | |
throw new Error("Internal @babel/parser error (this is a bug, please report it). SpreadElement should be converted by .toAssignable's caller."); | |
case "ArrayExpression": | |
e2.type = "ArrayPattern", this.toAssignableList(e2.elements, null == (n2 = e2.extra) ? void 0 : n2.trailingCommaLoc, t2); | |
break; | |
case "AssignmentExpression": | |
"=" !== e2.operator && this.raise(Ho.MissingEqInAssignment, { at: e2.left.loc.end }), e2.type = "AssignmentPattern", delete e2.operator, this.toAssignable(e2.left, t2); | |
break; | |
case "ParenthesizedExpression": | |
this.toAssignable(i2, t2); | |
} | |
} | |
toAssignableObjectExpressionProp(e2, t2, r2) { | |
if ("ObjectMethod" === e2.type) | |
this.raise("get" === e2.kind || "set" === e2.kind ? Ho.PatternHasAccessor : Ho.PatternHasMethod, { at: e2.key }); | |
else if ("SpreadElement" === e2.type) { | |
e2.type = "RestElement"; | |
const n2 = e2.argument; | |
this.checkToRestConversion(n2, false), this.toAssignable(n2, r2), t2 || this.raise(Ho.RestTrailingComma, { at: e2 }); | |
} else | |
this.toAssignable(e2, r2); | |
} | |
toAssignableList(e2, t2, r2) { | |
const n2 = e2.length - 1; | |
for (let i2 = 0; i2 <= n2; i2++) { | |
const a2 = e2[i2]; | |
if (a2) { | |
if ("SpreadElement" === a2.type) { | |
a2.type = "RestElement"; | |
const e3 = a2.argument; | |
this.checkToRestConversion(e3, true), this.toAssignable(e3, r2); | |
} else | |
this.toAssignable(a2, r2); | |
"RestElement" === a2.type && (i2 < n2 ? this.raise(Ho.RestTrailingComma, { at: a2 }) : t2 && this.raise(Ho.RestTrailingComma, { at: t2 })); | |
} | |
} | |
} | |
isAssignable(e2, t2) { | |
switch (e2.type) { | |
case "Identifier": | |
case "ObjectPattern": | |
case "ArrayPattern": | |
case "AssignmentPattern": | |
case "RestElement": | |
return true; | |
case "ObjectExpression": { | |
const t3 = e2.properties.length - 1; | |
return e2.properties.every((e3, r2) => "ObjectMethod" !== e3.type && (r2 === t3 || "SpreadElement" !== e3.type) && this.isAssignable(e3)); | |
} | |
case "ObjectProperty": | |
return this.isAssignable(e2.value); | |
case "SpreadElement": | |
return this.isAssignable(e2.argument); | |
case "ArrayExpression": | |
return e2.elements.every((e3) => null === e3 || this.isAssignable(e3)); | |
case "AssignmentExpression": | |
return "=" === e2.operator; | |
case "ParenthesizedExpression": | |
return this.isAssignable(e2.expression); | |
case "MemberExpression": | |
case "OptionalMemberExpression": | |
return !t2; | |
default: | |
return false; | |
} | |
} | |
toReferencedList(e2, t2) { | |
return e2; | |
} | |
toReferencedListDeep(e2, t2) { | |
this.toReferencedList(e2, t2); | |
for (const t3 of e2) | |
"ArrayExpression" === (null == t3 ? void 0 : t3.type) && this.toReferencedListDeep(t3.elements); | |
} | |
parseSpread(e2) { | |
const t2 = this.startNode(); | |
return this.next(), t2.argument = this.parseMaybeAssignAllowIn(e2, void 0), this.finishNode(t2, "SpreadElement"); | |
} | |
parseRestBinding() { | |
const e2 = this.startNode(); | |
return this.next(), e2.argument = this.parseBindingAtom(), this.finishNode(e2, "RestElement"); | |
} | |
parseBindingAtom() { | |
switch (this.state.type) { | |
case 0: { | |
const e2 = this.startNode(); | |
return this.next(), e2.elements = this.parseBindingList(3, 93, 1), this.finishNode(e2, "ArrayPattern"); | |
} | |
case 5: | |
return this.parseObjectLike(8, true); | |
} | |
return this.parseIdentifier(); | |
} | |
parseBindingList(e2, t2, r2) { | |
const n2 = 1 & r2, i2 = []; | |
let a2 = true; | |
for (; !this.eat(e2); ) | |
if (a2 ? a2 = false : this.expect(12), n2 && this.match(12)) | |
i2.push(null); | |
else { | |
if (this.eat(e2)) | |
break; | |
if (this.match(21)) { | |
if (i2.push(this.parseAssignableListItemTypes(this.parseRestBinding(), r2)), !this.checkCommaAfterRest(t2)) { | |
this.expect(e2); | |
break; | |
} | |
} else { | |
const e3 = []; | |
for (this.match(26) && this.hasPlugin("decorators") && this.raise(Ho.UnsupportedParameterDecorator, { at: this.state.startLoc }); this.match(26); ) | |
e3.push(this.parseDecorator()); | |
i2.push(this.parseAssignableListItem(r2, e3)); | |
} | |
} | |
return i2; | |
} | |
parseBindingRestProperty(e2) { | |
return this.next(), e2.argument = this.parseIdentifier(), this.checkCommaAfterRest(125), this.finishNode(e2, "RestElement"); | |
} | |
parseBindingProperty() { | |
const e2 = this.startNode(), { type: t2, startLoc: r2 } = this.state; | |
return 21 === t2 ? this.parseBindingRestProperty(e2) : (136 === t2 ? (this.expectPlugin("destructuringPrivate", r2), this.classScope.usePrivateName(this.state.value, r2), e2.key = this.parsePrivateName()) : this.parsePropertyName(e2), e2.method = false, this.parseObjPropValue(e2, r2, false, false, true, false)); | |
} | |
parseAssignableListItem(e2, t2) { | |
const r2 = this.parseMaybeDefault(); | |
this.parseAssignableListItemTypes(r2, e2); | |
const n2 = this.parseMaybeDefault(r2.loc.start, r2); | |
return t2.length && (r2.decorators = t2), n2; | |
} | |
parseAssignableListItemTypes(e2, t2) { | |
return e2; | |
} | |
parseMaybeDefault(e2, t2) { | |
var r2; | |
if (null != e2 || (e2 = this.state.startLoc), t2 = null != (r2 = t2) ? r2 : this.parseBindingAtom(), !this.eat(29)) | |
return t2; | |
const n2 = this.startNodeAt(e2); | |
return n2.left = t2, n2.right = this.parseMaybeAssignAllowIn(), this.finishNode(n2, "AssignmentPattern"); | |
} | |
isValidLVal(e2, t2, r2) { | |
return n2 = { AssignmentPattern: "left", RestElement: "argument", ObjectProperty: "value", ParenthesizedExpression: "expression", ArrayPattern: "elements", ObjectPattern: "properties" }, i2 = e2, Object.hasOwnProperty.call(n2, i2) && n2[i2]; | |
var n2, i2; | |
} | |
checkLVal(e2, { in: t2, binding: r2 = 64, checkClashes: n2 = false, strictModeChanged: i2 = false, hasParenthesizedAncestor: a2 = false }) { | |
var c2; | |
const u2 = e2.type; | |
if (this.isObjectMethod(e2)) | |
return; | |
if ("MemberExpression" === u2) | |
return void (64 !== r2 && this.raise(Ho.InvalidPropertyBindingPattern, { at: e2 })); | |
if ("Identifier" === u2) { | |
this.checkIdentifier(e2, r2, i2); | |
const { name: t3 } = e2; | |
return void (n2 && (n2.has(t3) ? this.raise(Ho.ParamDupe, { at: e2 }) : n2.add(t3))); | |
} | |
const m2 = this.isValidLVal(u2, !(a2 || null != (c2 = e2.extra) && c2.parenthesized) && "AssignmentExpression" === t2.type, r2); | |
if (true === m2) | |
return; | |
if (false === m2) { | |
const n3 = 64 === r2 ? Ho.InvalidLhs : Ho.InvalidLhsBinding; | |
return void this.raise(n3, { at: e2, ancestor: t2 }); | |
} | |
const [g2, b2] = Array.isArray(m2) ? m2 : [m2, "ParenthesizedExpression" === u2], x2 = "ArrayPattern" === u2 || "ObjectPattern" === u2 || "ParenthesizedExpression" === u2 ? { type: u2 } : t2; | |
for (const t3 of [].concat(e2[g2])) | |
t3 && this.checkLVal(t3, { in: x2, binding: r2, checkClashes: n2, strictModeChanged: i2, hasParenthesizedAncestor: b2 }); | |
} | |
checkIdentifier(e2, t2, r2 = false) { | |
this.state.strict && (r2 ? isStrictBindReservedWord(e2.name, this.inModule) : isStrictBindOnlyReservedWord(e2.name)) && (64 === t2 ? this.raise(Ho.StrictEvalArguments, { at: e2, referenceName: e2.name }) : this.raise(Ho.StrictEvalArgumentsBinding, { at: e2, bindingName: e2.name })), 8192 & t2 && "let" === e2.name && this.raise(Ho.LetInLexicalBinding, { at: e2 }), 64 & t2 || this.declareNameFromIdentifier(e2, t2); | |
} | |
declareNameFromIdentifier(e2, t2) { | |
this.scope.declareName(e2.name, t2, e2.loc.start); | |
} | |
checkToRestConversion(e2, t2) { | |
switch (e2.type) { | |
case "ParenthesizedExpression": | |
this.checkToRestConversion(e2.expression, t2); | |
break; | |
case "Identifier": | |
case "MemberExpression": | |
break; | |
case "ArrayExpression": | |
case "ObjectExpression": | |
if (t2) | |
break; | |
default: | |
this.raise(Ho.InvalidRestAssignmentPattern, { at: e2 }); | |
} | |
} | |
checkCommaAfterRest(e2) { | |
return !!this.match(12) && (this.raise(this.lookaheadCharCode() === e2 ? Ho.RestTrailingComma : Ho.ElementAfterRest, { at: this.state.startLoc }), true); | |
} | |
} | |
function assert$1(e2) { | |
if (!e2) | |
throw new Error("Assert fail"); | |
} | |
const La = ParseErrorEnum`typescript`({ AbstractMethodHasImplementation: ({ methodName: e2 }) => `Method '${e2}' cannot have an implementation because it is marked abstract.`, AbstractPropertyHasInitializer: ({ propertyName: e2 }) => `Property '${e2}' cannot have an initializer because it is marked abstract.`, AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.", AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.", AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.", ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.", ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.", ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.", ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.", DeclareAccessor: ({ kind: e2 }) => `'declare' is not allowed in ${e2}ters.`, DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.", DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.", DuplicateAccessibilityModifier: ({ modifier: e2 }) => "Accessibility modifier already seen.", DuplicateModifier: ({ modifier: e2 }) => `Duplicate modifier: '${e2}'.`, EmptyHeritageClauseType: ({ token: e2 }) => `'${e2}' list cannot be empty.`, EmptyTypeArguments: "Type argument list cannot be empty.", EmptyTypeParameters: "Type parameter list cannot be empty.", ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.", ImportAliasHasImportType: "An import alias can not use 'import type'.", ImportReflectionHasImportType: "An `import module` declaration can not use `type` modifier", IncompatibleModifiers: ({ modifiers: e2 }) => `'${e2[0]}' modifier cannot be used with '${e2[1]}' modifier.`, IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.", IndexSignatureHasAccessibility: ({ modifier: e2 }) => `Index signatures cannot have an accessibility modifier ('${e2}').`, IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.", IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.", IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.", InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.", InvalidModifierOnTypeMember: ({ modifier: e2 }) => `'${e2}' modifier cannot appear on a type member.`, InvalidModifierOnTypeParameter: ({ modifier: e2 }) => `'${e2}' modifier cannot appear on a type parameter.`, InvalidModifierOnTypeParameterPositions: ({ modifier: e2 }) => `'${e2}' modifier can only appear on a type parameter of a class, interface or type alias.`, InvalidModifiersOrder: ({ orderedModifiers: e2 }) => `'${e2[0]}' modifier must precede '${e2[1]}' modifier.`, InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.", InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.", MissingInterfaceName: "'interface' declarations must be followed by an identifier.", MixedLabeledAndUnlabeledElements: "Tuple members must all have names or all not have names.", NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.", NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.", OptionalTypeBeforeRequired: "A required element cannot follow an optional element.", OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.", PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.", PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.", PrivateElementHasAccessibility: ({ modifier: e2 }) => `Private elements cannot have an accessibility modifier ('${e2}').`, ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.", ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.", ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.", SetAccesorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.", SetAccesorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.", SetAccesorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.", SingleTypeParameterWithoutTrailingComma: ({ typeParameterName: e2 }) => `Single type parameter ${e2} should have a trailing comma. Example usage: <${e2},>.`, StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.", TupleOptionalAfterType: "A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).", TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.", TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.", TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.", TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.", UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.", UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.", UnexpectedTypeAnnotation: "Did not expect a type annotation here.", UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.", UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.", UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.", UnsupportedSignatureParameterKind: ({ type: e2 }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${e2}.` }); | |
function tsIsAccessModifier(e2) { | |
return "private" === e2 || "public" === e2 || "protected" === e2; | |
} | |
function tsIsVarianceAnnotations(e2) { | |
return "in" === e2 || "out" === e2; | |
} | |
function isPossiblyLiteralEnum(e2) { | |
if ("MemberExpression" !== e2.type) | |
return false; | |
const { computed: t2, property: r2 } = e2; | |
return (!t2 || "StringLiteral" === r2.type || !("TemplateLiteral" !== r2.type || r2.expressions.length > 0)) && isUncomputedMemberExpressionChain(e2.object); | |
} | |
function isValidAmbientConstInitializer(e2, t2) { | |
var r2; | |
const { type: n2 } = e2; | |
if (null != (r2 = e2.extra) && r2.parenthesized) | |
return false; | |
if (t2) { | |
if ("Literal" === n2) { | |
const { value: t3 } = e2; | |
if ("string" == typeof t3 || "boolean" == typeof t3) | |
return true; | |
} | |
} else if ("StringLiteral" === n2 || "BooleanLiteral" === n2) | |
return true; | |
return !(!isNumber(e2, t2) && !function(e3, t3) { | |
if ("UnaryExpression" === e3.type) { | |
const { operator: r3, argument: n3 } = e3; | |
if ("-" === r3 && isNumber(n3, t3)) | |
return true; | |
} | |
return false; | |
}(e2, t2)) || ("TemplateLiteral" === n2 && 0 === e2.expressions.length || !!isPossiblyLiteralEnum(e2)); | |
} | |
function isNumber(e2, t2) { | |
return t2 ? "Literal" === e2.type && ("number" == typeof e2.value || "bigint" in e2) : "NumericLiteral" === e2.type || "BigIntLiteral" === e2.type; | |
} | |
function isUncomputedMemberExpressionChain(e2) { | |
return "Identifier" === e2.type || "MemberExpression" === e2.type && !e2.computed && isUncomputedMemberExpressionChain(e2.object); | |
} | |
const Ra = ParseErrorEnum`placeholders`({ ClassNameIsRequired: "A class name is required.", UnexpectedSpace: "Unexpected space in placeholder." }); | |
function hasPlugin(e2, t2) { | |
const [r2, n2] = "string" == typeof t2 ? [t2, {}] : t2, i2 = Object.keys(n2), a2 = 0 === i2.length; | |
return e2.some((e3) => { | |
if ("string" == typeof e3) | |
return a2 && e3 === r2; | |
{ | |
const [t3, a3] = e3; | |
if (t3 !== r2) | |
return false; | |
for (const e4 of i2) | |
if (a3[e4] !== n2[e4]) | |
return false; | |
return true; | |
} | |
}); | |
} | |
function getPluginOption(e2, t2, r2) { | |
const n2 = e2.find((e3) => Array.isArray(e3) ? e3[0] === t2 : e3 === t2); | |
return n2 && Array.isArray(n2) && n2.length > 1 ? n2[1][r2] : null; | |
} | |
const Ma = ["minimal", "fsharp", "hack", "smart"], Fa = ["^^", "@@", "^", "%", "#"], Ba = ["hash", "bar"]; | |
const ja = { estree: (e2) => class extends e2 { | |
parse() { | |
const e3 = toESTreeLocation(super.parse()); | |
return this.options.tokens && (e3.tokens = e3.tokens.map(toESTreeLocation)), e3; | |
} | |
parseRegExpLiteral({ pattern: e3, flags: t2 }) { | |
let r2 = null; | |
try { | |
r2 = new RegExp(e3, t2); | |
} catch (e4) { | |
} | |
const n2 = this.estreeParseLiteral(r2); | |
return n2.regex = { pattern: e3, flags: t2 }, n2; | |
} | |
parseBigIntLiteral(e3) { | |
let t2; | |
try { | |
t2 = BigInt(e3); | |
} catch (e4) { | |
t2 = null; | |
} | |
const r2 = this.estreeParseLiteral(t2); | |
return r2.bigint = String(r2.value || e3), r2; | |
} | |
parseDecimalLiteral(e3) { | |
const t2 = this.estreeParseLiteral(null); | |
return t2.decimal = String(t2.value || e3), t2; | |
} | |
estreeParseLiteral(e3) { | |
return this.parseLiteral(e3, "Literal"); | |
} | |
parseStringLiteral(e3) { | |
return this.estreeParseLiteral(e3); | |
} | |
parseNumericLiteral(e3) { | |
return this.estreeParseLiteral(e3); | |
} | |
parseNullLiteral() { | |
return this.estreeParseLiteral(null); | |
} | |
parseBooleanLiteral(e3) { | |
return this.estreeParseLiteral(e3); | |
} | |
directiveToStmt(e3) { | |
const t2 = e3.value; | |
delete e3.value, t2.type = "Literal", t2.raw = t2.extra.raw, t2.value = t2.extra.expressionValue; | |
const r2 = e3; | |
return r2.type = "ExpressionStatement", r2.expression = t2, r2.directive = t2.extra.rawValue, delete t2.extra, r2; | |
} | |
initFunction(e3, t2) { | |
super.initFunction(e3, t2), e3.expression = false; | |
} | |
checkDeclaration(e3) { | |
null != e3 && this.isObjectProperty(e3) ? this.checkDeclaration(e3.value) : super.checkDeclaration(e3); | |
} | |
getObjectOrClassMethodParams(e3) { | |
return e3.value.params; | |
} | |
isValidDirective(e3) { | |
var t2; | |
return "ExpressionStatement" === e3.type && "Literal" === e3.expression.type && "string" == typeof e3.expression.value && !(null != (t2 = e3.expression.extra) && t2.parenthesized); | |
} | |
parseBlockBody(e3, t2, r2, n2, i2) { | |
super.parseBlockBody(e3, t2, r2, n2, i2); | |
const a2 = e3.directives.map((e4) => this.directiveToStmt(e4)); | |
e3.body = a2.concat(e3.body), delete e3.directives; | |
} | |
pushClassMethod(e3, t2, r2, n2, i2, a2) { | |
this.parseMethod(t2, r2, n2, i2, a2, "ClassMethod", true), t2.typeParameters && (t2.value.typeParameters = t2.typeParameters, delete t2.typeParameters), e3.body.push(t2); | |
} | |
parsePrivateName() { | |
const e3 = super.parsePrivateName(); | |
return this.getPluginOption("estree", "classFeatures") ? this.convertPrivateNameToPrivateIdentifier(e3) : e3; | |
} | |
convertPrivateNameToPrivateIdentifier(e3) { | |
const t2 = super.getPrivateNameSV(e3); | |
return delete e3.id, e3.name = t2, e3.type = "PrivateIdentifier", e3; | |
} | |
isPrivateName(e3) { | |
return this.getPluginOption("estree", "classFeatures") ? "PrivateIdentifier" === e3.type : super.isPrivateName(e3); | |
} | |
getPrivateNameSV(e3) { | |
return this.getPluginOption("estree", "classFeatures") ? e3.name : super.getPrivateNameSV(e3); | |
} | |
parseLiteral(e3, t2) { | |
const r2 = super.parseLiteral(e3, t2); | |
return r2.raw = r2.extra.raw, delete r2.extra, r2; | |
} | |
parseFunctionBody(e3, t2, r2 = false) { | |
super.parseFunctionBody(e3, t2, r2), e3.expression = "BlockStatement" !== e3.body.type; | |
} | |
parseMethod(e3, t2, r2, n2, i2, a2, c2 = false) { | |
let u2 = this.startNode(); | |
return u2.kind = e3.kind, u2 = super.parseMethod(u2, t2, r2, n2, i2, a2, c2), u2.type = "FunctionExpression", delete u2.kind, e3.value = u2, "ClassPrivateMethod" === a2 && (e3.computed = false), this.finishNode(e3, "MethodDefinition"); | |
} | |
parseClassProperty(...e3) { | |
const t2 = super.parseClassProperty(...e3); | |
return this.getPluginOption("estree", "classFeatures") ? (t2.type = "PropertyDefinition", t2) : t2; | |
} | |
parseClassPrivateProperty(...e3) { | |
const t2 = super.parseClassPrivateProperty(...e3); | |
return this.getPluginOption("estree", "classFeatures") ? (t2.type = "PropertyDefinition", t2.computed = false, t2) : t2; | |
} | |
parseObjectMethod(e3, t2, r2, n2, i2) { | |
const a2 = super.parseObjectMethod(e3, t2, r2, n2, i2); | |
return a2 && (a2.type = "Property", "method" === a2.kind && (a2.kind = "init"), a2.shorthand = false), a2; | |
} | |
parseObjectProperty(e3, t2, r2, n2) { | |
const i2 = super.parseObjectProperty(e3, t2, r2, n2); | |
return i2 && (i2.kind = "init", i2.type = "Property"), i2; | |
} | |
isValidLVal(e3, t2, r2) { | |
return "Property" === e3 ? "value" : super.isValidLVal(e3, t2, r2); | |
} | |
isAssignable(e3, t2) { | |
return null != e3 && this.isObjectProperty(e3) ? this.isAssignable(e3.value, t2) : super.isAssignable(e3, t2); | |
} | |
toAssignable(e3, t2 = false) { | |
if (null != e3 && this.isObjectProperty(e3)) { | |
const { key: r2, value: n2 } = e3; | |
this.isPrivateName(r2) && this.classScope.usePrivateName(this.getPrivateNameSV(r2), r2.loc.start), this.toAssignable(n2, t2); | |
} else | |
super.toAssignable(e3, t2); | |
} | |
toAssignableObjectExpressionProp(e3, t2, r2) { | |
"get" === e3.kind || "set" === e3.kind ? this.raise(Ho.PatternHasAccessor, { at: e3.key }) : e3.method ? this.raise(Ho.PatternHasMethod, { at: e3.key }) : super.toAssignableObjectExpressionProp(e3, t2, r2); | |
} | |
finishCallExpression(e3, t2) { | |
const r2 = super.finishCallExpression(e3, t2); | |
if ("Import" === r2.callee.type) { | |
var n2; | |
if (r2.type = "ImportExpression", r2.source = r2.arguments[0], this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) | |
r2.attributes = null != (n2 = r2.arguments[1]) ? n2 : null; | |
delete r2.arguments, delete r2.callee; | |
} | |
return r2; | |
} | |
toReferencedArguments(e3) { | |
"ImportExpression" !== e3.type && super.toReferencedArguments(e3); | |
} | |
parseExport(e3, t2) { | |
const r2 = this.state.lastTokStartLoc, n2 = super.parseExport(e3, t2); | |
switch (n2.type) { | |
case "ExportAllDeclaration": | |
n2.exported = null; | |
break; | |
case "ExportNamedDeclaration": | |
1 === n2.specifiers.length && "ExportNamespaceSpecifier" === n2.specifiers[0].type && (n2.type = "ExportAllDeclaration", n2.exported = n2.specifiers[0].exported, delete n2.specifiers); | |
case "ExportDefaultDeclaration": { | |
var i2; | |
const { declaration: e4 } = n2; | |
"ClassDeclaration" === (null == e4 ? void 0 : e4.type) && (null == (i2 = e4.decorators) ? void 0 : i2.length) > 0 && e4.start === n2.start && this.resetStartLocation(n2, r2); | |
} | |
} | |
return n2; | |
} | |
parseSubscript(e3, t2, r2, n2) { | |
const i2 = super.parseSubscript(e3, t2, r2, n2); | |
if (n2.optionalChainMember) { | |
if ("OptionalMemberExpression" !== i2.type && "OptionalCallExpression" !== i2.type || (i2.type = i2.type.substring(8)), n2.stop) { | |
const e4 = this.startNodeAtNode(i2); | |
return e4.expression = i2, this.finishNode(e4, "ChainExpression"); | |
} | |
} else | |
"MemberExpression" !== i2.type && "CallExpression" !== i2.type || (i2.optional = false); | |
return i2; | |
} | |
hasPropertyAsPrivateName(e3) { | |
return "ChainExpression" === e3.type && (e3 = e3.expression), super.hasPropertyAsPrivateName(e3); | |
} | |
isObjectProperty(e3) { | |
return "Property" === e3.type && "init" === e3.kind && !e3.method; | |
} | |
isObjectMethod(e3) { | |
return e3.method || "get" === e3.kind || "set" === e3.kind; | |
} | |
finishNodeAt(e3, t2, r2) { | |
return toESTreeLocation(super.finishNodeAt(e3, t2, r2)); | |
} | |
resetStartLocation(e3, t2) { | |
super.resetStartLocation(e3, t2), toESTreeLocation(e3); | |
} | |
resetEndLocation(e3, t2 = this.state.lastTokEndLoc) { | |
super.resetEndLocation(e3, t2), toESTreeLocation(e3); | |
} | |
}, jsx: (e2) => class extends e2 { | |
jsxReadToken() { | |
let e3 = "", t2 = this.state.pos; | |
for (; ; ) { | |
if (this.state.pos >= this.length) | |
throw this.raise(Oa.UnterminatedJsxContent, { at: this.state.startLoc }); | |
const r2 = this.input.charCodeAt(this.state.pos); | |
switch (r2) { | |
case 60: | |
case 123: | |
return this.state.pos === this.state.start ? void (60 === r2 && this.state.canStartJSXElement ? (++this.state.pos, this.finishToken(140)) : super.getTokenFromCode(r2)) : (e3 += this.input.slice(t2, this.state.pos), void this.finishToken(139, e3)); | |
case 38: | |
e3 += this.input.slice(t2, this.state.pos), e3 += this.jsxReadEntity(), t2 = this.state.pos; | |
break; | |
default: | |
isNewLine(r2) ? (e3 += this.input.slice(t2, this.state.pos), e3 += this.jsxReadNewLine(true), t2 = this.state.pos) : ++this.state.pos; | |
} | |
} | |
} | |
jsxReadNewLine(e3) { | |
const t2 = this.input.charCodeAt(this.state.pos); | |
let r2; | |
return ++this.state.pos, 13 === t2 && 10 === this.input.charCodeAt(this.state.pos) ? (++this.state.pos, r2 = e3 ? "\n" : "\r\n") : r2 = String.fromCharCode(t2), ++this.state.curLine, this.state.lineStart = this.state.pos, r2; | |
} | |
jsxReadString(e3) { | |
let t2 = "", r2 = ++this.state.pos; | |
for (; ; ) { | |
if (this.state.pos >= this.length) | |
throw this.raise(Ho.UnterminatedString, { at: this.state.startLoc }); | |
const n2 = this.input.charCodeAt(this.state.pos); | |
if (n2 === e3) | |
break; | |
38 === n2 ? (t2 += this.input.slice(r2, this.state.pos), t2 += this.jsxReadEntity(), r2 = this.state.pos) : isNewLine(n2) ? (t2 += this.input.slice(r2, this.state.pos), t2 += this.jsxReadNewLine(false), r2 = this.state.pos) : ++this.state.pos; | |
} | |
t2 += this.input.slice(r2, this.state.pos++), this.finishToken(131, t2); | |
} | |
jsxReadEntity() { | |
const e3 = ++this.state.pos; | |
if (35 === this.codePointAtPos(this.state.pos)) { | |
++this.state.pos; | |
let e4 = 10; | |
120 === this.codePointAtPos(this.state.pos) && (e4 = 16, ++this.state.pos); | |
const t2 = this.readInt(e4, void 0, false, "bail"); | |
if (null !== t2 && 59 === this.codePointAtPos(this.state.pos)) | |
return ++this.state.pos, String.fromCodePoint(t2); | |
} else { | |
let t2 = 0, r2 = false; | |
for (; t2++ < 10 && this.state.pos < this.length && !(r2 = 59 == this.codePointAtPos(this.state.pos)); ) | |
++this.state.pos; | |
if (r2) { | |
const t3 = this.input.slice(e3, this.state.pos), r3 = Na[t3]; | |
if (++this.state.pos, r3) | |
return r3; | |
} | |
} | |
return this.state.pos = e3, "&"; | |
} | |
jsxReadWord() { | |
let e3; | |
const t2 = this.state.pos; | |
do { | |
e3 = this.input.charCodeAt(++this.state.pos); | |
} while (isIdentifierChar(e3) || 45 === e3); | |
this.finishToken(138, this.input.slice(t2, this.state.pos)); | |
} | |
jsxParseIdentifier() { | |
const e3 = this.startNode(); | |
return this.match(138) ? e3.name = this.state.value : tokenIsKeyword(this.state.type) ? e3.name = tokenLabelName(this.state.type) : this.unexpected(), this.next(), this.finishNode(e3, "JSXIdentifier"); | |
} | |
jsxParseNamespacedName() { | |
const e3 = this.state.startLoc, t2 = this.jsxParseIdentifier(); | |
if (!this.eat(14)) | |
return t2; | |
const r2 = this.startNodeAt(e3); | |
return r2.namespace = t2, r2.name = this.jsxParseIdentifier(), this.finishNode(r2, "JSXNamespacedName"); | |
} | |
jsxParseElementName() { | |
const e3 = this.state.startLoc; | |
let t2 = this.jsxParseNamespacedName(); | |
if ("JSXNamespacedName" === t2.type) | |
return t2; | |
for (; this.eat(16); ) { | |
const r2 = this.startNodeAt(e3); | |
r2.object = t2, r2.property = this.jsxParseIdentifier(), t2 = this.finishNode(r2, "JSXMemberExpression"); | |
} | |
return t2; | |
} | |
jsxParseAttributeValue() { | |
let e3; | |
switch (this.state.type) { | |
case 5: | |
return e3 = this.startNode(), this.setContext(zo.brace), this.next(), e3 = this.jsxParseExpressionContainer(e3, zo.j_oTag), "JSXEmptyExpression" === e3.expression.type && this.raise(Oa.AttributeIsEmpty, { at: e3 }), e3; | |
case 140: | |
case 131: | |
return this.parseExprAtom(); | |
default: | |
throw this.raise(Oa.UnsupportedJsxValue, { at: this.state.startLoc }); | |
} | |
} | |
jsxParseEmptyExpression() { | |
const e3 = this.startNodeAt(this.state.lastTokEndLoc); | |
return this.finishNodeAt(e3, "JSXEmptyExpression", this.state.startLoc); | |
} | |
jsxParseSpreadChild(e3) { | |
return this.next(), e3.expression = this.parseExpression(), this.setContext(zo.j_expr), this.state.canStartJSXElement = true, this.expect(8), this.finishNode(e3, "JSXSpreadChild"); | |
} | |
jsxParseExpressionContainer(e3, t2) { | |
if (this.match(8)) | |
e3.expression = this.jsxParseEmptyExpression(); | |
else { | |
const t3 = this.parseExpression(); | |
e3.expression = t3; | |
} | |
return this.setContext(t2), this.state.canStartJSXElement = true, this.expect(8), this.finishNode(e3, "JSXExpressionContainer"); | |
} | |
jsxParseAttribute() { | |
const e3 = this.startNode(); | |
return this.match(5) ? (this.setContext(zo.brace), this.next(), this.expect(21), e3.argument = this.parseMaybeAssignAllowIn(), this.setContext(zo.j_oTag), this.state.canStartJSXElement = true, this.expect(8), this.finishNode(e3, "JSXSpreadAttribute")) : (e3.name = this.jsxParseNamespacedName(), e3.value = this.eat(29) ? this.jsxParseAttributeValue() : null, this.finishNode(e3, "JSXAttribute")); | |
} | |
jsxParseOpeningElementAt(e3) { | |
const t2 = this.startNodeAt(e3); | |
return this.eat(141) ? this.finishNode(t2, "JSXOpeningFragment") : (t2.name = this.jsxParseElementName(), this.jsxParseOpeningElementAfterName(t2)); | |
} | |
jsxParseOpeningElementAfterName(e3) { | |
const t2 = []; | |
for (; !this.match(56) && !this.match(141); ) | |
t2.push(this.jsxParseAttribute()); | |
return e3.attributes = t2, e3.selfClosing = this.eat(56), this.expect(141), this.finishNode(e3, "JSXOpeningElement"); | |
} | |
jsxParseClosingElementAt(e3) { | |
const t2 = this.startNodeAt(e3); | |
return this.eat(141) ? this.finishNode(t2, "JSXClosingFragment") : (t2.name = this.jsxParseElementName(), this.expect(141), this.finishNode(t2, "JSXClosingElement")); | |
} | |
jsxParseElementAt(e3) { | |
const t2 = this.startNodeAt(e3), r2 = [], n2 = this.jsxParseOpeningElementAt(e3); | |
let i2 = null; | |
if (!n2.selfClosing) { | |
e: | |
for (; ; ) | |
switch (this.state.type) { | |
case 140: | |
if (e3 = this.state.startLoc, this.next(), this.eat(56)) { | |
i2 = this.jsxParseClosingElementAt(e3); | |
break e; | |
} | |
r2.push(this.jsxParseElementAt(e3)); | |
break; | |
case 139: | |
r2.push(this.parseExprAtom()); | |
break; | |
case 5: { | |
const e4 = this.startNode(); | |
this.setContext(zo.brace), this.next(), this.match(21) ? r2.push(this.jsxParseSpreadChild(e4)) : r2.push(this.jsxParseExpressionContainer(e4, zo.j_expr)); | |
break; | |
} | |
default: | |
this.unexpected(); | |
} | |
isFragment(n2) && !isFragment(i2) && null !== i2 ? this.raise(Oa.MissingClosingTagFragment, { at: i2 }) : !isFragment(n2) && isFragment(i2) ? this.raise(Oa.MissingClosingTagElement, { at: i2, openingTagName: getQualifiedJSXName(n2.name) }) : isFragment(n2) || isFragment(i2) || getQualifiedJSXName(i2.name) !== getQualifiedJSXName(n2.name) && this.raise(Oa.MissingClosingTagElement, { at: i2, openingTagName: getQualifiedJSXName(n2.name) }); | |
} | |
if (isFragment(n2) ? (t2.openingFragment = n2, t2.closingFragment = i2) : (t2.openingElement = n2, t2.closingElement = i2), t2.children = r2, this.match(47)) | |
throw this.raise(Oa.UnwrappedAdjacentJSXElements, { at: this.state.startLoc }); | |
return isFragment(n2) ? this.finishNode(t2, "JSXFragment") : this.finishNode(t2, "JSXElement"); | |
} | |
jsxParseElement() { | |
const e3 = this.state.startLoc; | |
return this.next(), this.jsxParseElementAt(e3); | |
} | |
setContext(e3) { | |
const { context: t2 } = this.state; | |
t2[t2.length - 1] = e3; | |
} | |
parseExprAtom(e3) { | |
return this.match(139) ? this.parseLiteral(this.state.value, "JSXText") : this.match(140) ? this.jsxParseElement() : this.match(47) && 33 !== this.input.charCodeAt(this.state.pos) ? (this.replaceToken(140), this.jsxParseElement()) : super.parseExprAtom(e3); | |
} | |
skipSpace() { | |
this.curContext().preserveSpace || super.skipSpace(); | |
} | |
getTokenFromCode(e3) { | |
const t2 = this.curContext(); | |
if (t2 !== zo.j_expr) { | |
if (t2 === zo.j_oTag || t2 === zo.j_cTag) { | |
if (isIdentifierStart(e3)) | |
return void this.jsxReadWord(); | |
if (62 === e3) | |
return ++this.state.pos, void this.finishToken(141); | |
if ((34 === e3 || 39 === e3) && t2 === zo.j_oTag) | |
return void this.jsxReadString(e3); | |
} | |
if (60 === e3 && this.state.canStartJSXElement && 33 !== this.input.charCodeAt(this.state.pos + 1)) | |
return ++this.state.pos, void this.finishToken(140); | |
super.getTokenFromCode(e3); | |
} else | |
this.jsxReadToken(); | |
} | |
updateContext(e3) { | |
const { context: t2, type: r2 } = this.state; | |
if (56 === r2 && 140 === e3) | |
t2.splice(-2, 2, zo.j_cTag), this.state.canStartJSXElement = false; | |
else if (140 === r2) | |
t2.push(zo.j_oTag); | |
else if (141 === r2) { | |
const r3 = t2[t2.length - 1]; | |
r3 === zo.j_oTag && 56 === e3 || r3 === zo.j_cTag ? (t2.pop(), this.state.canStartJSXElement = t2[t2.length - 1] === zo.j_expr) : (this.setContext(zo.j_expr), this.state.canStartJSXElement = true); | |
} else | |
this.state.canStartJSXElement = ta[r2]; | |
} | |
}, flow: (e2) => class extends e2 { | |
constructor(...e3) { | |
super(...e3), this.flowPragma = void 0; | |
} | |
getScopeHandler() { | |
return FlowScopeHandler; | |
} | |
shouldParseTypes() { | |
return this.getPluginOption("flow", "all") || "flow" === this.flowPragma; | |
} | |
shouldParseEnums() { | |
return !!this.getPluginOption("flow", "enums"); | |
} | |
finishToken(e3, t2) { | |
131 !== e3 && 13 !== e3 && 28 !== e3 && void 0 === this.flowPragma && (this.flowPragma = null), super.finishToken(e3, t2); | |
} | |
addComment(e3) { | |
if (void 0 === this.flowPragma) { | |
const t2 = Da.exec(e3.value); | |
if (t2) | |
if ("flow" === t2[1]) | |
this.flowPragma = "flow"; | |
else { | |
if ("noflow" !== t2[1]) | |
throw new Error("Unexpected flow pragma"); | |
this.flowPragma = "noflow"; | |
} | |
else | |
; | |
} | |
super.addComment(e3); | |
} | |
flowParseTypeInitialiser(e3) { | |
const t2 = this.state.inType; | |
this.state.inType = true, this.expect(e3 || 14); | |
const r2 = this.flowParseType(); | |
return this.state.inType = t2, r2; | |
} | |
flowParsePredicate() { | |
const e3 = this.startNode(), t2 = this.state.startLoc; | |
return this.next(), this.expectContextual(108), this.state.lastTokStart > t2.index + 1 && this.raise(_a.UnexpectedSpaceBetweenModuloChecks, { at: t2 }), this.eat(10) ? (e3.value = super.parseExpression(), this.expect(11), this.finishNode(e3, "DeclaredPredicate")) : this.finishNode(e3, "InferredPredicate"); | |
} | |
flowParseTypeAndPredicateInitialiser() { | |
const e3 = this.state.inType; | |
this.state.inType = true, this.expect(14); | |
let t2 = null, r2 = null; | |
return this.match(54) ? (this.state.inType = e3, r2 = this.flowParsePredicate()) : (t2 = this.flowParseType(), this.state.inType = e3, this.match(54) && (r2 = this.flowParsePredicate())), [t2, r2]; | |
} | |
flowParseDeclareClass(e3) { | |
return this.next(), this.flowParseInterfaceish(e3, true), this.finishNode(e3, "DeclareClass"); | |
} | |
flowParseDeclareFunction(e3) { | |
this.next(); | |
const t2 = e3.id = this.parseIdentifier(), r2 = this.startNode(), n2 = this.startNode(); | |
this.match(47) ? r2.typeParameters = this.flowParseTypeParameterDeclaration() : r2.typeParameters = null, this.expect(10); | |
const i2 = this.flowParseFunctionTypeParams(); | |
return r2.params = i2.params, r2.rest = i2.rest, r2.this = i2._this, this.expect(11), [r2.returnType, e3.predicate] = this.flowParseTypeAndPredicateInitialiser(), n2.typeAnnotation = this.finishNode(r2, "FunctionTypeAnnotation"), t2.typeAnnotation = this.finishNode(n2, "TypeAnnotation"), this.resetEndLocation(t2), this.semicolon(), this.scope.declareName(e3.id.name, 2048, e3.id.loc.start), this.finishNode(e3, "DeclareFunction"); | |
} | |
flowParseDeclare(e3, t2) { | |
return this.match(80) ? this.flowParseDeclareClass(e3) : this.match(68) ? this.flowParseDeclareFunction(e3) : this.match(74) ? this.flowParseDeclareVariable(e3) : this.eatContextual(125) ? this.match(16) ? this.flowParseDeclareModuleExports(e3) : (t2 && this.raise(_a.NestedDeclareModule, { at: this.state.lastTokStartLoc }), this.flowParseDeclareModule(e3)) : this.isContextual(128) ? this.flowParseDeclareTypeAlias(e3) : this.isContextual(129) ? this.flowParseDeclareOpaqueType(e3) : this.isContextual(127) ? this.flowParseDeclareInterface(e3) : this.match(82) ? this.flowParseDeclareExportDeclaration(e3, t2) : void this.unexpected(); | |
} | |
flowParseDeclareVariable(e3) { | |
return this.next(), e3.id = this.flowParseTypeAnnotatableIdentifier(true), this.scope.declareName(e3.id.name, 5, e3.id.loc.start), this.semicolon(), this.finishNode(e3, "DeclareVariable"); | |
} | |
flowParseDeclareModule(e3) { | |
this.scope.enter(0), this.match(131) ? e3.id = super.parseExprAtom() : e3.id = this.parseIdentifier(); | |
const t2 = e3.body = this.startNode(), r2 = t2.body = []; | |
for (this.expect(5); !this.match(8); ) { | |
let e4 = this.startNode(); | |
this.match(83) ? (this.next(), this.isContextual(128) || this.match(87) || this.raise(_a.InvalidNonTypeImportInDeclareModule, { at: this.state.lastTokStartLoc }), super.parseImport(e4)) : (this.expectContextual(123, _a.UnsupportedStatementInDeclareModule), e4 = this.flowParseDeclare(e4, true)), r2.push(e4); | |
} | |
this.scope.exit(), this.expect(8), this.finishNode(t2, "BlockStatement"); | |
let n2 = null, i2 = false; | |
return r2.forEach((e4) => { | |
!function(e5) { | |
return "DeclareExportAllDeclaration" === e5.type || "DeclareExportDeclaration" === e5.type && (!e5.declaration || "TypeAlias" !== e5.declaration.type && "InterfaceDeclaration" !== e5.declaration.type); | |
}(e4) ? "DeclareModuleExports" === e4.type && (i2 && this.raise(_a.DuplicateDeclareModuleExports, { at: e4 }), "ES" === n2 && this.raise(_a.AmbiguousDeclareModuleKind, { at: e4 }), n2 = "CommonJS", i2 = true) : ("CommonJS" === n2 && this.raise(_a.AmbiguousDeclareModuleKind, { at: e4 }), n2 = "ES"); | |
}), e3.kind = n2 || "CommonJS", this.finishNode(e3, "DeclareModule"); | |
} | |
flowParseDeclareExportDeclaration(e3, t2) { | |
if (this.expect(82), this.eat(65)) | |
return this.match(68) || this.match(80) ? e3.declaration = this.flowParseDeclare(this.startNode()) : (e3.declaration = this.flowParseType(), this.semicolon()), e3.default = true, this.finishNode(e3, "DeclareExportDeclaration"); | |
if (this.match(75) || this.isLet() || (this.isContextual(128) || this.isContextual(127)) && !t2) { | |
const e4 = this.state.value; | |
throw this.raise(_a.UnsupportedDeclareExportKind, { at: this.state.startLoc, unsupportedExportKind: e4, suggestion: Ia[e4] }); | |
} | |
return this.match(74) || this.match(68) || this.match(80) || this.isContextual(129) ? (e3.declaration = this.flowParseDeclare(this.startNode()), e3.default = false, this.finishNode(e3, "DeclareExportDeclaration")) : this.match(55) || this.match(5) || this.isContextual(127) || this.isContextual(128) || this.isContextual(129) ? ("ExportNamedDeclaration" === (e3 = this.parseExport(e3, null)).type && (e3.type = "ExportDeclaration", e3.default = false, delete e3.exportKind), e3.type = "Declare" + e3.type, e3) : void this.unexpected(); | |
} | |
flowParseDeclareModuleExports(e3) { | |
return this.next(), this.expectContextual(109), e3.typeAnnotation = this.flowParseTypeAnnotation(), this.semicolon(), this.finishNode(e3, "DeclareModuleExports"); | |
} | |
flowParseDeclareTypeAlias(e3) { | |
this.next(); | |
const t2 = this.flowParseTypeAlias(e3); | |
return t2.type = "DeclareTypeAlias", t2; | |
} | |
flowParseDeclareOpaqueType(e3) { | |
this.next(); | |
const t2 = this.flowParseOpaqueType(e3, true); | |
return t2.type = "DeclareOpaqueType", t2; | |
} | |
flowParseDeclareInterface(e3) { | |
return this.next(), this.flowParseInterfaceish(e3, false), this.finishNode(e3, "DeclareInterface"); | |
} | |
flowParseInterfaceish(e3, t2) { | |
if (e3.id = this.flowParseRestrictedIdentifier(!t2, true), this.scope.declareName(e3.id.name, t2 ? 17 : 8201, e3.id.loc.start), this.match(47) ? e3.typeParameters = this.flowParseTypeParameterDeclaration() : e3.typeParameters = null, e3.extends = [], this.eat(81)) | |
do { | |
e3.extends.push(this.flowParseInterfaceExtends()); | |
} while (!t2 && this.eat(12)); | |
if (t2) { | |
if (e3.implements = [], e3.mixins = [], this.eatContextual(115)) | |
do { | |
e3.mixins.push(this.flowParseInterfaceExtends()); | |
} while (this.eat(12)); | |
if (this.eatContextual(111)) | |
do { | |
e3.implements.push(this.flowParseInterfaceExtends()); | |
} while (this.eat(12)); | |
} | |
e3.body = this.flowParseObjectType({ allowStatic: t2, allowExact: false, allowSpread: false, allowProto: t2, allowInexact: false }); | |
} | |
flowParseInterfaceExtends() { | |
const e3 = this.startNode(); | |
return e3.id = this.flowParseQualifiedTypeIdentifier(), this.match(47) ? e3.typeParameters = this.flowParseTypeParameterInstantiation() : e3.typeParameters = null, this.finishNode(e3, "InterfaceExtends"); | |
} | |
flowParseInterface(e3) { | |
return this.flowParseInterfaceish(e3, false), this.finishNode(e3, "InterfaceDeclaration"); | |
} | |
checkNotUnderscore(e3) { | |
"_" === e3 && this.raise(_a.UnexpectedReservedUnderscore, { at: this.state.startLoc }); | |
} | |
checkReservedType(e3, t2, r2) { | |
Ta.has(e3) && this.raise(r2 ? _a.AssignReservedType : _a.UnexpectedReservedType, { at: t2, reservedType: e3 }); | |
} | |
flowParseRestrictedIdentifier(e3, t2) { | |
return this.checkReservedType(this.state.value, this.state.startLoc, t2), this.parseIdentifier(e3); | |
} | |
flowParseTypeAlias(e3) { | |
return e3.id = this.flowParseRestrictedIdentifier(false, true), this.scope.declareName(e3.id.name, 8201, e3.id.loc.start), this.match(47) ? e3.typeParameters = this.flowParseTypeParameterDeclaration() : e3.typeParameters = null, e3.right = this.flowParseTypeInitialiser(29), this.semicolon(), this.finishNode(e3, "TypeAlias"); | |
} | |
flowParseOpaqueType(e3, t2) { | |
return this.expectContextual(128), e3.id = this.flowParseRestrictedIdentifier(true, true), this.scope.declareName(e3.id.name, 8201, e3.id.loc.start), this.match(47) ? e3.typeParameters = this.flowParseTypeParameterDeclaration() : e3.typeParameters = null, e3.supertype = null, this.match(14) && (e3.supertype = this.flowParseTypeInitialiser(14)), e3.impltype = null, t2 || (e3.impltype = this.flowParseTypeInitialiser(29)), this.semicolon(), this.finishNode(e3, "OpaqueType"); | |
} | |
flowParseTypeParameter(e3 = false) { | |
const t2 = this.state.startLoc, r2 = this.startNode(), n2 = this.flowParseVariance(), i2 = this.flowParseTypeAnnotatableIdentifier(); | |
return r2.name = i2.name, r2.variance = n2, r2.bound = i2.typeAnnotation, this.match(29) ? (this.eat(29), r2.default = this.flowParseType()) : e3 && this.raise(_a.MissingTypeParamDefault, { at: t2 }), this.finishNode(r2, "TypeParameter"); | |
} | |
flowParseTypeParameterDeclaration() { | |
const e3 = this.state.inType, t2 = this.startNode(); | |
t2.params = [], this.state.inType = true, this.match(47) || this.match(140) ? this.next() : this.unexpected(); | |
let r2 = false; | |
do { | |
const e4 = this.flowParseTypeParameter(r2); | |
t2.params.push(e4), e4.default && (r2 = true), this.match(48) || this.expect(12); | |
} while (!this.match(48)); | |
return this.expect(48), this.state.inType = e3, this.finishNode(t2, "TypeParameterDeclaration"); | |
} | |
flowParseTypeParameterInstantiation() { | |
const e3 = this.startNode(), t2 = this.state.inType; | |
e3.params = [], this.state.inType = true, this.expect(47); | |
const r2 = this.state.noAnonFunctionType; | |
for (this.state.noAnonFunctionType = false; !this.match(48); ) | |
e3.params.push(this.flowParseType()), this.match(48) || this.expect(12); | |
return this.state.noAnonFunctionType = r2, this.expect(48), this.state.inType = t2, this.finishNode(e3, "TypeParameterInstantiation"); | |
} | |
flowParseTypeParameterInstantiationCallOrNew() { | |
const e3 = this.startNode(), t2 = this.state.inType; | |
for (e3.params = [], this.state.inType = true, this.expect(47); !this.match(48); ) | |
e3.params.push(this.flowParseTypeOrImplicitInstantiation()), this.match(48) || this.expect(12); | |
return this.expect(48), this.state.inType = t2, this.finishNode(e3, "TypeParameterInstantiation"); | |
} | |
flowParseInterfaceType() { | |
const e3 = this.startNode(); | |
if (this.expectContextual(127), e3.extends = [], this.eat(81)) | |
do { | |
e3.extends.push(this.flowParseInterfaceExtends()); | |
} while (this.eat(12)); | |
return e3.body = this.flowParseObjectType({ allowStatic: false, allowExact: false, allowSpread: false, allowProto: false, allowInexact: false }), this.finishNode(e3, "InterfaceTypeAnnotation"); | |
} | |
flowParseObjectPropertyKey() { | |
return this.match(132) || this.match(131) ? super.parseExprAtom() : this.parseIdentifier(true); | |
} | |
flowParseObjectTypeIndexer(e3, t2, r2) { | |
return e3.static = t2, 14 === this.lookahead().type ? (e3.id = this.flowParseObjectPropertyKey(), e3.key = this.flowParseTypeInitialiser()) : (e3.id = null, e3.key = this.flowParseType()), this.expect(3), e3.value = this.flowParseTypeInitialiser(), e3.variance = r2, this.finishNode(e3, "ObjectTypeIndexer"); | |
} | |
flowParseObjectTypeInternalSlot(e3, t2) { | |
return e3.static = t2, e3.id = this.flowParseObjectPropertyKey(), this.expect(3), this.expect(3), this.match(47) || this.match(10) ? (e3.method = true, e3.optional = false, e3.value = this.flowParseObjectTypeMethodish(this.startNodeAt(e3.loc.start))) : (e3.method = false, this.eat(17) && (e3.optional = true), e3.value = this.flowParseTypeInitialiser()), this.finishNode(e3, "ObjectTypeInternalSlot"); | |
} | |
flowParseObjectTypeMethodish(e3) { | |
for (e3.params = [], e3.rest = null, e3.typeParameters = null, e3.this = null, this.match(47) && (e3.typeParameters = this.flowParseTypeParameterDeclaration()), this.expect(10), this.match(78) && (e3.this = this.flowParseFunctionTypeParam(true), e3.this.name = null, this.match(11) || this.expect(12)); !this.match(11) && !this.match(21); ) | |
e3.params.push(this.flowParseFunctionTypeParam(false)), this.match(11) || this.expect(12); | |
return this.eat(21) && (e3.rest = this.flowParseFunctionTypeParam(false)), this.expect(11), e3.returnType = this.flowParseTypeInitialiser(), this.finishNode(e3, "FunctionTypeAnnotation"); | |
} | |
flowParseObjectTypeCallProperty(e3, t2) { | |
const r2 = this.startNode(); | |
return e3.static = t2, e3.value = this.flowParseObjectTypeMethodish(r2), this.finishNode(e3, "ObjectTypeCallProperty"); | |
} | |
flowParseObjectType({ allowStatic: e3, allowExact: t2, allowSpread: r2, allowProto: n2, allowInexact: i2 }) { | |
const a2 = this.state.inType; | |
this.state.inType = true; | |
const c2 = this.startNode(); | |
let u2, m2; | |
c2.callProperties = [], c2.properties = [], c2.indexers = [], c2.internalSlots = []; | |
let g2 = false; | |
for (t2 && this.match(6) ? (this.expect(6), u2 = 9, m2 = true) : (this.expect(5), u2 = 8, m2 = false), c2.exact = m2; !this.match(u2); ) { | |
let t3 = false, a3 = null, u3 = null; | |
const b3 = this.startNode(); | |
if (n2 && this.isContextual(116)) { | |
const t4 = this.lookahead(); | |
14 !== t4.type && 17 !== t4.type && (this.next(), a3 = this.state.startLoc, e3 = false); | |
} | |
if (e3 && this.isContextual(104)) { | |
const e4 = this.lookahead(); | |
14 !== e4.type && 17 !== e4.type && (this.next(), t3 = true); | |
} | |
const x2 = this.flowParseVariance(); | |
if (this.eat(0)) | |
null != a3 && this.unexpected(a3), this.eat(0) ? (x2 && this.unexpected(x2.loc.start), c2.internalSlots.push(this.flowParseObjectTypeInternalSlot(b3, t3))) : c2.indexers.push(this.flowParseObjectTypeIndexer(b3, t3, x2)); | |
else if (this.match(10) || this.match(47)) | |
null != a3 && this.unexpected(a3), x2 && this.unexpected(x2.loc.start), c2.callProperties.push(this.flowParseObjectTypeCallProperty(b3, t3)); | |
else { | |
let e4 = "init"; | |
if (this.isContextual(98) || this.isContextual(103)) { | |
tokenIsLiteralPropertyName(this.lookahead().type) && (e4 = this.state.value, this.next()); | |
} | |
const n3 = this.flowParseObjectTypeProperty(b3, t3, a3, x2, e4, r2, null != i2 ? i2 : !m2); | |
null === n3 ? (g2 = true, u3 = this.state.lastTokStartLoc) : c2.properties.push(n3); | |
} | |
this.flowObjectTypeSemicolon(), !u3 || this.match(8) || this.match(9) || this.raise(_a.UnexpectedExplicitInexactInObject, { at: u3 }); | |
} | |
this.expect(u2), r2 && (c2.inexact = g2); | |
const b2 = this.finishNode(c2, "ObjectTypeAnnotation"); | |
return this.state.inType = a2, b2; | |
} | |
flowParseObjectTypeProperty(e3, t2, r2, n2, i2, a2, c2) { | |
if (this.eat(21)) { | |
return this.match(12) || this.match(13) || this.match(8) || this.match(9) ? (a2 ? c2 || this.raise(_a.InexactInsideExact, { at: this.state.lastTokStartLoc }) : this.raise(_a.InexactInsideNonObject, { at: this.state.lastTokStartLoc }), n2 && this.raise(_a.InexactVariance, { at: n2 }), null) : (a2 || this.raise(_a.UnexpectedSpreadType, { at: this.state.lastTokStartLoc }), null != r2 && this.unexpected(r2), n2 && this.raise(_a.SpreadVariance, { at: n2 }), e3.argument = this.flowParseType(), this.finishNode(e3, "ObjectTypeSpreadProperty")); | |
} | |
{ | |
e3.key = this.flowParseObjectPropertyKey(), e3.static = t2, e3.proto = null != r2, e3.kind = i2; | |
let c3 = false; | |
return this.match(47) || this.match(10) ? (e3.method = true, null != r2 && this.unexpected(r2), n2 && this.unexpected(n2.loc.start), e3.value = this.flowParseObjectTypeMethodish(this.startNodeAt(e3.loc.start)), "get" !== i2 && "set" !== i2 || this.flowCheckGetterSetterParams(e3), !a2 && "constructor" === e3.key.name && e3.value.this && this.raise(_a.ThisParamBannedInConstructor, { at: e3.value.this })) : ("init" !== i2 && this.unexpected(), e3.method = false, this.eat(17) && (c3 = true), e3.value = this.flowParseTypeInitialiser(), e3.variance = n2), e3.optional = c3, this.finishNode(e3, "ObjectTypeProperty"); | |
} | |
} | |
flowCheckGetterSetterParams(e3) { | |
const t2 = "get" === e3.kind ? 0 : 1, r2 = e3.value.params.length + (e3.value.rest ? 1 : 0); | |
e3.value.this && this.raise("get" === e3.kind ? _a.GetterMayNotHaveThisParam : _a.SetterMayNotHaveThisParam, { at: e3.value.this }), r2 !== t2 && this.raise("get" === e3.kind ? Ho.BadGetterArity : Ho.BadSetterArity, { at: e3 }), "set" === e3.kind && e3.value.rest && this.raise(Ho.BadSetterRestParameter, { at: e3 }); | |
} | |
flowObjectTypeSemicolon() { | |
this.eat(13) || this.eat(12) || this.match(8) || this.match(9) || this.unexpected(); | |
} | |
flowParseQualifiedTypeIdentifier(e3, t2) { | |
null != e3 || (e3 = this.state.startLoc); | |
let r2 = t2 || this.flowParseRestrictedIdentifier(true); | |
for (; this.eat(16); ) { | |
const t3 = this.startNodeAt(e3); | |
t3.qualification = r2, t3.id = this.flowParseRestrictedIdentifier(true), r2 = this.finishNode(t3, "QualifiedTypeIdentifier"); | |
} | |
return r2; | |
} | |
flowParseGenericType(e3, t2) { | |
const r2 = this.startNodeAt(e3); | |
return r2.typeParameters = null, r2.id = this.flowParseQualifiedTypeIdentifier(e3, t2), this.match(47) && (r2.typeParameters = this.flowParseTypeParameterInstantiation()), this.finishNode(r2, "GenericTypeAnnotation"); | |
} | |
flowParseTypeofType() { | |
const e3 = this.startNode(); | |
return this.expect(87), e3.argument = this.flowParsePrimaryType(), this.finishNode(e3, "TypeofTypeAnnotation"); | |
} | |
flowParseTupleType() { | |
const e3 = this.startNode(); | |
for (e3.types = [], this.expect(0); this.state.pos < this.length && !this.match(3) && (e3.types.push(this.flowParseType()), !this.match(3)); ) | |
this.expect(12); | |
return this.expect(3), this.finishNode(e3, "TupleTypeAnnotation"); | |
} | |
flowParseFunctionTypeParam(e3) { | |
let t2 = null, r2 = false, n2 = null; | |
const i2 = this.startNode(), a2 = this.lookahead(), c2 = 78 === this.state.type; | |
return 14 === a2.type || 17 === a2.type ? (c2 && !e3 && this.raise(_a.ThisParamMustBeFirst, { at: i2 }), t2 = this.parseIdentifier(c2), this.eat(17) && (r2 = true, c2 && this.raise(_a.ThisParamMayNotBeOptional, { at: i2 })), n2 = this.flowParseTypeInitialiser()) : n2 = this.flowParseType(), i2.name = t2, i2.optional = r2, i2.typeAnnotation = n2, this.finishNode(i2, "FunctionTypeParam"); | |
} | |
reinterpretTypeAsFunctionTypeParam(e3) { | |
const t2 = this.startNodeAt(e3.loc.start); | |
return t2.name = null, t2.optional = false, t2.typeAnnotation = e3, this.finishNode(t2, "FunctionTypeParam"); | |
} | |
flowParseFunctionTypeParams(e3 = []) { | |
let t2 = null, r2 = null; | |
for (this.match(78) && (r2 = this.flowParseFunctionTypeParam(true), r2.name = null, this.match(11) || this.expect(12)); !this.match(11) && !this.match(21); ) | |
e3.push(this.flowParseFunctionTypeParam(false)), this.match(11) || this.expect(12); | |
return this.eat(21) && (t2 = this.flowParseFunctionTypeParam(false)), { params: e3, rest: t2, _this: r2 }; | |
} | |
flowIdentToTypeAnnotation(e3, t2, r2) { | |
switch (r2.name) { | |
case "any": | |
return this.finishNode(t2, "AnyTypeAnnotation"); | |
case "bool": | |
case "boolean": | |
return this.finishNode(t2, "BooleanTypeAnnotation"); | |
case "mixed": | |
return this.finishNode(t2, "MixedTypeAnnotation"); | |
case "empty": | |
return this.finishNode(t2, "EmptyTypeAnnotation"); | |
case "number": | |
return this.finishNode(t2, "NumberTypeAnnotation"); | |
case "string": | |
return this.finishNode(t2, "StringTypeAnnotation"); | |
case "symbol": | |
return this.finishNode(t2, "SymbolTypeAnnotation"); | |
default: | |
return this.checkNotUnderscore(r2.name), this.flowParseGenericType(e3, r2); | |
} | |
} | |
flowParsePrimaryType() { | |
const e3 = this.state.startLoc, t2 = this.startNode(); | |
let r2, n2, i2 = false; | |
const a2 = this.state.noAnonFunctionType; | |
switch (this.state.type) { | |
case 5: | |
return this.flowParseObjectType({ allowStatic: false, allowExact: false, allowSpread: true, allowProto: false, allowInexact: true }); | |
case 6: | |
return this.flowParseObjectType({ allowStatic: false, allowExact: true, allowSpread: true, allowProto: false, allowInexact: false }); | |
case 0: | |
return this.state.noAnonFunctionType = false, n2 = this.flowParseTupleType(), this.state.noAnonFunctionType = a2, n2; | |
case 47: | |
return t2.typeParameters = this.flowParseTypeParameterDeclaration(), this.expect(10), r2 = this.flowParseFunctionTypeParams(), t2.params = r2.params, t2.rest = r2.rest, t2.this = r2._this, this.expect(11), this.expect(19), t2.returnType = this.flowParseType(), this.finishNode(t2, "FunctionTypeAnnotation"); | |
case 10: | |
if (this.next(), !this.match(11) && !this.match(21)) | |
if (tokenIsIdentifier(this.state.type) || this.match(78)) { | |
const e4 = this.lookahead().type; | |
i2 = 17 !== e4 && 14 !== e4; | |
} else | |
i2 = true; | |
if (i2) { | |
if (this.state.noAnonFunctionType = false, n2 = this.flowParseType(), this.state.noAnonFunctionType = a2, this.state.noAnonFunctionType || !(this.match(12) || this.match(11) && 19 === this.lookahead().type)) | |
return this.expect(11), n2; | |
this.eat(12); | |
} | |
return r2 = n2 ? this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(n2)]) : this.flowParseFunctionTypeParams(), t2.params = r2.params, t2.rest = r2.rest, t2.this = r2._this, this.expect(11), this.expect(19), t2.returnType = this.flowParseType(), t2.typeParameters = null, this.finishNode(t2, "FunctionTypeAnnotation"); | |
case 131: | |
return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation"); | |
case 85: | |
case 86: | |
return t2.value = this.match(85), this.next(), this.finishNode(t2, "BooleanLiteralTypeAnnotation"); | |
case 53: | |
if ("-" === this.state.value) { | |
if (this.next(), this.match(132)) | |
return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", t2); | |
if (this.match(133)) | |
return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", t2); | |
throw this.raise(_a.UnexpectedSubtractionOperand, { at: this.state.startLoc }); | |
} | |
return void this.unexpected(); | |
case 132: | |
return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation"); | |
case 133: | |
return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation"); | |
case 88: | |
return this.next(), this.finishNode(t2, "VoidTypeAnnotation"); | |
case 84: | |
return this.next(), this.finishNode(t2, "NullLiteralTypeAnnotation"); | |
case 78: | |
return this.next(), this.finishNode(t2, "ThisTypeAnnotation"); | |
case 55: | |
return this.next(), this.finishNode(t2, "ExistsTypeAnnotation"); | |
case 87: | |
return this.flowParseTypeofType(); | |
default: | |
if (tokenIsKeyword(this.state.type)) { | |
const e4 = tokenLabelName(this.state.type); | |
return this.next(), super.createIdentifier(t2, e4); | |
} | |
if (tokenIsIdentifier(this.state.type)) | |
return this.isContextual(127) ? this.flowParseInterfaceType() : this.flowIdentToTypeAnnotation(e3, t2, this.parseIdentifier()); | |
} | |
this.unexpected(); | |
} | |
flowParsePostfixType() { | |
const e3 = this.state.startLoc; | |
let t2 = this.flowParsePrimaryType(), r2 = false; | |
for (; (this.match(0) || this.match(18)) && !this.canInsertSemicolon(); ) { | |
const n2 = this.startNodeAt(e3), i2 = this.eat(18); | |
r2 = r2 || i2, this.expect(0), !i2 && this.match(3) ? (n2.elementType = t2, this.next(), t2 = this.finishNode(n2, "ArrayTypeAnnotation")) : (n2.objectType = t2, n2.indexType = this.flowParseType(), this.expect(3), r2 ? (n2.optional = i2, t2 = this.finishNode(n2, "OptionalIndexedAccessType")) : t2 = this.finishNode(n2, "IndexedAccessType")); | |
} | |
return t2; | |
} | |
flowParsePrefixType() { | |
const e3 = this.startNode(); | |
return this.eat(17) ? (e3.typeAnnotation = this.flowParsePrefixType(), this.finishNode(e3, "NullableTypeAnnotation")) : this.flowParsePostfixType(); | |
} | |
flowParseAnonFunctionWithoutParens() { | |
const e3 = this.flowParsePrefixType(); | |
if (!this.state.noAnonFunctionType && this.eat(19)) { | |
const t2 = this.startNodeAt(e3.loc.start); | |
return t2.params = [this.reinterpretTypeAsFunctionTypeParam(e3)], t2.rest = null, t2.this = null, t2.returnType = this.flowParseType(), t2.typeParameters = null, this.finishNode(t2, "FunctionTypeAnnotation"); | |
} | |
return e3; | |
} | |
flowParseIntersectionType() { | |
const e3 = this.startNode(); | |
this.eat(45); | |
const t2 = this.flowParseAnonFunctionWithoutParens(); | |
for (e3.types = [t2]; this.eat(45); ) | |
e3.types.push(this.flowParseAnonFunctionWithoutParens()); | |
return 1 === e3.types.length ? t2 : this.finishNode(e3, "IntersectionTypeAnnotation"); | |
} | |
flowParseUnionType() { | |
const e3 = this.startNode(); | |
this.eat(43); | |
const t2 = this.flowParseIntersectionType(); | |
for (e3.types = [t2]; this.eat(43); ) | |
e3.types.push(this.flowParseIntersectionType()); | |
return 1 === e3.types.length ? t2 : this.finishNode(e3, "UnionTypeAnnotation"); | |
} | |
flowParseType() { | |
const e3 = this.state.inType; | |
this.state.inType = true; | |
const t2 = this.flowParseUnionType(); | |
return this.state.inType = e3, t2; | |
} | |
flowParseTypeOrImplicitInstantiation() { | |
if (130 === this.state.type && "_" === this.state.value) { | |
const e3 = this.state.startLoc, t2 = this.parseIdentifier(); | |
return this.flowParseGenericType(e3, t2); | |
} | |
return this.flowParseType(); | |
} | |
flowParseTypeAnnotation() { | |
const e3 = this.startNode(); | |
return e3.typeAnnotation = this.flowParseTypeInitialiser(), this.finishNode(e3, "TypeAnnotation"); | |
} | |
flowParseTypeAnnotatableIdentifier(e3) { | |
const t2 = e3 ? this.parseIdentifier() : this.flowParseRestrictedIdentifier(); | |
return this.match(14) && (t2.typeAnnotation = this.flowParseTypeAnnotation(), this.resetEndLocation(t2)), t2; | |
} | |
typeCastToParameter(e3) { | |
return e3.expression.typeAnnotation = e3.typeAnnotation, this.resetEndLocation(e3.expression, e3.typeAnnotation.loc.end), e3.expression; | |
} | |
flowParseVariance() { | |
let e3 = null; | |
return this.match(53) ? (e3 = this.startNode(), "+" === this.state.value ? e3.kind = "plus" : e3.kind = "minus", this.next(), this.finishNode(e3, "Variance")) : e3; | |
} | |
parseFunctionBody(e3, t2, r2 = false) { | |
t2 ? this.forwardNoArrowParamsConversionAt(e3, () => super.parseFunctionBody(e3, true, r2)) : super.parseFunctionBody(e3, false, r2); | |
} | |
parseFunctionBodyAndFinish(e3, t2, r2 = false) { | |
if (this.match(14)) { | |
const t3 = this.startNode(); | |
[t3.typeAnnotation, e3.predicate] = this.flowParseTypeAndPredicateInitialiser(), e3.returnType = t3.typeAnnotation ? this.finishNode(t3, "TypeAnnotation") : null; | |
} | |
return super.parseFunctionBodyAndFinish(e3, t2, r2); | |
} | |
parseStatementLike(e3) { | |
if (this.state.strict && this.isContextual(127)) { | |
if (tokenIsKeywordOrIdentifier(this.lookahead().type)) { | |
const e4 = this.startNode(); | |
return this.next(), this.flowParseInterface(e4); | |
} | |
} else if (this.shouldParseEnums() && this.isContextual(124)) { | |
const e4 = this.startNode(); | |
return this.next(), this.flowParseEnumDeclaration(e4); | |
} | |
const t2 = super.parseStatementLike(e3); | |
return void 0 !== this.flowPragma || this.isValidDirective(t2) || (this.flowPragma = null), t2; | |
} | |
parseExpressionStatement(e3, t2, r2) { | |
if ("Identifier" === t2.type) { | |
if ("declare" === t2.name) { | |
if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) | |
return this.flowParseDeclare(e3); | |
} else if (tokenIsIdentifier(this.state.type)) { | |
if ("interface" === t2.name) | |
return this.flowParseInterface(e3); | |
if ("type" === t2.name) | |
return this.flowParseTypeAlias(e3); | |
if ("opaque" === t2.name) | |
return this.flowParseOpaqueType(e3, false); | |
} | |
} | |
return super.parseExpressionStatement(e3, t2, r2); | |
} | |
shouldParseExportDeclaration() { | |
const { type: e3 } = this.state; | |
return tokenIsFlowInterfaceOrTypeOrOpaque(e3) || this.shouldParseEnums() && 124 === e3 ? !this.state.containsEsc : super.shouldParseExportDeclaration(); | |
} | |
isExportDefaultSpecifier() { | |
const { type: e3 } = this.state; | |
return tokenIsFlowInterfaceOrTypeOrOpaque(e3) || this.shouldParseEnums() && 124 === e3 ? this.state.containsEsc : super.isExportDefaultSpecifier(); | |
} | |
parseExportDefaultExpression() { | |
if (this.shouldParseEnums() && this.isContextual(124)) { | |
const e3 = this.startNode(); | |
return this.next(), this.flowParseEnumDeclaration(e3); | |
} | |
return super.parseExportDefaultExpression(); | |
} | |
parseConditional(e3, t2, r2) { | |
if (!this.match(17)) | |
return e3; | |
if (this.state.maybeInArrowParameters) { | |
const t3 = this.lookaheadCharCode(); | |
if (44 === t3 || 61 === t3 || 58 === t3 || 41 === t3) | |
return this.setOptionalParametersError(r2), e3; | |
} | |
this.expect(17); | |
const n2 = this.state.clone(), i2 = this.state.noArrowAt, a2 = this.startNodeAt(t2); | |
let { consequent: c2, failed: u2 } = this.tryParseConditionalConsequent(), [m2, g2] = this.getArrowLikeExpressions(c2); | |
if (u2 || g2.length > 0) { | |
const e4 = [...i2]; | |
if (g2.length > 0) { | |
this.state = n2, this.state.noArrowAt = e4; | |
for (let t3 = 0; t3 < g2.length; t3++) | |
e4.push(g2[t3].start); | |
({ consequent: c2, failed: u2 } = this.tryParseConditionalConsequent()), [m2, g2] = this.getArrowLikeExpressions(c2); | |
} | |
u2 && m2.length > 1 && this.raise(_a.AmbiguousConditionalArrow, { at: n2.startLoc }), u2 && 1 === m2.length && (this.state = n2, e4.push(m2[0].start), this.state.noArrowAt = e4, { consequent: c2, failed: u2 } = this.tryParseConditionalConsequent()); | |
} | |
return this.getArrowLikeExpressions(c2, true), this.state.noArrowAt = i2, this.expect(14), a2.test = e3, a2.consequent = c2, a2.alternate = this.forwardNoArrowParamsConversionAt(a2, () => this.parseMaybeAssign(void 0, void 0)), this.finishNode(a2, "ConditionalExpression"); | |
} | |
tryParseConditionalConsequent() { | |
this.state.noArrowParamsConversionAt.push(this.state.start); | |
const e3 = this.parseMaybeAssignAllowIn(), t2 = !this.match(14); | |
return this.state.noArrowParamsConversionAt.pop(), { consequent: e3, failed: t2 }; | |
} | |
getArrowLikeExpressions(e3, t2) { | |
const r2 = [e3], n2 = []; | |
for (; 0 !== r2.length; ) { | |
const e4 = r2.pop(); | |
"ArrowFunctionExpression" === e4.type ? (e4.typeParameters || !e4.returnType ? this.finishArrowValidation(e4) : n2.push(e4), r2.push(e4.body)) : "ConditionalExpression" === e4.type && (r2.push(e4.consequent), r2.push(e4.alternate)); | |
} | |
return t2 ? (n2.forEach((e4) => this.finishArrowValidation(e4)), [n2, []]) : function(e4, t3) { | |
const r3 = [], n3 = []; | |
for (let i2 = 0; i2 < e4.length; i2++) | |
(t3(e4[i2], i2, e4) ? r3 : n3).push(e4[i2]); | |
return [r3, n3]; | |
}(n2, (e4) => e4.params.every((e5) => this.isAssignable(e5, true))); | |
} | |
finishArrowValidation(e3) { | |
var t2; | |
this.toAssignableList(e3.params, null == (t2 = e3.extra) ? void 0 : t2.trailingCommaLoc, false), this.scope.enter(6), super.checkParams(e3, false, true), this.scope.exit(); | |
} | |
forwardNoArrowParamsConversionAt(e3, t2) { | |
let r2; | |
return -1 !== this.state.noArrowParamsConversionAt.indexOf(e3.start) ? (this.state.noArrowParamsConversionAt.push(this.state.start), r2 = t2(), this.state.noArrowParamsConversionAt.pop()) : r2 = t2(), r2; | |
} | |
parseParenItem(e3, t2) { | |
if (e3 = super.parseParenItem(e3, t2), this.eat(17) && (e3.optional = true, this.resetEndLocation(e3)), this.match(14)) { | |
const r2 = this.startNodeAt(t2); | |
return r2.expression = e3, r2.typeAnnotation = this.flowParseTypeAnnotation(), this.finishNode(r2, "TypeCastExpression"); | |
} | |
return e3; | |
} | |
assertModuleNodeAllowed(e3) { | |
"ImportDeclaration" === e3.type && ("type" === e3.importKind || "typeof" === e3.importKind) || "ExportNamedDeclaration" === e3.type && "type" === e3.exportKind || "ExportAllDeclaration" === e3.type && "type" === e3.exportKind || super.assertModuleNodeAllowed(e3); | |
} | |
parseExportDeclaration(e3) { | |
if (this.isContextual(128)) { | |
e3.exportKind = "type"; | |
const t2 = this.startNode(); | |
return this.next(), this.match(5) ? (e3.specifiers = this.parseExportSpecifiers(true), super.parseExportFrom(e3), null) : this.flowParseTypeAlias(t2); | |
} | |
if (this.isContextual(129)) { | |
e3.exportKind = "type"; | |
const t2 = this.startNode(); | |
return this.next(), this.flowParseOpaqueType(t2, false); | |
} | |
if (this.isContextual(127)) { | |
e3.exportKind = "type"; | |
const t2 = this.startNode(); | |
return this.next(), this.flowParseInterface(t2); | |
} | |
if (this.shouldParseEnums() && this.isContextual(124)) { | |
e3.exportKind = "value"; | |
const t2 = this.startNode(); | |
return this.next(), this.flowParseEnumDeclaration(t2); | |
} | |
return super.parseExportDeclaration(e3); | |
} | |
eatExportStar(e3) { | |
return !!super.eatExportStar(e3) || !(!this.isContextual(128) || 55 !== this.lookahead().type) && (e3.exportKind = "type", this.next(), this.next(), true); | |
} | |
maybeParseExportNamespaceSpecifier(e3) { | |
const { startLoc: t2 } = this.state, r2 = super.maybeParseExportNamespaceSpecifier(e3); | |
return r2 && "type" === e3.exportKind && this.unexpected(t2), r2; | |
} | |
parseClassId(e3, t2, r2) { | |
super.parseClassId(e3, t2, r2), this.match(47) && (e3.typeParameters = this.flowParseTypeParameterDeclaration()); | |
} | |
parseClassMember(e3, t2, r2) { | |
const { startLoc: n2 } = this.state; | |
if (this.isContextual(123)) { | |
if (super.parseClassMemberFromModifier(e3, t2)) | |
return; | |
t2.declare = true; | |
} | |
super.parseClassMember(e3, t2, r2), t2.declare && ("ClassProperty" !== t2.type && "ClassPrivateProperty" !== t2.type && "PropertyDefinition" !== t2.type ? this.raise(_a.DeclareClassElement, { at: n2 }) : t2.value && this.raise(_a.DeclareClassFieldInitializer, { at: t2.value })); | |
} | |
isIterator(e3) { | |
return "iterator" === e3 || "asyncIterator" === e3; | |
} | |
readIterator() { | |
const e3 = super.readWord1(), t2 = "@@" + e3; | |
this.isIterator(e3) && this.state.inType || this.raise(Ho.InvalidIdentifier, { at: this.state.curPosition(), identifierName: t2 }), this.finishToken(130, t2); | |
} | |
getTokenFromCode(e3) { | |
const t2 = this.input.charCodeAt(this.state.pos + 1); | |
123 === e3 && 124 === t2 ? this.finishOp(6, 2) : !this.state.inType || 62 !== e3 && 60 !== e3 ? this.state.inType && 63 === e3 ? 46 === t2 ? this.finishOp(18, 2) : this.finishOp(17, 1) : !function(e4, t3, r2) { | |
return 64 === e4 && 64 === t3 && isIdentifierStart(r2); | |
}(e3, t2, this.input.charCodeAt(this.state.pos + 2)) ? super.getTokenFromCode(e3) : (this.state.pos += 2, this.readIterator()) : this.finishOp(62 === e3 ? 48 : 47, 1); | |
} | |
isAssignable(e3, t2) { | |
return "TypeCastExpression" === e3.type ? this.isAssignable(e3.expression, t2) : super.isAssignable(e3, t2); | |
} | |
toAssignable(e3, t2 = false) { | |
t2 || "AssignmentExpression" !== e3.type || "TypeCastExpression" !== e3.left.type || (e3.left = this.typeCastToParameter(e3.left)), super.toAssignable(e3, t2); | |
} | |
toAssignableList(e3, t2, r2) { | |
for (let t3 = 0; t3 < e3.length; t3++) { | |
const r3 = e3[t3]; | |
"TypeCastExpression" === (null == r3 ? void 0 : r3.type) && (e3[t3] = this.typeCastToParameter(r3)); | |
} | |
super.toAssignableList(e3, t2, r2); | |
} | |
toReferencedList(e3, t2) { | |
for (let n2 = 0; n2 < e3.length; n2++) { | |
var r2; | |
const i2 = e3[n2]; | |
!i2 || "TypeCastExpression" !== i2.type || null != (r2 = i2.extra) && r2.parenthesized || !(e3.length > 1) && t2 || this.raise(_a.TypeCastInPattern, { at: i2.typeAnnotation }); | |
} | |
return e3; | |
} | |
parseArrayLike(e3, t2, r2, n2) { | |
const i2 = super.parseArrayLike(e3, t2, r2, n2); | |
return t2 && !this.state.maybeInArrowParameters && this.toReferencedList(i2.elements), i2; | |
} | |
isValidLVal(e3, t2, r2) { | |
return "TypeCastExpression" === e3 || super.isValidLVal(e3, t2, r2); | |
} | |
parseClassProperty(e3) { | |
return this.match(14) && (e3.typeAnnotation = this.flowParseTypeAnnotation()), super.parseClassProperty(e3); | |
} | |
parseClassPrivateProperty(e3) { | |
return this.match(14) && (e3.typeAnnotation = this.flowParseTypeAnnotation()), super.parseClassPrivateProperty(e3); | |
} | |
isClassMethod() { | |
return this.match(47) || super.isClassMethod(); | |
} | |
isClassProperty() { | |
return this.match(14) || super.isClassProperty(); | |
} | |
isNonstaticConstructor(e3) { | |
return !this.match(14) && super.isNonstaticConstructor(e3); | |
} | |
pushClassMethod(e3, t2, r2, n2, i2, a2) { | |
if (t2.variance && this.unexpected(t2.variance.loc.start), delete t2.variance, this.match(47) && (t2.typeParameters = this.flowParseTypeParameterDeclaration()), super.pushClassMethod(e3, t2, r2, n2, i2, a2), t2.params && i2) { | |
const e4 = t2.params; | |
e4.length > 0 && this.isThisParam(e4[0]) && this.raise(_a.ThisParamBannedInConstructor, { at: t2 }); | |
} else if ("MethodDefinition" === t2.type && i2 && t2.value.params) { | |
const e4 = t2.value.params; | |
e4.length > 0 && this.isThisParam(e4[0]) && this.raise(_a.ThisParamBannedInConstructor, { at: t2 }); | |
} | |
} | |
pushClassPrivateMethod(e3, t2, r2, n2) { | |
t2.variance && this.unexpected(t2.variance.loc.start), delete t2.variance, this.match(47) && (t2.typeParameters = this.flowParseTypeParameterDeclaration()), super.pushClassPrivateMethod(e3, t2, r2, n2); | |
} | |
parseClassSuper(e3) { | |
if (super.parseClassSuper(e3), e3.superClass && this.match(47) && (e3.superTypeParameters = this.flowParseTypeParameterInstantiation()), this.isContextual(111)) { | |
this.next(); | |
const t2 = e3.implements = []; | |
do { | |
const e4 = this.startNode(); | |
e4.id = this.flowParseRestrictedIdentifier(true), this.match(47) ? e4.typeParameters = this.flowParseTypeParameterInstantiation() : e4.typeParameters = null, t2.push(this.finishNode(e4, "ClassImplements")); | |
} while (this.eat(12)); | |
} | |
} | |
checkGetterSetterParams(e3) { | |
super.checkGetterSetterParams(e3); | |
const t2 = this.getObjectOrClassMethodParams(e3); | |
if (t2.length > 0) { | |
const r2 = t2[0]; | |
this.isThisParam(r2) && "get" === e3.kind ? this.raise(_a.GetterMayNotHaveThisParam, { at: r2 }) : this.isThisParam(r2) && this.raise(_a.SetterMayNotHaveThisParam, { at: r2 }); | |
} | |
} | |
parsePropertyNamePrefixOperator(e3) { | |
e3.variance = this.flowParseVariance(); | |
} | |
parseObjPropValue(e3, t2, r2, n2, i2, a2, c2) { | |
let u2; | |
e3.variance && this.unexpected(e3.variance.loc.start), delete e3.variance, this.match(47) && !a2 && (u2 = this.flowParseTypeParameterDeclaration(), this.match(10) || this.unexpected()); | |
const m2 = super.parseObjPropValue(e3, t2, r2, n2, i2, a2, c2); | |
return u2 && ((m2.value || m2).typeParameters = u2), m2; | |
} | |
parseAssignableListItemTypes(e3) { | |
return this.eat(17) && ("Identifier" !== e3.type && this.raise(_a.PatternIsOptional, { at: e3 }), this.isThisParam(e3) && this.raise(_a.ThisParamMayNotBeOptional, { at: e3 }), e3.optional = true), this.match(14) ? e3.typeAnnotation = this.flowParseTypeAnnotation() : this.isThisParam(e3) && this.raise(_a.ThisParamAnnotationRequired, { at: e3 }), this.match(29) && this.isThisParam(e3) && this.raise(_a.ThisParamNoDefault, { at: e3 }), this.resetEndLocation(e3), e3; | |
} | |
parseMaybeDefault(e3, t2) { | |
const r2 = super.parseMaybeDefault(e3, t2); | |
return "AssignmentPattern" === r2.type && r2.typeAnnotation && r2.right.start < r2.typeAnnotation.start && this.raise(_a.TypeBeforeInitializer, { at: r2.typeAnnotation }), r2; | |
} | |
checkImportReflection(e3) { | |
super.checkImportReflection(e3), e3.module && "value" !== e3.importKind && this.raise(_a.ImportReflectionHasImportType, { at: e3.specifiers[0].loc.start }); | |
} | |
parseImportSpecifierLocal(e3, t2, r2) { | |
t2.local = hasTypeImportKind(e3) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier(), e3.specifiers.push(this.finishImportSpecifier(t2, r2)); | |
} | |
isPotentialImportPhase(e3) { | |
if (super.isPotentialImportPhase(e3)) | |
return true; | |
if (this.isContextual(128)) { | |
if (!e3) | |
return true; | |
const t2 = this.lookaheadCharCode(); | |
return 123 === t2 || 42 === t2; | |
} | |
return !e3 && this.isContextual(87); | |
} | |
applyImportPhase(e3, t2, r2, n2) { | |
if (super.applyImportPhase(e3, t2, r2, n2), t2) { | |
if (!r2 && this.match(65)) | |
return; | |
e3.exportKind = "type" === r2 ? r2 : "value"; | |
} else | |
"type" === r2 && this.match(55) && this.unexpected(), e3.importKind = "type" === r2 || "typeof" === r2 ? r2 : "value"; | |
} | |
parseImportSpecifier(e3, t2, r2, n2, i2) { | |
const a2 = e3.imported; | |
let c2 = null; | |
"Identifier" === a2.type && ("type" === a2.name ? c2 = "type" : "typeof" === a2.name && (c2 = "typeof")); | |
let u2 = false; | |
if (this.isContextual(93) && !this.isLookaheadContextual("as")) { | |
const t3 = this.parseIdentifier(true); | |
null === c2 || tokenIsKeywordOrIdentifier(this.state.type) ? (e3.imported = a2, e3.importKind = null, e3.local = this.parseIdentifier()) : (e3.imported = t3, e3.importKind = c2, e3.local = cloneIdentifier(t3)); | |
} else { | |
if (null !== c2 && tokenIsKeywordOrIdentifier(this.state.type)) | |
e3.imported = this.parseIdentifier(true), e3.importKind = c2; | |
else { | |
if (t2) | |
throw this.raise(Ho.ImportBindingIsString, { at: e3, importName: a2.value }); | |
e3.imported = a2, e3.importKind = null; | |
} | |
this.eatContextual(93) ? e3.local = this.parseIdentifier() : (u2 = true, e3.local = cloneIdentifier(e3.imported)); | |
} | |
const m2 = hasTypeImportKind(e3); | |
return r2 && m2 && this.raise(_a.ImportTypeShorthandOnlyInPureImport, { at: e3 }), (r2 || m2) && this.checkReservedType(e3.local.name, e3.local.loc.start, true), !u2 || r2 || m2 || this.checkReservedWord(e3.local.name, e3.loc.start, true, true), this.finishImportSpecifier(e3, "ImportSpecifier"); | |
} | |
parseBindingAtom() { | |
return 78 === this.state.type ? this.parseIdentifier(true) : super.parseBindingAtom(); | |
} | |
parseFunctionParams(e3, t2) { | |
const r2 = e3.kind; | |
"get" !== r2 && "set" !== r2 && this.match(47) && (e3.typeParameters = this.flowParseTypeParameterDeclaration()), super.parseFunctionParams(e3, t2); | |
} | |
parseVarId(e3, t2) { | |
super.parseVarId(e3, t2), this.match(14) && (e3.id.typeAnnotation = this.flowParseTypeAnnotation(), this.resetEndLocation(e3.id)); | |
} | |
parseAsyncArrowFromCallExpression(e3, t2) { | |
if (this.match(14)) { | |
const t3 = this.state.noAnonFunctionType; | |
this.state.noAnonFunctionType = true, e3.returnType = this.flowParseTypeAnnotation(), this.state.noAnonFunctionType = t3; | |
} | |
return super.parseAsyncArrowFromCallExpression(e3, t2); | |
} | |
shouldParseAsyncArrow() { | |
return this.match(14) || super.shouldParseAsyncArrow(); | |
} | |
parseMaybeAssign(e3, t2) { | |
var r2; | |
let n2, i2 = null; | |
if (this.hasPlugin("jsx") && (this.match(140) || this.match(47))) { | |
if (i2 = this.state.clone(), n2 = this.tryParse(() => super.parseMaybeAssign(e3, t2), i2), !n2.error) | |
return n2.node; | |
const { context: r3 } = this.state, a3 = r3[r3.length - 1]; | |
a3 !== zo.j_oTag && a3 !== zo.j_expr || r3.pop(); | |
} | |
if (null != (r2 = n2) && r2.error || this.match(47)) { | |
var a2, c2; | |
let r3; | |
i2 = i2 || this.state.clone(); | |
const u2 = this.tryParse((n3) => { | |
var i3; | |
r3 = this.flowParseTypeParameterDeclaration(); | |
const a3 = this.forwardNoArrowParamsConversionAt(r3, () => { | |
const n4 = super.parseMaybeAssign(e3, t2); | |
return this.resetStartLocationFromNode(n4, r3), n4; | |
}); | |
null != (i3 = a3.extra) && i3.parenthesized && n3(); | |
const c3 = this.maybeUnwrapTypeCastExpression(a3); | |
return "ArrowFunctionExpression" !== c3.type && n3(), c3.typeParameters = r3, this.resetStartLocationFromNode(c3, r3), a3; | |
}, i2); | |
let m2 = null; | |
if (u2.node && "ArrowFunctionExpression" === this.maybeUnwrapTypeCastExpression(u2.node).type) { | |
if (!u2.error && !u2.aborted) | |
return u2.node.async && this.raise(_a.UnexpectedTypeParameterBeforeAsyncArrowFunction, { at: r3 }), u2.node; | |
m2 = u2.node; | |
} | |
if (null != (a2 = n2) && a2.node) | |
return this.state = n2.failState, n2.node; | |
if (m2) | |
return this.state = u2.failState, m2; | |
if (null != (c2 = n2) && c2.thrown) | |
throw n2.error; | |
if (u2.thrown) | |
throw u2.error; | |
throw this.raise(_a.UnexpectedTokenAfterTypeParameter, { at: r3 }); | |
} | |
return super.parseMaybeAssign(e3, t2); | |
} | |
parseArrow(e3) { | |
if (this.match(14)) { | |
const t2 = this.tryParse(() => { | |
const t3 = this.state.noAnonFunctionType; | |
this.state.noAnonFunctionType = true; | |
const r2 = this.startNode(); | |
return [r2.typeAnnotation, e3.predicate] = this.flowParseTypeAndPredicateInitialiser(), this.state.noAnonFunctionType = t3, this.canInsertSemicolon() && this.unexpected(), this.match(19) || this.unexpected(), r2; | |
}); | |
if (t2.thrown) | |
return null; | |
t2.error && (this.state = t2.failState), e3.returnType = t2.node.typeAnnotation ? this.finishNode(t2.node, "TypeAnnotation") : null; | |
} | |
return super.parseArrow(e3); | |
} | |
shouldParseArrow(e3) { | |
return this.match(14) || super.shouldParseArrow(e3); | |
} | |
setArrowFunctionParameters(e3, t2) { | |
-1 !== this.state.noArrowParamsConversionAt.indexOf(e3.start) ? e3.params = t2 : super.setArrowFunctionParameters(e3, t2); | |
} | |
checkParams(e3, t2, r2, n2 = true) { | |
if (!r2 || -1 === this.state.noArrowParamsConversionAt.indexOf(e3.start)) { | |
for (let t3 = 0; t3 < e3.params.length; t3++) | |
this.isThisParam(e3.params[t3]) && t3 > 0 && this.raise(_a.ThisParamMustBeFirst, { at: e3.params[t3] }); | |
super.checkParams(e3, t2, r2, n2); | |
} | |
} | |
parseParenAndDistinguishExpression(e3) { | |
return super.parseParenAndDistinguishExpression(e3 && -1 === this.state.noArrowAt.indexOf(this.state.start)); | |
} | |
parseSubscripts(e3, t2, r2) { | |
if ("Identifier" === e3.type && "async" === e3.name && -1 !== this.state.noArrowAt.indexOf(t2.index)) { | |
this.next(); | |
const r3 = this.startNodeAt(t2); | |
r3.callee = e3, r3.arguments = super.parseCallExpressionArguments(11, false), e3 = this.finishNode(r3, "CallExpression"); | |
} else if ("Identifier" === e3.type && "async" === e3.name && this.match(47)) { | |
const n2 = this.state.clone(), i2 = this.tryParse((e4) => this.parseAsyncArrowWithTypeParameters(t2) || e4(), n2); | |
if (!i2.error && !i2.aborted) | |
return i2.node; | |
const a2 = this.tryParse(() => super.parseSubscripts(e3, t2, r2), n2); | |
if (a2.node && !a2.error) | |
return a2.node; | |
if (i2.node) | |
return this.state = i2.failState, i2.node; | |
if (a2.node) | |
return this.state = a2.failState, a2.node; | |
throw i2.error || a2.error; | |
} | |
return super.parseSubscripts(e3, t2, r2); | |
} | |
parseSubscript(e3, t2, r2, n2) { | |
if (this.match(18) && this.isLookaheadToken_lt()) { | |
if (n2.optionalChainMember = true, r2) | |
return n2.stop = true, e3; | |
this.next(); | |
const i2 = this.startNodeAt(t2); | |
return i2.callee = e3, i2.typeArguments = this.flowParseTypeParameterInstantiation(), this.expect(10), i2.arguments = this.parseCallExpressionArguments(11, false), i2.optional = true, this.finishCallExpression(i2, true); | |
} | |
if (!r2 && this.shouldParseTypes() && this.match(47)) { | |
const r3 = this.startNodeAt(t2); | |
r3.callee = e3; | |
const i2 = this.tryParse(() => (r3.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew(), this.expect(10), r3.arguments = super.parseCallExpressionArguments(11, false), n2.optionalChainMember && (r3.optional = false), this.finishCallExpression(r3, n2.optionalChainMember))); | |
if (i2.node) | |
return i2.error && (this.state = i2.failState), i2.node; | |
} | |
return super.parseSubscript(e3, t2, r2, n2); | |
} | |
parseNewCallee(e3) { | |
super.parseNewCallee(e3); | |
let t2 = null; | |
this.shouldParseTypes() && this.match(47) && (t2 = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node), e3.typeArguments = t2; | |
} | |
parseAsyncArrowWithTypeParameters(e3) { | |
const t2 = this.startNodeAt(e3); | |
if (this.parseFunctionParams(t2, false), this.parseArrow(t2)) | |
return super.parseArrowExpression(t2, void 0, true); | |
} | |
readToken_mult_modulo(e3) { | |
const t2 = this.input.charCodeAt(this.state.pos + 1); | |
if (42 === e3 && 47 === t2 && this.state.hasFlowComment) | |
return this.state.hasFlowComment = false, this.state.pos += 2, void this.nextToken(); | |
super.readToken_mult_modulo(e3); | |
} | |
readToken_pipe_amp(e3) { | |
const t2 = this.input.charCodeAt(this.state.pos + 1); | |
124 !== e3 || 125 !== t2 ? super.readToken_pipe_amp(e3) : this.finishOp(9, 2); | |
} | |
parseTopLevel(e3, t2) { | |
const r2 = super.parseTopLevel(e3, t2); | |
return this.state.hasFlowComment && this.raise(_a.UnterminatedFlowComment, { at: this.state.curPosition() }), r2; | |
} | |
skipBlockComment() { | |
if (!this.hasPlugin("flowComments") || !this.skipFlowComment()) | |
return super.skipBlockComment(this.state.hasFlowComment ? "*-/" : "*/"); | |
{ | |
if (this.state.hasFlowComment) | |
throw this.raise(_a.NestedFlowComment, { at: this.state.startLoc }); | |
this.hasFlowCommentCompletion(); | |
const e3 = this.skipFlowComment(); | |
e3 && (this.state.pos += e3, this.state.hasFlowComment = true); | |
} | |
} | |
skipFlowComment() { | |
const { pos: e3 } = this.state; | |
let t2 = 2; | |
for (; [32, 9].includes(this.input.charCodeAt(e3 + t2)); ) | |
t2++; | |
const r2 = this.input.charCodeAt(t2 + e3), n2 = this.input.charCodeAt(t2 + e3 + 1); | |
return 58 === r2 && 58 === n2 ? t2 + 2 : "flow-include" === this.input.slice(t2 + e3, t2 + e3 + 12) ? t2 + 12 : 58 === r2 && 58 !== n2 && t2; | |
} | |
hasFlowCommentCompletion() { | |
if (-1 === this.input.indexOf("*/", this.state.pos)) | |
throw this.raise(Ho.UnterminatedComment, { at: this.state.curPosition() }); | |
} | |
flowEnumErrorBooleanMemberNotInitialized(e3, { enumName: t2, memberName: r2 }) { | |
this.raise(_a.EnumBooleanMemberNotInitialized, { at: e3, memberName: r2, enumName: t2 }); | |
} | |
flowEnumErrorInvalidMemberInitializer(e3, t2) { | |
return this.raise(t2.explicitType ? "symbol" === t2.explicitType ? _a.EnumInvalidMemberInitializerSymbolType : _a.EnumInvalidMemberInitializerPrimaryType : _a.EnumInvalidMemberInitializerUnknownType, Object.assign({ at: e3 }, t2)); | |
} | |
flowEnumErrorNumberMemberNotInitialized(e3, { enumName: t2, memberName: r2 }) { | |
this.raise(_a.EnumNumberMemberNotInitialized, { at: e3, enumName: t2, memberName: r2 }); | |
} | |
flowEnumErrorStringMemberInconsistentlyInitailized(e3, { enumName: t2 }) { | |
this.raise(_a.EnumStringMemberInconsistentlyInitailized, { at: e3, enumName: t2 }); | |
} | |
flowEnumMemberInit() { | |
const e3 = this.state.startLoc, endOfInit = () => this.match(12) || this.match(8); | |
switch (this.state.type) { | |
case 132: { | |
const t2 = this.parseNumericLiteral(this.state.value); | |
return endOfInit() ? { type: "number", loc: t2.loc.start, value: t2 } : { type: "invalid", loc: e3 }; | |
} | |
case 131: { | |
const t2 = this.parseStringLiteral(this.state.value); | |
return endOfInit() ? { type: "string", loc: t2.loc.start, value: t2 } : { type: "invalid", loc: e3 }; | |
} | |
case 85: | |
case 86: { | |
const t2 = this.parseBooleanLiteral(this.match(85)); | |
return endOfInit() ? { type: "boolean", loc: t2.loc.start, value: t2 } : { type: "invalid", loc: e3 }; | |
} | |
default: | |
return { type: "invalid", loc: e3 }; | |
} | |
} | |
flowEnumMemberRaw() { | |
const e3 = this.state.startLoc; | |
return { id: this.parseIdentifier(true), init: this.eat(29) ? this.flowEnumMemberInit() : { type: "none", loc: e3 } }; | |
} | |
flowEnumCheckExplicitTypeMismatch(e3, t2, r2) { | |
const { explicitType: n2 } = t2; | |
null !== n2 && n2 !== r2 && this.flowEnumErrorInvalidMemberInitializer(e3, t2); | |
} | |
flowEnumMembers({ enumName: e3, explicitType: t2 }) { | |
const r2 = /* @__PURE__ */ new Set(), n2 = { booleanMembers: [], numberMembers: [], stringMembers: [], defaultedMembers: [] }; | |
let i2 = false; | |
for (; !this.match(8); ) { | |
if (this.eat(21)) { | |
i2 = true; | |
break; | |
} | |
const a2 = this.startNode(), { id: c2, init: u2 } = this.flowEnumMemberRaw(), m2 = c2.name; | |
if ("" === m2) | |
continue; | |
/^[a-z]/.test(m2) && this.raise(_a.EnumInvalidMemberName, { at: c2, memberName: m2, suggestion: m2[0].toUpperCase() + m2.slice(1), enumName: e3 }), r2.has(m2) && this.raise(_a.EnumDuplicateMemberName, { at: c2, memberName: m2, enumName: e3 }), r2.add(m2); | |
const g2 = { enumName: e3, explicitType: t2, memberName: m2 }; | |
switch (a2.id = c2, u2.type) { | |
case "boolean": | |
this.flowEnumCheckExplicitTypeMismatch(u2.loc, g2, "boolean"), a2.init = u2.value, n2.booleanMembers.push(this.finishNode(a2, "EnumBooleanMember")); | |
break; | |
case "number": | |
this.flowEnumCheckExplicitTypeMismatch(u2.loc, g2, "number"), a2.init = u2.value, n2.numberMembers.push(this.finishNode(a2, "EnumNumberMember")); | |
break; | |
case "string": | |
this.flowEnumCheckExplicitTypeMismatch(u2.loc, g2, "string"), a2.init = u2.value, n2.stringMembers.push(this.finishNode(a2, "EnumStringMember")); | |
break; | |
case "invalid": | |
throw this.flowEnumErrorInvalidMemberInitializer(u2.loc, g2); | |
case "none": | |
switch (t2) { | |
case "boolean": | |
this.flowEnumErrorBooleanMemberNotInitialized(u2.loc, g2); | |
break; | |
case "number": | |
this.flowEnumErrorNumberMemberNotInitialized(u2.loc, g2); | |
break; | |
default: | |
n2.defaultedMembers.push(this.finishNode(a2, "EnumDefaultedMember")); | |
} | |
} | |
this.match(8) || this.expect(12); | |
} | |
return { members: n2, hasUnknownMembers: i2 }; | |
} | |
flowEnumStringMembers(e3, t2, { enumName: r2 }) { | |
if (0 === e3.length) | |
return t2; | |
if (0 === t2.length) | |
return e3; | |
if (t2.length > e3.length) { | |
for (const t3 of e3) | |
this.flowEnumErrorStringMemberInconsistentlyInitailized(t3, { enumName: r2 }); | |
return t2; | |
} | |
for (const e4 of t2) | |
this.flowEnumErrorStringMemberInconsistentlyInitailized(e4, { enumName: r2 }); | |
return e3; | |
} | |
flowEnumParseExplicitType({ enumName: e3 }) { | |
if (!this.eatContextual(101)) | |
return null; | |
if (!tokenIsIdentifier(this.state.type)) | |
throw this.raise(_a.EnumInvalidExplicitTypeUnknownSupplied, { at: this.state.startLoc, enumName: e3 }); | |
const { value: t2 } = this.state; | |
return this.next(), "boolean" !== t2 && "number" !== t2 && "string" !== t2 && "symbol" !== t2 && this.raise(_a.EnumInvalidExplicitType, { at: this.state.startLoc, enumName: e3, invalidEnumType: t2 }), t2; | |
} | |
flowEnumBody(e3, t2) { | |
const r2 = t2.name, n2 = t2.loc.start, i2 = this.flowEnumParseExplicitType({ enumName: r2 }); | |
this.expect(5); | |
const { members: a2, hasUnknownMembers: c2 } = this.flowEnumMembers({ enumName: r2, explicitType: i2 }); | |
switch (e3.hasUnknownMembers = c2, i2) { | |
case "boolean": | |
return e3.explicitType = true, e3.members = a2.booleanMembers, this.expect(8), this.finishNode(e3, "EnumBooleanBody"); | |
case "number": | |
return e3.explicitType = true, e3.members = a2.numberMembers, this.expect(8), this.finishNode(e3, "EnumNumberBody"); | |
case "string": | |
return e3.explicitType = true, e3.members = this.flowEnumStringMembers(a2.stringMembers, a2.defaultedMembers, { enumName: r2 }), this.expect(8), this.finishNode(e3, "EnumStringBody"); | |
case "symbol": | |
return e3.members = a2.defaultedMembers, this.expect(8), this.finishNode(e3, "EnumSymbolBody"); | |
default: { | |
const empty = () => (e3.members = [], this.expect(8), this.finishNode(e3, "EnumStringBody")); | |
e3.explicitType = false; | |
const t3 = a2.booleanMembers.length, i3 = a2.numberMembers.length, c3 = a2.stringMembers.length, u2 = a2.defaultedMembers.length; | |
if (t3 || i3 || c3 || u2) { | |
if (t3 || i3) { | |
if (!i3 && !c3 && t3 >= u2) { | |
for (const e4 of a2.defaultedMembers) | |
this.flowEnumErrorBooleanMemberNotInitialized(e4.loc.start, { enumName: r2, memberName: e4.id.name }); | |
return e3.members = a2.booleanMembers, this.expect(8), this.finishNode(e3, "EnumBooleanBody"); | |
} | |
if (!t3 && !c3 && i3 >= u2) { | |
for (const e4 of a2.defaultedMembers) | |
this.flowEnumErrorNumberMemberNotInitialized(e4.loc.start, { enumName: r2, memberName: e4.id.name }); | |
return e3.members = a2.numberMembers, this.expect(8), this.finishNode(e3, "EnumNumberBody"); | |
} | |
return this.raise(_a.EnumInconsistentMemberValues, { at: n2, enumName: r2 }), empty(); | |
} | |
return e3.members = this.flowEnumStringMembers(a2.stringMembers, a2.defaultedMembers, { enumName: r2 }), this.expect(8), this.finishNode(e3, "EnumStringBody"); | |
} | |
return empty(); | |
} | |
} | |
} | |
flowParseEnumDeclaration(e3) { | |
const t2 = this.parseIdentifier(); | |
return e3.id = t2, e3.body = this.flowEnumBody(this.startNode(), t2), this.finishNode(e3, "EnumDeclaration"); | |
} | |
isLookaheadToken_lt() { | |
const e3 = this.nextTokenStart(); | |
if (60 === this.input.charCodeAt(e3)) { | |
const t2 = this.input.charCodeAt(e3 + 1); | |
return 60 !== t2 && 61 !== t2; | |
} | |
return false; | |
} | |
maybeUnwrapTypeCastExpression(e3) { | |
return "TypeCastExpression" === e3.type ? e3.expression : e3; | |
} | |
}, typescript: (e2) => class extends e2 { | |
constructor(...e3) { | |
super(...e3), this.tsParseInOutModifiers = this.tsParseModifiers.bind(this, { allowedModifiers: ["in", "out"], disallowedModifiers: ["const", "public", "private", "protected", "readonly", "declare", "abstract", "override"], errorTemplate: La.InvalidModifierOnTypeParameter }), this.tsParseConstModifier = this.tsParseModifiers.bind(this, { allowedModifiers: ["const"], disallowedModifiers: ["in", "out"], errorTemplate: La.InvalidModifierOnTypeParameterPositions }), this.tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, { allowedModifiers: ["in", "out", "const"], disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"], errorTemplate: La.InvalidModifierOnTypeParameter }); | |
} | |
getScopeHandler() { | |
return TypeScriptScopeHandler; | |
} | |
tsIsIdentifier() { | |
return tokenIsIdentifier(this.state.type); | |
} | |
tsTokenCanFollowModifier() { | |
return (this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(136) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak(); | |
} | |
tsNextTokenCanFollowModifier() { | |
return this.next(), this.tsTokenCanFollowModifier(); | |
} | |
tsParseModifier(e3, t2) { | |
if (!tokenIsIdentifier(this.state.type) && 58 !== this.state.type && 75 !== this.state.type) | |
return; | |
const r2 = this.state.value; | |
if (-1 !== e3.indexOf(r2)) { | |
if (t2 && this.tsIsStartOfStaticBlocks()) | |
return; | |
if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) | |
return r2; | |
} | |
} | |
tsParseModifiers({ allowedModifiers: e3, disallowedModifiers: t2, stopOnStartOfClassStaticBlock: r2, errorTemplate: n2 = La.InvalidModifierOnTypeMember }, i2) { | |
const enforceOrder = (e4, t3, r3, n3) => { | |
t3 === r3 && i2[n3] && this.raise(La.InvalidModifiersOrder, { at: e4, orderedModifiers: [r3, n3] }); | |
}, incompatible = (e4, t3, r3, n3) => { | |
(i2[r3] && t3 === n3 || i2[n3] && t3 === r3) && this.raise(La.IncompatibleModifiers, { at: e4, modifiers: [r3, n3] }); | |
}; | |
for (; ; ) { | |
const { startLoc: a2 } = this.state, c2 = this.tsParseModifier(e3.concat(null != t2 ? t2 : []), r2); | |
if (!c2) | |
break; | |
tsIsAccessModifier(c2) ? i2.accessibility ? this.raise(La.DuplicateAccessibilityModifier, { at: a2, modifier: c2 }) : (enforceOrder(a2, c2, c2, "override"), enforceOrder(a2, c2, c2, "static"), enforceOrder(a2, c2, c2, "readonly"), i2.accessibility = c2) : tsIsVarianceAnnotations(c2) ? (i2[c2] && this.raise(La.DuplicateModifier, { at: a2, modifier: c2 }), i2[c2] = true, enforceOrder(a2, c2, "in", "out")) : (Object.hasOwnProperty.call(i2, c2) ? this.raise(La.DuplicateModifier, { at: a2, modifier: c2 }) : (enforceOrder(a2, c2, "static", "readonly"), enforceOrder(a2, c2, "static", "override"), enforceOrder(a2, c2, "override", "readonly"), enforceOrder(a2, c2, "abstract", "override"), incompatible(a2, c2, "declare", "override"), incompatible(a2, c2, "static", "abstract")), i2[c2] = true), null != t2 && t2.includes(c2) && this.raise(n2, { at: a2, modifier: c2 }); | |
} | |
} | |
tsIsListTerminator(e3) { | |
switch (e3) { | |
case "EnumMembers": | |
case "TypeMembers": | |
return this.match(8); | |
case "HeritageClauseElement": | |
return this.match(5); | |
case "TupleElementTypes": | |
return this.match(3); | |
case "TypeParametersOrArguments": | |
return this.match(48); | |
} | |
} | |
tsParseList(e3, t2) { | |
const r2 = []; | |
for (; !this.tsIsListTerminator(e3); ) | |
r2.push(t2()); | |
return r2; | |
} | |
tsParseDelimitedList(e3, t2, r2) { | |
return function(e4) { | |
if (null == e4) | |
throw new Error(`Unexpected ${e4} value.`); | |
return e4; | |
}(this.tsParseDelimitedListWorker(e3, t2, true, r2)); | |
} | |
tsParseDelimitedListWorker(e3, t2, r2, n2) { | |
const i2 = []; | |
let a2 = -1; | |
for (; !this.tsIsListTerminator(e3); ) { | |
a2 = -1; | |
const n3 = t2(); | |
if (null == n3) | |
return; | |
if (i2.push(n3), !this.eat(12)) { | |
if (this.tsIsListTerminator(e3)) | |
break; | |
return void (r2 && this.expect(12)); | |
} | |
a2 = this.state.lastTokStart; | |
} | |
return n2 && (n2.value = a2), i2; | |
} | |
tsParseBracketedList(e3, t2, r2, n2, i2) { | |
n2 || (r2 ? this.expect(0) : this.expect(47)); | |
const a2 = this.tsParseDelimitedList(e3, t2, i2); | |
return r2 ? this.expect(3) : this.expect(48), a2; | |
} | |
tsParseImportType() { | |
const e3 = this.startNode(); | |
return this.expect(83), this.expect(10), this.match(131) || this.raise(La.UnsupportedImportTypeArgument, { at: this.state.startLoc }), e3.argument = super.parseExprAtom(), this.expect(11), this.eat(16) && (e3.qualifier = this.tsParseEntityName()), this.match(47) && (e3.typeParameters = this.tsParseTypeArguments()), this.finishNode(e3, "TSImportType"); | |
} | |
tsParseEntityName(e3 = true) { | |
let t2 = this.parseIdentifier(e3); | |
for (; this.eat(16); ) { | |
const r2 = this.startNodeAtNode(t2); | |
r2.left = t2, r2.right = this.parseIdentifier(e3), t2 = this.finishNode(r2, "TSQualifiedName"); | |
} | |
return t2; | |
} | |
tsParseTypeReference() { | |
const e3 = this.startNode(); | |
return e3.typeName = this.tsParseEntityName(), !this.hasPrecedingLineBreak() && this.match(47) && (e3.typeParameters = this.tsParseTypeArguments()), this.finishNode(e3, "TSTypeReference"); | |
} | |
tsParseThisTypePredicate(e3) { | |
this.next(); | |
const t2 = this.startNodeAtNode(e3); | |
return t2.parameterName = e3, t2.typeAnnotation = this.tsParseTypeAnnotation(false), t2.asserts = false, this.finishNode(t2, "TSTypePredicate"); | |
} | |
tsParseThisTypeNode() { | |
const e3 = this.startNode(); | |
return this.next(), this.finishNode(e3, "TSThisType"); | |
} | |
tsParseTypeQuery() { | |
const e3 = this.startNode(); | |
return this.expect(87), this.match(83) ? e3.exprName = this.tsParseImportType() : e3.exprName = this.tsParseEntityName(), !this.hasPrecedingLineBreak() && this.match(47) && (e3.typeParameters = this.tsParseTypeArguments()), this.finishNode(e3, "TSTypeQuery"); | |
} | |
tsParseTypeParameter(e3) { | |
const t2 = this.startNode(); | |
return e3(t2), t2.name = this.tsParseTypeParameterName(), t2.constraint = this.tsEatThenParseType(81), t2.default = this.tsEatThenParseType(29), this.finishNode(t2, "TSTypeParameter"); | |
} | |
tsTryParseTypeParameters(e3) { | |
if (this.match(47)) | |
return this.tsParseTypeParameters(e3); | |
} | |
tsParseTypeParameters(e3) { | |
const t2 = this.startNode(); | |
this.match(47) || this.match(140) ? this.next() : this.unexpected(); | |
const r2 = { value: -1 }; | |
return t2.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, e3), false, true, r2), 0 === t2.params.length && this.raise(La.EmptyTypeParameters, { at: t2 }), -1 !== r2.value && this.addExtra(t2, "trailingComma", r2.value), this.finishNode(t2, "TSTypeParameterDeclaration"); | |
} | |
tsFillSignature(e3, t2) { | |
const r2 = 19 === e3, n2 = "typeAnnotation"; | |
t2.typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier), this.expect(10), t2.parameters = this.tsParseBindingListForSignature(), (r2 || this.match(e3)) && (t2[n2] = this.tsParseTypeOrTypePredicateAnnotation(e3)); | |
} | |
tsParseBindingListForSignature() { | |
const e3 = super.parseBindingList(11, 41, 2); | |
for (const t2 of e3) { | |
const { type: e4 } = t2; | |
"AssignmentPattern" !== e4 && "TSParameterProperty" !== e4 || this.raise(La.UnsupportedSignatureParameterKind, { at: t2, type: e4 }); | |
} | |
return e3; | |
} | |
tsParseTypeMemberSemicolon() { | |
this.eat(12) || this.isLineTerminator() || this.expect(13); | |
} | |
tsParseSignatureMember(e3, t2) { | |
return this.tsFillSignature(14, t2), this.tsParseTypeMemberSemicolon(), this.finishNode(t2, e3); | |
} | |
tsIsUnambiguouslyIndexSignature() { | |
return this.next(), !!tokenIsIdentifier(this.state.type) && (this.next(), this.match(14)); | |
} | |
tsTryParseIndexSignature(e3) { | |
if (!this.match(0) || !this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))) | |
return; | |
this.expect(0); | |
const t2 = this.parseIdentifier(); | |
t2.typeAnnotation = this.tsParseTypeAnnotation(), this.resetEndLocation(t2), this.expect(3), e3.parameters = [t2]; | |
const r2 = this.tsTryParseTypeAnnotation(); | |
return r2 && (e3.typeAnnotation = r2), this.tsParseTypeMemberSemicolon(), this.finishNode(e3, "TSIndexSignature"); | |
} | |
tsParsePropertyOrMethodSignature(e3, t2) { | |
this.eat(17) && (e3.optional = true); | |
const r2 = e3; | |
if (this.match(10) || this.match(47)) { | |
t2 && this.raise(La.ReadonlyForMethodSignature, { at: e3 }); | |
const n2 = r2; | |
n2.kind && this.match(47) && this.raise(La.AccesorCannotHaveTypeParameters, { at: this.state.curPosition() }), this.tsFillSignature(14, n2), this.tsParseTypeMemberSemicolon(); | |
const i2 = "parameters", a2 = "typeAnnotation"; | |
if ("get" === n2.kind) | |
n2[i2].length > 0 && (this.raise(Ho.BadGetterArity, { at: this.state.curPosition() }), this.isThisParam(n2[i2][0]) && this.raise(La.AccesorCannotDeclareThisParameter, { at: this.state.curPosition() })); | |
else if ("set" === n2.kind) { | |
if (1 !== n2[i2].length) | |
this.raise(Ho.BadSetterArity, { at: this.state.curPosition() }); | |
else { | |
const e4 = n2[i2][0]; | |
this.isThisParam(e4) && this.raise(La.AccesorCannotDeclareThisParameter, { at: this.state.curPosition() }), "Identifier" === e4.type && e4.optional && this.raise(La.SetAccesorCannotHaveOptionalParameter, { at: this.state.curPosition() }), "RestElement" === e4.type && this.raise(La.SetAccesorCannotHaveRestParameter, { at: this.state.curPosition() }); | |
} | |
n2[a2] && this.raise(La.SetAccesorCannotHaveReturnType, { at: n2[a2] }); | |
} else | |
n2.kind = "method"; | |
return this.finishNode(n2, "TSMethodSignature"); | |
} | |
{ | |
const e4 = r2; | |
t2 && (e4.readonly = true); | |
const n2 = this.tsTryParseTypeAnnotation(); | |
return n2 && (e4.typeAnnotation = n2), this.tsParseTypeMemberSemicolon(), this.finishNode(e4, "TSPropertySignature"); | |
} | |
} | |
tsParseTypeMember() { | |
const e3 = this.startNode(); | |
if (this.match(10) || this.match(47)) | |
return this.tsParseSignatureMember("TSCallSignatureDeclaration", e3); | |
if (this.match(77)) { | |
const t3 = this.startNode(); | |
return this.next(), this.match(10) || this.match(47) ? this.tsParseSignatureMember("TSConstructSignatureDeclaration", e3) : (e3.key = this.createIdentifier(t3, "new"), this.tsParsePropertyOrMethodSignature(e3, false)); | |
} | |
this.tsParseModifiers({ allowedModifiers: ["readonly"], disallowedModifiers: ["declare", "abstract", "private", "protected", "public", "static", "override"] }, e3); | |
const t2 = this.tsTryParseIndexSignature(e3); | |
return t2 || (super.parsePropertyName(e3), e3.computed || "Identifier" !== e3.key.type || "get" !== e3.key.name && "set" !== e3.key.name || !this.tsTokenCanFollowModifier() || (e3.kind = e3.key.name, super.parsePropertyName(e3)), this.tsParsePropertyOrMethodSignature(e3, !!e3.readonly)); | |
} | |
tsParseTypeLiteral() { | |
const e3 = this.startNode(); | |
return e3.members = this.tsParseObjectTypeMembers(), this.finishNode(e3, "TSTypeLiteral"); | |
} | |
tsParseObjectTypeMembers() { | |
this.expect(5); | |
const e3 = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this)); | |
return this.expect(8), e3; | |
} | |
tsIsStartOfMappedType() { | |
return this.next(), this.eat(53) ? this.isContextual(120) : (this.isContextual(120) && this.next(), !!this.match(0) && (this.next(), !!this.tsIsIdentifier() && (this.next(), this.match(58)))); | |
} | |
tsParseMappedTypeParameter() { | |
const e3 = this.startNode(); | |
return e3.name = this.tsParseTypeParameterName(), e3.constraint = this.tsExpectThenParseType(58), this.finishNode(e3, "TSTypeParameter"); | |
} | |
tsParseMappedType() { | |
const e3 = this.startNode(); | |
return this.expect(5), this.match(53) ? (e3.readonly = this.state.value, this.next(), this.expectContextual(120)) : this.eatContextual(120) && (e3.readonly = true), this.expect(0), e3.typeParameter = this.tsParseMappedTypeParameter(), e3.nameType = this.eatContextual(93) ? this.tsParseType() : null, this.expect(3), this.match(53) ? (e3.optional = this.state.value, this.next(), this.expect(17)) : this.eat(17) && (e3.optional = true), e3.typeAnnotation = this.tsTryParseType(), this.semicolon(), this.expect(8), this.finishNode(e3, "TSMappedType"); | |
} | |
tsParseTupleType() { | |
const e3 = this.startNode(); | |
e3.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false); | |
let t2 = false, r2 = null; | |
return e3.elementTypes.forEach((e4) => { | |
const { type: n2 } = e4; | |
!t2 || "TSRestType" === n2 || "TSOptionalType" === n2 || "TSNamedTupleMember" === n2 && e4.optional || this.raise(La.OptionalTypeBeforeRequired, { at: e4 }), t2 || (t2 = "TSNamedTupleMember" === n2 && e4.optional || "TSOptionalType" === n2); | |
let i2 = n2; | |
"TSRestType" === n2 && (i2 = (e4 = e4.typeAnnotation).type); | |
const a2 = "TSNamedTupleMember" === i2; | |
null != r2 || (r2 = a2), r2 !== a2 && this.raise(La.MixedLabeledAndUnlabeledElements, { at: e4 }); | |
}), this.finishNode(e3, "TSTupleType"); | |
} | |
tsParseTupleElementType() { | |
const { startLoc: e3 } = this.state, t2 = this.eat(21); | |
let r2, n2, i2, a2; | |
const c2 = tokenIsKeywordOrIdentifier(this.state.type) ? this.lookaheadCharCode() : null; | |
if (58 === c2) | |
r2 = true, i2 = false, n2 = this.parseIdentifier(true), this.expect(14), a2 = this.tsParseType(); | |
else if (63 === c2) { | |
i2 = true; | |
const e4 = this.state.startLoc, t3 = this.state.value, c3 = this.tsParseNonArrayType(); | |
58 === this.lookaheadCharCode() ? (r2 = true, n2 = this.createIdentifier(this.startNodeAt(e4), t3), this.expect(17), this.expect(14), a2 = this.tsParseType()) : (r2 = false, a2 = c3, this.expect(17)); | |
} else | |
a2 = this.tsParseType(), i2 = this.eat(17), r2 = this.eat(14); | |
if (r2) { | |
let e4; | |
n2 ? (e4 = this.startNodeAtNode(n2), e4.optional = i2, e4.label = n2, e4.elementType = a2, this.eat(17) && (e4.optional = true, this.raise(La.TupleOptionalAfterType, { at: this.state.lastTokStartLoc }))) : (e4 = this.startNodeAtNode(a2), e4.optional = i2, this.raise(La.InvalidTupleMemberLabel, { at: a2 }), e4.label = a2, e4.elementType = this.tsParseType()), a2 = this.finishNode(e4, "TSNamedTupleMember"); | |
} else if (i2) { | |
const e4 = this.startNodeAtNode(a2); | |
e4.typeAnnotation = a2, a2 = this.finishNode(e4, "TSOptionalType"); | |
} | |
if (t2) { | |
const t3 = this.startNodeAt(e3); | |
t3.typeAnnotation = a2, a2 = this.finishNode(t3, "TSRestType"); | |
} | |
return a2; | |
} | |
tsParseParenthesizedType() { | |
const e3 = this.startNode(); | |
return this.expect(10), e3.typeAnnotation = this.tsParseType(), this.expect(11), this.finishNode(e3, "TSParenthesizedType"); | |
} | |
tsParseFunctionOrConstructorType(e3, t2) { | |
const r2 = this.startNode(); | |
return "TSConstructorType" === e3 && (r2.abstract = !!t2, t2 && this.next(), this.next()), this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, r2)), this.finishNode(r2, e3); | |
} | |
tsParseLiteralTypeNode() { | |
const e3 = this.startNode(); | |
switch (this.state.type) { | |
case 132: | |
case 133: | |
case 131: | |
case 85: | |
case 86: | |
e3.literal = super.parseExprAtom(); | |
break; | |
default: | |
this.unexpected(); | |
} | |
return this.finishNode(e3, "TSLiteralType"); | |
} | |
tsParseTemplateLiteralType() { | |
const e3 = this.startNode(); | |
return e3.literal = super.parseTemplate(false), this.finishNode(e3, "TSLiteralType"); | |
} | |
parseTemplateSubstitution() { | |
return this.state.inType ? this.tsParseType() : super.parseTemplateSubstitution(); | |
} | |
tsParseThisTypeOrThisTypePredicate() { | |
const e3 = this.tsParseThisTypeNode(); | |
return this.isContextual(114) && !this.hasPrecedingLineBreak() ? this.tsParseThisTypePredicate(e3) : e3; | |
} | |
tsParseNonArrayType() { | |
switch (this.state.type) { | |
case 131: | |
case 132: | |
case 133: | |
case 85: | |
case 86: | |
return this.tsParseLiteralTypeNode(); | |
case 53: | |
if ("-" === this.state.value) { | |
const e3 = this.startNode(), t2 = this.lookahead(); | |
return 132 !== t2.type && 133 !== t2.type && this.unexpected(), e3.literal = this.parseMaybeUnary(), this.finishNode(e3, "TSLiteralType"); | |
} | |
break; | |
case 78: | |
return this.tsParseThisTypeOrThisTypePredicate(); | |
case 87: | |
return this.tsParseTypeQuery(); | |
case 83: | |
return this.tsParseImportType(); | |
case 5: | |
return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral(); | |
case 0: | |
return this.tsParseTupleType(); | |
case 10: | |
return this.tsParseParenthesizedType(); | |
case 25: | |
case 24: | |
return this.tsParseTemplateLiteralType(); | |
default: { | |
const { type: e3 } = this.state; | |
if (tokenIsIdentifier(e3) || 88 === e3 || 84 === e3) { | |
const t2 = 88 === e3 ? "TSVoidKeyword" : 84 === e3 ? "TSNullKeyword" : function(e4) { | |
switch (e4) { | |
case "any": | |
return "TSAnyKeyword"; | |
case "boolean": | |
return "TSBooleanKeyword"; | |
case "bigint": | |
return "TSBigIntKeyword"; | |
case "never": | |
return "TSNeverKeyword"; | |
case "number": | |
return "TSNumberKeyword"; | |
case "object": | |
return "TSObjectKeyword"; | |
case "string": | |
return "TSStringKeyword"; | |
case "symbol": | |
return "TSSymbolKeyword"; | |
case "undefined": | |
return "TSUndefinedKeyword"; | |
case "unknown": | |
return "TSUnknownKeyword"; | |
default: | |
return; | |
} | |
}(this.state.value); | |
if (void 0 !== t2 && 46 !== this.lookaheadCharCode()) { | |
const e4 = this.startNode(); | |
return this.next(), this.finishNode(e4, t2); | |
} | |
return this.tsParseTypeReference(); | |
} | |
} | |
} | |
this.unexpected(); | |
} | |
tsParseArrayTypeOrHigher() { | |
let e3 = this.tsParseNonArrayType(); | |
for (; !this.hasPrecedingLineBreak() && this.eat(0); ) | |
if (this.match(3)) { | |
const t2 = this.startNodeAtNode(e3); | |
t2.elementType = e3, this.expect(3), e3 = this.finishNode(t2, "TSArrayType"); | |
} else { | |
const t2 = this.startNodeAtNode(e3); | |
t2.objectType = e3, t2.indexType = this.tsParseType(), this.expect(3), e3 = this.finishNode(t2, "TSIndexedAccessType"); | |
} | |
return e3; | |
} | |
tsParseTypeOperator() { | |
const e3 = this.startNode(), t2 = this.state.value; | |
return this.next(), e3.operator = t2, e3.typeAnnotation = this.tsParseTypeOperatorOrHigher(), "readonly" === t2 && this.tsCheckTypeAnnotationForReadOnly(e3), this.finishNode(e3, "TSTypeOperator"); | |
} | |
tsCheckTypeAnnotationForReadOnly(e3) { | |
switch (e3.typeAnnotation.type) { | |
case "TSTupleType": | |
case "TSArrayType": | |
return; | |
default: | |
this.raise(La.UnexpectedReadonly, { at: e3 }); | |
} | |
} | |
tsParseInferType() { | |
const e3 = this.startNode(); | |
this.expectContextual(113); | |
const t2 = this.startNode(); | |
return t2.name = this.tsParseTypeParameterName(), t2.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType()), e3.typeParameter = this.finishNode(t2, "TSTypeParameter"), this.finishNode(e3, "TSInferType"); | |
} | |
tsParseConstraintForInferType() { | |
if (this.eat(81)) { | |
const e3 = this.tsInDisallowConditionalTypesContext(() => this.tsParseType()); | |
if (this.state.inDisallowConditionalTypesContext || !this.match(17)) | |
return e3; | |
} | |
} | |
tsParseTypeOperatorOrHigher() { | |
var e3; | |
return (e3 = this.state.type) >= 119 && e3 <= 121 && !this.state.containsEsc ? this.tsParseTypeOperator() : this.isContextual(113) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher()); | |
} | |
tsParseUnionOrIntersectionType(e3, t2, r2) { | |
const n2 = this.startNode(), i2 = this.eat(r2), a2 = []; | |
do { | |
a2.push(t2()); | |
} while (this.eat(r2)); | |
return 1 !== a2.length || i2 ? (n2.types = a2, this.finishNode(n2, e3)) : a2[0]; | |
} | |
tsParseIntersectionTypeOrHigher() { | |
return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45); | |
} | |
tsParseUnionTypeOrHigher() { | |
return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43); | |
} | |
tsIsStartOfFunctionType() { | |
return !!this.match(47) || this.match(10) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this)); | |
} | |
tsSkipParameterStart() { | |
if (tokenIsIdentifier(this.state.type) || this.match(78)) | |
return this.next(), true; | |
if (this.match(5)) { | |
const { errors: e3 } = this.state, t2 = e3.length; | |
try { | |
return this.parseObjectLike(8, true), e3.length === t2; | |
} catch (e4) { | |
return false; | |
} | |
} | |
if (this.match(0)) { | |
this.next(); | |
const { errors: e3 } = this.state, t2 = e3.length; | |
try { | |
return super.parseBindingList(3, 93, 1), e3.length === t2; | |
} catch (e4) { | |
return false; | |
} | |
} | |
return false; | |
} | |
tsIsUnambiguouslyStartOfFunctionType() { | |
if (this.next(), this.match(11) || this.match(21)) | |
return true; | |
if (this.tsSkipParameterStart()) { | |
if (this.match(14) || this.match(12) || this.match(17) || this.match(29)) | |
return true; | |
if (this.match(11) && (this.next(), this.match(19))) | |
return true; | |
} | |
return false; | |
} | |
tsParseTypeOrTypePredicateAnnotation(e3) { | |
return this.tsInType(() => { | |
const t2 = this.startNode(); | |
this.expect(e3); | |
const r2 = this.startNode(), n2 = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this)); | |
if (n2 && this.match(78)) { | |
let e4 = this.tsParseThisTypeOrThisTypePredicate(); | |
return "TSThisType" === e4.type ? (r2.parameterName = e4, r2.asserts = true, r2.typeAnnotation = null, e4 = this.finishNode(r2, "TSTypePredicate")) : (this.resetStartLocationFromNode(e4, r2), e4.asserts = true), t2.typeAnnotation = e4, this.finishNode(t2, "TSTypeAnnotation"); | |
} | |
const i2 = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this)); | |
if (!i2) | |
return n2 ? (r2.parameterName = this.parseIdentifier(), r2.asserts = n2, r2.typeAnnotation = null, t2.typeAnnotation = this.finishNode(r2, "TSTypePredicate"), this.finishNode(t2, "TSTypeAnnotation")) : this.tsParseTypeAnnotation(false, t2); | |
const a2 = this.tsParseTypeAnnotation(false); | |
return r2.parameterName = i2, r2.typeAnnotation = a2, r2.asserts = n2, t2.typeAnnotation = this.finishNode(r2, "TSTypePredicate"), this.finishNode(t2, "TSTypeAnnotation"); | |
}); | |
} | |
tsTryParseTypeOrTypePredicateAnnotation() { | |
if (this.match(14)) | |
return this.tsParseTypeOrTypePredicateAnnotation(14); | |
} | |
tsTryParseTypeAnnotation() { | |
if (this.match(14)) | |
return this.tsParseTypeAnnotation(); | |
} | |
tsTryParseType() { | |
return this.tsEatThenParseType(14); | |
} | |
tsParseTypePredicatePrefix() { | |
const e3 = this.parseIdentifier(); | |
if (this.isContextual(114) && !this.hasPrecedingLineBreak()) | |
return this.next(), e3; | |
} | |
tsParseTypePredicateAsserts() { | |
if (107 !== this.state.type) | |
return false; | |
const e3 = this.state.containsEsc; | |
return this.next(), !(!tokenIsIdentifier(this.state.type) && !this.match(78)) && (e3 && this.raise(Ho.InvalidEscapedReservedWord, { at: this.state.lastTokStartLoc, reservedWord: "asserts" }), true); | |
} | |
tsParseTypeAnnotation(e3 = true, t2 = this.startNode()) { | |
return this.tsInType(() => { | |
e3 && this.expect(14), t2.typeAnnotation = this.tsParseType(); | |
}), this.finishNode(t2, "TSTypeAnnotation"); | |
} | |
tsParseType() { | |
assert$1(this.state.inType); | |
const e3 = this.tsParseNonConditionalType(); | |
if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) | |
return e3; | |
const t2 = this.startNodeAtNode(e3); | |
return t2.checkType = e3, t2.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType()), this.expect(17), t2.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType()), this.expect(14), t2.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType()), this.finishNode(t2, "TSConditionalType"); | |
} | |
isAbstractConstructorSignature() { | |
return this.isContextual(122) && 77 === this.lookahead().type; | |
} | |
tsParseNonConditionalType() { | |
return this.tsIsStartOfFunctionType() ? this.tsParseFunctionOrConstructorType("TSFunctionType") : this.match(77) ? this.tsParseFunctionOrConstructorType("TSConstructorType") : this.isAbstractConstructorSignature() ? this.tsParseFunctionOrConstructorType("TSConstructorType", true) : this.tsParseUnionTypeOrHigher(); | |
} | |
tsParseTypeAssertion() { | |
this.getPluginOption("typescript", "disallowAmbiguousJSXLike") && this.raise(La.ReservedTypeAssertion, { at: this.state.startLoc }); | |
const e3 = this.startNode(); | |
return e3.typeAnnotation = this.tsInType(() => (this.next(), this.match(75) ? this.tsParseTypeReference() : this.tsParseType())), this.expect(48), e3.expression = this.parseMaybeUnary(), this.finishNode(e3, "TSTypeAssertion"); | |
} | |
tsParseHeritageClause(e3) { | |
const t2 = this.state.startLoc, r2 = this.tsParseDelimitedList("HeritageClauseElement", () => { | |
const e4 = this.startNode(); | |
return e4.expression = this.tsParseEntityName(), this.match(47) && (e4.typeParameters = this.tsParseTypeArguments()), this.finishNode(e4, "TSExpressionWithTypeArguments"); | |
}); | |
return r2.length || this.raise(La.EmptyHeritageClauseType, { at: t2, token: e3 }), r2; | |
} | |
tsParseInterfaceDeclaration(e3, t2 = {}) { | |
if (this.hasFollowingLineBreak()) | |
return null; | |
this.expectContextual(127), t2.declare && (e3.declare = true), tokenIsIdentifier(this.state.type) ? (e3.id = this.parseIdentifier(), this.checkIdentifier(e3.id, 130)) : (e3.id = null, this.raise(La.MissingInterfaceName, { at: this.state.startLoc })), e3.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers), this.eat(81) && (e3.extends = this.tsParseHeritageClause("extends")); | |
const r2 = this.startNode(); | |
return r2.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this)), e3.body = this.finishNode(r2, "TSInterfaceBody"), this.finishNode(e3, "TSInterfaceDeclaration"); | |
} | |
tsParseTypeAliasDeclaration(e3) { | |
return e3.id = this.parseIdentifier(), this.checkIdentifier(e3.id, 2), e3.typeAnnotation = this.tsInType(() => { | |
if (e3.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers), this.expect(29), this.isContextual(112) && 16 !== this.lookahead().type) { | |
const e4 = this.startNode(); | |
return this.next(), this.finishNode(e4, "TSIntrinsicKeyword"); | |
} | |
return this.tsParseType(); | |
}), this.semicolon(), this.finishNode(e3, "TSTypeAliasDeclaration"); | |
} | |
tsInNoContext(e3) { | |
const t2 = this.state.context; | |
this.state.context = [t2[0]]; | |
try { | |
return e3(); | |
} finally { | |
this.state.context = t2; | |
} | |
} | |
tsInType(e3) { | |
const t2 = this.state.inType; | |
this.state.inType = true; | |
try { | |
return e3(); | |
} finally { | |
this.state.inType = t2; | |
} | |
} | |
tsInDisallowConditionalTypesContext(e3) { | |
const t2 = this.state.inDisallowConditionalTypesContext; | |
this.state.inDisallowConditionalTypesContext = true; | |
try { | |
return e3(); | |
} finally { | |
this.state.inDisallowConditionalTypesContext = t2; | |
} | |
} | |
tsInAllowConditionalTypesContext(e3) { | |
const t2 = this.state.inDisallowConditionalTypesContext; | |
this.state.inDisallowConditionalTypesContext = false; | |
try { | |
return e3(); | |
} finally { | |
this.state.inDisallowConditionalTypesContext = t2; | |
} | |
} | |
tsEatThenParseType(e3) { | |
if (this.match(e3)) | |
return this.tsNextThenParseType(); | |
} | |
tsExpectThenParseType(e3) { | |
return this.tsInType(() => (this.expect(e3), this.tsParseType())); | |
} | |
tsNextThenParseType() { | |
return this.tsInType(() => (this.next(), this.tsParseType())); | |
} | |
tsParseEnumMember() { | |
const e3 = this.startNode(); | |
return e3.id = this.match(131) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true), this.eat(29) && (e3.initializer = super.parseMaybeAssignAllowIn()), this.finishNode(e3, "TSEnumMember"); | |
} | |
tsParseEnumDeclaration(e3, t2 = {}) { | |
return t2.const && (e3.const = true), t2.declare && (e3.declare = true), this.expectContextual(124), e3.id = this.parseIdentifier(), this.checkIdentifier(e3.id, e3.const ? 8971 : 8459), this.expect(5), e3.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this)), this.expect(8), this.finishNode(e3, "TSEnumDeclaration"); | |
} | |
tsParseModuleBlock() { | |
const e3 = this.startNode(); | |
return this.scope.enter(0), this.expect(5), super.parseBlockOrModuleBlockBody(e3.body = [], void 0, true, 8), this.scope.exit(), this.finishNode(e3, "TSModuleBlock"); | |
} | |
tsParseModuleOrNamespaceDeclaration(e3, t2 = false) { | |
if (e3.id = this.parseIdentifier(), t2 || this.checkIdentifier(e3.id, 1024), this.eat(16)) { | |
const t3 = this.startNode(); | |
this.tsParseModuleOrNamespaceDeclaration(t3, true), e3.body = t3; | |
} else | |
this.scope.enter(256), this.prodParam.enter(0), e3.body = this.tsParseModuleBlock(), this.prodParam.exit(), this.scope.exit(); | |
return this.finishNode(e3, "TSModuleDeclaration"); | |
} | |
tsParseAmbientExternalModuleDeclaration(e3) { | |
return this.isContextual(110) ? (e3.global = true, e3.id = this.parseIdentifier()) : this.match(131) ? e3.id = super.parseStringLiteral(this.state.value) : this.unexpected(), this.match(5) ? (this.scope.enter(256), this.prodParam.enter(0), e3.body = this.tsParseModuleBlock(), this.prodParam.exit(), this.scope.exit()) : this.semicolon(), this.finishNode(e3, "TSModuleDeclaration"); | |
} | |
tsParseImportEqualsDeclaration(e3, t2, r2) { | |
e3.isExport = r2 || false, e3.id = t2 || this.parseIdentifier(), this.checkIdentifier(e3.id, 4096), this.expect(29); | |
const n2 = this.tsParseModuleReference(); | |
return "type" === e3.importKind && "TSExternalModuleReference" !== n2.type && this.raise(La.ImportAliasHasImportType, { at: n2 }), e3.moduleReference = n2, this.semicolon(), this.finishNode(e3, "TSImportEqualsDeclaration"); | |
} | |
tsIsExternalModuleReference() { | |
return this.isContextual(117) && 40 === this.lookaheadCharCode(); | |
} | |
tsParseModuleReference() { | |
return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false); | |
} | |
tsParseExternalModuleReference() { | |
const e3 = this.startNode(); | |
return this.expectContextual(117), this.expect(10), this.match(131) || this.unexpected(), e3.expression = super.parseExprAtom(), this.expect(11), this.sawUnambiguousESM = true, this.finishNode(e3, "TSExternalModuleReference"); | |
} | |
tsLookAhead(e3) { | |
const t2 = this.state.clone(), r2 = e3(); | |
return this.state = t2, r2; | |
} | |
tsTryParseAndCatch(e3) { | |
const t2 = this.tryParse((t3) => e3() || t3()); | |
if (!t2.aborted && t2.node) | |
return t2.error && (this.state = t2.failState), t2.node; | |
} | |
tsTryParse(e3) { | |
const t2 = this.state.clone(), r2 = e3(); | |
if (void 0 !== r2 && false !== r2) | |
return r2; | |
this.state = t2; | |
} | |
tsTryParseDeclare(e3) { | |
if (this.isLineTerminator()) | |
return; | |
let t2, r2 = this.state.type; | |
return this.isContextual(99) && (r2 = 74, t2 = "let"), this.tsInAmbientContext(() => { | |
switch (r2) { | |
case 68: | |
return e3.declare = true, super.parseFunctionStatement(e3, false, false); | |
case 80: | |
return e3.declare = true, this.parseClass(e3, true, false); | |
case 124: | |
return this.tsParseEnumDeclaration(e3, { declare: true }); | |
case 110: | |
return this.tsParseAmbientExternalModuleDeclaration(e3); | |
case 75: | |
case 74: | |
return this.match(75) && this.isLookaheadContextual("enum") ? (this.expect(75), this.tsParseEnumDeclaration(e3, { const: true, declare: true })) : (e3.declare = true, this.parseVarStatement(e3, t2 || this.state.value, true)); | |
case 127: { | |
const t3 = this.tsParseInterfaceDeclaration(e3, { declare: true }); | |
if (t3) | |
return t3; | |
} | |
default: | |
if (tokenIsIdentifier(r2)) | |
return this.tsParseDeclaration(e3, this.state.value, true, null); | |
} | |
}); | |
} | |
tsTryParseExportDeclaration() { | |
return this.tsParseDeclaration(this.startNode(), this.state.value, true, null); | |
} | |
tsParseExpressionStatement(e3, t2, r2) { | |
switch (t2.name) { | |
case "declare": { | |
const t3 = this.tsTryParseDeclare(e3); | |
return t3 && (t3.declare = true), t3; | |
} | |
case "global": | |
if (this.match(5)) { | |
this.scope.enter(256), this.prodParam.enter(0); | |
const r3 = e3; | |
return r3.global = true, r3.id = t2, r3.body = this.tsParseModuleBlock(), this.scope.exit(), this.prodParam.exit(), this.finishNode(r3, "TSModuleDeclaration"); | |
} | |
break; | |
default: | |
return this.tsParseDeclaration(e3, t2.name, false, r2); | |
} | |
} | |
tsParseDeclaration(e3, t2, r2, n2) { | |
switch (t2) { | |
case "abstract": | |
if (this.tsCheckLineTerminator(r2) && (this.match(80) || tokenIsIdentifier(this.state.type))) | |
return this.tsParseAbstractDeclaration(e3, n2); | |
break; | |
case "module": | |
if (this.tsCheckLineTerminator(r2)) { | |
if (this.match(131)) | |
return this.tsParseAmbientExternalModuleDeclaration(e3); | |
if (tokenIsIdentifier(this.state.type)) | |
return this.tsParseModuleOrNamespaceDeclaration(e3); | |
} | |
break; | |
case "namespace": | |
if (this.tsCheckLineTerminator(r2) && tokenIsIdentifier(this.state.type)) | |
return this.tsParseModuleOrNamespaceDeclaration(e3); | |
break; | |
case "type": | |
if (this.tsCheckLineTerminator(r2) && tokenIsIdentifier(this.state.type)) | |
return this.tsParseTypeAliasDeclaration(e3); | |
} | |
} | |
tsCheckLineTerminator(e3) { | |
return e3 ? !this.hasFollowingLineBreak() && (this.next(), true) : !this.isLineTerminator(); | |
} | |
tsTryParseGenericAsyncArrowFunction(e3) { | |
if (!this.match(47)) | |
return; | |
const t2 = this.state.maybeInArrowParameters; | |
this.state.maybeInArrowParameters = true; | |
const r2 = this.tsTryParseAndCatch(() => { | |
const t3 = this.startNodeAt(e3); | |
return t3.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier), super.parseFunctionParams(t3), t3.returnType = this.tsTryParseTypeOrTypePredicateAnnotation(), this.expect(19), t3; | |
}); | |
return this.state.maybeInArrowParameters = t2, r2 ? super.parseArrowExpression(r2, null, true) : void 0; | |
} | |
tsParseTypeArgumentsInExpression() { | |
if (47 === this.reScan_lt()) | |
return this.tsParseTypeArguments(); | |
} | |
tsParseTypeArguments() { | |
const e3 = this.startNode(); | |
return e3.params = this.tsInType(() => this.tsInNoContext(() => (this.expect(47), this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this))))), 0 === e3.params.length ? this.raise(La.EmptyTypeArguments, { at: e3 }) : this.state.inType || this.curContext() !== zo.brace || this.reScan_lt_gt(), this.expect(48), this.finishNode(e3, "TSTypeParameterInstantiation"); | |
} | |
tsIsDeclarationStart() { | |
return (e3 = this.state.type) >= 122 && e3 <= 128; | |
var e3; | |
} | |
isExportDefaultSpecifier() { | |
return !this.tsIsDeclarationStart() && super.isExportDefaultSpecifier(); | |
} | |
parseAssignableListItem(e3, t2) { | |
const r2 = this.state.startLoc, n2 = {}; | |
this.tsParseModifiers({ allowedModifiers: ["public", "private", "protected", "override", "readonly"] }, n2); | |
const i2 = n2.accessibility, a2 = n2.override, c2 = n2.readonly; | |
4 & e3 || !(i2 || c2 || a2) || this.raise(La.UnexpectedParameterModifier, { at: r2 }); | |
const u2 = this.parseMaybeDefault(); | |
this.parseAssignableListItemTypes(u2, e3); | |
const m2 = this.parseMaybeDefault(u2.loc.start, u2); | |
if (i2 || c2 || a2) { | |
const e4 = this.startNodeAt(r2); | |
return t2.length && (e4.decorators = t2), i2 && (e4.accessibility = i2), c2 && (e4.readonly = c2), a2 && (e4.override = a2), "Identifier" !== m2.type && "AssignmentPattern" !== m2.type && this.raise(La.UnsupportedParameterPropertyKind, { at: e4 }), e4.parameter = m2, this.finishNode(e4, "TSParameterProperty"); | |
} | |
return t2.length && (u2.decorators = t2), m2; | |
} | |
isSimpleParameter(e3) { | |
return "TSParameterProperty" === e3.type && super.isSimpleParameter(e3.parameter) || super.isSimpleParameter(e3); | |
} | |
tsDisallowOptionalPattern(e3) { | |
for (const t2 of e3.params) | |
"Identifier" !== t2.type && t2.optional && !this.state.isAmbientContext && this.raise(La.PatternIsOptional, { at: t2 }); | |
} | |
setArrowFunctionParameters(e3, t2, r2) { | |
super.setArrowFunctionParameters(e3, t2, r2), this.tsDisallowOptionalPattern(e3); | |
} | |
parseFunctionBodyAndFinish(e3, t2, r2 = false) { | |
this.match(14) && (e3.returnType = this.tsParseTypeOrTypePredicateAnnotation(14)); | |
const n2 = "FunctionDeclaration" === t2 ? "TSDeclareFunction" : "ClassMethod" === t2 || "ClassPrivateMethod" === t2 ? "TSDeclareMethod" : void 0; | |
return n2 && !this.match(5) && this.isLineTerminator() ? this.finishNode(e3, n2) : "TSDeclareFunction" === n2 && this.state.isAmbientContext && (this.raise(La.DeclareFunctionHasImplementation, { at: e3 }), e3.declare) ? super.parseFunctionBodyAndFinish(e3, n2, r2) : (this.tsDisallowOptionalPattern(e3), super.parseFunctionBodyAndFinish(e3, t2, r2)); | |
} | |
registerFunctionStatementId(e3) { | |
!e3.body && e3.id ? this.checkIdentifier(e3.id, 1024) : super.registerFunctionStatementId(e3); | |
} | |
tsCheckForInvalidTypeCasts(e3) { | |
e3.forEach((e4) => { | |
"TSTypeCastExpression" === (null == e4 ? void 0 : e4.type) && this.raise(La.UnexpectedTypeAnnotation, { at: e4.typeAnnotation }); | |
}); | |
} | |
toReferencedList(e3, t2) { | |
return this.tsCheckForInvalidTypeCasts(e3), e3; | |
} | |
parseArrayLike(e3, t2, r2, n2) { | |
const i2 = super.parseArrayLike(e3, t2, r2, n2); | |
return "ArrayExpression" === i2.type && this.tsCheckForInvalidTypeCasts(i2.elements), i2; | |
} | |
parseSubscript(e3, t2, r2, n2) { | |
if (!this.hasPrecedingLineBreak() && this.match(35)) { | |
this.state.canStartJSXElement = false, this.next(); | |
const r3 = this.startNodeAt(t2); | |
return r3.expression = e3, this.finishNode(r3, "TSNonNullExpression"); | |
} | |
let i2 = false; | |
if (this.match(18) && 60 === this.lookaheadCharCode()) { | |
if (r2) | |
return n2.stop = true, e3; | |
n2.optionalChainMember = i2 = true, this.next(); | |
} | |
if (this.match(47) || this.match(51)) { | |
let a2; | |
const c2 = this.tsTryParseAndCatch(() => { | |
if (!r2 && this.atPossibleAsyncArrow(e3)) { | |
const e4 = this.tsTryParseGenericAsyncArrowFunction(t2); | |
if (e4) | |
return e4; | |
} | |
const c3 = this.tsParseTypeArgumentsInExpression(); | |
if (!c3) | |
return; | |
if (i2 && !this.match(10)) | |
return void (a2 = this.state.curPosition()); | |
if (tokenIsTemplate(this.state.type)) { | |
const r3 = super.parseTaggedTemplateExpression(e3, t2, n2); | |
return r3.typeParameters = c3, r3; | |
} | |
if (!r2 && this.eat(10)) { | |
const r3 = this.startNodeAt(t2); | |
return r3.callee = e3, r3.arguments = this.parseCallExpressionArguments(11, false), this.tsCheckForInvalidTypeCasts(r3.arguments), r3.typeParameters = c3, n2.optionalChainMember && (r3.optional = i2), this.finishCallExpression(r3, n2.optionalChainMember); | |
} | |
const u2 = this.state.type; | |
if (48 === u2 || 52 === u2 || 10 !== u2 && tokenCanStartExpression(u2) && !this.hasPrecedingLineBreak()) | |
return; | |
const m2 = this.startNodeAt(t2); | |
return m2.expression = e3, m2.typeParameters = c3, this.finishNode(m2, "TSInstantiationExpression"); | |
}); | |
if (a2 && this.unexpected(a2, 10), c2) | |
return "TSInstantiationExpression" === c2.type && (this.match(16) || this.match(18) && 40 !== this.lookaheadCharCode()) && this.raise(La.InvalidPropertyAccessAfterInstantiationExpression, { at: this.state.startLoc }), c2; | |
} | |
return super.parseSubscript(e3, t2, r2, n2); | |
} | |
parseNewCallee(e3) { | |
var t2; | |
super.parseNewCallee(e3); | |
const { callee: r2 } = e3; | |
"TSInstantiationExpression" !== r2.type || null != (t2 = r2.extra) && t2.parenthesized || (e3.typeParameters = r2.typeParameters, e3.callee = r2.expression); | |
} | |
parseExprOp(e3, t2, r2) { | |
let n2; | |
if (tokenOperatorPrecedence(58) > r2 && !this.hasPrecedingLineBreak() && (this.isContextual(93) || (n2 = this.isContextual(118)))) { | |
const i2 = this.startNodeAt(t2); | |
return i2.expression = e3, i2.typeAnnotation = this.tsInType(() => (this.next(), this.match(75) ? (n2 && this.raise(Ho.UnexpectedKeyword, { at: this.state.startLoc, keyword: "const" }), this.tsParseTypeReference()) : this.tsParseType())), this.finishNode(i2, n2 ? "TSSatisfiesExpression" : "TSAsExpression"), this.reScan_lt_gt(), this.parseExprOp(i2, t2, r2); | |
} | |
return super.parseExprOp(e3, t2, r2); | |
} | |
checkReservedWord(e3, t2, r2, n2) { | |
this.state.isAmbientContext || super.checkReservedWord(e3, t2, r2, n2); | |
} | |
checkImportReflection(e3) { | |
super.checkImportReflection(e3), e3.module && "value" !== e3.importKind && this.raise(La.ImportReflectionHasImportType, { at: e3.specifiers[0].loc.start }); | |
} | |
checkDuplicateExports() { | |
} | |
isPotentialImportPhase(e3) { | |
if (super.isPotentialImportPhase(e3)) | |
return true; | |
if (this.isContextual(128)) { | |
const t2 = this.lookaheadCharCode(); | |
return e3 ? 123 === t2 || 42 === t2 : 61 !== t2; | |
} | |
return !e3 && this.isContextual(87); | |
} | |
applyImportPhase(e3, t2, r2, n2) { | |
super.applyImportPhase(e3, t2, r2, n2), t2 ? e3.exportKind = "type" === r2 ? "type" : "value" : e3.importKind = "type" === r2 || "typeof" === r2 ? r2 : "value"; | |
} | |
parseImport(e3) { | |
if (this.match(131)) | |
return e3.importKind = "value", super.parseImport(e3); | |
let t2; | |
if (tokenIsIdentifier(this.state.type) && 61 === this.lookaheadCharCode()) | |
return e3.importKind = "value", this.tsParseImportEqualsDeclaration(e3); | |
if (this.isContextual(128)) { | |
const r2 = this.parseMaybeImportPhase(e3, false); | |
if (61 === this.lookaheadCharCode()) | |
return this.tsParseImportEqualsDeclaration(e3, r2); | |
t2 = super.parseImportSpecifiersAndAfter(e3, r2); | |
} else | |
t2 = super.parseImport(e3); | |
return "type" === t2.importKind && t2.specifiers.length > 1 && "ImportDefaultSpecifier" === t2.specifiers[0].type && this.raise(La.TypeImportCannotSpecifyDefaultAndNamed, { at: t2 }), t2; | |
} | |
parseExport(e3, t2) { | |
if (this.match(83)) { | |
this.next(); | |
let t3 = null; | |
return this.isContextual(128) && this.isPotentialImportPhase(false) ? t3 = this.parseMaybeImportPhase(e3, false) : e3.importKind = "value", this.tsParseImportEqualsDeclaration(e3, t3, true); | |
} | |
if (this.eat(29)) { | |
const t3 = e3; | |
return t3.expression = super.parseExpression(), this.semicolon(), this.sawUnambiguousESM = true, this.finishNode(t3, "TSExportAssignment"); | |
} | |
if (this.eatContextual(93)) { | |
const t3 = e3; | |
return this.expectContextual(126), t3.id = this.parseIdentifier(), this.semicolon(), this.finishNode(t3, "TSNamespaceExportDeclaration"); | |
} | |
return super.parseExport(e3, t2); | |
} | |
isAbstractClass() { | |
return this.isContextual(122) && 80 === this.lookahead().type; | |
} | |
parseExportDefaultExpression() { | |
if (this.isAbstractClass()) { | |
const e3 = this.startNode(); | |
return this.next(), e3.abstract = true, this.parseClass(e3, true, true); | |
} | |
if (this.match(127)) { | |
const e3 = this.tsParseInterfaceDeclaration(this.startNode()); | |
if (e3) | |
return e3; | |
} | |
return super.parseExportDefaultExpression(); | |
} | |
parseVarStatement(e3, t2, r2 = false) { | |
const { isAmbientContext: n2 } = this.state, i2 = super.parseVarStatement(e3, t2, r2 || n2); | |
if (!n2) | |
return i2; | |
for (const { id: e4, init: r3 } of i2.declarations) | |
r3 && ("const" !== t2 || e4.typeAnnotation ? this.raise(La.InitializerNotAllowedInAmbientContext, { at: r3 }) : isValidAmbientConstInitializer(r3, this.hasPlugin("estree")) || this.raise(La.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference, { at: r3 })); | |
return i2; | |
} | |
parseStatementContent(e3, t2) { | |
if (this.match(75) && this.isLookaheadContextual("enum")) { | |
const e4 = this.startNode(); | |
return this.expect(75), this.tsParseEnumDeclaration(e4, { const: true }); | |
} | |
if (this.isContextual(124)) | |
return this.tsParseEnumDeclaration(this.startNode()); | |
if (this.isContextual(127)) { | |
const e4 = this.tsParseInterfaceDeclaration(this.startNode()); | |
if (e4) | |
return e4; | |
} | |
return super.parseStatementContent(e3, t2); | |
} | |
parseAccessModifier() { | |
return this.tsParseModifier(["public", "protected", "private"]); | |
} | |
tsHasSomeModifiers(e3, t2) { | |
return t2.some((t3) => tsIsAccessModifier(t3) ? e3.accessibility === t3 : !!e3[t3]); | |
} | |
tsIsStartOfStaticBlocks() { | |
return this.isContextual(104) && 123 === this.lookaheadCharCode(); | |
} | |
parseClassMember(e3, t2, r2) { | |
const n2 = ["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"]; | |
this.tsParseModifiers({ allowedModifiers: n2, disallowedModifiers: ["in", "out"], stopOnStartOfClassStaticBlock: true, errorTemplate: La.InvalidModifierOnTypeParameterPositions }, t2); | |
const callParseClassMemberWithIsStatic = () => { | |
this.tsIsStartOfStaticBlocks() ? (this.next(), this.next(), this.tsHasSomeModifiers(t2, n2) && this.raise(La.StaticBlockCannotHaveModifier, { at: this.state.curPosition() }), super.parseClassStaticBlock(e3, t2)) : this.parseClassMemberWithIsStatic(e3, t2, r2, !!t2.static); | |
}; | |
t2.declare ? this.tsInAmbientContext(callParseClassMemberWithIsStatic) : callParseClassMemberWithIsStatic(); | |
} | |
parseClassMemberWithIsStatic(e3, t2, r2, n2) { | |
const i2 = this.tsTryParseIndexSignature(t2); | |
if (i2) | |
return e3.body.push(i2), t2.abstract && this.raise(La.IndexSignatureHasAbstract, { at: t2 }), t2.accessibility && this.raise(La.IndexSignatureHasAccessibility, { at: t2, modifier: t2.accessibility }), t2.declare && this.raise(La.IndexSignatureHasDeclare, { at: t2 }), void (t2.override && this.raise(La.IndexSignatureHasOverride, { at: t2 })); | |
!this.state.inAbstractClass && t2.abstract && this.raise(La.NonAbstractClassHasAbstractMethod, { at: t2 }), t2.override && (r2.hadSuperClass || this.raise(La.OverrideNotInSubClass, { at: t2 })), super.parseClassMemberWithIsStatic(e3, t2, r2, n2); | |
} | |
parsePostMemberNameModifiers(e3) { | |
this.eat(17) && (e3.optional = true), e3.readonly && this.match(10) && this.raise(La.ClassMethodHasReadonly, { at: e3 }), e3.declare && this.match(10) && this.raise(La.ClassMethodHasDeclare, { at: e3 }); | |
} | |
parseExpressionStatement(e3, t2, r2) { | |
return ("Identifier" === t2.type ? this.tsParseExpressionStatement(e3, t2, r2) : void 0) || super.parseExpressionStatement(e3, t2, r2); | |
} | |
shouldParseExportDeclaration() { | |
return !!this.tsIsDeclarationStart() || super.shouldParseExportDeclaration(); | |
} | |
parseConditional(e3, t2, r2) { | |
if (!this.state.maybeInArrowParameters || !this.match(17)) | |
return super.parseConditional(e3, t2, r2); | |
const n2 = this.tryParse(() => super.parseConditional(e3, t2)); | |
return n2.node ? (n2.error && (this.state = n2.failState), n2.node) : (n2.error && super.setOptionalParametersError(r2, n2.error), e3); | |
} | |
parseParenItem(e3, t2) { | |
if (e3 = super.parseParenItem(e3, t2), this.eat(17) && (e3.optional = true, this.resetEndLocation(e3)), this.match(14)) { | |
const r2 = this.startNodeAt(t2); | |
return r2.expression = e3, r2.typeAnnotation = this.tsParseTypeAnnotation(), this.finishNode(r2, "TSTypeCastExpression"); | |
} | |
return e3; | |
} | |
parseExportDeclaration(e3) { | |
if (!this.state.isAmbientContext && this.isContextual(123)) | |
return this.tsInAmbientContext(() => this.parseExportDeclaration(e3)); | |
const t2 = this.state.startLoc, r2 = this.eatContextual(123); | |
if (r2 && (this.isContextual(123) || !this.shouldParseExportDeclaration())) | |
throw this.raise(La.ExpectedAmbientAfterExportDeclare, { at: this.state.startLoc }); | |
const n2 = tokenIsIdentifier(this.state.type) && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(e3); | |
return n2 ? (("TSInterfaceDeclaration" === n2.type || "TSTypeAliasDeclaration" === n2.type || r2) && (e3.exportKind = "type"), r2 && (this.resetStartLocation(n2, t2), n2.declare = true), n2) : null; | |
} | |
parseClassId(e3, t2, r2, n2) { | |
if ((!t2 || r2) && this.isContextual(111)) | |
return; | |
super.parseClassId(e3, t2, r2, e3.declare ? 1024 : 8331); | |
const i2 = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers); | |
i2 && (e3.typeParameters = i2); | |
} | |
parseClassPropertyAnnotation(e3) { | |
e3.optional || (this.eat(35) ? e3.definite = true : this.eat(17) && (e3.optional = true)); | |
const t2 = this.tsTryParseTypeAnnotation(); | |
t2 && (e3.typeAnnotation = t2); | |
} | |
parseClassProperty(e3) { | |
if (this.parseClassPropertyAnnotation(e3), this.state.isAmbientContext && (!e3.readonly || e3.typeAnnotation) && this.match(29) && this.raise(La.DeclareClassFieldHasInitializer, { at: this.state.startLoc }), e3.abstract && this.match(29)) { | |
const { key: t2 } = e3; | |
this.raise(La.AbstractPropertyHasInitializer, { at: this.state.startLoc, propertyName: "Identifier" !== t2.type || e3.computed ? `[${this.input.slice(t2.start, t2.end)}]` : t2.name }); | |
} | |
return super.parseClassProperty(e3); | |
} | |
parseClassPrivateProperty(e3) { | |
return e3.abstract && this.raise(La.PrivateElementHasAbstract, { at: e3 }), e3.accessibility && this.raise(La.PrivateElementHasAccessibility, { at: e3, modifier: e3.accessibility }), this.parseClassPropertyAnnotation(e3), super.parseClassPrivateProperty(e3); | |
} | |
parseClassAccessorProperty(e3) { | |
return this.parseClassPropertyAnnotation(e3), e3.optional && this.raise(La.AccessorCannotBeOptional, { at: e3 }), super.parseClassAccessorProperty(e3); | |
} | |
pushClassMethod(e3, t2, r2, n2, i2, a2) { | |
const c2 = this.tsTryParseTypeParameters(this.tsParseConstModifier); | |
c2 && i2 && this.raise(La.ConstructorHasTypeParameters, { at: c2 }); | |
const { declare: u2 = false, kind: m2 } = t2; | |
!u2 || "get" !== m2 && "set" !== m2 || this.raise(La.DeclareAccessor, { at: t2, kind: m2 }), c2 && (t2.typeParameters = c2), super.pushClassMethod(e3, t2, r2, n2, i2, a2); | |
} | |
pushClassPrivateMethod(e3, t2, r2, n2) { | |
const i2 = this.tsTryParseTypeParameters(this.tsParseConstModifier); | |
i2 && (t2.typeParameters = i2), super.pushClassPrivateMethod(e3, t2, r2, n2); | |
} | |
declareClassPrivateMethodInScope(e3, t2) { | |
"TSDeclareMethod" !== e3.type && ("MethodDefinition" !== e3.type || e3.value.body) && super.declareClassPrivateMethodInScope(e3, t2); | |
} | |
parseClassSuper(e3) { | |
super.parseClassSuper(e3), e3.superClass && (this.match(47) || this.match(51)) && (e3.superTypeParameters = this.tsParseTypeArgumentsInExpression()), this.eatContextual(111) && (e3.implements = this.tsParseHeritageClause("implements")); | |
} | |
parseObjPropValue(e3, t2, r2, n2, i2, a2, c2) { | |
const u2 = this.tsTryParseTypeParameters(this.tsParseConstModifier); | |
return u2 && (e3.typeParameters = u2), super.parseObjPropValue(e3, t2, r2, n2, i2, a2, c2); | |
} | |
parseFunctionParams(e3, t2) { | |
const r2 = this.tsTryParseTypeParameters(this.tsParseConstModifier); | |
r2 && (e3.typeParameters = r2), super.parseFunctionParams(e3, t2); | |
} | |
parseVarId(e3, t2) { | |
super.parseVarId(e3, t2), "Identifier" === e3.id.type && !this.hasPrecedingLineBreak() && this.eat(35) && (e3.definite = true); | |
const r2 = this.tsTryParseTypeAnnotation(); | |
r2 && (e3.id.typeAnnotation = r2, this.resetEndLocation(e3.id)); | |
} | |
parseAsyncArrowFromCallExpression(e3, t2) { | |
return this.match(14) && (e3.returnType = this.tsParseTypeAnnotation()), super.parseAsyncArrowFromCallExpression(e3, t2); | |
} | |
parseMaybeAssign(e3, t2) { | |
var r2, n2, i2, a2, c2; | |
let u2, m2, g2, b2; | |
if (this.hasPlugin("jsx") && (this.match(140) || this.match(47))) { | |
if (u2 = this.state.clone(), m2 = this.tryParse(() => super.parseMaybeAssign(e3, t2), u2), !m2.error) | |
return m2.node; | |
const { context: r3 } = this.state, n3 = r3[r3.length - 1]; | |
n3 !== zo.j_oTag && n3 !== zo.j_expr || r3.pop(); | |
} | |
if (!(null != (r2 = m2) && r2.error || this.match(47))) | |
return super.parseMaybeAssign(e3, t2); | |
u2 && u2 !== this.state || (u2 = this.state.clone()); | |
const x2 = this.tryParse((r3) => { | |
var n3, i3; | |
b2 = this.tsParseTypeParameters(this.tsParseConstModifier); | |
const a3 = super.parseMaybeAssign(e3, t2); | |
return ("ArrowFunctionExpression" !== a3.type || null != (n3 = a3.extra) && n3.parenthesized) && r3(), 0 !== (null == (i3 = b2) ? void 0 : i3.params.length) && this.resetStartLocationFromNode(a3, b2), a3.typeParameters = b2, a3; | |
}, u2); | |
if (!x2.error && !x2.aborted) | |
return b2 && this.reportReservedArrowTypeParam(b2), x2.node; | |
if (!m2 && (assert$1(!this.hasPlugin("jsx")), g2 = this.tryParse(() => super.parseMaybeAssign(e3, t2), u2), !g2.error)) | |
return g2.node; | |
if (null != (n2 = m2) && n2.node) | |
return this.state = m2.failState, m2.node; | |
if (x2.node) | |
return this.state = x2.failState, b2 && this.reportReservedArrowTypeParam(b2), x2.node; | |
if (null != (i2 = g2) && i2.node) | |
return this.state = g2.failState, g2.node; | |
throw (null == (a2 = m2) ? void 0 : a2.error) || x2.error || (null == (c2 = g2) ? void 0 : c2.error); | |
} | |
reportReservedArrowTypeParam(e3) { | |
var t2; | |
1 !== e3.params.length || e3.params[0].constraint || null != (t2 = e3.extra) && t2.trailingComma || !this.getPluginOption("typescript", "disallowAmbiguousJSXLike") || this.raise(La.ReservedArrowTypeParam, { at: e3 }); | |
} | |
parseMaybeUnary(e3, t2) { | |
return !this.hasPlugin("jsx") && this.match(47) ? this.tsParseTypeAssertion() : super.parseMaybeUnary(e3, t2); | |
} | |
parseArrow(e3) { | |
if (this.match(14)) { | |
const t2 = this.tryParse((e4) => { | |
const t3 = this.tsParseTypeOrTypePredicateAnnotation(14); | |
return !this.canInsertSemicolon() && this.match(19) || e4(), t3; | |
}); | |
if (t2.aborted) | |
return; | |
t2.thrown || (t2.error && (this.state = t2.failState), e3.returnType = t2.node); | |
} | |
return super.parseArrow(e3); | |
} | |
parseAssignableListItemTypes(e3, t2) { | |
if (!(2 & t2)) | |
return e3; | |
this.eat(17) && (e3.optional = true); | |
const r2 = this.tsTryParseTypeAnnotation(); | |
return r2 && (e3.typeAnnotation = r2), this.resetEndLocation(e3), e3; | |
} | |
isAssignable(e3, t2) { | |
switch (e3.type) { | |
case "TSTypeCastExpression": | |
return this.isAssignable(e3.expression, t2); | |
case "TSParameterProperty": | |
return true; | |
default: | |
return super.isAssignable(e3, t2); | |
} | |
} | |
toAssignable(e3, t2 = false) { | |
switch (e3.type) { | |
case "ParenthesizedExpression": | |
this.toAssignableParenthesizedExpression(e3, t2); | |
break; | |
case "TSAsExpression": | |
case "TSSatisfiesExpression": | |
case "TSNonNullExpression": | |
case "TSTypeAssertion": | |
t2 ? this.expressionScope.recordArrowParameterBindingError(La.UnexpectedTypeCastInParameter, { at: e3 }) : this.raise(La.UnexpectedTypeCastInParameter, { at: e3 }), this.toAssignable(e3.expression, t2); | |
break; | |
case "AssignmentExpression": | |
t2 || "TSTypeCastExpression" !== e3.left.type || (e3.left = this.typeCastToParameter(e3.left)); | |
default: | |
super.toAssignable(e3, t2); | |
} | |
} | |
toAssignableParenthesizedExpression(e3, t2) { | |
switch (e3.expression.type) { | |
case "TSAsExpression": | |
case "TSSatisfiesExpression": | |
case "TSNonNullExpression": | |
case "TSTypeAssertion": | |
case "ParenthesizedExpression": | |
this.toAssignable(e3.expression, t2); | |
break; | |
default: | |
super.toAssignable(e3, t2); | |
} | |
} | |
checkToRestConversion(e3, t2) { | |
switch (e3.type) { | |
case "TSAsExpression": | |
case "TSSatisfiesExpression": | |
case "TSTypeAssertion": | |
case "TSNonNullExpression": | |
this.checkToRestConversion(e3.expression, false); | |
break; | |
default: | |
super.checkToRestConversion(e3, t2); | |
} | |
} | |
isValidLVal(e3, t2, r2) { | |
return n2 = { TSTypeCastExpression: true, TSParameterProperty: "parameter", TSNonNullExpression: "expression", TSAsExpression: (64 !== r2 || !t2) && ["expression", true], TSSatisfiesExpression: (64 !== r2 || !t2) && ["expression", true], TSTypeAssertion: (64 !== r2 || !t2) && ["expression", true] }, i2 = e3, Object.hasOwnProperty.call(n2, i2) && n2[i2] || super.isValidLVal(e3, t2, r2); | |
var n2, i2; | |
} | |
parseBindingAtom() { | |
return 78 === this.state.type ? this.parseIdentifier(true) : super.parseBindingAtom(); | |
} | |
parseMaybeDecoratorArguments(e3) { | |
if (this.match(47) || this.match(51)) { | |
const t2 = this.tsParseTypeArgumentsInExpression(); | |
if (this.match(10)) { | |
const r2 = super.parseMaybeDecoratorArguments(e3); | |
return r2.typeParameters = t2, r2; | |
} | |
this.unexpected(null, 10); | |
} | |
return super.parseMaybeDecoratorArguments(e3); | |
} | |
checkCommaAfterRest(e3) { | |
return this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === e3 ? (this.next(), false) : super.checkCommaAfterRest(e3); | |
} | |
isClassMethod() { | |
return this.match(47) || super.isClassMethod(); | |
} | |
isClassProperty() { | |
return this.match(35) || this.match(14) || super.isClassProperty(); | |
} | |
parseMaybeDefault(e3, t2) { | |
const r2 = super.parseMaybeDefault(e3, t2); | |
return "AssignmentPattern" === r2.type && r2.typeAnnotation && r2.right.start < r2.typeAnnotation.start && this.raise(La.TypeAnnotationAfterAssign, { at: r2.typeAnnotation }), r2; | |
} | |
getTokenFromCode(e3) { | |
if (this.state.inType) { | |
if (62 === e3) | |
return void this.finishOp(48, 1); | |
if (60 === e3) | |
return void this.finishOp(47, 1); | |
} | |
super.getTokenFromCode(e3); | |
} | |
reScan_lt_gt() { | |
const { type: e3 } = this.state; | |
47 === e3 ? (this.state.pos -= 1, this.readToken_lt()) : 48 === e3 && (this.state.pos -= 1, this.readToken_gt()); | |
} | |
reScan_lt() { | |
const { type: e3 } = this.state; | |
return 51 === e3 ? (this.state.pos -= 2, this.finishOp(47, 1), 47) : e3; | |
} | |
toAssignableList(e3, t2, r2) { | |
for (let t3 = 0; t3 < e3.length; t3++) { | |
const r3 = e3[t3]; | |
"TSTypeCastExpression" === (null == r3 ? void 0 : r3.type) && (e3[t3] = this.typeCastToParameter(r3)); | |
} | |
super.toAssignableList(e3, t2, r2); | |
} | |
typeCastToParameter(e3) { | |
return e3.expression.typeAnnotation = e3.typeAnnotation, this.resetEndLocation(e3.expression, e3.typeAnnotation.loc.end), e3.expression; | |
} | |
shouldParseArrow(e3) { | |
return this.match(14) ? e3.every((e4) => this.isAssignable(e4, true)) : super.shouldParseArrow(e3); | |
} | |
shouldParseAsyncArrow() { | |
return this.match(14) || super.shouldParseAsyncArrow(); | |
} | |
canHaveLeadingDecorator() { | |
return super.canHaveLeadingDecorator() || this.isAbstractClass(); | |
} | |
jsxParseOpeningElementAfterName(e3) { | |
if (this.match(47) || this.match(51)) { | |
const t2 = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression()); | |
t2 && (e3.typeParameters = t2); | |
} | |
return super.jsxParseOpeningElementAfterName(e3); | |
} | |
getGetterSetterExpectedParamCount(e3) { | |
const t2 = super.getGetterSetterExpectedParamCount(e3), r2 = this.getObjectOrClassMethodParams(e3)[0]; | |
return r2 && this.isThisParam(r2) ? t2 + 1 : t2; | |
} | |
parseCatchClauseParam() { | |
const e3 = super.parseCatchClauseParam(), t2 = this.tsTryParseTypeAnnotation(); | |
return t2 && (e3.typeAnnotation = t2, this.resetEndLocation(e3)), e3; | |
} | |
tsInAmbientContext(e3) { | |
const t2 = this.state.isAmbientContext; | |
this.state.isAmbientContext = true; | |
try { | |
return e3(); | |
} finally { | |
this.state.isAmbientContext = t2; | |
} | |
} | |
parseClass(e3, t2, r2) { | |
const n2 = this.state.inAbstractClass; | |
this.state.inAbstractClass = !!e3.abstract; | |
try { | |
return super.parseClass(e3, t2, r2); | |
} finally { | |
this.state.inAbstractClass = n2; | |
} | |
} | |
tsParseAbstractDeclaration(e3, t2) { | |
if (this.match(80)) | |
return e3.abstract = true, this.maybeTakeDecorators(t2, this.parseClass(e3, true, false)); | |
if (this.isContextual(127)) { | |
if (!this.hasFollowingLineBreak()) | |
return e3.abstract = true, this.raise(La.NonClassMethodPropertyHasAbstractModifer, { at: e3 }), this.tsParseInterfaceDeclaration(e3); | |
} else | |
this.unexpected(null, 80); | |
} | |
parseMethod(e3, t2, r2, n2, i2, a2, c2) { | |
const u2 = super.parseMethod(e3, t2, r2, n2, i2, a2, c2); | |
if (u2.abstract) { | |
if (this.hasPlugin("estree") ? !!u2.value.body : !!u2.body) { | |
const { key: e4 } = u2; | |
this.raise(La.AbstractMethodHasImplementation, { at: u2, methodName: "Identifier" !== e4.type || u2.computed ? `[${this.input.slice(e4.start, e4.end)}]` : e4.name }); | |
} | |
} | |
return u2; | |
} | |
tsParseTypeParameterName() { | |
return this.parseIdentifier().name; | |
} | |
shouldParseAsAmbientContext() { | |
return !!this.getPluginOption("typescript", "dts"); | |
} | |
parse() { | |
return this.shouldParseAsAmbientContext() && (this.state.isAmbientContext = true), super.parse(); | |
} | |
getExpression() { | |
return this.shouldParseAsAmbientContext() && (this.state.isAmbientContext = true), super.getExpression(); | |
} | |
parseExportSpecifier(e3, t2, r2, n2) { | |
return !t2 && n2 ? (this.parseTypeOnlyImportExportSpecifier(e3, false, r2), this.finishNode(e3, "ExportSpecifier")) : (e3.exportKind = "value", super.parseExportSpecifier(e3, t2, r2, n2)); | |
} | |
parseImportSpecifier(e3, t2, r2, n2, i2) { | |
return !t2 && n2 ? (this.parseTypeOnlyImportExportSpecifier(e3, true, r2), this.finishNode(e3, "ImportSpecifier")) : (e3.importKind = "value", super.parseImportSpecifier(e3, t2, r2, n2, r2 ? 4098 : 4096)); | |
} | |
parseTypeOnlyImportExportSpecifier(e3, t2, r2) { | |
const n2 = t2 ? "imported" : "local", i2 = t2 ? "local" : "exported"; | |
let a2, c2 = e3[n2], u2 = false, m2 = true; | |
const g2 = c2.loc.start; | |
if (this.isContextual(93)) { | |
const e4 = this.parseIdentifier(); | |
if (this.isContextual(93)) { | |
const r3 = this.parseIdentifier(); | |
tokenIsKeywordOrIdentifier(this.state.type) ? (u2 = true, c2 = e4, a2 = t2 ? this.parseIdentifier() : this.parseModuleExportName(), m2 = false) : (a2 = r3, m2 = false); | |
} else | |
tokenIsKeywordOrIdentifier(this.state.type) ? (m2 = false, a2 = t2 ? this.parseIdentifier() : this.parseModuleExportName()) : (u2 = true, c2 = e4); | |
} else | |
tokenIsKeywordOrIdentifier(this.state.type) && (u2 = true, t2 ? (c2 = this.parseIdentifier(true), this.isContextual(93) || this.checkReservedWord(c2.name, c2.loc.start, true, true)) : c2 = this.parseModuleExportName()); | |
u2 && r2 && this.raise(t2 ? La.TypeModifierIsUsedInTypeImports : La.TypeModifierIsUsedInTypeExports, { at: g2 }), e3[n2] = c2, e3[i2] = a2; | |
e3[t2 ? "importKind" : "exportKind"] = u2 ? "type" : "value", m2 && this.eatContextual(93) && (e3[i2] = t2 ? this.parseIdentifier() : this.parseModuleExportName()), e3[i2] || (e3[i2] = cloneIdentifier(e3[n2])), t2 && this.checkIdentifier(e3[i2], u2 ? 4098 : 4096); | |
} | |
}, v8intrinsic: (e2) => class extends e2 { | |
parseV8Intrinsic() { | |
if (this.match(54)) { | |
const e3 = this.state.startLoc, t2 = this.startNode(); | |
if (this.next(), tokenIsIdentifier(this.state.type)) { | |
const e4 = this.parseIdentifierName(), r2 = this.createIdentifier(t2, e4); | |
if (r2.type = "V8IntrinsicIdentifier", this.match(10)) | |
return r2; | |
} | |
this.unexpected(e3); | |
} | |
} | |
parseExprAtom(e3) { | |
return this.parseV8Intrinsic() || super.parseExprAtom(e3); | |
} | |
}, placeholders: (e2) => class extends e2 { | |
parsePlaceholder(e3) { | |
if (this.match(142)) { | |
const t2 = this.startNode(); | |
return this.next(), this.assertNoSpace(), t2.name = super.parseIdentifier(true), this.assertNoSpace(), this.expect(142), this.finishPlaceholder(t2, e3); | |
} | |
} | |
finishPlaceholder(e3, t2) { | |
const r2 = !(!e3.expectedNode || "Placeholder" !== e3.type); | |
return e3.expectedNode = t2, r2 ? e3 : this.finishNode(e3, "Placeholder"); | |
} | |
getTokenFromCode(e3) { | |
37 === e3 && 37 === this.input.charCodeAt(this.state.pos + 1) ? this.finishOp(142, 2) : super.getTokenFromCode(e3); | |
} | |
parseExprAtom(e3) { | |
return this.parsePlaceholder("Expression") || super.parseExprAtom(e3); | |
} | |
parseIdentifier(e3) { | |
return this.parsePlaceholder("Identifier") || super.parseIdentifier(e3); | |
} | |
checkReservedWord(e3, t2, r2, n2) { | |
void 0 !== e3 && super.checkReservedWord(e3, t2, r2, n2); | |
} | |
parseBindingAtom() { | |
return this.parsePlaceholder("Pattern") || super.parseBindingAtom(); | |
} | |
isValidLVal(e3, t2, r2) { | |
return "Placeholder" === e3 || super.isValidLVal(e3, t2, r2); | |
} | |
toAssignable(e3, t2) { | |
e3 && "Placeholder" === e3.type && "Expression" === e3.expectedNode ? e3.expectedNode = "Pattern" : super.toAssignable(e3, t2); | |
} | |
chStartsBindingIdentifier(e3, t2) { | |
if (super.chStartsBindingIdentifier(e3, t2)) | |
return true; | |
return 142 === this.lookahead().type; | |
} | |
verifyBreakContinue(e3, t2) { | |
e3.label && "Placeholder" === e3.label.type || super.verifyBreakContinue(e3, t2); | |
} | |
parseExpressionStatement(e3, t2) { | |
var r2; | |
if ("Placeholder" !== t2.type || null != (r2 = t2.extra) && r2.parenthesized) | |
return super.parseExpressionStatement(e3, t2); | |
if (this.match(14)) { | |
const r3 = e3; | |
return r3.label = this.finishPlaceholder(t2, "Identifier"), this.next(), r3.body = super.parseStatementOrSloppyAnnexBFunctionDeclaration(), this.finishNode(r3, "LabeledStatement"); | |
} | |
return this.semicolon(), e3.name = t2.name, this.finishPlaceholder(e3, "Statement"); | |
} | |
parseBlock(e3, t2, r2) { | |
return this.parsePlaceholder("BlockStatement") || super.parseBlock(e3, t2, r2); | |
} | |
parseFunctionId(e3) { | |
return this.parsePlaceholder("Identifier") || super.parseFunctionId(e3); | |
} | |
parseClass(e3, t2, r2) { | |
const n2 = t2 ? "ClassDeclaration" : "ClassExpression"; | |
this.next(); | |
const i2 = this.state.strict, a2 = this.parsePlaceholder("Identifier"); | |
if (a2) { | |
if (!(this.match(81) || this.match(142) || this.match(5))) { | |
if (r2 || !t2) | |
return e3.id = null, e3.body = this.finishPlaceholder(a2, "ClassBody"), this.finishNode(e3, n2); | |
throw this.raise(Ra.ClassNameIsRequired, { at: this.state.startLoc }); | |
} | |
e3.id = a2; | |
} else | |
this.parseClassId(e3, t2, r2); | |
return super.parseClassSuper(e3), e3.body = this.parsePlaceholder("ClassBody") || super.parseClassBody(!!e3.superClass, i2), this.finishNode(e3, n2); | |
} | |
parseExport(e3, t2) { | |
const r2 = this.parsePlaceholder("Identifier"); | |
if (!r2) | |
return super.parseExport(e3, t2); | |
if (!this.isContextual(97) && !this.match(12)) | |
return e3.specifiers = [], e3.source = null, e3.declaration = this.finishPlaceholder(r2, "Declaration"), this.finishNode(e3, "ExportNamedDeclaration"); | |
this.expectPlugin("exportDefaultFrom"); | |
const n2 = this.startNode(); | |
return n2.exported = r2, e3.specifiers = [this.finishNode(n2, "ExportDefaultSpecifier")], super.parseExport(e3, t2); | |
} | |
isExportDefaultSpecifier() { | |
if (this.match(65)) { | |
const e3 = this.nextTokenStart(); | |
if (this.isUnparsedContextual(e3, "from") && this.input.startsWith(tokenLabelName(142), this.nextTokenStartSince(e3 + 4))) | |
return true; | |
} | |
return super.isExportDefaultSpecifier(); | |
} | |
maybeParseExportDefaultSpecifier(e3, t2) { | |
var r2; | |
return !(null == (r2 = e3.specifiers) || !r2.length) || super.maybeParseExportDefaultSpecifier(e3, t2); | |
} | |
checkExport(e3) { | |
const { specifiers: t2 } = e3; | |
null != t2 && t2.length && (e3.specifiers = t2.filter((e4) => "Placeholder" === e4.exported.type)), super.checkExport(e3), e3.specifiers = t2; | |
} | |
parseImport(e3) { | |
const t2 = this.parsePlaceholder("Identifier"); | |
if (!t2) | |
return super.parseImport(e3); | |
if (e3.specifiers = [], !this.isContextual(97) && !this.match(12)) | |
return e3.source = this.finishPlaceholder(t2, "StringLiteral"), this.semicolon(), this.finishNode(e3, "ImportDeclaration"); | |
const r2 = this.startNodeAtNode(t2); | |
if (r2.local = t2, e3.specifiers.push(this.finishNode(r2, "ImportDefaultSpecifier")), this.eat(12)) { | |
this.maybeParseStarImportSpecifier(e3) || this.parseNamedImportSpecifiers(e3); | |
} | |
return this.expectContextual(97), e3.source = this.parseImportSource(), this.semicolon(), this.finishNode(e3, "ImportDeclaration"); | |
} | |
parseImportSource() { | |
return this.parsePlaceholder("StringLiteral") || super.parseImportSource(); | |
} | |
assertNoSpace() { | |
this.state.start > this.state.lastTokEndLoc.index && this.raise(Ra.UnexpectedSpace, { at: this.state.lastTokEndLoc }); | |
} | |
} }, $a = Object.keys(ja), Ua = { sourceType: "script", sourceFilename: void 0, startColumn: 0, startLine: 1, allowAwaitOutsideFunction: false, allowReturnOutsideFunction: false, allowNewTargetOutsideFunction: false, allowImportExportEverywhere: false, allowSuperOutsideMethod: false, allowUndeclaredExports: false, plugins: [], strictMode: null, ranges: false, tokens: false, createParenthesizedExpressions: false, errorRecovery: false, attachComment: true, annexB: true }; | |
class ExpressionParser extends LValParser { | |
checkProto(e2, t2, r2, n2) { | |
if ("SpreadElement" === e2.type || this.isObjectMethod(e2) || e2.computed || e2.shorthand) | |
return; | |
const i2 = e2.key; | |
if ("__proto__" === ("Identifier" === i2.type ? i2.name : i2.value)) { | |
if (t2) | |
return void this.raise(Ho.RecordNoProto, { at: i2 }); | |
r2.used && (n2 ? null === n2.doubleProtoLoc && (n2.doubleProtoLoc = i2.loc.start) : this.raise(Ho.DuplicateProto, { at: i2 })), r2.used = true; | |
} | |
} | |
shouldExitDescending(e2, t2) { | |
return "ArrowFunctionExpression" === e2.type && e2.start === t2; | |
} | |
getExpression() { | |
this.enterInitialScopes(), this.nextToken(); | |
const e2 = this.parseExpression(); | |
return this.match(137) || this.unexpected(), this.finalizeRemainingComments(), e2.comments = this.state.comments, e2.errors = this.state.errors, this.options.tokens && (e2.tokens = this.tokens), e2; | |
} | |
parseExpression(e2, t2) { | |
return e2 ? this.disallowInAnd(() => this.parseExpressionBase(t2)) : this.allowInAnd(() => this.parseExpressionBase(t2)); | |
} | |
parseExpressionBase(e2) { | |
const t2 = this.state.startLoc, r2 = this.parseMaybeAssign(e2); | |
if (this.match(12)) { | |
const n2 = this.startNodeAt(t2); | |
for (n2.expressions = [r2]; this.eat(12); ) | |
n2.expressions.push(this.parseMaybeAssign(e2)); | |
return this.toReferencedList(n2.expressions), this.finishNode(n2, "SequenceExpression"); | |
} | |
return r2; | |
} | |
parseMaybeAssignDisallowIn(e2, t2) { | |
return this.disallowInAnd(() => this.parseMaybeAssign(e2, t2)); | |
} | |
parseMaybeAssignAllowIn(e2, t2) { | |
return this.allowInAnd(() => this.parseMaybeAssign(e2, t2)); | |
} | |
setOptionalParametersError(e2, t2) { | |
var r2; | |
e2.optionalParametersLoc = null != (r2 = null == t2 ? void 0 : t2.loc) ? r2 : this.state.startLoc; | |
} | |
parseMaybeAssign(e2, t2) { | |
const r2 = this.state.startLoc; | |
if (this.isContextual(106) && this.prodParam.hasYield) { | |
let e3 = this.parseYield(); | |
return t2 && (e3 = t2.call(this, e3, r2)), e3; | |
} | |
let n2; | |
e2 ? n2 = false : (e2 = new ExpressionErrors(), n2 = true); | |
const { type: i2 } = this.state; | |
(10 === i2 || tokenIsIdentifier(i2)) && (this.state.potentialArrowAt = this.state.start); | |
let a2 = this.parseMaybeConditional(e2); | |
if (t2 && (a2 = t2.call(this, a2, r2)), (c2 = this.state.type) >= 29 && c2 <= 33) { | |
const t3 = this.startNodeAt(r2), n3 = this.state.value; | |
if (t3.operator = n3, this.match(29)) { | |
this.toAssignable(a2, true), t3.left = a2; | |
const n4 = r2.index; | |
null != e2.doubleProtoLoc && e2.doubleProtoLoc.index >= n4 && (e2.doubleProtoLoc = null), null != e2.shorthandAssignLoc && e2.shorthandAssignLoc.index >= n4 && (e2.shorthandAssignLoc = null), null != e2.privateKeyLoc && e2.privateKeyLoc.index >= n4 && (this.checkDestructuringPrivate(e2), e2.privateKeyLoc = null); | |
} else | |
t3.left = a2; | |
return this.next(), t3.right = this.parseMaybeAssign(), this.checkLVal(a2, { in: this.finishNode(t3, "AssignmentExpression") }), t3; | |
} | |
var c2; | |
return n2 && this.checkExpressionErrors(e2, true), a2; | |
} | |
parseMaybeConditional(e2) { | |
const t2 = this.state.startLoc, r2 = this.state.potentialArrowAt, n2 = this.parseExprOps(e2); | |
return this.shouldExitDescending(n2, r2) ? n2 : this.parseConditional(n2, t2, e2); | |
} | |
parseConditional(e2, t2, r2) { | |
if (this.eat(17)) { | |
const r3 = this.startNodeAt(t2); | |
return r3.test = e2, r3.consequent = this.parseMaybeAssignAllowIn(), this.expect(14), r3.alternate = this.parseMaybeAssign(), this.finishNode(r3, "ConditionalExpression"); | |
} | |
return e2; | |
} | |
parseMaybeUnaryOrPrivate(e2) { | |
return this.match(136) ? this.parsePrivateName() : this.parseMaybeUnary(e2); | |
} | |
parseExprOps(e2) { | |
const t2 = this.state.startLoc, r2 = this.state.potentialArrowAt, n2 = this.parseMaybeUnaryOrPrivate(e2); | |
return this.shouldExitDescending(n2, r2) ? n2 : this.parseExprOp(n2, t2, -1); | |
} | |
parseExprOp(e2, t2, r2) { | |
if (this.isPrivateName(e2)) { | |
const t3 = this.getPrivateNameSV(e2); | |
(r2 >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) && this.raise(Ho.PrivateInExpectedIn, { at: e2, identifierName: t3 }), this.classScope.usePrivateName(t3, e2.loc.start); | |
} | |
const n2 = this.state.type; | |
if ((i2 = n2) >= 39 && i2 <= 59 && (this.prodParam.hasIn || !this.match(58))) { | |
let i3 = tokenOperatorPrecedence(n2); | |
if (i3 > r2) { | |
if (39 === n2) { | |
if (this.expectPlugin("pipelineOperator"), this.state.inFSharpPipelineDirectBody) | |
return e2; | |
this.checkPipelineAtInfixOperator(e2, t2); | |
} | |
const a2 = this.startNodeAt(t2); | |
a2.left = e2, a2.operator = this.state.value; | |
const c2 = 41 === n2 || 42 === n2, u2 = 40 === n2; | |
if (u2 && (i3 = tokenOperatorPrecedence(42)), this.next(), 39 === n2 && this.hasPlugin(["pipelineOperator", { proposal: "minimal" }]) && 96 === this.state.type && this.prodParam.hasAwait) | |
throw this.raise(Ho.UnexpectedAwaitAfterPipelineBody, { at: this.state.startLoc }); | |
a2.right = this.parseExprOpRightExpr(n2, i3); | |
const m2 = this.finishNode(a2, c2 || u2 ? "LogicalExpression" : "BinaryExpression"), g2 = this.state.type; | |
if (u2 && (41 === g2 || 42 === g2) || c2 && 40 === g2) | |
throw this.raise(Ho.MixingCoalesceWithLogical, { at: this.state.startLoc }); | |
return this.parseExprOp(m2, t2, r2); | |
} | |
} | |
var i2; | |
return e2; | |
} | |
parseExprOpRightExpr(e2, t2) { | |
const r2 = this.state.startLoc; | |
if (39 === e2) | |
switch (this.getPluginOption("pipelineOperator", "proposal")) { | |
case "hack": | |
return this.withTopicBindingContext(() => this.parseHackPipeBody()); | |
case "smart": | |
return this.withTopicBindingContext(() => { | |
if (this.prodParam.hasYield && this.isContextual(106)) | |
throw this.raise(Ho.PipeBodyIsTighter, { at: this.state.startLoc }); | |
return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(e2, t2), r2); | |
}); | |
case "fsharp": | |
return this.withSoloAwaitPermittingContext(() => this.parseFSharpPipelineBody(t2)); | |
} | |
return this.parseExprOpBaseRightExpr(e2, t2); | |
} | |
parseExprOpBaseRightExpr(e2, t2) { | |
const r2 = this.state.startLoc; | |
return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), r2, 57 === e2 ? t2 - 1 : t2); | |
} | |
parseHackPipeBody() { | |
var e2; | |
const { startLoc: t2 } = this.state, r2 = this.parseMaybeAssign(); | |
return !Bo.has(r2.type) || null != (e2 = r2.extra) && e2.parenthesized || this.raise(Ho.PipeUnparenthesizedBody, { at: t2, type: r2.type }), this.topicReferenceWasUsedInCurrentContext() || this.raise(Ho.PipeTopicUnused, { at: t2 }), r2; | |
} | |
checkExponentialAfterUnary(e2) { | |
this.match(57) && this.raise(Ho.UnexpectedTokenUnaryExponentiation, { at: e2.argument }); | |
} | |
parseMaybeUnary(e2, t2) { | |
const r2 = this.state.startLoc, n2 = this.isContextual(96); | |
if (n2 && this.isAwaitAllowed()) { | |
this.next(); | |
const e3 = this.parseAwait(r2); | |
return t2 || this.checkExponentialAfterUnary(e3), e3; | |
} | |
const i2 = this.match(34), a2 = this.startNode(); | |
if (c2 = this.state.type, na[c2]) { | |
a2.operator = this.state.value, a2.prefix = true, this.match(72) && this.expectPlugin("throwExpressions"); | |
const r3 = this.match(89); | |
if (this.next(), a2.argument = this.parseMaybeUnary(null, true), this.checkExpressionErrors(e2, true), this.state.strict && r3) { | |
const e3 = a2.argument; | |
"Identifier" === e3.type ? this.raise(Ho.StrictDelete, { at: a2 }) : this.hasPropertyAsPrivateName(e3) && this.raise(Ho.DeletePrivateField, { at: a2 }); | |
} | |
if (!i2) | |
return t2 || this.checkExponentialAfterUnary(a2), this.finishNode(a2, "UnaryExpression"); | |
} | |
var c2; | |
const u2 = this.parseUpdate(a2, i2, e2); | |
if (n2) { | |
const { type: e3 } = this.state; | |
if ((this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(e3) : tokenCanStartExpression(e3) && !this.match(54)) && !this.isAmbiguousAwait()) | |
return this.raiseOverwrite(Ho.AwaitNotInAsyncContext, { at: r2 }), this.parseAwait(r2); | |
} | |
return u2; | |
} | |
parseUpdate(e2, t2, r2) { | |
if (t2) { | |
const t3 = e2; | |
return this.checkLVal(t3.argument, { in: this.finishNode(t3, "UpdateExpression") }), e2; | |
} | |
const n2 = this.state.startLoc; | |
let i2 = this.parseExprSubscripts(r2); | |
if (this.checkExpressionErrors(r2, false)) | |
return i2; | |
for (; 34 === this.state.type && !this.canInsertSemicolon(); ) { | |
const e3 = this.startNodeAt(n2); | |
e3.operator = this.state.value, e3.prefix = false, e3.argument = i2, this.next(), this.checkLVal(i2, { in: i2 = this.finishNode(e3, "UpdateExpression") }); | |
} | |
return i2; | |
} | |
parseExprSubscripts(e2) { | |
const t2 = this.state.startLoc, r2 = this.state.potentialArrowAt, n2 = this.parseExprAtom(e2); | |
return this.shouldExitDescending(n2, r2) ? n2 : this.parseSubscripts(n2, t2); | |
} | |
parseSubscripts(e2, t2, r2) { | |
const n2 = { optionalChainMember: false, maybeAsyncArrow: this.atPossibleAsyncArrow(e2), stop: false }; | |
do { | |
e2 = this.parseSubscript(e2, t2, r2, n2), n2.maybeAsyncArrow = false; | |
} while (!n2.stop); | |
return e2; | |
} | |
parseSubscript(e2, t2, r2, n2) { | |
const { type: i2 } = this.state; | |
if (!r2 && 15 === i2) | |
return this.parseBind(e2, t2, r2, n2); | |
if (tokenIsTemplate(i2)) | |
return this.parseTaggedTemplateExpression(e2, t2, n2); | |
let a2 = false; | |
if (18 === i2) { | |
if (r2 && (this.raise(Ho.OptionalChainingNoNew, { at: this.state.startLoc }), 40 === this.lookaheadCharCode())) | |
return n2.stop = true, e2; | |
n2.optionalChainMember = a2 = true, this.next(); | |
} | |
if (!r2 && this.match(10)) | |
return this.parseCoverCallAndAsyncArrowHead(e2, t2, n2, a2); | |
{ | |
const r3 = this.eat(0); | |
return r3 || a2 || this.eat(16) ? this.parseMember(e2, t2, n2, r3, a2) : (n2.stop = true, e2); | |
} | |
} | |
parseMember(e2, t2, r2, n2, i2) { | |
const a2 = this.startNodeAt(t2); | |
return a2.object = e2, a2.computed = n2, n2 ? (a2.property = this.parseExpression(), this.expect(3)) : this.match(136) ? ("Super" === e2.type && this.raise(Ho.SuperPrivateField, { at: t2 }), this.classScope.usePrivateName(this.state.value, this.state.startLoc), a2.property = this.parsePrivateName()) : a2.property = this.parseIdentifier(true), r2.optionalChainMember ? (a2.optional = i2, this.finishNode(a2, "OptionalMemberExpression")) : this.finishNode(a2, "MemberExpression"); | |
} | |
parseBind(e2, t2, r2, n2) { | |
const i2 = this.startNodeAt(t2); | |
return i2.object = e2, this.next(), i2.callee = this.parseNoCallExpr(), n2.stop = true, this.parseSubscripts(this.finishNode(i2, "BindExpression"), t2, r2); | |
} | |
parseCoverCallAndAsyncArrowHead(e2, t2, r2, n2) { | |
const i2 = this.state.maybeInArrowParameters; | |
let a2 = null; | |
this.state.maybeInArrowParameters = true, this.next(); | |
const c2 = this.startNodeAt(t2); | |
c2.callee = e2; | |
const { maybeAsyncArrow: u2, optionalChainMember: m2 } = r2; | |
u2 && (this.expressionScope.enter(new ArrowHeadParsingScope(2)), a2 = new ExpressionErrors()), m2 && (c2.optional = n2), c2.arguments = n2 ? this.parseCallExpressionArguments(11) : this.parseCallExpressionArguments(11, "Import" === e2.type, "Super" !== e2.type, c2, a2); | |
let g2 = this.finishCallExpression(c2, m2); | |
return u2 && this.shouldParseAsyncArrow() && !n2 ? (r2.stop = true, this.checkDestructuringPrivate(a2), this.expressionScope.validateAsPattern(), this.expressionScope.exit(), g2 = this.parseAsyncArrowFromCallExpression(this.startNodeAt(t2), g2)) : (u2 && (this.checkExpressionErrors(a2, true), this.expressionScope.exit()), this.toReferencedArguments(g2)), this.state.maybeInArrowParameters = i2, g2; | |
} | |
toReferencedArguments(e2, t2) { | |
this.toReferencedListDeep(e2.arguments, t2); | |
} | |
parseTaggedTemplateExpression(e2, t2, r2) { | |
const n2 = this.startNodeAt(t2); | |
return n2.tag = e2, n2.quasi = this.parseTemplate(true), r2.optionalChainMember && this.raise(Ho.OptionalChainingNoTemplate, { at: t2 }), this.finishNode(n2, "TaggedTemplateExpression"); | |
} | |
atPossibleAsyncArrow(e2) { | |
return "Identifier" === e2.type && "async" === e2.name && this.state.lastTokEndLoc.index === e2.end && !this.canInsertSemicolon() && e2.end - e2.start == 5 && e2.start === this.state.potentialArrowAt; | |
} | |
expectImportAttributesPlugin() { | |
this.hasPlugin("importAssertions") || this.expectPlugin("importAttributes"); | |
} | |
finishCallExpression(e2, t2) { | |
if ("Import" === e2.callee.type) | |
if (2 === e2.arguments.length && (this.hasPlugin("moduleAttributes") || this.expectImportAttributesPlugin()), 0 === e2.arguments.length || e2.arguments.length > 2) | |
this.raise(Ho.ImportCallArity, { at: e2, maxArgumentCount: this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? 2 : 1 }); | |
else | |
for (const t3 of e2.arguments) | |
"SpreadElement" === t3.type && this.raise(Ho.ImportCallSpreadArgument, { at: t3 }); | |
return this.finishNode(e2, t2 ? "OptionalCallExpression" : "CallExpression"); | |
} | |
parseCallExpressionArguments(e2, t2, r2, n2, i2) { | |
const a2 = []; | |
let c2 = true; | |
const u2 = this.state.inFSharpPipelineDirectBody; | |
for (this.state.inFSharpPipelineDirectBody = false; !this.eat(e2); ) { | |
if (c2) | |
c2 = false; | |
else if (this.expect(12), this.match(e2)) { | |
!t2 || this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") || this.raise(Ho.ImportCallArgumentTrailingComma, { at: this.state.lastTokStartLoc }), n2 && this.addTrailingCommaExtraToNode(n2), this.next(); | |
break; | |
} | |
a2.push(this.parseExprListItem(false, i2, r2)); | |
} | |
return this.state.inFSharpPipelineDirectBody = u2, a2; | |
} | |
shouldParseAsyncArrow() { | |
return this.match(19) && !this.canInsertSemicolon(); | |
} | |
parseAsyncArrowFromCallExpression(e2, t2) { | |
var r2; | |
return this.resetPreviousNodeTrailingComments(t2), this.expect(19), this.parseArrowExpression(e2, t2.arguments, true, null == (r2 = t2.extra) ? void 0 : r2.trailingCommaLoc), t2.innerComments && setInnerComments(e2, t2.innerComments), t2.callee.trailingComments && setInnerComments(e2, t2.callee.trailingComments), e2; | |
} | |
parseNoCallExpr() { | |
const e2 = this.state.startLoc; | |
return this.parseSubscripts(this.parseExprAtom(), e2, true); | |
} | |
parseExprAtom(e2) { | |
let t2, r2 = null; | |
const { type: n2 } = this.state; | |
switch (n2) { | |
case 79: | |
return this.parseSuper(); | |
case 83: | |
return t2 = this.startNode(), this.next(), this.match(16) ? this.parseImportMetaProperty(t2) : (this.match(10) || this.raise(Ho.UnsupportedImport, { at: this.state.lastTokStartLoc }), this.finishNode(t2, "Import")); | |
case 78: | |
return t2 = this.startNode(), this.next(), this.finishNode(t2, "ThisExpression"); | |
case 90: | |
return this.parseDo(this.startNode(), false); | |
case 56: | |
case 31: | |
return this.readRegexp(), this.parseRegExpLiteral(this.state.value); | |
case 132: | |
return this.parseNumericLiteral(this.state.value); | |
case 133: | |
return this.parseBigIntLiteral(this.state.value); | |
case 134: | |
return this.parseDecimalLiteral(this.state.value); | |
case 131: | |
return this.parseStringLiteral(this.state.value); | |
case 84: | |
return this.parseNullLiteral(); | |
case 85: | |
return this.parseBooleanLiteral(true); | |
case 86: | |
return this.parseBooleanLiteral(false); | |
case 10: { | |
const e3 = this.state.potentialArrowAt === this.state.start; | |
return this.parseParenAndDistinguishExpression(e3); | |
} | |
case 2: | |
case 1: | |
return this.parseArrayLike(2 === this.state.type ? 4 : 3, false, true); | |
case 0: | |
return this.parseArrayLike(3, true, false, e2); | |
case 6: | |
case 7: | |
return this.parseObjectLike(6 === this.state.type ? 9 : 8, false, true); | |
case 5: | |
return this.parseObjectLike(8, false, false, e2); | |
case 68: | |
return this.parseFunctionOrFunctionSent(); | |
case 26: | |
r2 = this.parseDecorators(); | |
case 80: | |
return this.parseClass(this.maybeTakeDecorators(r2, this.startNode()), false); | |
case 77: | |
return this.parseNewOrNewTarget(); | |
case 25: | |
case 24: | |
return this.parseTemplate(false); | |
case 15: { | |
t2 = this.startNode(), this.next(), t2.object = null; | |
const e3 = t2.callee = this.parseNoCallExpr(); | |
if ("MemberExpression" === e3.type) | |
return this.finishNode(t2, "BindExpression"); | |
throw this.raise(Ho.UnsupportedBind, { at: e3 }); | |
} | |
case 136: | |
return this.raise(Ho.PrivateInExpectedIn, { at: this.state.startLoc, identifierName: this.state.value }), this.parsePrivateName(); | |
case 33: | |
return this.parseTopicReferenceThenEqualsSign(54, "%"); | |
case 32: | |
return this.parseTopicReferenceThenEqualsSign(44, "^"); | |
case 37: | |
case 38: | |
return this.parseTopicReference("hack"); | |
case 44: | |
case 54: | |
case 27: { | |
const e3 = this.getPluginOption("pipelineOperator", "proposal"); | |
if (e3) | |
return this.parseTopicReference(e3); | |
this.unexpected(); | |
break; | |
} | |
case 47: { | |
const e3 = this.input.codePointAt(this.nextTokenStart()); | |
isIdentifierStart(e3) || 62 === e3 ? this.expectOnePlugin(["jsx", "flow", "typescript"]) : this.unexpected(); | |
break; | |
} | |
default: | |
if (tokenIsIdentifier(n2)) { | |
if (this.isContextual(125) && 123 === this.lookaheadInLineCharCode()) | |
return this.parseModuleExpression(); | |
const e3 = this.state.potentialArrowAt === this.state.start, t3 = this.state.containsEsc, r3 = this.parseIdentifier(); | |
if (!t3 && "async" === r3.name && !this.canInsertSemicolon()) { | |
const { type: e4 } = this.state; | |
if (68 === e4) | |
return this.resetPreviousNodeTrailingComments(r3), this.next(), this.parseAsyncFunctionExpression(this.startNodeAtNode(r3)); | |
if (tokenIsIdentifier(e4)) | |
return 61 === this.lookaheadCharCode() ? this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(r3)) : r3; | |
if (90 === e4) | |
return this.resetPreviousNodeTrailingComments(r3), this.parseDo(this.startNodeAtNode(r3), true); | |
} | |
return e3 && this.match(19) && !this.canInsertSemicolon() ? (this.next(), this.parseArrowExpression(this.startNodeAtNode(r3), [r3], false)) : r3; | |
} | |
this.unexpected(); | |
} | |
} | |
parseTopicReferenceThenEqualsSign(e2, t2) { | |
const r2 = this.getPluginOption("pipelineOperator", "proposal"); | |
if (r2) | |
return this.state.type = e2, this.state.value = t2, this.state.pos--, this.state.end--, this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1), this.parseTopicReference(r2); | |
this.unexpected(); | |
} | |
parseTopicReference(e2) { | |
const t2 = this.startNode(), r2 = this.state.startLoc, n2 = this.state.type; | |
return this.next(), this.finishTopicReference(t2, r2, e2, n2); | |
} | |
finishTopicReference(e2, t2, r2, n2) { | |
if (this.testTopicReferenceConfiguration(r2, t2, n2)) { | |
const n3 = "smart" === r2 ? "PipelinePrimaryTopicReference" : "TopicReference"; | |
return this.topicReferenceIsAllowedInCurrentContext() || this.raise("smart" === r2 ? Ho.PrimaryTopicNotAllowed : Ho.PipeTopicUnbound, { at: t2 }), this.registerTopicReference(), this.finishNode(e2, n3); | |
} | |
throw this.raise(Ho.PipeTopicUnconfiguredToken, { at: t2, token: tokenLabelName(n2) }); | |
} | |
testTopicReferenceConfiguration(e2, t2, r2) { | |
switch (e2) { | |
case "hack": | |
return this.hasPlugin(["pipelineOperator", { topicToken: tokenLabelName(r2) }]); | |
case "smart": | |
return 27 === r2; | |
default: | |
throw this.raise(Ho.PipeTopicRequiresHackPipes, { at: t2 }); | |
} | |
} | |
parseAsyncArrowUnaryFunction(e2) { | |
this.prodParam.enter(functionFlags(true, this.prodParam.hasYield)); | |
const t2 = [this.parseIdentifier()]; | |
return this.prodParam.exit(), this.hasPrecedingLineBreak() && this.raise(Ho.LineTerminatorBeforeArrow, { at: this.state.curPosition() }), this.expect(19), this.parseArrowExpression(e2, t2, true); | |
} | |
parseDo(e2, t2) { | |
this.expectPlugin("doExpressions"), t2 && this.expectPlugin("asyncDoExpressions"), e2.async = t2, this.next(); | |
const r2 = this.state.labels; | |
return this.state.labels = [], t2 ? (this.prodParam.enter(2), e2.body = this.parseBlock(), this.prodParam.exit()) : e2.body = this.parseBlock(), this.state.labels = r2, this.finishNode(e2, "DoExpression"); | |
} | |
parseSuper() { | |
const e2 = this.startNode(); | |
return this.next(), !this.match(10) || this.scope.allowDirectSuper || this.options.allowSuperOutsideMethod ? this.scope.allowSuper || this.options.allowSuperOutsideMethod || this.raise(Ho.UnexpectedSuper, { at: e2 }) : this.raise(Ho.SuperNotAllowed, { at: e2 }), this.match(10) || this.match(0) || this.match(16) || this.raise(Ho.UnsupportedSuper, { at: e2 }), this.finishNode(e2, "Super"); | |
} | |
parsePrivateName() { | |
const e2 = this.startNode(), t2 = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1)), r2 = this.state.value; | |
return this.next(), e2.id = this.createIdentifier(t2, r2), this.finishNode(e2, "PrivateName"); | |
} | |
parseFunctionOrFunctionSent() { | |
const e2 = this.startNode(); | |
if (this.next(), this.prodParam.hasYield && this.match(16)) { | |
const t2 = this.createIdentifier(this.startNodeAtNode(e2), "function"); | |
return this.next(), this.match(102) ? this.expectPlugin("functionSent") : this.hasPlugin("functionSent") || this.unexpected(), this.parseMetaProperty(e2, t2, "sent"); | |
} | |
return this.parseFunction(e2); | |
} | |
parseMetaProperty(e2, t2, r2) { | |
e2.meta = t2; | |
const n2 = this.state.containsEsc; | |
return e2.property = this.parseIdentifier(true), (e2.property.name !== r2 || n2) && this.raise(Ho.UnsupportedMetaProperty, { at: e2.property, target: t2.name, onlyValidPropertyName: r2 }), this.finishNode(e2, "MetaProperty"); | |
} | |
parseImportMetaProperty(e2) { | |
const t2 = this.createIdentifier(this.startNodeAtNode(e2), "import"); | |
return this.next(), this.isContextual(100) && (this.inModule || this.raise(Ho.ImportMetaOutsideModule, { at: t2 }), this.sawUnambiguousESM = true), this.parseMetaProperty(e2, t2, "meta"); | |
} | |
parseLiteralAtNode(e2, t2, r2) { | |
return this.addExtra(r2, "rawValue", e2), this.addExtra(r2, "raw", this.input.slice(r2.start, this.state.end)), r2.value = e2, this.next(), this.finishNode(r2, t2); | |
} | |
parseLiteral(e2, t2) { | |
const r2 = this.startNode(); | |
return this.parseLiteralAtNode(e2, t2, r2); | |
} | |
parseStringLiteral(e2) { | |
return this.parseLiteral(e2, "StringLiteral"); | |
} | |
parseNumericLiteral(e2) { | |
return this.parseLiteral(e2, "NumericLiteral"); | |
} | |
parseBigIntLiteral(e2) { | |
return this.parseLiteral(e2, "BigIntLiteral"); | |
} | |
parseDecimalLiteral(e2) { | |
return this.parseLiteral(e2, "DecimalLiteral"); | |
} | |
parseRegExpLiteral(e2) { | |
const t2 = this.parseLiteral(e2.value, "RegExpLiteral"); | |
return t2.pattern = e2.pattern, t2.flags = e2.flags, t2; | |
} | |
parseBooleanLiteral(e2) { | |
const t2 = this.startNode(); | |
return t2.value = e2, this.next(), this.finishNode(t2, "BooleanLiteral"); | |
} | |
parseNullLiteral() { | |
const e2 = this.startNode(); | |
return this.next(), this.finishNode(e2, "NullLiteral"); | |
} | |
parseParenAndDistinguishExpression(e2) { | |
const t2 = this.state.startLoc; | |
let r2; | |
this.next(), this.expressionScope.enter(new ArrowHeadParsingScope(1)); | |
const n2 = this.state.maybeInArrowParameters, i2 = this.state.inFSharpPipelineDirectBody; | |
this.state.maybeInArrowParameters = true, this.state.inFSharpPipelineDirectBody = false; | |
const a2 = this.state.startLoc, c2 = [], u2 = new ExpressionErrors(); | |
let m2, g2, b2 = true; | |
for (; !this.match(11); ) { | |
if (b2) | |
b2 = false; | |
else if (this.expect(12, null === u2.optionalParametersLoc ? null : u2.optionalParametersLoc), this.match(11)) { | |
g2 = this.state.startLoc; | |
break; | |
} | |
if (this.match(21)) { | |
const e3 = this.state.startLoc; | |
if (m2 = this.state.startLoc, c2.push(this.parseParenItem(this.parseRestBinding(), e3)), !this.checkCommaAfterRest(41)) | |
break; | |
} else | |
c2.push(this.parseMaybeAssignAllowIn(u2, this.parseParenItem)); | |
} | |
const x2 = this.state.lastTokEndLoc; | |
this.expect(11), this.state.maybeInArrowParameters = n2, this.state.inFSharpPipelineDirectBody = i2; | |
let C2 = this.startNodeAt(t2); | |
return e2 && this.shouldParseArrow(c2) && (C2 = this.parseArrow(C2)) ? (this.checkDestructuringPrivate(u2), this.expressionScope.validateAsPattern(), this.expressionScope.exit(), this.parseArrowExpression(C2, c2, false), C2) : (this.expressionScope.exit(), c2.length || this.unexpected(this.state.lastTokStartLoc), g2 && this.unexpected(g2), m2 && this.unexpected(m2), this.checkExpressionErrors(u2, true), this.toReferencedListDeep(c2, true), c2.length > 1 ? (r2 = this.startNodeAt(a2), r2.expressions = c2, this.finishNode(r2, "SequenceExpression"), this.resetEndLocation(r2, x2)) : r2 = c2[0], this.wrapParenthesis(t2, r2)); | |
} | |
wrapParenthesis(e2, t2) { | |
if (!this.options.createParenthesizedExpressions) | |
return this.addExtra(t2, "parenthesized", true), this.addExtra(t2, "parenStart", e2.index), this.takeSurroundingComments(t2, e2.index, this.state.lastTokEndLoc.index), t2; | |
const r2 = this.startNodeAt(e2); | |
return r2.expression = t2, this.finishNode(r2, "ParenthesizedExpression"); | |
} | |
shouldParseArrow(e2) { | |
return !this.canInsertSemicolon(); | |
} | |
parseArrow(e2) { | |
if (this.eat(19)) | |
return e2; | |
} | |
parseParenItem(e2, t2) { | |
return e2; | |
} | |
parseNewOrNewTarget() { | |
const e2 = this.startNode(); | |
if (this.next(), this.match(16)) { | |
const t2 = this.createIdentifier(this.startNodeAtNode(e2), "new"); | |
this.next(); | |
const r2 = this.parseMetaProperty(e2, t2, "target"); | |
return this.scope.inNonArrowFunction || this.scope.inClass || this.options.allowNewTargetOutsideFunction || this.raise(Ho.UnexpectedNewTarget, { at: r2 }), r2; | |
} | |
return this.parseNew(e2); | |
} | |
parseNew(e2) { | |
if (this.parseNewCallee(e2), this.eat(10)) { | |
const t2 = this.parseExprList(11); | |
this.toReferencedList(t2), e2.arguments = t2; | |
} else | |
e2.arguments = []; | |
return this.finishNode(e2, "NewExpression"); | |
} | |
parseNewCallee(e2) { | |
e2.callee = this.parseNoCallExpr(), "Import" === e2.callee.type && this.raise(Ho.ImportCallNotNewExpression, { at: e2.callee }); | |
} | |
parseTemplateElement(e2) { | |
const { start: t2, startLoc: r2, end: n2, value: i2 } = this.state, a2 = t2 + 1, c2 = this.startNodeAt(createPositionWithColumnOffset(r2, 1)); | |
null === i2 && (e2 || this.raise(Ho.InvalidEscapeSequenceTemplate, { at: createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1) })); | |
const u2 = this.match(24), m2 = u2 ? -1 : -2, g2 = n2 + m2; | |
c2.value = { raw: this.input.slice(a2, g2).replace(/\r\n?/g, "\n"), cooked: null === i2 ? null : i2.slice(1, m2) }, c2.tail = u2, this.next(); | |
const b2 = this.finishNode(c2, "TemplateElement"); | |
return this.resetEndLocation(b2, createPositionWithColumnOffset(this.state.lastTokEndLoc, m2)), b2; | |
} | |
parseTemplate(e2) { | |
const t2 = this.startNode(); | |
t2.expressions = []; | |
let r2 = this.parseTemplateElement(e2); | |
for (t2.quasis = [r2]; !r2.tail; ) | |
t2.expressions.push(this.parseTemplateSubstitution()), this.readTemplateContinuation(), t2.quasis.push(r2 = this.parseTemplateElement(e2)); | |
return this.finishNode(t2, "TemplateLiteral"); | |
} | |
parseTemplateSubstitution() { | |
return this.parseExpression(); | |
} | |
parseObjectLike(e2, t2, r2, n2) { | |
r2 && this.expectPlugin("recordAndTuple"); | |
const i2 = this.state.inFSharpPipelineDirectBody; | |
this.state.inFSharpPipelineDirectBody = false; | |
const a2 = /* @__PURE__ */ Object.create(null); | |
let c2 = true; | |
const u2 = this.startNode(); | |
for (u2.properties = [], this.next(); !this.match(e2); ) { | |
if (c2) | |
c2 = false; | |
else if (this.expect(12), this.match(e2)) { | |
this.addTrailingCommaExtraToNode(u2); | |
break; | |
} | |
let i3; | |
t2 ? i3 = this.parseBindingProperty() : (i3 = this.parsePropertyDefinition(n2), this.checkProto(i3, r2, a2, n2)), r2 && !this.isObjectProperty(i3) && "SpreadElement" !== i3.type && this.raise(Ho.InvalidRecordProperty, { at: i3 }), i3.shorthand && this.addExtra(i3, "shorthand", true), u2.properties.push(i3); | |
} | |
this.next(), this.state.inFSharpPipelineDirectBody = i2; | |
let m2 = "ObjectExpression"; | |
return t2 ? m2 = "ObjectPattern" : r2 && (m2 = "RecordExpression"), this.finishNode(u2, m2); | |
} | |
addTrailingCommaExtraToNode(e2) { | |
this.addExtra(e2, "trailingComma", this.state.lastTokStart), this.addExtra(e2, "trailingCommaLoc", this.state.lastTokStartLoc, false); | |
} | |
maybeAsyncOrAccessorProp(e2) { | |
return !e2.computed && "Identifier" === e2.key.type && (this.isLiteralPropertyName() || this.match(0) || this.match(55)); | |
} | |
parsePropertyDefinition(e2) { | |
let t2 = []; | |
if (this.match(26)) | |
for (this.hasPlugin("decorators") && this.raise(Ho.UnsupportedPropertyDecorator, { at: this.state.startLoc }); this.match(26); ) | |
t2.push(this.parseDecorator()); | |
const r2 = this.startNode(); | |
let n2, i2 = false, a2 = false; | |
if (this.match(21)) | |
return t2.length && this.unexpected(), this.parseSpread(); | |
t2.length && (r2.decorators = t2, t2 = []), r2.method = false, e2 && (n2 = this.state.startLoc); | |
let c2 = this.eat(55); | |
this.parsePropertyNamePrefixOperator(r2); | |
const u2 = this.state.containsEsc, m2 = this.parsePropertyName(r2, e2); | |
if (!c2 && !u2 && this.maybeAsyncOrAccessorProp(r2)) { | |
const e3 = m2.name; | |
"async" !== e3 || this.hasPrecedingLineBreak() || (i2 = true, this.resetPreviousNodeTrailingComments(m2), c2 = this.eat(55), this.parsePropertyName(r2)), "get" !== e3 && "set" !== e3 || (a2 = true, this.resetPreviousNodeTrailingComments(m2), r2.kind = e3, this.match(55) && (c2 = true, this.raise(Ho.AccessorIsGenerator, { at: this.state.curPosition(), kind: e3 }), this.next()), this.parsePropertyName(r2)); | |
} | |
return this.parseObjPropValue(r2, n2, c2, i2, false, a2, e2); | |
} | |
getGetterSetterExpectedParamCount(e2) { | |
return "get" === e2.kind ? 0 : 1; | |
} | |
getObjectOrClassMethodParams(e2) { | |
return e2.params; | |
} | |
checkGetterSetterParams(e2) { | |
var t2; | |
const r2 = this.getGetterSetterExpectedParamCount(e2), n2 = this.getObjectOrClassMethodParams(e2); | |
n2.length !== r2 && this.raise("get" === e2.kind ? Ho.BadGetterArity : Ho.BadSetterArity, { at: e2 }), "set" === e2.kind && "RestElement" === (null == (t2 = n2[n2.length - 1]) ? void 0 : t2.type) && this.raise(Ho.BadSetterRestParameter, { at: e2 }); | |
} | |
parseObjectMethod(e2, t2, r2, n2, i2) { | |
if (i2) { | |
const r3 = this.parseMethod(e2, t2, false, false, false, "ObjectMethod"); | |
return this.checkGetterSetterParams(r3), r3; | |
} | |
if (r2 || t2 || this.match(10)) | |
return n2 && this.unexpected(), e2.kind = "method", e2.method = true, this.parseMethod(e2, t2, r2, false, false, "ObjectMethod"); | |
} | |
parseObjectProperty(e2, t2, r2, n2) { | |
if (e2.shorthand = false, this.eat(14)) | |
return e2.value = r2 ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowIn(n2), this.finishNode(e2, "ObjectProperty"); | |
if (!e2.computed && "Identifier" === e2.key.type) { | |
if (this.checkReservedWord(e2.key.name, e2.key.loc.start, true, false), r2) | |
e2.value = this.parseMaybeDefault(t2, cloneIdentifier(e2.key)); | |
else if (this.match(29)) { | |
const r3 = this.state.startLoc; | |
null != n2 ? null === n2.shorthandAssignLoc && (n2.shorthandAssignLoc = r3) : this.raise(Ho.InvalidCoverInitializedName, { at: r3 }), e2.value = this.parseMaybeDefault(t2, cloneIdentifier(e2.key)); | |
} else | |
e2.value = cloneIdentifier(e2.key); | |
return e2.shorthand = true, this.finishNode(e2, "ObjectProperty"); | |
} | |
} | |
parseObjPropValue(e2, t2, r2, n2, i2, a2, c2) { | |
const u2 = this.parseObjectMethod(e2, r2, n2, i2, a2) || this.parseObjectProperty(e2, t2, i2, c2); | |
return u2 || this.unexpected(), u2; | |
} | |
parsePropertyName(e2, t2) { | |
if (this.eat(0)) | |
e2.computed = true, e2.key = this.parseMaybeAssignAllowIn(), this.expect(3); | |
else { | |
const { type: r2, value: n2 } = this.state; | |
let i2; | |
if (tokenIsKeywordOrIdentifier(r2)) | |
i2 = this.parseIdentifier(true); | |
else | |
switch (r2) { | |
case 132: | |
i2 = this.parseNumericLiteral(n2); | |
break; | |
case 131: | |
i2 = this.parseStringLiteral(n2); | |
break; | |
case 133: | |
i2 = this.parseBigIntLiteral(n2); | |
break; | |
case 134: | |
i2 = this.parseDecimalLiteral(n2); | |
break; | |
case 136: { | |
const e3 = this.state.startLoc; | |
null != t2 ? null === t2.privateKeyLoc && (t2.privateKeyLoc = e3) : this.raise(Ho.UnexpectedPrivateField, { at: e3 }), i2 = this.parsePrivateName(); | |
break; | |
} | |
default: | |
this.unexpected(); | |
} | |
e2.key = i2, 136 !== r2 && (e2.computed = false); | |
} | |
return e2.key; | |
} | |
initFunction(e2, t2) { | |
e2.id = null, e2.generator = false, e2.async = t2; | |
} | |
parseMethod(e2, t2, r2, n2, i2, a2, c2 = false) { | |
this.initFunction(e2, r2), e2.generator = t2, this.scope.enter(18 | (c2 ? 64 : 0) | (i2 ? 32 : 0)), this.prodParam.enter(functionFlags(r2, e2.generator)), this.parseFunctionParams(e2, n2); | |
const u2 = this.parseFunctionBodyAndFinish(e2, a2, true); | |
return this.prodParam.exit(), this.scope.exit(), u2; | |
} | |
parseArrayLike(e2, t2, r2, n2) { | |
r2 && this.expectPlugin("recordAndTuple"); | |
const i2 = this.state.inFSharpPipelineDirectBody; | |
this.state.inFSharpPipelineDirectBody = false; | |
const a2 = this.startNode(); | |
return this.next(), a2.elements = this.parseExprList(e2, !r2, n2, a2), this.state.inFSharpPipelineDirectBody = i2, this.finishNode(a2, r2 ? "TupleExpression" : "ArrayExpression"); | |
} | |
parseArrowExpression(e2, t2, r2, n2) { | |
this.scope.enter(6); | |
let i2 = functionFlags(r2, false); | |
!this.match(5) && this.prodParam.hasIn && (i2 |= 8), this.prodParam.enter(i2), this.initFunction(e2, r2); | |
const a2 = this.state.maybeInArrowParameters; | |
return t2 && (this.state.maybeInArrowParameters = true, this.setArrowFunctionParameters(e2, t2, n2)), this.state.maybeInArrowParameters = false, this.parseFunctionBody(e2, true), this.prodParam.exit(), this.scope.exit(), this.state.maybeInArrowParameters = a2, this.finishNode(e2, "ArrowFunctionExpression"); | |
} | |
setArrowFunctionParameters(e2, t2, r2) { | |
this.toAssignableList(t2, r2, false), e2.params = t2; | |
} | |
parseFunctionBodyAndFinish(e2, t2, r2 = false) { | |
return this.parseFunctionBody(e2, false, r2), this.finishNode(e2, t2); | |
} | |
parseFunctionBody(e2, t2, r2 = false) { | |
const n2 = t2 && !this.match(5); | |
if (this.expressionScope.enter(newExpressionScope()), n2) | |
e2.body = this.parseMaybeAssign(), this.checkParams(e2, false, t2, false); | |
else { | |
const n3 = this.state.strict, i2 = this.state.labels; | |
this.state.labels = [], this.prodParam.enter(4 | this.prodParam.currentFlags()), e2.body = this.parseBlock(true, false, (i3) => { | |
const a2 = !this.isSimpleParamList(e2.params); | |
i3 && a2 && this.raise(Ho.IllegalLanguageModeDirective, { at: "method" !== e2.kind && "constructor" !== e2.kind || !e2.key ? e2 : e2.key.loc.end }); | |
const c2 = !n3 && this.state.strict; | |
this.checkParams(e2, !(this.state.strict || t2 || r2 || a2), t2, c2), this.state.strict && e2.id && this.checkIdentifier(e2.id, 65, c2); | |
}), this.prodParam.exit(), this.state.labels = i2; | |
} | |
this.expressionScope.exit(); | |
} | |
isSimpleParameter(e2) { | |
return "Identifier" === e2.type; | |
} | |
isSimpleParamList(e2) { | |
for (let t2 = 0, r2 = e2.length; t2 < r2; t2++) | |
if (!this.isSimpleParameter(e2[t2])) | |
return false; | |
return true; | |
} | |
checkParams(e2, t2, r2, n2 = true) { | |
const i2 = !t2 && /* @__PURE__ */ new Set(), a2 = { type: "FormalParameters" }; | |
for (const t3 of e2.params) | |
this.checkLVal(t3, { in: a2, binding: 5, checkClashes: i2, strictModeChanged: n2 }); | |
} | |
parseExprList(e2, t2, r2, n2) { | |
const i2 = []; | |
let a2 = true; | |
for (; !this.eat(e2); ) { | |
if (a2) | |
a2 = false; | |
else if (this.expect(12), this.match(e2)) { | |
n2 && this.addTrailingCommaExtraToNode(n2), this.next(); | |
break; | |
} | |
i2.push(this.parseExprListItem(t2, r2)); | |
} | |
return i2; | |
} | |
parseExprListItem(e2, t2, r2) { | |
let n2; | |
if (this.match(12)) | |
e2 || this.raise(Ho.UnexpectedToken, { at: this.state.curPosition(), unexpected: "," }), n2 = null; | |
else if (this.match(21)) { | |
const e3 = this.state.startLoc; | |
n2 = this.parseParenItem(this.parseSpread(t2), e3); | |
} else if (this.match(17)) { | |
this.expectPlugin("partialApplication"), r2 || this.raise(Ho.UnexpectedArgumentPlaceholder, { at: this.state.startLoc }); | |
const e3 = this.startNode(); | |
this.next(), n2 = this.finishNode(e3, "ArgumentPlaceholder"); | |
} else | |
n2 = this.parseMaybeAssignAllowIn(t2, this.parseParenItem); | |
return n2; | |
} | |
parseIdentifier(e2) { | |
const t2 = this.startNode(), r2 = this.parseIdentifierName(e2); | |
return this.createIdentifier(t2, r2); | |
} | |
createIdentifier(e2, t2) { | |
return e2.name = t2, e2.loc.identifierName = t2, this.finishNode(e2, "Identifier"); | |
} | |
parseIdentifierName(e2) { | |
let t2; | |
const { startLoc: r2, type: n2 } = this.state; | |
tokenIsKeywordOrIdentifier(n2) ? t2 = this.state.value : this.unexpected(); | |
const i2 = n2 <= 92; | |
return e2 ? i2 && this.replaceToken(130) : this.checkReservedWord(t2, r2, i2, false), this.next(), t2; | |
} | |
checkReservedWord(e2, t2, r2, n2) { | |
if (e2.length > 10) | |
return; | |
if (!function(e3) { | |
return ga.has(e3); | |
}(e2)) | |
return; | |
if (r2 && function(e3) { | |
return ha.has(e3); | |
}(e2)) | |
return void this.raise(Ho.UnexpectedKeyword, { at: t2, keyword: e2 }); | |
if ((this.state.strict ? n2 ? isStrictBindReservedWord : isStrictReservedWord : isReservedWord)(e2, this.inModule)) | |
this.raise(Ho.UnexpectedReservedWord, { at: t2, reservedWord: e2 }); | |
else if ("yield" === e2) { | |
if (this.prodParam.hasYield) | |
return void this.raise(Ho.YieldBindingIdentifier, { at: t2 }); | |
} else if ("await" === e2) { | |
if (this.prodParam.hasAwait) | |
return void this.raise(Ho.AwaitBindingIdentifier, { at: t2 }); | |
if (this.scope.inStaticBlock) | |
return void this.raise(Ho.AwaitBindingIdentifierInStaticBlock, { at: t2 }); | |
this.expressionScope.recordAsyncArrowParametersError({ at: t2 }); | |
} else if ("arguments" === e2 && this.scope.inClassAndNotInNonArrowFunction) | |
return void this.raise(Ho.ArgumentsInClass, { at: t2 }); | |
} | |
isAwaitAllowed() { | |
return !!this.prodParam.hasAwait || !(!this.options.allowAwaitOutsideFunction || this.scope.inFunction); | |
} | |
parseAwait(e2) { | |
const t2 = this.startNodeAt(e2); | |
return this.expressionScope.recordParameterInitializerError(Ho.AwaitExpressionFormalParameter, { at: t2 }), this.eat(55) && this.raise(Ho.ObsoleteAwaitStar, { at: t2 }), this.scope.inFunction || this.options.allowAwaitOutsideFunction || (this.isAmbiguousAwait() ? this.ambiguousScriptDifferentAst = true : this.sawUnambiguousESM = true), this.state.soloAwait || (t2.argument = this.parseMaybeUnary(null, true)), this.finishNode(t2, "AwaitExpression"); | |
} | |
isAmbiguousAwait() { | |
if (this.hasPrecedingLineBreak()) | |
return true; | |
const { type: e2 } = this.state; | |
return 53 === e2 || 10 === e2 || 0 === e2 || tokenIsTemplate(e2) || 101 === e2 && !this.state.containsEsc || 135 === e2 || 56 === e2 || this.hasPlugin("v8intrinsic") && 54 === e2; | |
} | |
parseYield() { | |
const e2 = this.startNode(); | |
this.expressionScope.recordParameterInitializerError(Ho.YieldInParameter, { at: e2 }), this.next(); | |
let t2 = false, r2 = null; | |
if (!this.hasPrecedingLineBreak()) | |
switch (t2 = this.eat(55), this.state.type) { | |
case 13: | |
case 137: | |
case 8: | |
case 11: | |
case 3: | |
case 9: | |
case 14: | |
case 12: | |
if (!t2) | |
break; | |
default: | |
r2 = this.parseMaybeAssign(); | |
} | |
return e2.delegate = t2, e2.argument = r2, this.finishNode(e2, "YieldExpression"); | |
} | |
checkPipelineAtInfixOperator(e2, t2) { | |
this.hasPlugin(["pipelineOperator", { proposal: "smart" }]) && "SequenceExpression" === e2.type && this.raise(Ho.PipelineHeadSequenceExpression, { at: t2 }); | |
} | |
parseSmartPipelineBodyInStyle(e2, t2) { | |
if (this.isSimpleReference(e2)) { | |
const r2 = this.startNodeAt(t2); | |
return r2.callee = e2, this.finishNode(r2, "PipelineBareFunction"); | |
} | |
{ | |
const r2 = this.startNodeAt(t2); | |
return this.checkSmartPipeTopicBodyEarlyErrors(t2), r2.expression = e2, this.finishNode(r2, "PipelineTopicExpression"); | |
} | |
} | |
isSimpleReference(e2) { | |
switch (e2.type) { | |
case "MemberExpression": | |
return !e2.computed && this.isSimpleReference(e2.object); | |
case "Identifier": | |
return true; | |
default: | |
return false; | |
} | |
} | |
checkSmartPipeTopicBodyEarlyErrors(e2) { | |
if (this.match(19)) | |
throw this.raise(Ho.PipelineBodyNoArrow, { at: this.state.startLoc }); | |
this.topicReferenceWasUsedInCurrentContext() || this.raise(Ho.PipelineTopicUnused, { at: e2 }); | |
} | |
withTopicBindingContext(e2) { | |
const t2 = this.state.topicContext; | |
this.state.topicContext = { maxNumOfResolvableTopics: 1, maxTopicIndex: null }; | |
try { | |
return e2(); | |
} finally { | |
this.state.topicContext = t2; | |
} | |
} | |
withSmartMixTopicForbiddingContext(e2) { | |
if (!this.hasPlugin(["pipelineOperator", { proposal: "smart" }])) | |
return e2(); | |
{ | |
const t2 = this.state.topicContext; | |
this.state.topicContext = { maxNumOfResolvableTopics: 0, maxTopicIndex: null }; | |
try { | |
return e2(); | |
} finally { | |
this.state.topicContext = t2; | |
} | |
} | |
} | |
withSoloAwaitPermittingContext(e2) { | |
const t2 = this.state.soloAwait; | |
this.state.soloAwait = true; | |
try { | |
return e2(); | |
} finally { | |
this.state.soloAwait = t2; | |
} | |
} | |
allowInAnd(e2) { | |
const t2 = this.prodParam.currentFlags(); | |
if (8 & ~t2) { | |
this.prodParam.enter(8 | t2); | |
try { | |
return e2(); | |
} finally { | |
this.prodParam.exit(); | |
} | |
} | |
return e2(); | |
} | |
disallowInAnd(e2) { | |
const t2 = this.prodParam.currentFlags(); | |
if (8 & t2) { | |
this.prodParam.enter(-9 & t2); | |
try { | |
return e2(); | |
} finally { | |
this.prodParam.exit(); | |
} | |
} | |
return e2(); | |
} | |
registerTopicReference() { | |
this.state.topicContext.maxTopicIndex = 0; | |
} | |
topicReferenceIsAllowedInCurrentContext() { | |
return this.state.topicContext.maxNumOfResolvableTopics >= 1; | |
} | |
topicReferenceWasUsedInCurrentContext() { | |
return null != this.state.topicContext.maxTopicIndex && this.state.topicContext.maxTopicIndex >= 0; | |
} | |
parseFSharpPipelineBody(e2) { | |
const t2 = this.state.startLoc; | |
this.state.potentialArrowAt = this.state.start; | |
const r2 = this.state.inFSharpPipelineDirectBody; | |
this.state.inFSharpPipelineDirectBody = true; | |
const n2 = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), t2, e2); | |
return this.state.inFSharpPipelineDirectBody = r2, n2; | |
} | |
parseModuleExpression() { | |
this.expectPlugin("moduleBlocks"); | |
const e2 = this.startNode(); | |
this.next(), this.match(5) || this.unexpected(null, 5); | |
const t2 = this.startNodeAt(this.state.endLoc); | |
this.next(); | |
const r2 = this.initializeScopes(true); | |
this.enterInitialScopes(); | |
try { | |
e2.body = this.parseProgram(t2, 8, "module"); | |
} finally { | |
r2(); | |
} | |
return this.finishNode(e2, "ModuleExpression"); | |
} | |
parsePropertyNamePrefixOperator(e2) { | |
} | |
} | |
const Ha = { kind: "loop" }, Va = { kind: "switch" }, za = /[\uD800-\uDFFF]/u, qa = /in(?:stanceof)?/y; | |
class StatementParser extends ExpressionParser { | |
parseTopLevel(e2, t2) { | |
return e2.program = this.parseProgram(t2), e2.comments = this.state.comments, this.options.tokens && (e2.tokens = function(e3, t3) { | |
for (let r2 = 0; r2 < e3.length; r2++) { | |
const n2 = e3[r2], { type: i2 } = n2; | |
if ("number" == typeof i2) { | |
if (136 === i2) { | |
const { loc: t4, start: i3, value: a2, end: c2 } = n2, u2 = i3 + 1, m2 = createPositionWithColumnOffset(t4.start, 1); | |
e3.splice(r2, 1, new Token({ type: getExportedToken(27), value: "#", start: i3, end: u2, startLoc: t4.start, endLoc: m2 }), new Token({ type: getExportedToken(130), value: a2, start: u2, end: c2, startLoc: m2, endLoc: t4.end })), r2++; | |
continue; | |
} | |
if (tokenIsTemplate(i2)) { | |
const { loc: a2, start: c2, value: u2, end: m2 } = n2, g2 = c2 + 1, b2 = createPositionWithColumnOffset(a2.start, 1); | |
let x2, C2, A2, P2, T2; | |
x2 = 96 === t3.charCodeAt(c2) ? new Token({ type: getExportedToken(22), value: "`", start: c2, end: g2, startLoc: a2.start, endLoc: b2 }) : new Token({ type: getExportedToken(8), value: "}", start: c2, end: g2, startLoc: a2.start, endLoc: b2 }), 24 === i2 ? (A2 = m2 - 1, P2 = createPositionWithColumnOffset(a2.end, -1), C2 = null === u2 ? null : u2.slice(1, -1), T2 = new Token({ type: getExportedToken(22), value: "`", start: A2, end: m2, startLoc: P2, endLoc: a2.end })) : (A2 = m2 - 2, P2 = createPositionWithColumnOffset(a2.end, -2), C2 = null === u2 ? null : u2.slice(1, -2), T2 = new Token({ type: getExportedToken(23), value: "${", start: A2, end: m2, startLoc: P2, endLoc: a2.end })), e3.splice(r2, 1, x2, new Token({ type: getExportedToken(20), value: C2, start: g2, end: A2, startLoc: b2, endLoc: P2 }), T2), r2 += 2; | |
continue; | |
} | |
n2.type = getExportedToken(i2); | |
} | |
} | |
return e3; | |
}(this.tokens, this.input)), this.finishNode(e2, "File"); | |
} | |
parseProgram(e2, t2 = 137, r2 = this.options.sourceType) { | |
if (e2.sourceType = r2, e2.interpreter = this.parseInterpreterDirective(), this.parseBlockBody(e2, true, true, t2), this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) | |
for (const [e3, t3] of Array.from(this.scope.undefinedExports)) | |
this.raise(Ho.ModuleExportUndefined, { at: t3, localName: e3 }); | |
let n2; | |
return n2 = 137 === t2 ? this.finishNode(e2, "Program") : this.finishNodeAt(e2, "Program", createPositionWithColumnOffset(this.state.startLoc, -1)), n2; | |
} | |
stmtToDirective(e2) { | |
const t2 = e2; | |
t2.type = "Directive", t2.value = t2.expression, delete t2.expression; | |
const r2 = t2.value, n2 = r2.value, i2 = this.input.slice(r2.start, r2.end), a2 = r2.value = i2.slice(1, -1); | |
return this.addExtra(r2, "raw", i2), this.addExtra(r2, "rawValue", a2), this.addExtra(r2, "expressionValue", n2), r2.type = "DirectiveLiteral", t2; | |
} | |
parseInterpreterDirective() { | |
if (!this.match(28)) | |
return null; | |
const e2 = this.startNode(); | |
return e2.value = this.state.value, this.next(), this.finishNode(e2, "InterpreterDirective"); | |
} | |
isLet() { | |
return !!this.isContextual(99) && this.hasFollowingBindingAtom(); | |
} | |
chStartsBindingIdentifier(e2, t2) { | |
if (isIdentifierStart(e2)) { | |
if (qa.lastIndex = t2, qa.test(this.input)) { | |
const e3 = this.codePointAtPos(qa.lastIndex); | |
if (!isIdentifierChar(e3) && 92 !== e3) | |
return false; | |
} | |
return true; | |
} | |
return 92 === e2; | |
} | |
chStartsBindingPattern(e2) { | |
return 91 === e2 || 123 === e2; | |
} | |
hasFollowingBindingAtom() { | |
const e2 = this.nextTokenStart(), t2 = this.codePointAtPos(e2); | |
return this.chStartsBindingPattern(t2) || this.chStartsBindingIdentifier(t2, e2); | |
} | |
hasInLineFollowingBindingIdentifier() { | |
const e2 = this.nextTokenInLineStart(), t2 = this.codePointAtPos(e2); | |
return this.chStartsBindingIdentifier(t2, e2); | |
} | |
startsUsingForOf() { | |
const { type: e2, containsEsc: t2 } = this.lookahead(); | |
return !(101 === e2 && !t2) && (tokenIsIdentifier(e2) && !this.hasFollowingLineBreak() ? (this.expectPlugin("explicitResourceManagement"), true) : void 0); | |
} | |
startsAwaitUsing() { | |
let e2 = this.nextTokenInLineStart(); | |
if (this.isUnparsedContextual(e2, "using")) { | |
e2 = this.nextTokenInLineStartSince(e2 + 5); | |
const t2 = this.codePointAtPos(e2); | |
if (this.chStartsBindingIdentifier(t2, e2)) | |
return this.expectPlugin("explicitResourceManagement"), true; | |
} | |
return false; | |
} | |
parseModuleItem() { | |
return this.parseStatementLike(15); | |
} | |
parseStatementListItem() { | |
return this.parseStatementLike(6 | (!this.options.annexB || this.state.strict ? 0 : 8)); | |
} | |
parseStatementOrSloppyAnnexBFunctionDeclaration(e2 = false) { | |
let t2 = 0; | |
return this.options.annexB && !this.state.strict && (t2 |= 4, e2 && (t2 |= 8)), this.parseStatementLike(t2); | |
} | |
parseStatement() { | |
return this.parseStatementLike(0); | |
} | |
parseStatementLike(e2) { | |
let t2 = null; | |
return this.match(26) && (t2 = this.parseDecorators(true)), this.parseStatementContent(e2, t2); | |
} | |
parseStatementContent(e2, t2) { | |
const r2 = this.state.type, n2 = this.startNode(), i2 = !!(2 & e2), a2 = !!(4 & e2), c2 = 1 & e2; | |
switch (r2) { | |
case 60: | |
return this.parseBreakContinueStatement(n2, true); | |
case 63: | |
return this.parseBreakContinueStatement(n2, false); | |
case 64: | |
return this.parseDebuggerStatement(n2); | |
case 90: | |
return this.parseDoWhileStatement(n2); | |
case 91: | |
return this.parseForStatement(n2); | |
case 68: | |
if (46 === this.lookaheadCharCode()) | |
break; | |
return a2 || this.raise(this.state.strict ? Ho.StrictFunction : this.options.annexB ? Ho.SloppyFunctionAnnexB : Ho.SloppyFunction, { at: this.state.startLoc }), this.parseFunctionStatement(n2, false, !i2 && a2); | |
case 80: | |
return i2 || this.unexpected(), this.parseClass(this.maybeTakeDecorators(t2, n2), true); | |
case 69: | |
return this.parseIfStatement(n2); | |
case 70: | |
return this.parseReturnStatement(n2); | |
case 71: | |
return this.parseSwitchStatement(n2); | |
case 72: | |
return this.parseThrowStatement(n2); | |
case 73: | |
return this.parseTryStatement(n2); | |
case 96: | |
if (!this.state.containsEsc && this.startsAwaitUsing()) | |
return this.isAwaitAllowed() ? i2 || this.raise(Ho.UnexpectedLexicalDeclaration, { at: n2 }) : this.raise(Ho.AwaitUsingNotInAsyncContext, { at: n2 }), this.next(), this.parseVarStatement(n2, "await using"); | |
break; | |
case 105: | |
if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifier()) | |
break; | |
return this.expectPlugin("explicitResourceManagement"), !this.scope.inModule && this.scope.inTopLevel ? this.raise(Ho.UnexpectedUsingDeclaration, { at: this.state.startLoc }) : i2 || this.raise(Ho.UnexpectedLexicalDeclaration, { at: this.state.startLoc }), this.parseVarStatement(n2, "using"); | |
case 99: { | |
if (this.state.containsEsc) | |
break; | |
const e3 = this.nextTokenStart(), t3 = this.codePointAtPos(e3); | |
if (91 !== t3) { | |
if (!i2 && this.hasFollowingLineBreak()) | |
break; | |
if (!this.chStartsBindingIdentifier(t3, e3) && 123 !== t3) | |
break; | |
} | |
} | |
case 75: | |
i2 || this.raise(Ho.UnexpectedLexicalDeclaration, { at: this.state.startLoc }); | |
case 74: { | |
const e3 = this.state.value; | |
return this.parseVarStatement(n2, e3); | |
} | |
case 92: | |
return this.parseWhileStatement(n2); | |
case 76: | |
return this.parseWithStatement(n2); | |
case 5: | |
return this.parseBlock(); | |
case 13: | |
return this.parseEmptyStatement(n2); | |
case 83: { | |
const e3 = this.lookaheadCharCode(); | |
if (40 === e3 || 46 === e3) | |
break; | |
} | |
case 82: { | |
let e3; | |
return this.options.allowImportExportEverywhere || c2 || this.raise(Ho.UnexpectedImportExport, { at: this.state.startLoc }), this.next(), 83 === r2 ? (e3 = this.parseImport(n2), "ImportDeclaration" !== e3.type || e3.importKind && "value" !== e3.importKind || (this.sawUnambiguousESM = true)) : (e3 = this.parseExport(n2, t2), ("ExportNamedDeclaration" !== e3.type || e3.exportKind && "value" !== e3.exportKind) && ("ExportAllDeclaration" !== e3.type || e3.exportKind && "value" !== e3.exportKind) && "ExportDefaultDeclaration" !== e3.type || (this.sawUnambiguousESM = true)), this.assertModuleNodeAllowed(e3), e3; | |
} | |
default: | |
if (this.isAsyncFunction()) | |
return i2 || this.raise(Ho.AsyncFunctionInSingleStatementContext, { at: this.state.startLoc }), this.next(), this.parseFunctionStatement(n2, true, !i2 && a2); | |
} | |
const u2 = this.state.value, m2 = this.parseExpression(); | |
return tokenIsIdentifier(r2) && "Identifier" === m2.type && this.eat(14) ? this.parseLabeledStatement(n2, u2, m2, e2) : this.parseExpressionStatement(n2, m2, t2); | |
} | |
assertModuleNodeAllowed(e2) { | |
this.options.allowImportExportEverywhere || this.inModule || this.raise(Ho.ImportOutsideModule, { at: e2 }); | |
} | |
decoratorsEnabledBeforeExport() { | |
return !!this.hasPlugin("decorators-legacy") || this.hasPlugin("decorators") && false !== this.getPluginOption("decorators", "decoratorsBeforeExport"); | |
} | |
maybeTakeDecorators(e2, t2, r2) { | |
return e2 && (t2.decorators && t2.decorators.length > 0 ? ("boolean" != typeof this.getPluginOption("decorators", "decoratorsBeforeExport") && this.raise(Ho.DecoratorsBeforeAfterExport, { at: t2.decorators[0] }), t2.decorators.unshift(...e2)) : t2.decorators = e2, this.resetStartLocationFromNode(t2, e2[0]), r2 && this.resetStartLocationFromNode(r2, t2)), t2; | |
} | |
canHaveLeadingDecorator() { | |
return this.match(80); | |
} | |
parseDecorators(e2) { | |
const t2 = []; | |
do { | |
t2.push(this.parseDecorator()); | |
} while (this.match(26)); | |
if (this.match(82)) | |
e2 || this.unexpected(), this.decoratorsEnabledBeforeExport() || this.raise(Ho.DecoratorExportClass, { at: this.state.startLoc }); | |
else if (!this.canHaveLeadingDecorator()) | |
throw this.raise(Ho.UnexpectedLeadingDecorator, { at: this.state.startLoc }); | |
return t2; | |
} | |
parseDecorator() { | |
this.expectOnePlugin(["decorators", "decorators-legacy"]); | |
const e2 = this.startNode(); | |
if (this.next(), this.hasPlugin("decorators")) { | |
const t2 = this.state.startLoc; | |
let r2; | |
if (this.match(10)) { | |
const t3 = this.state.startLoc; | |
this.next(), r2 = this.parseExpression(), this.expect(11), r2 = this.wrapParenthesis(t3, r2); | |
const n2 = this.state.startLoc; | |
e2.expression = this.parseMaybeDecoratorArguments(r2), false === this.getPluginOption("decorators", "allowCallParenthesized") && e2.expression !== r2 && this.raise(Ho.DecoratorArgumentsOutsideParentheses, { at: n2 }); | |
} else { | |
for (r2 = this.parseIdentifier(false); this.eat(16); ) { | |
const e3 = this.startNodeAt(t2); | |
e3.object = r2, this.match(136) ? (this.classScope.usePrivateName(this.state.value, this.state.startLoc), e3.property = this.parsePrivateName()) : e3.property = this.parseIdentifier(true), e3.computed = false, r2 = this.finishNode(e3, "MemberExpression"); | |
} | |
e2.expression = this.parseMaybeDecoratorArguments(r2); | |
} | |
} else | |
e2.expression = this.parseExprSubscripts(); | |
return this.finishNode(e2, "Decorator"); | |
} | |
parseMaybeDecoratorArguments(e2) { | |
if (this.eat(10)) { | |
const t2 = this.startNodeAtNode(e2); | |
return t2.callee = e2, t2.arguments = this.parseCallExpressionArguments(11, false), this.toReferencedList(t2.arguments), this.finishNode(t2, "CallExpression"); | |
} | |
return e2; | |
} | |
parseBreakContinueStatement(e2, t2) { | |
return this.next(), this.isLineTerminator() ? e2.label = null : (e2.label = this.parseIdentifier(), this.semicolon()), this.verifyBreakContinue(e2, t2), this.finishNode(e2, t2 ? "BreakStatement" : "ContinueStatement"); | |
} | |
verifyBreakContinue(e2, t2) { | |
let r2; | |
for (r2 = 0; r2 < this.state.labels.length; ++r2) { | |
const n2 = this.state.labels[r2]; | |
if (null == e2.label || n2.name === e2.label.name) { | |
if (null != n2.kind && (t2 || "loop" === n2.kind)) | |
break; | |
if (e2.label && t2) | |
break; | |
} | |
} | |
if (r2 === this.state.labels.length) { | |
const r3 = t2 ? "BreakStatement" : "ContinueStatement"; | |
this.raise(Ho.IllegalBreakContinue, { at: e2, type: r3 }); | |
} | |
} | |
parseDebuggerStatement(e2) { | |
return this.next(), this.semicolon(), this.finishNode(e2, "DebuggerStatement"); | |
} | |
parseHeaderExpression() { | |
this.expect(10); | |
const e2 = this.parseExpression(); | |
return this.expect(11), e2; | |
} | |
parseDoWhileStatement(e2) { | |
return this.next(), this.state.labels.push(Ha), e2.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()), this.state.labels.pop(), this.expect(92), e2.test = this.parseHeaderExpression(), this.eat(13), this.finishNode(e2, "DoWhileStatement"); | |
} | |
parseForStatement(e2) { | |
this.next(), this.state.labels.push(Ha); | |
let t2 = null; | |
if (this.isAwaitAllowed() && this.eatContextual(96) && (t2 = this.state.lastTokStartLoc), this.scope.enter(0), this.expect(10), this.match(13)) | |
return null !== t2 && this.unexpected(t2), this.parseFor(e2, null); | |
const r2 = this.isContextual(99); | |
{ | |
const n3 = this.isContextual(96) && this.startsAwaitUsing(), i3 = n3 || this.isContextual(105) && this.startsUsingForOf(), a3 = r2 && this.hasFollowingBindingAtom() || i3; | |
if (this.match(74) || this.match(75) || a3) { | |
const r3 = this.startNode(); | |
let a4; | |
n3 ? (a4 = "await using", this.isAwaitAllowed() || this.raise(Ho.AwaitUsingNotInAsyncContext, { at: this.state.startLoc }), this.next()) : a4 = this.state.value, this.next(), this.parseVar(r3, true, a4); | |
const c3 = this.finishNode(r3, "VariableDeclaration"), u2 = this.match(58); | |
return u2 && i3 && this.raise(Ho.ForInUsing, { at: c3 }), (u2 || this.isContextual(101)) && 1 === c3.declarations.length ? this.parseForIn(e2, c3, t2) : (null !== t2 && this.unexpected(t2), this.parseFor(e2, c3)); | |
} | |
} | |
const n2 = this.isContextual(95), i2 = new ExpressionErrors(), a2 = this.parseExpression(true, i2), c2 = this.isContextual(101); | |
if (c2 && (r2 && this.raise(Ho.ForOfLet, { at: a2 }), null === t2 && n2 && "Identifier" === a2.type && this.raise(Ho.ForOfAsync, { at: a2 })), c2 || this.match(58)) { | |
this.checkDestructuringPrivate(i2), this.toAssignable(a2, true); | |
const r3 = c2 ? "ForOfStatement" : "ForInStatement"; | |
return this.checkLVal(a2, { in: { type: r3 } }), this.parseForIn(e2, a2, t2); | |
} | |
return this.checkExpressionErrors(i2, true), null !== t2 && this.unexpected(t2), this.parseFor(e2, a2); | |
} | |
parseFunctionStatement(e2, t2, r2) { | |
return this.next(), this.parseFunction(e2, 1 | (r2 ? 2 : 0) | (t2 ? 8 : 0)); | |
} | |
parseIfStatement(e2) { | |
return this.next(), e2.test = this.parseHeaderExpression(), e2.consequent = this.parseStatementOrSloppyAnnexBFunctionDeclaration(), e2.alternate = this.eat(66) ? this.parseStatementOrSloppyAnnexBFunctionDeclaration() : null, this.finishNode(e2, "IfStatement"); | |
} | |
parseReturnStatement(e2) { | |
return this.prodParam.hasReturn || this.options.allowReturnOutsideFunction || this.raise(Ho.IllegalReturn, { at: this.state.startLoc }), this.next(), this.isLineTerminator() ? e2.argument = null : (e2.argument = this.parseExpression(), this.semicolon()), this.finishNode(e2, "ReturnStatement"); | |
} | |
parseSwitchStatement(e2) { | |
this.next(), e2.discriminant = this.parseHeaderExpression(); | |
const t2 = e2.cases = []; | |
let r2; | |
this.expect(5), this.state.labels.push(Va), this.scope.enter(0); | |
for (let e3; !this.match(8); ) | |
if (this.match(61) || this.match(65)) { | |
const n2 = this.match(61); | |
r2 && this.finishNode(r2, "SwitchCase"), t2.push(r2 = this.startNode()), r2.consequent = [], this.next(), n2 ? r2.test = this.parseExpression() : (e3 && this.raise(Ho.MultipleDefaultsInSwitch, { at: this.state.lastTokStartLoc }), e3 = true, r2.test = null), this.expect(14); | |
} else | |
r2 ? r2.consequent.push(this.parseStatementListItem()) : this.unexpected(); | |
return this.scope.exit(), r2 && this.finishNode(r2, "SwitchCase"), this.next(), this.state.labels.pop(), this.finishNode(e2, "SwitchStatement"); | |
} | |
parseThrowStatement(e2) { | |
return this.next(), this.hasPrecedingLineBreak() && this.raise(Ho.NewlineAfterThrow, { at: this.state.lastTokEndLoc }), e2.argument = this.parseExpression(), this.semicolon(), this.finishNode(e2, "ThrowStatement"); | |
} | |
parseCatchClauseParam() { | |
const e2 = this.parseBindingAtom(); | |
return this.scope.enter(this.options.annexB && "Identifier" === e2.type ? 8 : 0), this.checkLVal(e2, { in: { type: "CatchClause" }, binding: 9 }), e2; | |
} | |
parseTryStatement(e2) { | |
if (this.next(), e2.block = this.parseBlock(), e2.handler = null, this.match(62)) { | |
const t2 = this.startNode(); | |
this.next(), this.match(10) ? (this.expect(10), t2.param = this.parseCatchClauseParam(), this.expect(11)) : (t2.param = null, this.scope.enter(0)), t2.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false)), this.scope.exit(), e2.handler = this.finishNode(t2, "CatchClause"); | |
} | |
return e2.finalizer = this.eat(67) ? this.parseBlock() : null, e2.handler || e2.finalizer || this.raise(Ho.NoCatchOrFinally, { at: e2 }), this.finishNode(e2, "TryStatement"); | |
} | |
parseVarStatement(e2, t2, r2 = false) { | |
return this.next(), this.parseVar(e2, false, t2, r2), this.semicolon(), this.finishNode(e2, "VariableDeclaration"); | |
} | |
parseWhileStatement(e2) { | |
return this.next(), e2.test = this.parseHeaderExpression(), this.state.labels.push(Ha), e2.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()), this.state.labels.pop(), this.finishNode(e2, "WhileStatement"); | |
} | |
parseWithStatement(e2) { | |
return this.state.strict && this.raise(Ho.StrictWith, { at: this.state.startLoc }), this.next(), e2.object = this.parseHeaderExpression(), e2.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()), this.finishNode(e2, "WithStatement"); | |
} | |
parseEmptyStatement(e2) { | |
return this.next(), this.finishNode(e2, "EmptyStatement"); | |
} | |
parseLabeledStatement(e2, t2, r2, n2) { | |
for (const e3 of this.state.labels) | |
e3.name === t2 && this.raise(Ho.LabelRedeclaration, { at: r2, labelName: t2 }); | |
const i2 = (a2 = this.state.type) >= 90 && a2 <= 92 ? "loop" : this.match(71) ? "switch" : null; | |
var a2; | |
for (let t3 = this.state.labels.length - 1; t3 >= 0; t3--) { | |
const r3 = this.state.labels[t3]; | |
if (r3.statementStart !== e2.start) | |
break; | |
r3.statementStart = this.state.start, r3.kind = i2; | |
} | |
return this.state.labels.push({ name: t2, kind: i2, statementStart: this.state.start }), e2.body = 8 & n2 ? this.parseStatementOrSloppyAnnexBFunctionDeclaration(true) : this.parseStatement(), this.state.labels.pop(), e2.label = r2, this.finishNode(e2, "LabeledStatement"); | |
} | |
parseExpressionStatement(e2, t2, r2) { | |
return e2.expression = t2, this.semicolon(), this.finishNode(e2, "ExpressionStatement"); | |
} | |
parseBlock(e2 = false, t2 = true, r2) { | |
const n2 = this.startNode(); | |
return e2 && this.state.strictErrors.clear(), this.expect(5), t2 && this.scope.enter(0), this.parseBlockBody(n2, e2, false, 8, r2), t2 && this.scope.exit(), this.finishNode(n2, "BlockStatement"); | |
} | |
isValidDirective(e2) { | |
return "ExpressionStatement" === e2.type && "StringLiteral" === e2.expression.type && !e2.expression.extra.parenthesized; | |
} | |
parseBlockBody(e2, t2, r2, n2, i2) { | |
const a2 = e2.body = [], c2 = e2.directives = []; | |
this.parseBlockOrModuleBlockBody(a2, t2 ? c2 : void 0, r2, n2, i2); | |
} | |
parseBlockOrModuleBlockBody(e2, t2, r2, n2, i2) { | |
const a2 = this.state.strict; | |
let c2 = false, u2 = false; | |
for (; !this.match(n2); ) { | |
const n3 = r2 ? this.parseModuleItem() : this.parseStatementListItem(); | |
if (t2 && !u2) { | |
if (this.isValidDirective(n3)) { | |
const e3 = this.stmtToDirective(n3); | |
t2.push(e3), c2 || "use strict" !== e3.value.value || (c2 = true, this.setStrict(true)); | |
continue; | |
} | |
u2 = true, this.state.strictErrors.clear(); | |
} | |
e2.push(n3); | |
} | |
null == i2 || i2.call(this, c2), a2 || this.setStrict(false), this.next(); | |
} | |
parseFor(e2, t2) { | |
return e2.init = t2, this.semicolon(false), e2.test = this.match(13) ? null : this.parseExpression(), this.semicolon(false), e2.update = this.match(11) ? null : this.parseExpression(), this.expect(11), e2.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()), this.scope.exit(), this.state.labels.pop(), this.finishNode(e2, "ForStatement"); | |
} | |
parseForIn(e2, t2, r2) { | |
const n2 = this.match(58); | |
return this.next(), n2 ? null !== r2 && this.unexpected(r2) : e2.await = null !== r2, "VariableDeclaration" !== t2.type || null == t2.declarations[0].init || n2 && this.options.annexB && !this.state.strict && "var" === t2.kind && "Identifier" === t2.declarations[0].id.type || this.raise(Ho.ForInOfLoopInitializer, { at: t2, type: n2 ? "ForInStatement" : "ForOfStatement" }), "AssignmentPattern" === t2.type && this.raise(Ho.InvalidLhs, { at: t2, ancestor: { type: "ForStatement" } }), e2.left = t2, e2.right = n2 ? this.parseExpression() : this.parseMaybeAssignAllowIn(), this.expect(11), e2.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()), this.scope.exit(), this.state.labels.pop(), this.finishNode(e2, n2 ? "ForInStatement" : "ForOfStatement"); | |
} | |
parseVar(e2, t2, r2, n2 = false) { | |
const i2 = e2.declarations = []; | |
for (e2.kind = r2; ; ) { | |
const e3 = this.startNode(); | |
if (this.parseVarId(e3, r2), e3.init = this.eat(29) ? t2 ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn() : null, null !== e3.init || n2 || ("Identifier" === e3.id.type || t2 && (this.match(58) || this.isContextual(101)) ? "const" !== r2 || this.match(58) || this.isContextual(101) || this.raise(Ho.DeclarationMissingInitializer, { at: this.state.lastTokEndLoc, kind: "const" }) : this.raise(Ho.DeclarationMissingInitializer, { at: this.state.lastTokEndLoc, kind: "destructuring" })), i2.push(this.finishNode(e3, "VariableDeclarator")), !this.eat(12)) | |
break; | |
} | |
return e2; | |
} | |
parseVarId(e2, t2) { | |
const r2 = this.parseBindingAtom(); | |
this.checkLVal(r2, { in: { type: "VariableDeclarator" }, binding: "var" === t2 ? 5 : 8201 }), e2.id = r2; | |
} | |
parseAsyncFunctionExpression(e2) { | |
return this.parseFunction(e2, 8); | |
} | |
parseFunction(e2, t2 = 0) { | |
const r2 = 2 & t2, n2 = !!(1 & t2), i2 = n2 && !(4 & t2), a2 = !!(8 & t2); | |
this.initFunction(e2, a2), this.match(55) && (r2 && this.raise(Ho.GeneratorInSingleStatementContext, { at: this.state.startLoc }), this.next(), e2.generator = true), n2 && (e2.id = this.parseFunctionId(i2)); | |
const c2 = this.state.maybeInArrowParameters; | |
return this.state.maybeInArrowParameters = false, this.scope.enter(2), this.prodParam.enter(functionFlags(a2, e2.generator)), n2 || (e2.id = this.parseFunctionId()), this.parseFunctionParams(e2, false), this.withSmartMixTopicForbiddingContext(() => { | |
this.parseFunctionBodyAndFinish(e2, n2 ? "FunctionDeclaration" : "FunctionExpression"); | |
}), this.prodParam.exit(), this.scope.exit(), n2 && !r2 && this.registerFunctionStatementId(e2), this.state.maybeInArrowParameters = c2, e2; | |
} | |
parseFunctionId(e2) { | |
return e2 || tokenIsIdentifier(this.state.type) ? this.parseIdentifier() : null; | |
} | |
parseFunctionParams(e2, t2) { | |
this.expect(10), this.expressionScope.enter(new ExpressionScope(3)), e2.params = this.parseBindingList(11, 41, 2 | (t2 ? 4 : 0)), this.expressionScope.exit(); | |
} | |
registerFunctionStatementId(e2) { | |
e2.id && this.scope.declareName(e2.id.name, !this.options.annexB || this.state.strict || e2.generator || e2.async ? this.scope.treatFunctionsAsVar ? 5 : 8201 : 17, e2.id.loc.start); | |
} | |
parseClass(e2, t2, r2) { | |
this.next(); | |
const n2 = this.state.strict; | |
return this.state.strict = true, this.parseClassId(e2, t2, r2), this.parseClassSuper(e2), e2.body = this.parseClassBody(!!e2.superClass, n2), this.finishNode(e2, t2 ? "ClassDeclaration" : "ClassExpression"); | |
} | |
isClassProperty() { | |
return this.match(29) || this.match(13) || this.match(8); | |
} | |
isClassMethod() { | |
return this.match(10); | |
} | |
isNonstaticConstructor(e2) { | |
return !(e2.computed || e2.static || "constructor" !== e2.key.name && "constructor" !== e2.key.value); | |
} | |
parseClassBody(e2, t2) { | |
this.classScope.enter(); | |
const r2 = { hadConstructor: false, hadSuperClass: e2 }; | |
let n2 = []; | |
const i2 = this.startNode(); | |
if (i2.body = [], this.expect(5), this.withSmartMixTopicForbiddingContext(() => { | |
for (; !this.match(8); ) { | |
if (this.eat(13)) { | |
if (n2.length > 0) | |
throw this.raise(Ho.DecoratorSemicolon, { at: this.state.lastTokEndLoc }); | |
continue; | |
} | |
if (this.match(26)) { | |
n2.push(this.parseDecorator()); | |
continue; | |
} | |
const e3 = this.startNode(); | |
n2.length && (e3.decorators = n2, this.resetStartLocationFromNode(e3, n2[0]), n2 = []), this.parseClassMember(i2, e3, r2), "constructor" === e3.kind && e3.decorators && e3.decorators.length > 0 && this.raise(Ho.DecoratorConstructor, { at: e3 }); | |
} | |
}), this.state.strict = t2, this.next(), n2.length) | |
throw this.raise(Ho.TrailingDecorator, { at: this.state.startLoc }); | |
return this.classScope.exit(), this.finishNode(i2, "ClassBody"); | |
} | |
parseClassMemberFromModifier(e2, t2) { | |
const r2 = this.parseIdentifier(true); | |
if (this.isClassMethod()) { | |
const n2 = t2; | |
return n2.kind = "method", n2.computed = false, n2.key = r2, n2.static = false, this.pushClassMethod(e2, n2, false, false, false, false), true; | |
} | |
if (this.isClassProperty()) { | |
const n2 = t2; | |
return n2.computed = false, n2.key = r2, n2.static = false, e2.body.push(this.parseClassProperty(n2)), true; | |
} | |
return this.resetPreviousNodeTrailingComments(r2), false; | |
} | |
parseClassMember(e2, t2, r2) { | |
const n2 = this.isContextual(104); | |
if (n2) { | |
if (this.parseClassMemberFromModifier(e2, t2)) | |
return; | |
if (this.eat(5)) | |
return void this.parseClassStaticBlock(e2, t2); | |
} | |
this.parseClassMemberWithIsStatic(e2, t2, r2, n2); | |
} | |
parseClassMemberWithIsStatic(e2, t2, r2, n2) { | |
const i2 = t2, a2 = t2, c2 = t2, u2 = t2, m2 = t2, g2 = i2, b2 = i2; | |
if (t2.static = n2, this.parsePropertyNamePrefixOperator(t2), this.eat(55)) { | |
g2.kind = "method"; | |
const t3 = this.match(136); | |
return this.parseClassElementName(g2), t3 ? void this.pushClassPrivateMethod(e2, a2, true, false) : (this.isNonstaticConstructor(i2) && this.raise(Ho.ConstructorIsGenerator, { at: i2.key }), void this.pushClassMethod(e2, i2, true, false, false, false)); | |
} | |
const x2 = tokenIsIdentifier(this.state.type) && !this.state.containsEsc, C2 = this.match(136), A2 = this.parseClassElementName(t2), P2 = this.state.startLoc; | |
if (this.parsePostMemberNameModifiers(b2), this.isClassMethod()) { | |
if (g2.kind = "method", C2) | |
return void this.pushClassPrivateMethod(e2, a2, false, false); | |
const n3 = this.isNonstaticConstructor(i2); | |
let c3 = false; | |
n3 && (i2.kind = "constructor", r2.hadConstructor && !this.hasPlugin("typescript") && this.raise(Ho.DuplicateConstructor, { at: A2 }), n3 && this.hasPlugin("typescript") && t2.override && this.raise(Ho.OverrideOnConstructor, { at: A2 }), r2.hadConstructor = true, c3 = r2.hadSuperClass), this.pushClassMethod(e2, i2, false, false, n3, c3); | |
} else if (this.isClassProperty()) | |
C2 ? this.pushClassPrivateProperty(e2, u2) : this.pushClassProperty(e2, c2); | |
else if (x2 && "async" === A2.name && !this.isLineTerminator()) { | |
this.resetPreviousNodeTrailingComments(A2); | |
const t3 = this.eat(55); | |
b2.optional && this.unexpected(P2), g2.kind = "method"; | |
const r3 = this.match(136); | |
this.parseClassElementName(g2), this.parsePostMemberNameModifiers(b2), r3 ? this.pushClassPrivateMethod(e2, a2, t3, true) : (this.isNonstaticConstructor(i2) && this.raise(Ho.ConstructorIsAsync, { at: i2.key }), this.pushClassMethod(e2, i2, t3, true, false, false)); | |
} else if (!x2 || "get" !== A2.name && "set" !== A2.name || this.match(55) && this.isLineTerminator()) | |
if (x2 && "accessor" === A2.name && !this.isLineTerminator()) { | |
this.expectPlugin("decoratorAutoAccessors"), this.resetPreviousNodeTrailingComments(A2); | |
const t3 = this.match(136); | |
this.parseClassElementName(c2), this.pushClassAccessorProperty(e2, m2, t3); | |
} else | |
this.isLineTerminator() ? C2 ? this.pushClassPrivateProperty(e2, u2) : this.pushClassProperty(e2, c2) : this.unexpected(); | |
else { | |
this.resetPreviousNodeTrailingComments(A2), g2.kind = A2.name; | |
const t3 = this.match(136); | |
this.parseClassElementName(i2), t3 ? this.pushClassPrivateMethod(e2, a2, false, false) : (this.isNonstaticConstructor(i2) && this.raise(Ho.ConstructorIsAccessor, { at: i2.key }), this.pushClassMethod(e2, i2, false, false, false, false)), this.checkGetterSetterParams(i2); | |
} | |
} | |
parseClassElementName(e2) { | |
const { type: t2, value: r2 } = this.state; | |
if (130 !== t2 && 131 !== t2 || !e2.static || "prototype" !== r2 || this.raise(Ho.StaticPrototype, { at: this.state.startLoc }), 136 === t2) { | |
"constructor" === r2 && this.raise(Ho.ConstructorClassPrivateField, { at: this.state.startLoc }); | |
const t3 = this.parsePrivateName(); | |
return e2.key = t3, t3; | |
} | |
return this.parsePropertyName(e2); | |
} | |
parseClassStaticBlock(e2, t2) { | |
var r2; | |
this.scope.enter(208); | |
const n2 = this.state.labels; | |
this.state.labels = [], this.prodParam.enter(0); | |
const i2 = t2.body = []; | |
this.parseBlockOrModuleBlockBody(i2, void 0, false, 8), this.prodParam.exit(), this.scope.exit(), this.state.labels = n2, e2.body.push(this.finishNode(t2, "StaticBlock")), null != (r2 = t2.decorators) && r2.length && this.raise(Ho.DecoratorStaticBlock, { at: t2 }); | |
} | |
pushClassProperty(e2, t2) { | |
t2.computed || "constructor" !== t2.key.name && "constructor" !== t2.key.value || this.raise(Ho.ConstructorClassField, { at: t2.key }), e2.body.push(this.parseClassProperty(t2)); | |
} | |
pushClassPrivateProperty(e2, t2) { | |
const r2 = this.parseClassPrivateProperty(t2); | |
e2.body.push(r2), this.classScope.declarePrivateName(this.getPrivateNameSV(r2.key), 0, r2.key.loc.start); | |
} | |
pushClassAccessorProperty(e2, t2, r2) { | |
if (!r2 && !t2.computed) { | |
const e3 = t2.key; | |
"constructor" !== e3.name && "constructor" !== e3.value || this.raise(Ho.ConstructorClassField, { at: e3 }); | |
} | |
const n2 = this.parseClassAccessorProperty(t2); | |
e2.body.push(n2), r2 && this.classScope.declarePrivateName(this.getPrivateNameSV(n2.key), 0, n2.key.loc.start); | |
} | |
pushClassMethod(e2, t2, r2, n2, i2, a2) { | |
e2.body.push(this.parseMethod(t2, r2, n2, i2, a2, "ClassMethod", true)); | |
} | |
pushClassPrivateMethod(e2, t2, r2, n2) { | |
const i2 = this.parseMethod(t2, r2, n2, false, false, "ClassPrivateMethod", true); | |
e2.body.push(i2); | |
const a2 = "get" === i2.kind ? i2.static ? 6 : 2 : "set" === i2.kind ? i2.static ? 5 : 1 : 0; | |
this.declareClassPrivateMethodInScope(i2, a2); | |
} | |
declareClassPrivateMethodInScope(e2, t2) { | |
this.classScope.declarePrivateName(this.getPrivateNameSV(e2.key), t2, e2.key.loc.start); | |
} | |
parsePostMemberNameModifiers(e2) { | |
} | |
parseClassPrivateProperty(e2) { | |
return this.parseInitializer(e2), this.semicolon(), this.finishNode(e2, "ClassPrivateProperty"); | |
} | |
parseClassProperty(e2) { | |
return this.parseInitializer(e2), this.semicolon(), this.finishNode(e2, "ClassProperty"); | |
} | |
parseClassAccessorProperty(e2) { | |
return this.parseInitializer(e2), this.semicolon(), this.finishNode(e2, "ClassAccessorProperty"); | |
} | |
parseInitializer(e2) { | |
this.scope.enter(80), this.expressionScope.enter(newExpressionScope()), this.prodParam.enter(0), e2.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null, this.expressionScope.exit(), this.prodParam.exit(), this.scope.exit(); | |
} | |
parseClassId(e2, t2, r2, n2 = 8331) { | |
if (tokenIsIdentifier(this.state.type)) | |
e2.id = this.parseIdentifier(), t2 && this.declareNameFromIdentifier(e2.id, n2); | |
else { | |
if (!r2 && t2) | |
throw this.raise(Ho.MissingClassName, { at: this.state.startLoc }); | |
e2.id = null; | |
} | |
} | |
parseClassSuper(e2) { | |
e2.superClass = this.eat(81) ? this.parseExprSubscripts() : null; | |
} | |
parseExport(e2, t2) { | |
const r2 = this.parseMaybeImportPhase(e2, true), n2 = this.maybeParseExportDefaultSpecifier(e2, r2), i2 = !n2 || this.eat(12), a2 = i2 && this.eatExportStar(e2), c2 = a2 && this.maybeParseExportNamespaceSpecifier(e2), u2 = i2 && (!c2 || this.eat(12)), m2 = n2 || a2; | |
if (a2 && !c2) { | |
if (n2 && this.unexpected(), t2) | |
throw this.raise(Ho.UnsupportedDecoratorExport, { at: e2 }); | |
return this.parseExportFrom(e2, true), this.finishNode(e2, "ExportAllDeclaration"); | |
} | |
const g2 = this.maybeParseExportNamedSpecifiers(e2); | |
let b2; | |
if (n2 && i2 && !a2 && !g2 && this.unexpected(null, 5), c2 && u2 && this.unexpected(null, 97), m2 || g2) { | |
if (b2 = false, t2) | |
throw this.raise(Ho.UnsupportedDecoratorExport, { at: e2 }); | |
this.parseExportFrom(e2, m2); | |
} else | |
b2 = this.maybeParseExportDeclaration(e2); | |
if (m2 || g2 || b2) { | |
var x2; | |
const r3 = e2; | |
if (this.checkExport(r3, true, false, !!r3.source), "ClassDeclaration" === (null == (x2 = r3.declaration) ? void 0 : x2.type)) | |
this.maybeTakeDecorators(t2, r3.declaration, r3); | |
else if (t2) | |
throw this.raise(Ho.UnsupportedDecoratorExport, { at: e2 }); | |
return this.finishNode(r3, "ExportNamedDeclaration"); | |
} | |
if (this.eat(65)) { | |
const r3 = e2, n3 = this.parseExportDefaultExpression(); | |
if (r3.declaration = n3, "ClassDeclaration" === n3.type) | |
this.maybeTakeDecorators(t2, n3, r3); | |
else if (t2) | |
throw this.raise(Ho.UnsupportedDecoratorExport, { at: e2 }); | |
return this.checkExport(r3, true, true), this.finishNode(r3, "ExportDefaultDeclaration"); | |
} | |
this.unexpected(null, 5); | |
} | |
eatExportStar(e2) { | |
return this.eat(55); | |
} | |
maybeParseExportDefaultSpecifier(e2, t2) { | |
if (t2 || this.isExportDefaultSpecifier()) { | |
this.expectPlugin("exportDefaultFrom", null == t2 ? void 0 : t2.loc.start); | |
const r2 = t2 || this.parseIdentifier(true), n2 = this.startNodeAtNode(r2); | |
return n2.exported = r2, e2.specifiers = [this.finishNode(n2, "ExportDefaultSpecifier")], true; | |
} | |
return false; | |
} | |
maybeParseExportNamespaceSpecifier(e2) { | |
if (this.isContextual(93)) { | |
e2.specifiers || (e2.specifiers = []); | |
const t2 = this.startNodeAt(this.state.lastTokStartLoc); | |
return this.next(), t2.exported = this.parseModuleExportName(), e2.specifiers.push(this.finishNode(t2, "ExportNamespaceSpecifier")), true; | |
} | |
return false; | |
} | |
maybeParseExportNamedSpecifiers(e2) { | |
if (this.match(5)) { | |
e2.specifiers || (e2.specifiers = []); | |
const t2 = "type" === e2.exportKind; | |
return e2.specifiers.push(...this.parseExportSpecifiers(t2)), e2.source = null, e2.declaration = null, this.hasPlugin("importAssertions") && (e2.assertions = []), true; | |
} | |
return false; | |
} | |
maybeParseExportDeclaration(e2) { | |
return !!this.shouldParseExportDeclaration() && (e2.specifiers = [], e2.source = null, this.hasPlugin("importAssertions") && (e2.assertions = []), e2.declaration = this.parseExportDeclaration(e2), true); | |
} | |
isAsyncFunction() { | |
if (!this.isContextual(95)) | |
return false; | |
const e2 = this.nextTokenInLineStart(); | |
return this.isUnparsedContextual(e2, "function"); | |
} | |
parseExportDefaultExpression() { | |
const e2 = this.startNode(); | |
if (this.match(68)) | |
return this.next(), this.parseFunction(e2, 5); | |
if (this.isAsyncFunction()) | |
return this.next(), this.next(), this.parseFunction(e2, 13); | |
if (this.match(80)) | |
return this.parseClass(e2, true, true); | |
if (this.match(26)) | |
return this.hasPlugin("decorators") && true === this.getPluginOption("decorators", "decoratorsBeforeExport") && this.raise(Ho.DecoratorBeforeExport, { at: this.state.startLoc }), this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true); | |
if (this.match(75) || this.match(74) || this.isLet()) | |
throw this.raise(Ho.UnsupportedDefaultExport, { at: this.state.startLoc }); | |
const t2 = this.parseMaybeAssignAllowIn(); | |
return this.semicolon(), t2; | |
} | |
parseExportDeclaration(e2) { | |
if (this.match(80)) { | |
return this.parseClass(this.startNode(), true, false); | |
} | |
return this.parseStatementListItem(); | |
} | |
isExportDefaultSpecifier() { | |
const { type: e2 } = this.state; | |
if (tokenIsIdentifier(e2)) { | |
if (95 === e2 && !this.state.containsEsc || 99 === e2) | |
return false; | |
if ((128 === e2 || 127 === e2) && !this.state.containsEsc) { | |
const { type: e3 } = this.lookahead(); | |
if (tokenIsIdentifier(e3) && 97 !== e3 || 5 === e3) | |
return this.expectOnePlugin(["flow", "typescript"]), false; | |
} | |
} else if (!this.match(65)) | |
return false; | |
const t2 = this.nextTokenStart(), r2 = this.isUnparsedContextual(t2, "from"); | |
if (44 === this.input.charCodeAt(t2) || tokenIsIdentifier(this.state.type) && r2) | |
return true; | |
if (this.match(65) && r2) { | |
const e3 = this.input.charCodeAt(this.nextTokenStartSince(t2 + 4)); | |
return 34 === e3 || 39 === e3; | |
} | |
return false; | |
} | |
parseExportFrom(e2, t2) { | |
this.eatContextual(97) ? (e2.source = this.parseImportSource(), this.checkExport(e2), this.maybeParseImportAttributes(e2), this.checkJSONModuleImport(e2)) : t2 && this.unexpected(), this.semicolon(); | |
} | |
shouldParseExportDeclaration() { | |
const { type: e2 } = this.state; | |
return 26 === e2 && (this.expectOnePlugin(["decorators", "decorators-legacy"]), this.hasPlugin("decorators")) ? (true === this.getPluginOption("decorators", "decoratorsBeforeExport") && this.raise(Ho.DecoratorBeforeExport, { at: this.state.startLoc }), true) : 74 === e2 || 75 === e2 || 68 === e2 || 80 === e2 || this.isLet() || this.isAsyncFunction(); | |
} | |
checkExport(e2, t2, r2, n2) { | |
var i2; | |
if (t2) { | |
if (r2) { | |
if (this.checkDuplicateExports(e2, "default"), this.hasPlugin("exportDefaultFrom")) { | |
var a2; | |
const t3 = e2.declaration; | |
"Identifier" !== t3.type || "from" !== t3.name || t3.end - t3.start != 4 || null != (a2 = t3.extra) && a2.parenthesized || this.raise(Ho.ExportDefaultFromAsIdentifier, { at: t3 }); | |
} | |
} else if (null != (i2 = e2.specifiers) && i2.length) | |
for (const t3 of e2.specifiers) { | |
const { exported: e3 } = t3, r3 = "Identifier" === e3.type ? e3.name : e3.value; | |
if (this.checkDuplicateExports(t3, r3), !n2 && t3.local) { | |
const { local: e4 } = t3; | |
"Identifier" !== e4.type ? this.raise(Ho.ExportBindingIsString, { at: t3, localName: e4.value, exportName: r3 }) : (this.checkReservedWord(e4.name, e4.loc.start, true, false), this.scope.checkLocalExport(e4)); | |
} | |
} | |
else if (e2.declaration) { | |
if ("FunctionDeclaration" === e2.declaration.type || "ClassDeclaration" === e2.declaration.type) { | |
const t3 = e2.declaration.id; | |
if (!t3) | |
throw new Error("Assertion failure"); | |
this.checkDuplicateExports(e2, t3.name); | |
} else if ("VariableDeclaration" === e2.declaration.type) | |
for (const t3 of e2.declaration.declarations) | |
this.checkDeclaration(t3.id); | |
} | |
} | |
} | |
checkDeclaration(e2) { | |
if ("Identifier" === e2.type) | |
this.checkDuplicateExports(e2, e2.name); | |
else if ("ObjectPattern" === e2.type) | |
for (const t2 of e2.properties) | |
this.checkDeclaration(t2); | |
else if ("ArrayPattern" === e2.type) | |
for (const t2 of e2.elements) | |
t2 && this.checkDeclaration(t2); | |
else | |
"ObjectProperty" === e2.type ? this.checkDeclaration(e2.value) : "RestElement" === e2.type ? this.checkDeclaration(e2.argument) : "AssignmentPattern" === e2.type && this.checkDeclaration(e2.left); | |
} | |
checkDuplicateExports(e2, t2) { | |
this.exportedIdentifiers.has(t2) && ("default" === t2 ? this.raise(Ho.DuplicateDefaultExport, { at: e2 }) : this.raise(Ho.DuplicateExport, { at: e2, exportName: t2 })), this.exportedIdentifiers.add(t2); | |
} | |
parseExportSpecifiers(e2) { | |
const t2 = []; | |
let r2 = true; | |
for (this.expect(5); !this.eat(8); ) { | |
if (r2) | |
r2 = false; | |
else if (this.expect(12), this.eat(8)) | |
break; | |
const n2 = this.isContextual(128), i2 = this.match(131), a2 = this.startNode(); | |
a2.local = this.parseModuleExportName(), t2.push(this.parseExportSpecifier(a2, i2, e2, n2)); | |
} | |
return t2; | |
} | |
parseExportSpecifier(e2, t2, r2, n2) { | |
return this.eatContextual(93) ? e2.exported = this.parseModuleExportName() : t2 ? e2.exported = cloneStringLiteral(e2.local) : e2.exported || (e2.exported = cloneIdentifier(e2.local)), this.finishNode(e2, "ExportSpecifier"); | |
} | |
parseModuleExportName() { | |
if (this.match(131)) { | |
const e2 = this.parseStringLiteral(this.state.value), t2 = e2.value.match(za); | |
return t2 && this.raise(Ho.ModuleExportNameHasLoneSurrogate, { at: e2, surrogateCharCode: t2[0].charCodeAt(0) }), e2; | |
} | |
return this.parseIdentifier(true); | |
} | |
isJSONModuleImport(e2) { | |
return null != e2.assertions && e2.assertions.some(({ key: e3, value: t2 }) => "json" === t2.value && ("Identifier" === e3.type ? "type" === e3.name : "type" === e3.value)); | |
} | |
checkImportReflection(e2) { | |
var t2; | |
e2.module && (1 === e2.specifiers.length && "ImportDefaultSpecifier" === e2.specifiers[0].type || this.raise(Ho.ImportReflectionNotBinding, { at: e2.specifiers[0].loc.start }), (null == (t2 = e2.assertions) ? void 0 : t2.length) > 0 && this.raise(Ho.ImportReflectionHasAssertion, { at: e2.specifiers[0].loc.start })); | |
} | |
checkJSONModuleImport(e2) { | |
if (this.isJSONModuleImport(e2) && "ExportAllDeclaration" !== e2.type) { | |
const { specifiers: t2 } = e2; | |
if (null != t2) { | |
const e3 = t2.find((e4) => { | |
let t3; | |
if ("ExportSpecifier" === e4.type ? t3 = e4.local : "ImportSpecifier" === e4.type && (t3 = e4.imported), void 0 !== t3) | |
return "Identifier" === t3.type ? "default" !== t3.name : "default" !== t3.value; | |
}); | |
void 0 !== e3 && this.raise(Ho.ImportJSONBindingNotDefault, { at: e3.loc.start }); | |
} | |
} | |
} | |
isPotentialImportPhase(e2) { | |
return !e2 && this.isContextual(125); | |
} | |
applyImportPhase(e2, t2, r2, n2) { | |
t2 || ("module" === r2 ? (this.expectPlugin("importReflection", n2), e2.module = true) : this.hasPlugin("importReflection") && (e2.module = false)); | |
} | |
parseMaybeImportPhase(e2, t2) { | |
if (!this.isPotentialImportPhase(t2)) | |
return this.applyImportPhase(e2, t2, null), null; | |
const r2 = this.parseIdentifier(true), { type: n2 } = this.state; | |
return (tokenIsKeywordOrIdentifier(n2) ? 97 !== n2 || 102 === this.lookaheadCharCode() : 12 !== n2) ? (this.resetPreviousIdentifierLeadingComments(r2), this.applyImportPhase(e2, t2, r2.name, r2.loc.start), null) : (this.applyImportPhase(e2, t2, null), r2); | |
} | |
isPrecedingIdImportPhase(e2) { | |
const { type: t2 } = this.state; | |
return tokenIsIdentifier(t2) ? 97 !== t2 || 102 === this.lookaheadCharCode() : 12 !== t2; | |
} | |
parseImport(e2) { | |
return this.match(131) ? this.parseImportSourceAndAttributes(e2) : this.parseImportSpecifiersAndAfter(e2, this.parseMaybeImportPhase(e2, false)); | |
} | |
parseImportSpecifiersAndAfter(e2, t2) { | |
e2.specifiers = []; | |
const r2 = !this.maybeParseDefaultImportSpecifier(e2, t2) || this.eat(12), n2 = r2 && this.maybeParseStarImportSpecifier(e2); | |
return r2 && !n2 && this.parseNamedImportSpecifiers(e2), this.expectContextual(97), this.parseImportSourceAndAttributes(e2); | |
} | |
parseImportSourceAndAttributes(e2) { | |
return null != e2.specifiers || (e2.specifiers = []), e2.source = this.parseImportSource(), this.maybeParseImportAttributes(e2), this.checkImportReflection(e2), this.checkJSONModuleImport(e2), this.semicolon(), this.finishNode(e2, "ImportDeclaration"); | |
} | |
parseImportSource() { | |
return this.match(131) || this.unexpected(), this.parseExprAtom(); | |
} | |
parseImportSpecifierLocal(e2, t2, r2) { | |
t2.local = this.parseIdentifier(), e2.specifiers.push(this.finishImportSpecifier(t2, r2)); | |
} | |
finishImportSpecifier(e2, t2, r2 = 8201) { | |
return this.checkLVal(e2.local, { in: { type: t2 }, binding: r2 }), this.finishNode(e2, t2); | |
} | |
parseImportAttributes() { | |
this.expect(5); | |
const e2 = [], t2 = /* @__PURE__ */ new Set(); | |
do { | |
if (this.match(8)) | |
break; | |
const r2 = this.startNode(), n2 = this.state.value; | |
if (t2.has(n2) && this.raise(Ho.ModuleAttributesWithDuplicateKeys, { at: this.state.startLoc, key: n2 }), t2.add(n2), this.match(131) ? r2.key = this.parseStringLiteral(n2) : r2.key = this.parseIdentifier(true), this.expect(14), !this.match(131)) | |
throw this.raise(Ho.ModuleAttributeInvalidValue, { at: this.state.startLoc }); | |
r2.value = this.parseStringLiteral(this.state.value), e2.push(this.finishNode(r2, "ImportAttribute")); | |
} while (this.eat(12)); | |
return this.expect(8), e2; | |
} | |
parseModuleAttributes() { | |
const e2 = [], t2 = /* @__PURE__ */ new Set(); | |
do { | |
const r2 = this.startNode(); | |
if (r2.key = this.parseIdentifier(true), "type" !== r2.key.name && this.raise(Ho.ModuleAttributeDifferentFromType, { at: r2.key }), t2.has(r2.key.name) && this.raise(Ho.ModuleAttributesWithDuplicateKeys, { at: r2.key, key: r2.key.name }), t2.add(r2.key.name), this.expect(14), !this.match(131)) | |
throw this.raise(Ho.ModuleAttributeInvalidValue, { at: this.state.startLoc }); | |
r2.value = this.parseStringLiteral(this.state.value), e2.push(this.finishNode(r2, "ImportAttribute")); | |
} while (this.eat(12)); | |
return e2; | |
} | |
maybeParseImportAttributes(e2) { | |
let t2, r2 = false; | |
if (this.match(76)) { | |
if (this.hasPrecedingLineBreak() && 40 === this.lookaheadCharCode()) | |
return; | |
this.next(), this.hasPlugin("moduleAttributes") ? t2 = this.parseModuleAttributes() : (this.expectImportAttributesPlugin(), t2 = this.parseImportAttributes()), r2 = true; | |
} else if (this.isContextual(94) && !this.hasPrecedingLineBreak()) | |
this.hasPlugin("importAttributes") ? (true !== this.getPluginOption("importAttributes", "deprecatedAssertSyntax") && this.raise(Ho.ImportAttributesUseAssert, { at: this.state.startLoc }), this.addExtra(e2, "deprecatedAssertSyntax", true)) : this.expectOnePlugin(["importAttributes", "importAssertions"]), this.next(), t2 = this.parseImportAttributes(); | |
else if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) | |
t2 = []; | |
else { | |
if (!this.hasPlugin("moduleAttributes")) | |
return; | |
t2 = []; | |
} | |
!r2 && this.hasPlugin("importAssertions") ? e2.assertions = t2 : e2.attributes = t2; | |
} | |
maybeParseDefaultImportSpecifier(e2, t2) { | |
if (t2) { | |
const r2 = this.startNodeAtNode(t2); | |
return r2.local = t2, e2.specifiers.push(this.finishImportSpecifier(r2, "ImportDefaultSpecifier")), true; | |
} | |
return !!tokenIsKeywordOrIdentifier(this.state.type) && (this.parseImportSpecifierLocal(e2, this.startNode(), "ImportDefaultSpecifier"), true); | |
} | |
maybeParseStarImportSpecifier(e2) { | |
if (this.match(55)) { | |
const t2 = this.startNode(); | |
return this.next(), this.expectContextual(93), this.parseImportSpecifierLocal(e2, t2, "ImportNamespaceSpecifier"), true; | |
} | |
return false; | |
} | |
parseNamedImportSpecifiers(e2) { | |
let t2 = true; | |
for (this.expect(5); !this.eat(8); ) { | |
if (t2) | |
t2 = false; | |
else { | |
if (this.eat(14)) | |
throw this.raise(Ho.DestructureNamedImport, { at: this.state.startLoc }); | |
if (this.expect(12), this.eat(8)) | |
break; | |
} | |
const r2 = this.startNode(), n2 = this.match(131), i2 = this.isContextual(128); | |
r2.imported = this.parseModuleExportName(); | |
const a2 = this.parseImportSpecifier(r2, n2, "type" === e2.importKind || "typeof" === e2.importKind, i2, void 0); | |
e2.specifiers.push(a2); | |
} | |
} | |
parseImportSpecifier(e2, t2, r2, n2, i2) { | |
if (this.eatContextual(93)) | |
e2.local = this.parseIdentifier(); | |
else { | |
const { imported: r3 } = e2; | |
if (t2) | |
throw this.raise(Ho.ImportBindingIsString, { at: e2, importName: r3.value }); | |
this.checkReservedWord(r3.name, e2.loc.start, true, true), e2.local || (e2.local = cloneIdentifier(r3)); | |
} | |
return this.finishImportSpecifier(e2, "ImportSpecifier", i2); | |
} | |
isThisParam(e2) { | |
return "Identifier" === e2.type && "this" === e2.name; | |
} | |
} | |
class Parser extends StatementParser { | |
constructor(e2, t2) { | |
super(e2 = function(e3) { | |
if (null == e3) | |
return Object.assign({}, Ua); | |
if (null != e3.annexB && false !== e3.annexB) | |
throw new Error("The `annexB` option can only be set to `false`."); | |
const t3 = {}; | |
for (const n2 of Object.keys(Ua)) { | |
var r2; | |
t3[n2] = null != (r2 = e3[n2]) ? r2 : Ua[n2]; | |
} | |
return t3; | |
}(e2), t2), this.options = e2, this.initializeScopes(), this.plugins = function(e3) { | |
const t3 = /* @__PURE__ */ new Map(); | |
for (const r2 of e3) { | |
const [e4, n2] = Array.isArray(r2) ? r2 : [r2, {}]; | |
t3.has(e4) || t3.set(e4, n2 || {}); | |
} | |
return t3; | |
}(this.options.plugins), this.filename = e2.sourceFilename; | |
} | |
getScopeHandler() { | |
return ScopeHandler; | |
} | |
parse() { | |
this.enterInitialScopes(); | |
const e2 = this.startNode(), t2 = this.startNode(); | |
return this.nextToken(), e2.errors = null, this.parseTopLevel(e2, t2), e2.errors = this.state.errors, e2; | |
} | |
} | |
const Wa = function(e2) { | |
const t2 = {}; | |
for (const r2 of Object.keys(e2)) | |
t2[r2] = getExportedToken(e2[r2]); | |
return t2; | |
}(sa); | |
function getParser(e2, t2) { | |
let r2 = Parser; | |
return null != e2 && e2.plugins && (!function(e3) { | |
if (hasPlugin(e3, "decorators")) { | |
if (hasPlugin(e3, "decorators-legacy")) | |
throw new Error("Cannot use the decorators and decorators-legacy plugin together"); | |
const t3 = getPluginOption(e3, "decorators", "decoratorsBeforeExport"); | |
if (null != t3 && "boolean" != typeof t3) | |
throw new Error("'decoratorsBeforeExport' must be a boolean, if specified."); | |
const r3 = getPluginOption(e3, "decorators", "allowCallParenthesized"); | |
if (null != r3 && "boolean" != typeof r3) | |
throw new Error("'allowCallParenthesized' must be a boolean."); | |
} | |
if (hasPlugin(e3, "flow") && hasPlugin(e3, "typescript")) | |
throw new Error("Cannot combine flow and typescript plugins."); | |
if (hasPlugin(e3, "placeholders") && hasPlugin(e3, "v8intrinsic")) | |
throw new Error("Cannot combine placeholders and v8intrinsic plugins."); | |
if (hasPlugin(e3, "pipelineOperator")) { | |
const t3 = getPluginOption(e3, "pipelineOperator", "proposal"); | |
if (!Ma.includes(t3)) { | |
const e4 = Ma.map((e5) => `"${e5}"`).join(", "); | |
throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${e4}.`); | |
} | |
const r3 = hasPlugin(e3, ["recordAndTuple", { syntaxType: "hash" }]); | |
if ("hack" === t3) { | |
if (hasPlugin(e3, "placeholders")) | |
throw new Error("Cannot combine placeholders plugin and Hack-style pipes."); | |
if (hasPlugin(e3, "v8intrinsic")) | |
throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes."); | |
const t4 = getPluginOption(e3, "pipelineOperator", "topicToken"); | |
if (!Fa.includes(t4)) { | |
const e4 = Fa.map((e5) => `"${e5}"`).join(", "); | |
throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${e4}.`); | |
} | |
if ("#" === t4 && r3) | |
throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "hack", topicToken: "#" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.'); | |
} else if ("smart" === t3 && r3) | |
throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.'); | |
} | |
if (hasPlugin(e3, "moduleAttributes")) { | |
if (hasPlugin(e3, "importAssertions") || hasPlugin(e3, "importAttributes")) | |
throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins."); | |
if ("may-2020" !== getPluginOption(e3, "moduleAttributes", "version")) | |
throw new Error("The 'moduleAttributes' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is 'may-2020'."); | |
} | |
if (hasPlugin(e3, "importAssertions") && hasPlugin(e3, "importAttributes")) | |
throw new Error("Cannot combine importAssertions and importAttributes plugins."); | |
if (hasPlugin(e3, "recordAndTuple") && null != getPluginOption(e3, "recordAndTuple", "syntaxType") && !Ba.includes(getPluginOption(e3, "recordAndTuple", "syntaxType"))) | |
throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + Ba.map((e4) => `'${e4}'`).join(", ")); | |
if (hasPlugin(e3, "asyncDoExpressions") && !hasPlugin(e3, "doExpressions")) { | |
const e4 = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins."); | |
throw e4.missingPlugins = "doExpressions", e4; | |
} | |
}(e2.plugins), r2 = function(e3) { | |
const t3 = $a.filter((t4) => hasPlugin(e3, t4)), r3 = t3.join("/"); | |
let n2 = Ka[r3]; | |
if (!n2) { | |
n2 = Parser; | |
for (const e4 of t3) | |
n2 = ja[e4](n2); | |
Ka[r3] = n2; | |
} | |
return n2; | |
}(e2.plugins)), new r2(e2, t2); | |
} | |
const Ka = {}; | |
No.parse = function(e2, t2) { | |
var r2; | |
if ("unambiguous" !== (null == (r2 = t2) ? void 0 : r2.sourceType)) | |
return getParser(t2, e2).parse(); | |
t2 = Object.assign({}, t2); | |
try { | |
t2.sourceType = "module"; | |
const r3 = getParser(t2, e2), n2 = r3.parse(); | |
if (r3.sawUnambiguousESM) | |
return n2; | |
if (r3.ambiguousScriptDifferentAst) | |
try { | |
return t2.sourceType = "script", getParser(t2, e2).parse(); | |
} catch (e3) { | |
} | |
else | |
n2.program.sourceType = "script"; | |
return n2; | |
} catch (r3) { | |
try { | |
return t2.sourceType = "script", getParser(t2, e2).parse(); | |
} catch (e3) { | |
} | |
throw r3; | |
} | |
}, No.parseExpression = function(e2, t2) { | |
const r2 = getParser(t2, e2); | |
return r2.options.strictMode && (r2.state.strict = true), r2.getExpression(); | |
}, No.tokTypes = Wa; | |
var Ja = {}, Ga = {}, Za = {}, Ya = {}, Xa = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""); | |
Ya.encode = function(e2) { | |
if (0 <= e2 && e2 < Xa.length) | |
return Xa[e2]; | |
throw new TypeError("Must be between 0 and 63: " + e2); | |
}, Ya.decode = function(e2) { | |
return 65 <= e2 && e2 <= 90 ? e2 - 65 : 97 <= e2 && e2 <= 122 ? e2 - 97 + 26 : 48 <= e2 && e2 <= 57 ? e2 - 48 + 52 : 43 == e2 ? 62 : 47 == e2 ? 63 : -1; | |
}; | |
var Qa = Ya; | |
Za.encode = function(e2) { | |
var t2, r2 = "", n2 = function(e3) { | |
return e3 < 0 ? 1 + (-e3 << 1) : 0 + (e3 << 1); | |
}(e2); | |
do { | |
t2 = 31 & n2, (n2 >>>= 5) > 0 && (t2 |= 32), r2 += Qa.encode(t2); | |
} while (n2 > 0); | |
return r2; | |
}, Za.decode = function(e2, t2, r2) { | |
var n2, i2, a2, c2, u2 = e2.length, m2 = 0, g2 = 0; | |
do { | |
if (t2 >= u2) | |
throw new Error("Expected more digits in base 64 VLQ value."); | |
if (-1 === (i2 = Qa.decode(e2.charCodeAt(t2++)))) | |
throw new Error("Invalid base64 digit: " + e2.charAt(t2 - 1)); | |
n2 = !!(32 & i2), m2 += (i2 &= 31) << g2, g2 += 5; | |
} while (n2); | |
r2.value = (c2 = (a2 = m2) >> 1, 1 == (1 & a2) ? -c2 : c2), r2.rest = t2; | |
}; | |
var ec = {}; | |
!function(e2) { | |
e2.getArg = function(e3, t3, r3) { | |
if (t3 in e3) | |
return e3[t3]; | |
if (3 === arguments.length) | |
return r3; | |
throw new Error('"' + t3 + '" is a required argument.'); | |
}; | |
var t2 = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/, r2 = /^data:.+\,.+$/; | |
function urlParse(e3) { | |
var r3 = e3.match(t2); | |
return r3 ? { scheme: r3[1], auth: r3[2], host: r3[3], port: r3[4], path: r3[5] } : null; | |
} | |
function urlGenerate(e3) { | |
var t3 = ""; | |
return e3.scheme && (t3 += e3.scheme + ":"), t3 += "//", e3.auth && (t3 += e3.auth + "@"), e3.host && (t3 += e3.host), e3.port && (t3 += ":" + e3.port), e3.path && (t3 += e3.path), t3; | |
} | |
e2.urlParse = urlParse, e2.urlGenerate = urlGenerate; | |
var n2 = function(e3) { | |
var t3 = []; | |
return function(r3) { | |
for (var n3 = 0; n3 < t3.length; n3++) | |
if (t3[n3].input === r3) { | |
var i3 = t3[0]; | |
return t3[0] = t3[n3], t3[n3] = i3, t3[0].result; | |
} | |
var a2 = e3(r3); | |
return t3.unshift({ input: r3, result: a2 }), t3.length > 32 && t3.pop(), a2; | |
}; | |
}(function(t3) { | |
var r3 = t3, n3 = urlParse(t3); | |
if (n3) { | |
if (!n3.path) | |
return t3; | |
r3 = n3.path; | |
} | |
for (var i3 = e2.isAbsolute(r3), a2 = [], c2 = 0, u2 = 0; ; ) { | |
if (c2 = u2, -1 === (u2 = r3.indexOf("/", c2))) { | |
a2.push(r3.slice(c2)); | |
break; | |
} | |
for (a2.push(r3.slice(c2, u2)); u2 < r3.length && "/" === r3[u2]; ) | |
u2++; | |
} | |
var m2, g2 = 0; | |
for (u2 = a2.length - 1; u2 >= 0; u2--) | |
"." === (m2 = a2[u2]) ? a2.splice(u2, 1) : ".." === m2 ? g2++ : g2 > 0 && ("" === m2 ? (a2.splice(u2 + 1, g2), g2 = 0) : (a2.splice(u2, 2), g2--)); | |
return "" === (r3 = a2.join("/")) && (r3 = i3 ? "/" : "."), n3 ? (n3.path = r3, urlGenerate(n3)) : r3; | |
}); | |
function join(e3, t3) { | |
"" === e3 && (e3 = "."), "" === t3 && (t3 = "."); | |
var i3 = urlParse(t3), a2 = urlParse(e3); | |
if (a2 && (e3 = a2.path || "/"), i3 && !i3.scheme) | |
return a2 && (i3.scheme = a2.scheme), urlGenerate(i3); | |
if (i3 || t3.match(r2)) | |
return t3; | |
if (a2 && !a2.host && !a2.path) | |
return a2.host = t3, urlGenerate(a2); | |
var c2 = "/" === t3.charAt(0) ? t3 : n2(e3.replace(/\/+$/, "") + "/" + t3); | |
return a2 ? (a2.path = c2, urlGenerate(a2)) : c2; | |
} | |
e2.normalize = n2, e2.join = join, e2.isAbsolute = function(e3) { | |
return "/" === e3.charAt(0) || t2.test(e3); | |
}, e2.relative = function(e3, t3) { | |
"" === e3 && (e3 = "."), e3 = e3.replace(/\/$/, ""); | |
for (var r3 = 0; 0 !== t3.indexOf(e3 + "/"); ) { | |
var n3 = e3.lastIndexOf("/"); | |
if (n3 < 0) | |
return t3; | |
if ((e3 = e3.slice(0, n3)).match(/^([^\/]+:\/)?\/*$/)) | |
return t3; | |
++r3; | |
} | |
return Array(r3 + 1).join("../") + t3.substr(e3.length + 1); | |
}; | |
var i2 = !("__proto__" in /* @__PURE__ */ Object.create(null)); | |
function identity(e3) { | |
return e3; | |
} | |
function isProtoString(e3) { | |
if (!e3) | |
return false; | |
var t3 = e3.length; | |
if (t3 < 9) | |
return false; | |
if (95 !== e3.charCodeAt(t3 - 1) || 95 !== e3.charCodeAt(t3 - 2) || 111 !== e3.charCodeAt(t3 - 3) || 116 !== e3.charCodeAt(t3 - 4) || 111 !== e3.charCodeAt(t3 - 5) || 114 !== e3.charCodeAt(t3 - 6) || 112 !== e3.charCodeAt(t3 - 7) || 95 !== e3.charCodeAt(t3 - 8) || 95 !== e3.charCodeAt(t3 - 9)) | |
return false; | |
for (var r3 = t3 - 10; r3 >= 0; r3--) | |
if (36 !== e3.charCodeAt(r3)) | |
return false; | |
return true; | |
} | |
function strcmp(e3, t3) { | |
return e3 === t3 ? 0 : null === e3 ? 1 : null === t3 ? -1 : e3 > t3 ? 1 : -1; | |
} | |
e2.toSetString = i2 ? identity : function(e3) { | |
return isProtoString(e3) ? "$" + e3 : e3; | |
}, e2.fromSetString = i2 ? identity : function(e3) { | |
return isProtoString(e3) ? e3.slice(1) : e3; | |
}, e2.compareByOriginalPositions = function(e3, t3, r3) { | |
var n3 = strcmp(e3.source, t3.source); | |
return 0 !== n3 || 0 !== (n3 = e3.originalLine - t3.originalLine) || 0 !== (n3 = e3.originalColumn - t3.originalColumn) || r3 || 0 !== (n3 = e3.generatedColumn - t3.generatedColumn) || 0 !== (n3 = e3.generatedLine - t3.generatedLine) ? n3 : strcmp(e3.name, t3.name); | |
}, e2.compareByOriginalPositionsNoSource = function(e3, t3, r3) { | |
var n3; | |
return 0 !== (n3 = e3.originalLine - t3.originalLine) || 0 !== (n3 = e3.originalColumn - t3.originalColumn) || r3 || 0 !== (n3 = e3.generatedColumn - t3.generatedColumn) || 0 !== (n3 = e3.generatedLine - t3.generatedLine) ? n3 : strcmp(e3.name, t3.name); | |
}, e2.compareByGeneratedPositionsDeflated = function(e3, t3, r3) { | |
var n3 = e3.generatedLine - t3.generatedLine; | |
return 0 !== n3 || 0 !== (n3 = e3.generatedColumn - t3.generatedColumn) || r3 || 0 !== (n3 = strcmp(e3.source, t3.source)) || 0 !== (n3 = e3.originalLine - t3.originalLine) || 0 !== (n3 = e3.originalColumn - t3.originalColumn) ? n3 : strcmp(e3.name, t3.name); | |
}, e2.compareByGeneratedPositionsDeflatedNoLine = function(e3, t3, r3) { | |
var n3 = e3.generatedColumn - t3.generatedColumn; | |
return 0 !== n3 || r3 || 0 !== (n3 = strcmp(e3.source, t3.source)) || 0 !== (n3 = e3.originalLine - t3.originalLine) || 0 !== (n3 = e3.originalColumn - t3.originalColumn) ? n3 : strcmp(e3.name, t3.name); | |
}, e2.compareByGeneratedPositionsInflated = function(e3, t3) { | |
var r3 = e3.generatedLine - t3.generatedLine; | |
return 0 !== r3 || 0 !== (r3 = e3.generatedColumn - t3.generatedColumn) || 0 !== (r3 = strcmp(e3.source, t3.source)) || 0 !== (r3 = e3.originalLine - t3.originalLine) || 0 !== (r3 = e3.originalColumn - t3.originalColumn) ? r3 : strcmp(e3.name, t3.name); | |
}, e2.parseSourceMapInput = function(e3) { | |
return JSON.parse(e3.replace(/^\)]}'[^\n]*\n/, "")); | |
}, e2.computeSourceURL = function(e3, t3, r3) { | |
if (t3 = t3 || "", e3 && ("/" !== e3[e3.length - 1] && "/" !== t3[0] && (e3 += "/"), t3 = e3 + t3), r3) { | |
var i3 = urlParse(r3); | |
if (!i3) | |
throw new Error("sourceMapURL could not be parsed"); | |
if (i3.path) { | |
var a2 = i3.path.lastIndexOf("/"); | |
a2 >= 0 && (i3.path = i3.path.substring(0, a2 + 1)); | |
} | |
t3 = join(urlGenerate(i3), t3); | |
} | |
return n2(t3); | |
}; | |
}(ec); | |
var tc = {}, rc = ec, nc = Object.prototype.hasOwnProperty, sc = "undefined" != typeof Map; | |
function ArraySet$2() { | |
this._array = [], this._set = sc ? /* @__PURE__ */ new Map() : /* @__PURE__ */ Object.create(null); | |
} | |
ArraySet$2.fromArray = function(e2, t2) { | |
for (var r2 = new ArraySet$2(), n2 = 0, i2 = e2.length; n2 < i2; n2++) | |
r2.add(e2[n2], t2); | |
return r2; | |
}, ArraySet$2.prototype.size = function() { | |
return sc ? this._set.size : Object.getOwnPropertyNames(this._set).length; | |
}, ArraySet$2.prototype.add = function(e2, t2) { | |
var r2 = sc ? e2 : rc.toSetString(e2), n2 = sc ? this.has(e2) : nc.call(this._set, r2), i2 = this._array.length; | |
n2 && !t2 || this._array.push(e2), n2 || (sc ? this._set.set(e2, i2) : this._set[r2] = i2); | |
}, ArraySet$2.prototype.has = function(e2) { | |
if (sc) | |
return this._set.has(e2); | |
var t2 = rc.toSetString(e2); | |
return nc.call(this._set, t2); | |
}, ArraySet$2.prototype.indexOf = function(e2) { | |
if (sc) { | |
var t2 = this._set.get(e2); | |
if (t2 >= 0) | |
return t2; | |
} else { | |
var r2 = rc.toSetString(e2); | |
if (nc.call(this._set, r2)) | |
return this._set[r2]; | |
} | |
throw new Error('"' + e2 + '" is not in the set.'); | |
}, ArraySet$2.prototype.at = function(e2) { | |
if (e2 >= 0 && e2 < this._array.length) | |
return this._array[e2]; | |
throw new Error("No element indexed by " + e2); | |
}, ArraySet$2.prototype.toArray = function() { | |
return this._array.slice(); | |
}, tc.ArraySet = ArraySet$2; | |
var ic = {}, oc = ec; | |
function MappingList$1() { | |
this._array = [], this._sorted = true, this._last = { generatedLine: -1, generatedColumn: 0 }; | |
} | |
MappingList$1.prototype.unsortedForEach = function(e2, t2) { | |
this._array.forEach(e2, t2); | |
}, MappingList$1.prototype.add = function(e2) { | |
var t2, r2, n2, i2, a2, c2; | |
t2 = this._last, r2 = e2, n2 = t2.generatedLine, i2 = r2.generatedLine, a2 = t2.generatedColumn, c2 = r2.generatedColumn, i2 > n2 || i2 == n2 && c2 >= a2 || oc.compareByGeneratedPositionsInflated(t2, r2) <= 0 ? (this._last = e2, this._array.push(e2)) : (this._sorted = false, this._array.push(e2)); | |
}, MappingList$1.prototype.toArray = function() { | |
return this._sorted || (this._array.sort(oc.compareByGeneratedPositionsInflated), this._sorted = true), this._array; | |
}, ic.MappingList = MappingList$1; | |
var ac = Za, cc = ec, lc = tc.ArraySet, pc = ic.MappingList; | |
function SourceMapGenerator$1(e2) { | |
e2 || (e2 = {}), this._file = cc.getArg(e2, "file", null), this._sourceRoot = cc.getArg(e2, "sourceRoot", null), this._skipValidation = cc.getArg(e2, "skipValidation", false), this._sources = new lc(), this._names = new lc(), this._mappings = new pc(), this._sourcesContents = null; | |
} | |
SourceMapGenerator$1.prototype._version = 3, SourceMapGenerator$1.fromSourceMap = function(e2) { | |
var t2 = e2.sourceRoot, r2 = new SourceMapGenerator$1({ file: e2.file, sourceRoot: t2 }); | |
return e2.eachMapping(function(e3) { | |
var n2 = { generated: { line: e3.generatedLine, column: e3.generatedColumn } }; | |
null != e3.source && (n2.source = e3.source, null != t2 && (n2.source = cc.relative(t2, n2.source)), n2.original = { line: e3.originalLine, column: e3.originalColumn }, null != e3.name && (n2.name = e3.name)), r2.addMapping(n2); | |
}), e2.sources.forEach(function(n2) { | |
var i2 = n2; | |
null !== t2 && (i2 = cc.relative(t2, n2)), r2._sources.has(i2) || r2._sources.add(i2); | |
var a2 = e2.sourceContentFor(n2); | |
null != a2 && r2.setSourceContent(n2, a2); | |
}), r2; | |
}, SourceMapGenerator$1.prototype.addMapping = function(e2) { | |
var t2 = cc.getArg(e2, "generated"), r2 = cc.getArg(e2, "original", null), n2 = cc.getArg(e2, "source", null), i2 = cc.getArg(e2, "name", null); | |
this._skipValidation || this._validateMapping(t2, r2, n2, i2), null != n2 && (n2 = String(n2), this._sources.has(n2) || this._sources.add(n2)), null != i2 && (i2 = String(i2), this._names.has(i2) || this._names.add(i2)), this._mappings.add({ generatedLine: t2.line, generatedColumn: t2.column, originalLine: null != r2 && r2.line, originalColumn: null != r2 && r2.column, source: n2, name: i2 }); | |
}, SourceMapGenerator$1.prototype.setSourceContent = function(e2, t2) { | |
var r2 = e2; | |
null != this._sourceRoot && (r2 = cc.relative(this._sourceRoot, r2)), null != t2 ? (this._sourcesContents || (this._sourcesContents = /* @__PURE__ */ Object.create(null)), this._sourcesContents[cc.toSetString(r2)] = t2) : this._sourcesContents && (delete this._sourcesContents[cc.toSetString(r2)], 0 === Object.keys(this._sourcesContents).length && (this._sourcesContents = null)); | |
}, SourceMapGenerator$1.prototype.applySourceMap = function(e2, t2, r2) { | |
var n2 = t2; | |
if (null == t2) { | |
if (null == e2.file) | |
throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`); | |
n2 = e2.file; | |
} | |
var i2 = this._sourceRoot; | |
null != i2 && (n2 = cc.relative(i2, n2)); | |
var a2 = new lc(), c2 = new lc(); | |
this._mappings.unsortedForEach(function(t3) { | |
if (t3.source === n2 && null != t3.originalLine) { | |
var u2 = e2.originalPositionFor({ line: t3.originalLine, column: t3.originalColumn }); | |
null != u2.source && (t3.source = u2.source, null != r2 && (t3.source = cc.join(r2, t3.source)), null != i2 && (t3.source = cc.relative(i2, t3.source)), t3.originalLine = u2.line, t3.originalColumn = u2.column, null != u2.name && (t3.name = u2.name)); | |
} | |
var m2 = t3.source; | |
null == m2 || a2.has(m2) || a2.add(m2); | |
var g2 = t3.name; | |
null == g2 || c2.has(g2) || c2.add(g2); | |
}, this), this._sources = a2, this._names = c2, e2.sources.forEach(function(t3) { | |
var n3 = e2.sourceContentFor(t3); | |
null != n3 && (null != r2 && (t3 = cc.join(r2, t3)), null != i2 && (t3 = cc.relative(i2, t3)), this.setSourceContent(t3, n3)); | |
}, this); | |
}, SourceMapGenerator$1.prototype._validateMapping = function(e2, t2, r2, n2) { | |
if (t2 && "number" != typeof t2.line && "number" != typeof t2.column) | |
throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values."); | |
if ((!(e2 && "line" in e2 && "column" in e2 && e2.line > 0 && e2.column >= 0) || t2 || r2 || n2) && !(e2 && "line" in e2 && "column" in e2 && t2 && "line" in t2 && "column" in t2 && e2.line > 0 && e2.column >= 0 && t2.line > 0 && t2.column >= 0 && r2)) | |
throw new Error("Invalid mapping: " + JSON.stringify({ generated: e2, source: r2, original: t2, name: n2 })); | |
}, SourceMapGenerator$1.prototype._serializeMappings = function() { | |
for (var e2, t2, r2, n2, i2 = 0, a2 = 1, c2 = 0, u2 = 0, m2 = 0, g2 = 0, b2 = "", x2 = this._mappings.toArray(), C2 = 0, A2 = x2.length; C2 < A2; C2++) { | |
if (e2 = "", (t2 = x2[C2]).generatedLine !== a2) | |
for (i2 = 0; t2.generatedLine !== a2; ) | |
e2 += ";", a2++; | |
else if (C2 > 0) { | |
if (!cc.compareByGeneratedPositionsInflated(t2, x2[C2 - 1])) | |
continue; | |
e2 += ","; | |
} | |
e2 += ac.encode(t2.generatedColumn - i2), i2 = t2.generatedColumn, null != t2.source && (n2 = this._sources.indexOf(t2.source), e2 += ac.encode(n2 - g2), g2 = n2, e2 += ac.encode(t2.originalLine - 1 - u2), u2 = t2.originalLine - 1, e2 += ac.encode(t2.originalColumn - c2), c2 = t2.originalColumn, null != t2.name && (r2 = this._names.indexOf(t2.name), e2 += ac.encode(r2 - m2), m2 = r2)), b2 += e2; | |
} | |
return b2; | |
}, SourceMapGenerator$1.prototype._generateSourcesContent = function(e2, t2) { | |
return e2.map(function(e3) { | |
if (!this._sourcesContents) | |
return null; | |
null != t2 && (e3 = cc.relative(t2, e3)); | |
var r2 = cc.toSetString(e3); | |
return Object.prototype.hasOwnProperty.call(this._sourcesContents, r2) ? this._sourcesContents[r2] : null; | |
}, this); | |
}, SourceMapGenerator$1.prototype.toJSON = function() { | |
var e2 = { version: this._version, sources: this._sources.toArray(), names: this._names.toArray(), mappings: this._serializeMappings() }; | |
return null != this._file && (e2.file = this._file), null != this._sourceRoot && (e2.sourceRoot = this._sourceRoot), this._sourcesContents && (e2.sourcesContent = this._generateSourcesContent(e2.sources, e2.sourceRoot)), e2; | |
}, SourceMapGenerator$1.prototype.toString = function() { | |
return JSON.stringify(this.toJSON()); | |
}, Ga.SourceMapGenerator = SourceMapGenerator$1; | |
var uc = {}, dc = {}; | |
!function(e2) { | |
function recursiveSearch(t2, r2, n2, i2, a2, c2) { | |
var u2 = Math.floor((r2 - t2) / 2) + t2, m2 = a2(n2, i2[u2], true); | |
return 0 === m2 ? u2 : m2 > 0 ? r2 - u2 > 1 ? recursiveSearch(u2, r2, n2, i2, a2, c2) : c2 == e2.LEAST_UPPER_BOUND ? r2 < i2.length ? r2 : -1 : u2 : u2 - t2 > 1 ? recursiveSearch(t2, u2, n2, i2, a2, c2) : c2 == e2.LEAST_UPPER_BOUND ? u2 : t2 < 0 ? -1 : t2; | |
} | |
e2.GREATEST_LOWER_BOUND = 1, e2.LEAST_UPPER_BOUND = 2, e2.search = function(t2, r2, n2, i2) { | |
if (0 === r2.length) | |
return -1; | |
var a2 = recursiveSearch(-1, r2.length, t2, r2, n2, i2 || e2.GREATEST_LOWER_BOUND); | |
if (a2 < 0) | |
return -1; | |
for (; a2 - 1 >= 0 && 0 === n2(r2[a2], r2[a2 - 1], true); ) | |
--a2; | |
return a2; | |
}; | |
}(dc); | |
var hc = {}; | |
function SortTemplate(e2) { | |
function swap2(e3, t2, r2) { | |
var n2 = e3[t2]; | |
e3[t2] = e3[r2], e3[r2] = n2; | |
} | |
return function doQuickSort(e3, t2, r2, n2) { | |
if (r2 < n2) { | |
var i2 = r2 - 1; | |
swap2(e3, (m2 = r2, g2 = n2, Math.round(m2 + Math.random() * (g2 - m2))), n2); | |
for (var a2 = e3[n2], c2 = r2; c2 < n2; c2++) | |
t2(e3[c2], a2, false) <= 0 && swap2(e3, i2 += 1, c2); | |
swap2(e3, i2 + 1, c2); | |
var u2 = i2 + 1; | |
doQuickSort(e3, t2, r2, u2 - 1), doQuickSort(e3, t2, u2 + 1, n2); | |
} | |
var m2, g2; | |
}; | |
} | |
let fc = /* @__PURE__ */ new WeakMap(); | |
hc.quickSort = function(e2, t2, r2 = 0) { | |
let n2 = fc.get(t2); | |
void 0 === n2 && (n2 = function(e3) { | |
let t3 = SortTemplate.toString(); | |
return new Function(`return ${t3}`)()(e3); | |
}(t2), fc.set(t2, n2)), n2(e2, t2, r2, e2.length - 1); | |
}; | |
var mc = ec, gc = dc, yc = tc.ArraySet, bc = Za, vc = hc.quickSort; | |
function SourceMapConsumer(e2, t2) { | |
var r2 = e2; | |
return "string" == typeof e2 && (r2 = mc.parseSourceMapInput(e2)), null != r2.sections ? new IndexedSourceMapConsumer(r2, t2) : new BasicSourceMapConsumer(r2, t2); | |
} | |
function BasicSourceMapConsumer(e2, t2) { | |
var r2 = e2; | |
"string" == typeof e2 && (r2 = mc.parseSourceMapInput(e2)); | |
var n2 = mc.getArg(r2, "version"), i2 = mc.getArg(r2, "sources"), a2 = mc.getArg(r2, "names", []), c2 = mc.getArg(r2, "sourceRoot", null), u2 = mc.getArg(r2, "sourcesContent", null), m2 = mc.getArg(r2, "mappings"), g2 = mc.getArg(r2, "file", null); | |
if (n2 != this._version) | |
throw new Error("Unsupported version: " + n2); | |
c2 && (c2 = mc.normalize(c2)), i2 = i2.map(String).map(mc.normalize).map(function(e3) { | |
return c2 && mc.isAbsolute(c2) && mc.isAbsolute(e3) ? mc.relative(c2, e3) : e3; | |
}), this._names = yc.fromArray(a2.map(String), true), this._sources = yc.fromArray(i2, true), this._absoluteSources = this._sources.toArray().map(function(e3) { | |
return mc.computeSourceURL(c2, e3, t2); | |
}), this.sourceRoot = c2, this.sourcesContent = u2, this._mappings = m2, this._sourceMapURL = t2, this.file = g2; | |
} | |
function Mapping() { | |
this.generatedLine = 0, this.generatedColumn = 0, this.source = null, this.originalLine = null, this.originalColumn = null, this.name = null; | |
} | |
SourceMapConsumer.fromSourceMap = function(e2, t2) { | |
return BasicSourceMapConsumer.fromSourceMap(e2, t2); | |
}, SourceMapConsumer.prototype._version = 3, SourceMapConsumer.prototype.__generatedMappings = null, Object.defineProperty(SourceMapConsumer.prototype, "_generatedMappings", { configurable: true, enumerable: true, get: function() { | |
return this.__generatedMappings || this._parseMappings(this._mappings, this.sourceRoot), this.__generatedMappings; | |
} }), SourceMapConsumer.prototype.__originalMappings = null, Object.defineProperty(SourceMapConsumer.prototype, "_originalMappings", { configurable: true, enumerable: true, get: function() { | |
return this.__originalMappings || this._parseMappings(this._mappings, this.sourceRoot), this.__originalMappings; | |
} }), SourceMapConsumer.prototype._charIsMappingSeparator = function(e2, t2) { | |
var r2 = e2.charAt(t2); | |
return ";" === r2 || "," === r2; | |
}, SourceMapConsumer.prototype._parseMappings = function(e2, t2) { | |
throw new Error("Subclasses must implement _parseMappings"); | |
}, SourceMapConsumer.GENERATED_ORDER = 1, SourceMapConsumer.ORIGINAL_ORDER = 2, SourceMapConsumer.GREATEST_LOWER_BOUND = 1, SourceMapConsumer.LEAST_UPPER_BOUND = 2, SourceMapConsumer.prototype.eachMapping = function(e2, t2, r2) { | |
var n2, i2 = t2 || null; | |
switch (r2 || SourceMapConsumer.GENERATED_ORDER) { | |
case SourceMapConsumer.GENERATED_ORDER: | |
n2 = this._generatedMappings; | |
break; | |
case SourceMapConsumer.ORIGINAL_ORDER: | |
n2 = this._originalMappings; | |
break; | |
default: | |
throw new Error("Unknown order of iteration."); | |
} | |
for (var a2 = this.sourceRoot, c2 = e2.bind(i2), u2 = this._names, m2 = this._sources, g2 = this._sourceMapURL, b2 = 0, x2 = n2.length; b2 < x2; b2++) { | |
var C2 = n2[b2], A2 = null === C2.source ? null : m2.at(C2.source); | |
c2({ source: A2 = mc.computeSourceURL(a2, A2, g2), generatedLine: C2.generatedLine, generatedColumn: C2.generatedColumn, originalLine: C2.originalLine, originalColumn: C2.originalColumn, name: null === C2.name ? null : u2.at(C2.name) }); | |
} | |
}, SourceMapConsumer.prototype.allGeneratedPositionsFor = function(e2) { | |
var t2 = mc.getArg(e2, "line"), r2 = { source: mc.getArg(e2, "source"), originalLine: t2, originalColumn: mc.getArg(e2, "column", 0) }; | |
if (r2.source = this._findSourceIndex(r2.source), r2.source < 0) | |
return []; | |
var n2 = [], i2 = this._findMapping(r2, this._originalMappings, "originalLine", "originalColumn", mc.compareByOriginalPositions, gc.LEAST_UPPER_BOUND); | |
if (i2 >= 0) { | |
var a2 = this._originalMappings[i2]; | |
if (void 0 === e2.column) | |
for (var c2 = a2.originalLine; a2 && a2.originalLine === c2; ) | |
n2.push({ line: mc.getArg(a2, "generatedLine", null), column: mc.getArg(a2, "generatedColumn", null), lastColumn: mc.getArg(a2, "lastGeneratedColumn", null) }), a2 = this._originalMappings[++i2]; | |
else | |
for (var u2 = a2.originalColumn; a2 && a2.originalLine === t2 && a2.originalColumn == u2; ) | |
n2.push({ line: mc.getArg(a2, "generatedLine", null), column: mc.getArg(a2, "generatedColumn", null), lastColumn: mc.getArg(a2, "lastGeneratedColumn", null) }), a2 = this._originalMappings[++i2]; | |
} | |
return n2; | |
}, uc.SourceMapConsumer = SourceMapConsumer, BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype), BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer, BasicSourceMapConsumer.prototype._findSourceIndex = function(e2) { | |
var t2, r2 = e2; | |
if (null != this.sourceRoot && (r2 = mc.relative(this.sourceRoot, r2)), this._sources.has(r2)) | |
return this._sources.indexOf(r2); | |
for (t2 = 0; t2 < this._absoluteSources.length; ++t2) | |
if (this._absoluteSources[t2] == e2) | |
return t2; | |
return -1; | |
}, BasicSourceMapConsumer.fromSourceMap = function(e2, t2) { | |
var r2 = Object.create(BasicSourceMapConsumer.prototype), n2 = r2._names = yc.fromArray(e2._names.toArray(), true), i2 = r2._sources = yc.fromArray(e2._sources.toArray(), true); | |
r2.sourceRoot = e2._sourceRoot, r2.sourcesContent = e2._generateSourcesContent(r2._sources.toArray(), r2.sourceRoot), r2.file = e2._file, r2._sourceMapURL = t2, r2._absoluteSources = r2._sources.toArray().map(function(e3) { | |
return mc.computeSourceURL(r2.sourceRoot, e3, t2); | |
}); | |
for (var a2 = e2._mappings.toArray().slice(), c2 = r2.__generatedMappings = [], u2 = r2.__originalMappings = [], m2 = 0, g2 = a2.length; m2 < g2; m2++) { | |
var b2 = a2[m2], x2 = new Mapping(); | |
x2.generatedLine = b2.generatedLine, x2.generatedColumn = b2.generatedColumn, b2.source && (x2.source = i2.indexOf(b2.source), x2.originalLine = b2.originalLine, x2.originalColumn = b2.originalColumn, b2.name && (x2.name = n2.indexOf(b2.name)), u2.push(x2)), c2.push(x2); | |
} | |
return vc(r2.__originalMappings, mc.compareByOriginalPositions), r2; | |
}, BasicSourceMapConsumer.prototype._version = 3, Object.defineProperty(BasicSourceMapConsumer.prototype, "sources", { get: function() { | |
return this._absoluteSources.slice(); | |
} }); | |
const xc = mc.compareByGeneratedPositionsDeflatedNoLine; | |
function sortGenerated(e2, t2) { | |
let r2 = e2.length, n2 = e2.length - t2; | |
if (!(n2 <= 1)) | |
if (2 == n2) { | |
let r3 = e2[t2], n3 = e2[t2 + 1]; | |
xc(r3, n3) > 0 && (e2[t2] = n3, e2[t2 + 1] = r3); | |
} else if (n2 < 20) | |
for (let n3 = t2; n3 < r2; n3++) | |
for (let r3 = n3; r3 > t2; r3--) { | |
let t3 = e2[r3 - 1], n4 = e2[r3]; | |
if (xc(t3, n4) <= 0) | |
break; | |
e2[r3 - 1] = n4, e2[r3] = t3; | |
} | |
else | |
vc(e2, xc, t2); | |
} | |
function IndexedSourceMapConsumer(e2, t2) { | |
var r2 = e2; | |
"string" == typeof e2 && (r2 = mc.parseSourceMapInput(e2)); | |
var n2 = mc.getArg(r2, "version"), i2 = mc.getArg(r2, "sections"); | |
if (n2 != this._version) | |
throw new Error("Unsupported version: " + n2); | |
this._sources = new yc(), this._names = new yc(); | |
var a2 = { line: -1, column: 0 }; | |
this._sections = i2.map(function(e3) { | |
if (e3.url) | |
throw new Error("Support for url field in sections not implemented."); | |
var r3 = mc.getArg(e3, "offset"), n3 = mc.getArg(r3, "line"), i3 = mc.getArg(r3, "column"); | |
if (n3 < a2.line || n3 === a2.line && i3 < a2.column) | |
throw new Error("Section offsets must be ordered and non-overlapping."); | |
return a2 = r3, { generatedOffset: { generatedLine: n3 + 1, generatedColumn: i3 + 1 }, consumer: new SourceMapConsumer(mc.getArg(e3, "map"), t2) }; | |
}); | |
} | |
BasicSourceMapConsumer.prototype._parseMappings = function(e2, t2) { | |
var r2, n2, i2, a2, c2 = 1, u2 = 0, m2 = 0, g2 = 0, b2 = 0, x2 = 0, C2 = e2.length, A2 = 0, P2 = {}, T2 = [], _2 = []; | |
let I2 = 0; | |
for (; A2 < C2; ) | |
if (";" === e2.charAt(A2)) | |
c2++, A2++, u2 = 0, sortGenerated(_2, I2), I2 = _2.length; | |
else if ("," === e2.charAt(A2)) | |
A2++; | |
else { | |
for ((r2 = new Mapping()).generatedLine = c2, i2 = A2; i2 < C2 && !this._charIsMappingSeparator(e2, i2); i2++) | |
; | |
for (e2.slice(A2, i2), n2 = []; A2 < i2; ) | |
bc.decode(e2, A2, P2), a2 = P2.value, A2 = P2.rest, n2.push(a2); | |
if (2 === n2.length) | |
throw new Error("Found a source, but no line and column"); | |
if (3 === n2.length) | |
throw new Error("Found a source and line, but no column"); | |
if (r2.generatedColumn = u2 + n2[0], u2 = r2.generatedColumn, n2.length > 1 && (r2.source = b2 + n2[1], b2 += n2[1], r2.originalLine = m2 + n2[2], m2 = r2.originalLine, r2.originalLine += 1, r2.originalColumn = g2 + n2[3], g2 = r2.originalColumn, n2.length > 4 && (r2.name = x2 + n2[4], x2 += n2[4])), _2.push(r2), "number" == typeof r2.originalLine) { | |
let e3 = r2.source; | |
for (; T2.length <= e3; ) | |
T2.push(null); | |
null === T2[e3] && (T2[e3] = []), T2[e3].push(r2); | |
} | |
} | |
sortGenerated(_2, I2), this.__generatedMappings = _2; | |
for (var D2 = 0; D2 < T2.length; D2++) | |
null != T2[D2] && vc(T2[D2], mc.compareByOriginalPositionsNoSource); | |
this.__originalMappings = [].concat(...T2); | |
}, BasicSourceMapConsumer.prototype._findMapping = function(e2, t2, r2, n2, i2, a2) { | |
if (e2[r2] <= 0) | |
throw new TypeError("Line must be greater than or equal to 1, got " + e2[r2]); | |
if (e2[n2] < 0) | |
throw new TypeError("Column must be greater than or equal to 0, got " + e2[n2]); | |
return gc.search(e2, t2, i2, a2); | |
}, BasicSourceMapConsumer.prototype.computeColumnSpans = function() { | |
for (var e2 = 0; e2 < this._generatedMappings.length; ++e2) { | |
var t2 = this._generatedMappings[e2]; | |
if (e2 + 1 < this._generatedMappings.length) { | |
var r2 = this._generatedMappings[e2 + 1]; | |
if (t2.generatedLine === r2.generatedLine) { | |
t2.lastGeneratedColumn = r2.generatedColumn - 1; | |
continue; | |
} | |
} | |
t2.lastGeneratedColumn = 1 / 0; | |
} | |
}, BasicSourceMapConsumer.prototype.originalPositionFor = function(e2) { | |
var t2 = { generatedLine: mc.getArg(e2, "line"), generatedColumn: mc.getArg(e2, "column") }, r2 = this._findMapping(t2, this._generatedMappings, "generatedLine", "generatedColumn", mc.compareByGeneratedPositionsDeflated, mc.getArg(e2, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND)); | |
if (r2 >= 0) { | |
var n2 = this._generatedMappings[r2]; | |
if (n2.generatedLine === t2.generatedLine) { | |
var i2 = mc.getArg(n2, "source", null); | |
null !== i2 && (i2 = this._sources.at(i2), i2 = mc.computeSourceURL(this.sourceRoot, i2, this._sourceMapURL)); | |
var a2 = mc.getArg(n2, "name", null); | |
return null !== a2 && (a2 = this._names.at(a2)), { source: i2, line: mc.getArg(n2, "originalLine", null), column: mc.getArg(n2, "originalColumn", null), name: a2 }; | |
} | |
} | |
return { source: null, line: null, column: null, name: null }; | |
}, BasicSourceMapConsumer.prototype.hasContentsOfAllSources = function() { | |
return !!this.sourcesContent && (this.sourcesContent.length >= this._sources.size() && !this.sourcesContent.some(function(e2) { | |
return null == e2; | |
})); | |
}, BasicSourceMapConsumer.prototype.sourceContentFor = function(e2, t2) { | |
if (!this.sourcesContent) | |
return null; | |
var r2 = this._findSourceIndex(e2); | |
if (r2 >= 0) | |
return this.sourcesContent[r2]; | |
var n2, i2 = e2; | |
if (null != this.sourceRoot && (i2 = mc.relative(this.sourceRoot, i2)), null != this.sourceRoot && (n2 = mc.urlParse(this.sourceRoot))) { | |
var a2 = i2.replace(/^file:\/\//, ""); | |
if ("file" == n2.scheme && this._sources.has(a2)) | |
return this.sourcesContent[this._sources.indexOf(a2)]; | |
if ((!n2.path || "/" == n2.path) && this._sources.has("/" + i2)) | |
return this.sourcesContent[this._sources.indexOf("/" + i2)]; | |
} | |
if (t2) | |
return null; | |
throw new Error('"' + i2 + '" is not in the SourceMap.'); | |
}, BasicSourceMapConsumer.prototype.generatedPositionFor = function(e2) { | |
var t2 = mc.getArg(e2, "source"); | |
if ((t2 = this._findSourceIndex(t2)) < 0) | |
return { line: null, column: null, lastColumn: null }; | |
var r2 = { source: t2, originalLine: mc.getArg(e2, "line"), originalColumn: mc.getArg(e2, "column") }, n2 = this._findMapping(r2, this._originalMappings, "originalLine", "originalColumn", mc.compareByOriginalPositions, mc.getArg(e2, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND)); | |
if (n2 >= 0) { | |
var i2 = this._originalMappings[n2]; | |
if (i2.source === r2.source) | |
return { line: mc.getArg(i2, "generatedLine", null), column: mc.getArg(i2, "generatedColumn", null), lastColumn: mc.getArg(i2, "lastGeneratedColumn", null) }; | |
} | |
return { line: null, column: null, lastColumn: null }; | |
}, uc.BasicSourceMapConsumer = BasicSourceMapConsumer, IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype), IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer, IndexedSourceMapConsumer.prototype._version = 3, Object.defineProperty(IndexedSourceMapConsumer.prototype, "sources", { get: function() { | |
for (var e2 = [], t2 = 0; t2 < this._sections.length; t2++) | |
for (var r2 = 0; r2 < this._sections[t2].consumer.sources.length; r2++) | |
e2.push(this._sections[t2].consumer.sources[r2]); | |
return e2; | |
} }), IndexedSourceMapConsumer.prototype.originalPositionFor = function(e2) { | |
var t2 = { generatedLine: mc.getArg(e2, "line"), generatedColumn: mc.getArg(e2, "column") }, r2 = gc.search(t2, this._sections, function(e3, t3) { | |
var r3 = e3.generatedLine - t3.generatedOffset.generatedLine; | |
return r3 || e3.generatedColumn - t3.generatedOffset.generatedColumn; | |
}), n2 = this._sections[r2]; | |
return n2 ? n2.consumer.originalPositionFor({ line: t2.generatedLine - (n2.generatedOffset.generatedLine - 1), column: t2.generatedColumn - (n2.generatedOffset.generatedLine === t2.generatedLine ? n2.generatedOffset.generatedColumn - 1 : 0), bias: e2.bias }) : { source: null, line: null, column: null, name: null }; | |
}, IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = function() { | |
return this._sections.every(function(e2) { | |
return e2.consumer.hasContentsOfAllSources(); | |
}); | |
}, IndexedSourceMapConsumer.prototype.sourceContentFor = function(e2, t2) { | |
for (var r2 = 0; r2 < this._sections.length; r2++) { | |
var n2 = this._sections[r2].consumer.sourceContentFor(e2, true); | |
if (n2) | |
return n2; | |
} | |
if (t2) | |
return null; | |
throw new Error('"' + e2 + '" is not in the SourceMap.'); | |
}, IndexedSourceMapConsumer.prototype.generatedPositionFor = function(e2) { | |
for (var t2 = 0; t2 < this._sections.length; t2++) { | |
var r2 = this._sections[t2]; | |
if (-1 !== r2.consumer._findSourceIndex(mc.getArg(e2, "source"))) { | |
var n2 = r2.consumer.generatedPositionFor(e2); | |
if (n2) | |
return { line: n2.line + (r2.generatedOffset.generatedLine - 1), column: n2.column + (r2.generatedOffset.generatedLine === n2.line ? r2.generatedOffset.generatedColumn - 1 : 0) }; | |
} | |
} | |
return { line: null, column: null }; | |
}, IndexedSourceMapConsumer.prototype._parseMappings = function(e2, t2) { | |
this.__generatedMappings = [], this.__originalMappings = []; | |
for (var r2 = 0; r2 < this._sections.length; r2++) | |
for (var n2 = this._sections[r2], i2 = n2.consumer._generatedMappings, a2 = 0; a2 < i2.length; a2++) { | |
var c2 = i2[a2], u2 = n2.consumer._sources.at(c2.source); | |
u2 = mc.computeSourceURL(n2.consumer.sourceRoot, u2, this._sourceMapURL), this._sources.add(u2), u2 = this._sources.indexOf(u2); | |
var m2 = null; | |
c2.name && (m2 = n2.consumer._names.at(c2.name), this._names.add(m2), m2 = this._names.indexOf(m2)); | |
var g2 = { source: u2, generatedLine: c2.generatedLine + (n2.generatedOffset.generatedLine - 1), generatedColumn: c2.generatedColumn + (n2.generatedOffset.generatedLine === c2.generatedLine ? n2.generatedOffset.generatedColumn - 1 : 0), originalLine: c2.originalLine, originalColumn: c2.originalColumn, name: m2 }; | |
this.__generatedMappings.push(g2), "number" == typeof g2.originalLine && this.__originalMappings.push(g2); | |
} | |
vc(this.__generatedMappings, mc.compareByGeneratedPositionsDeflated), vc(this.__originalMappings, mc.compareByOriginalPositions); | |
}, uc.IndexedSourceMapConsumer = IndexedSourceMapConsumer; | |
var wc = {}, Cc = Ga.SourceMapGenerator, Ec = ec, Sc = /(\r?\n)/, Ac = "$$$isSourceNode$$$"; | |
function SourceNode(e2, t2, r2, n2, i2) { | |
this.children = [], this.sourceContents = {}, this.line = null == e2 ? null : e2, this.column = null == t2 ? null : t2, this.source = null == r2 ? null : r2, this.name = null == i2 ? null : i2, this[Ac] = true, null != n2 && this.add(n2); | |
} | |
SourceNode.fromStringWithSourceMap = function(e2, t2, r2) { | |
var n2 = new SourceNode(), i2 = e2.split(Sc), a2 = 0, shiftNextLine = function() { | |
return getNextLine() + (getNextLine() || ""); | |
function getNextLine() { | |
return a2 < i2.length ? i2[a2++] : void 0; | |
} | |
}, c2 = 1, u2 = 0, m2 = null; | |
return t2.eachMapping(function(e3) { | |
if (null !== m2) { | |
if (!(c2 < e3.generatedLine)) { | |
var t3 = (r3 = i2[a2] || "").substr(0, e3.generatedColumn - u2); | |
return i2[a2] = r3.substr(e3.generatedColumn - u2), u2 = e3.generatedColumn, addMappingWithCode(m2, t3), void (m2 = e3); | |
} | |
addMappingWithCode(m2, shiftNextLine()), c2++, u2 = 0; | |
} | |
for (; c2 < e3.generatedLine; ) | |
n2.add(shiftNextLine()), c2++; | |
if (u2 < e3.generatedColumn) { | |
var r3 = i2[a2] || ""; | |
n2.add(r3.substr(0, e3.generatedColumn)), i2[a2] = r3.substr(e3.generatedColumn), u2 = e3.generatedColumn; | |
} | |
m2 = e3; | |
}, this), a2 < i2.length && (m2 && addMappingWithCode(m2, shiftNextLine()), n2.add(i2.splice(a2).join(""))), t2.sources.forEach(function(e3) { | |
var i3 = t2.sourceContentFor(e3); | |
null != i3 && (null != r2 && (e3 = Ec.join(r2, e3)), n2.setSourceContent(e3, i3)); | |
}), n2; | |
function addMappingWithCode(e3, t3) { | |
if (null === e3 || void 0 === e3.source) | |
n2.add(t3); | |
else { | |
var i3 = r2 ? Ec.join(r2, e3.source) : e3.source; | |
n2.add(new SourceNode(e3.originalLine, e3.originalColumn, i3, t3, e3.name)); | |
} | |
} | |
}, SourceNode.prototype.add = function(e2) { | |
if (Array.isArray(e2)) | |
e2.forEach(function(e3) { | |
this.add(e3); | |
}, this); | |
else { | |
if (!e2[Ac] && "string" != typeof e2) | |
throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + e2); | |
e2 && this.children.push(e2); | |
} | |
return this; | |
}, SourceNode.prototype.prepend = function(e2) { | |
if (Array.isArray(e2)) | |
for (var t2 = e2.length - 1; t2 >= 0; t2--) | |
this.prepend(e2[t2]); | |
else { | |
if (!e2[Ac] && "string" != typeof e2) | |
throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + e2); | |
this.children.unshift(e2); | |
} | |
return this; | |
}, SourceNode.prototype.walk = function(e2) { | |
for (var t2, r2 = 0, n2 = this.children.length; r2 < n2; r2++) | |
(t2 = this.children[r2])[Ac] ? t2.walk(e2) : "" !== t2 && e2(t2, { source: this.source, line: this.line, column: this.column, name: this.name }); | |
}, SourceNode.prototype.join = function(e2) { | |
var t2, r2, n2 = this.children.length; | |
if (n2 > 0) { | |
for (t2 = [], r2 = 0; r2 < n2 - 1; r2++) | |
t2.push(this.children[r2]), t2.push(e2); | |
t2.push(this.children[r2]), this.children = t2; | |
} | |
return this; | |
}, SourceNode.prototype.replaceRight = function(e2, t2) { | |
var r2 = this.children[this.children.length - 1]; | |
return r2[Ac] ? r2.replaceRight(e2, t2) : "string" == typeof r2 ? this.children[this.children.length - 1] = r2.replace(e2, t2) : this.children.push("".replace(e2, t2)), this; | |
}, SourceNode.prototype.setSourceContent = function(e2, t2) { | |
this.sourceContents[Ec.toSetString(e2)] = t2; | |
}, SourceNode.prototype.walkSourceContents = function(e2) { | |
for (var t2 = 0, r2 = this.children.length; t2 < r2; t2++) | |
this.children[t2][Ac] && this.children[t2].walkSourceContents(e2); | |
var n2 = Object.keys(this.sourceContents); | |
for (t2 = 0, r2 = n2.length; t2 < r2; t2++) | |
e2(Ec.fromSetString(n2[t2]), this.sourceContents[n2[t2]]); | |
}, SourceNode.prototype.toString = function() { | |
var e2 = ""; | |
return this.walk(function(t2) { | |
e2 += t2; | |
}), e2; | |
}, SourceNode.prototype.toStringWithSourceMap = function(e2) { | |
var t2 = { code: "", line: 1, column: 0 }, r2 = new Cc(e2), n2 = false, i2 = null, a2 = null, c2 = null, u2 = null; | |
return this.walk(function(e3, m2) { | |
t2.code += e3, null !== m2.source && null !== m2.line && null !== m2.column ? (i2 === m2.source && a2 === m2.line && c2 === m2.column && u2 === m2.name || r2.addMapping({ source: m2.source, original: { line: m2.line, column: m2.column }, generated: { line: t2.line, column: t2.column }, name: m2.name }), i2 = m2.source, a2 = m2.line, c2 = m2.column, u2 = m2.name, n2 = true) : n2 && (r2.addMapping({ generated: { line: t2.line, column: t2.column } }), i2 = null, n2 = false); | |
for (var g2 = 0, b2 = e3.length; g2 < b2; g2++) | |
10 === e3.charCodeAt(g2) ? (t2.line++, t2.column = 0, g2 + 1 === b2 ? (i2 = null, n2 = false) : n2 && r2.addMapping({ source: m2.source, original: { line: m2.line, column: m2.column }, generated: { line: t2.line, column: t2.column }, name: m2.name })) : t2.column++; | |
}), this.walkSourceContents(function(e3, t3) { | |
r2.setSourceContent(e3, t3); | |
}), { code: t2.code, map: r2 }; | |
}, wc.SourceNode = SourceNode, Ja.SourceMapGenerator = Ga.SourceMapGenerator, Ja.SourceMapConsumer = uc.SourceMapConsumer, Ja.SourceNode = wc.SourceNode; | |
var kc = { exports: {} }; | |
(function(e2) { | |
class WalkerBase { | |
constructor() { | |
this.should_skip = false, this.should_remove = false, this.replacement = null, this.context = { skip: () => this.should_skip = true, remove: () => this.should_remove = true, replace: (e3) => this.replacement = e3 }; | |
} | |
replace(e3, t2, r2, n2) { | |
e3 && (null !== r2 ? e3[t2][r2] = n2 : e3[t2] = n2); | |
} | |
remove(e3, t2, r2) { | |
e3 && (null !== r2 ? e3[t2].splice(r2, 1) : delete e3[t2]); | |
} | |
} | |
class SyncWalker extends WalkerBase { | |
constructor(e3, t2) { | |
super(), this.enter = e3, this.leave = t2; | |
} | |
visit(e3, t2, r2, n2) { | |
if (e3) { | |
if (this.enter) { | |
const i2 = this.should_skip, a2 = this.should_remove, c2 = this.replacement; | |
this.should_skip = false, this.should_remove = false, this.replacement = null, this.enter.call(this.context, e3, t2, r2, n2), this.replacement && (e3 = this.replacement, this.replace(t2, r2, n2, e3)), this.should_remove && this.remove(t2, r2, n2); | |
const u2 = this.should_skip, m2 = this.should_remove; | |
if (this.should_skip = i2, this.should_remove = a2, this.replacement = c2, u2) | |
return e3; | |
if (m2) | |
return null; | |
} | |
for (const t3 in e3) { | |
const r3 = e3[t3]; | |
if ("object" == typeof r3) | |
if (Array.isArray(r3)) | |
for (let n3 = 0; n3 < r3.length; n3 += 1) | |
null !== r3[n3] && "string" == typeof r3[n3].type && (this.visit(r3[n3], e3, t3, n3) || n3--); | |
else | |
null !== r3 && "string" == typeof r3.type && this.visit(r3, e3, t3, null); | |
} | |
if (this.leave) { | |
const i2 = this.replacement, a2 = this.should_remove; | |
this.replacement = null, this.should_remove = false, this.leave.call(this.context, e3, t2, r2, n2), this.replacement && (e3 = this.replacement, this.replace(t2, r2, n2, e3)), this.should_remove && this.remove(t2, r2, n2); | |
const c2 = this.should_remove; | |
if (this.replacement = i2, this.should_remove = a2, c2) | |
return null; | |
} | |
} | |
return e3; | |
} | |
} | |
class AsyncWalker extends WalkerBase { | |
constructor(e3, t2) { | |
super(), this.enter = e3, this.leave = t2; | |
} | |
async visit(e3, t2, r2, n2) { | |
if (e3) { | |
if (this.enter) { | |
const i2 = this.should_skip, a2 = this.should_remove, c2 = this.replacement; | |
this.should_skip = false, this.should_remove = false, this.replacement = null, await this.enter.call(this.context, e3, t2, r2, n2), this.replacement && (e3 = this.replacement, this.replace(t2, r2, n2, e3)), this.should_remove && this.remove(t2, r2, n2); | |
const u2 = this.should_skip, m2 = this.should_remove; | |
if (this.should_skip = i2, this.should_remove = a2, this.replacement = c2, u2) | |
return e3; | |
if (m2) | |
return null; | |
} | |
for (const t3 in e3) { | |
const r3 = e3[t3]; | |
if ("object" == typeof r3) | |
if (Array.isArray(r3)) | |
for (let n3 = 0; n3 < r3.length; n3 += 1) | |
null !== r3[n3] && "string" == typeof r3[n3].type && (await this.visit(r3[n3], e3, t3, n3) || n3--); | |
else | |
null !== r3 && "string" == typeof r3.type && await this.visit(r3, e3, t3, null); | |
} | |
if (this.leave) { | |
const i2 = this.replacement, a2 = this.should_remove; | |
this.replacement = null, this.should_remove = false, await this.leave.call(this.context, e3, t2, r2, n2), this.replacement && (e3 = this.replacement, this.replace(t2, r2, n2, e3)), this.should_remove && this.remove(t2, r2, n2); | |
const c2 = this.should_remove; | |
if (this.replacement = i2, this.should_remove = a2, c2) | |
return null; | |
} | |
} | |
return e3; | |
} | |
} | |
function walk2(e3, { enter: t2, leave: r2 }) { | |
return new SyncWalker(t2, r2).visit(e3, null); | |
} | |
async function asyncWalk(e3, { enter: t2, leave: r2 }) { | |
const n2 = new AsyncWalker(t2, r2); | |
return await n2.visit(e3, null); | |
} | |
e2.asyncWalk = asyncWalk, e2.walk = walk2, Object.defineProperty(e2, "__esModule", { value: true }); | |
})(kc.exports); | |
var Pc = kc.exports; | |
Object.defineProperty(Ki, "__esModule", { value: true }); | |
var Tc = Do, _c = No, Ic = Ja, Dc = Pc; | |
function defaultOnError(e2) { | |
throw e2; | |
} | |
function defaultOnWarn(e2) { | |
} | |
function createCompilerError(e2, t2, r2, n2) { | |
const i2 = (r2 || Nc)[e2] + (n2 || ""), a2 = new SyntaxError(String(i2)); | |
return a2.code = e2, a2.loc = t2, a2; | |
} | |
const Nc = { 0: "Illegal comment.", 1: "CDATA section is allowed only in XML context.", 2: "Duplicate attribute.", 3: "End tag cannot have attributes.", 4: "Illegal '/' in tags.", 5: "Unexpected EOF in tag.", 6: "Unexpected EOF in CDATA section.", 7: "Unexpected EOF in comment.", 8: "Unexpected EOF in script.", 9: "Unexpected EOF in tag.", 10: "Incorrectly closed comment.", 11: "Incorrectly opened comment.", 12: "Illegal tag name. Use '<' to print '<'.", 13: "Attribute value was expected.", 14: "End tag name was expected.", 15: "Whitespace was expected.", 16: "Unexpected '<!--' in comment.", 17: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`, 18: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).", 19: "Attribute name cannot start with '='.", 21: "'<?' is allowed only in XML context.", 20: "Unexpected null character.", 22: "Illegal '/' in tags.", 23: "Invalid end tag.", 24: "Element is missing end tag.", 25: "Interpolation end sign was not found.", 27: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.", 26: "Legal directive name was expected.", 28: "v-if/v-else-if is missing expression.", 29: "v-if/else branches must use unique keys.", 30: "v-else/v-else-if has no adjacent v-if or v-else-if.", 31: "v-for is missing expression.", 32: "v-for has invalid expression.", 33: "<template v-for> key should be placed on the <template> tag.", 34: "v-bind is missing expression.", 35: "v-on is missing expression.", 36: "Unexpected custom directive on <slot> outlet.", 37: "Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.", 38: "Duplicate slot names found. ", 39: "Extraneous children found when component already has explicitly named default slot. These children will be ignored.", 40: "v-slot can only be used on components or <template> tags.", 41: "v-model is missing expression.", 42: "v-model value must be a valid JavaScript member expression.", 43: "v-model cannot be used on v-for or v-slot scope variables because they are not writable.", 44: "v-model cannot be used on a prop, because local prop bindings are not writable.\nUse a v-bind binding combined with a v-on listener that emits update:x event instead.", 45: "Error parsing JavaScript expression: ", 46: "<KeepAlive> expects exactly one child component.", 47: '"prefixIdentifiers" option is not supported in this build of compiler.', 48: "ES module mode is not supported in this build of compiler.", 49: '"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.', 50: '"scopeId" option is only supported in module mode.', 51: "@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.", 52: 'v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.', 53: "" }, Oc = Symbol(""), Lc = Symbol(""), Rc = Symbol(""), Mc = Symbol(""), Fc = Symbol(""), Bc = Symbol(""), jc = Symbol(""), $c = Symbol(""), Uc = Symbol(""), Hc = Symbol(""), Vc = Symbol(""), zc = Symbol(""), qc = Symbol(""), Wc = Symbol(""), Kc = Symbol(""), Jc = Symbol(""), Gc = Symbol(""), Zc = Symbol(""), Yc = Symbol(""), Xc = Symbol(""), Qc = Symbol(""), el = Symbol(""), tl = Symbol(""), rl = Symbol(""), nl = Symbol(""), sl = Symbol(""), il = Symbol(""), ol = Symbol(""), al = Symbol(""), cl = Symbol(""), ll = Symbol(""), pl = Symbol(""), ul = Symbol(""), dl = Symbol(""), hl = Symbol(""), fl = Symbol(""), ml = Symbol(""), gl = Symbol(""), yl = Symbol(""), bl = { [Oc]: "Fragment", [Lc]: "Teleport", [Rc]: "Suspense", [Mc]: "KeepAlive", [Fc]: "BaseTransition", [Bc]: "openBlock", [jc]: "createBlock", [$c]: "createElementBlock", [Uc]: "createVNode", [Hc]: "createElementVNode", [Vc]: "createCommentVNode", [zc]: "createTextVNode", [qc]: "createStaticVNode", [Wc]: "resolveComponent", [Kc]: "resolveDynamicComponent", [Jc]: "resolveDirective", [Gc]: "resolveFilter", [Zc]: "withDirectives", [Yc]: "renderList", [Xc]: "renderSlot", [Qc]: "createSlots", [el]: "toDisplayString", [tl]: "mergeProps", [rl]: "normalizeClass", [nl]: "normalizeStyle", [sl]: "normalizeProps", [il]: "guardReactiveProps", [ol]: "toHandlers", [al]: "camelize", [cl]: "capitalize", [ll]: "toHandlerKey", [pl]: "setBlockTracking", [ul]: "pushScopeId", [dl]: "popScopeId", [hl]: "withCtx", [fl]: "unref", [ml]: "isRef", [gl]: "withMemo", [yl]: "isMemoSame" }; | |
const vl = { source: "", start: { line: 1, column: 1, offset: 0 }, end: { line: 1, column: 1, offset: 0 } }; | |
function createRoot(e2, t2 = vl) { | |
return { type: 0, children: e2, helpers: /* @__PURE__ */ new Set(), components: [], directives: [], hoists: [], imports: [], cached: 0, temps: 0, codegenNode: void 0, loc: t2 }; | |
} | |
function createVNodeCall(e2, t2, r2, n2, i2, a2, c2, u2 = false, m2 = false, g2 = false, b2 = vl) { | |
return e2 && (u2 ? (e2.helper(Bc), e2.helper(getVNodeBlockHelper(e2.inSSR, g2))) : e2.helper(getVNodeHelper(e2.inSSR, g2)), c2 && e2.helper(Zc)), { type: 13, tag: t2, props: r2, children: n2, patchFlag: i2, dynamicProps: a2, directives: c2, isBlock: u2, disableTracking: m2, isComponent: g2, loc: b2 }; | |
} | |
function createArrayExpression(e2, t2 = vl) { | |
return { type: 17, loc: t2, elements: e2 }; | |
} | |
function createObjectExpression(e2, t2 = vl) { | |
return { type: 15, loc: t2, properties: e2 }; | |
} | |
function createObjectProperty(e2, t2) { | |
return { type: 16, loc: vl, key: Tc.isString(e2) ? createSimpleExpression(e2, true) : e2, value: t2 }; | |
} | |
function createSimpleExpression(e2, t2 = false, r2 = vl, n2 = 0) { | |
return { type: 4, loc: r2, content: e2, isStatic: t2, constType: t2 ? 3 : n2 }; | |
} | |
function createCompoundExpression(e2, t2 = vl) { | |
return { type: 8, loc: t2, children: e2 }; | |
} | |
function createCallExpression(e2, t2 = [], r2 = vl) { | |
return { type: 14, loc: r2, callee: e2, arguments: t2 }; | |
} | |
function createFunctionExpression(e2, t2 = void 0, r2 = false, n2 = false, i2 = vl) { | |
return { type: 18, params: e2, returns: t2, newline: r2, isSlot: n2, loc: i2 }; | |
} | |
function createConditionalExpression(e2, t2, r2, n2 = true) { | |
return { type: 19, test: e2, consequent: t2, alternate: r2, newline: n2, loc: vl }; | |
} | |
function createCacheExpression(e2, t2, r2 = false) { | |
return { type: 20, index: e2, value: t2, isVNode: r2, loc: vl }; | |
} | |
function createBlockStatement(e2) { | |
return { type: 21, body: e2, loc: vl }; | |
} | |
function getVNodeHelper(e2, t2) { | |
return e2 || t2 ? Uc : Hc; | |
} | |
function getVNodeBlockHelper(e2, t2) { | |
return e2 || t2 ? jc : $c; | |
} | |
function convertToBlock(e2, { helper: t2, removeHelper: r2, inSSR: n2 }) { | |
e2.isBlock || (e2.isBlock = true, r2(getVNodeHelper(n2, e2.isComponent)), t2(Bc), t2(getVNodeBlockHelper(n2, e2.isComponent))); | |
} | |
const isStaticExp = (e2) => 4 === e2.type && e2.isStatic, isBuiltInType = (e2, t2) => e2 === t2 || e2 === Tc.hyphenate(t2); | |
function isCoreComponent(e2) { | |
return isBuiltInType(e2, "Teleport") ? Lc : isBuiltInType(e2, "Suspense") ? Rc : isBuiltInType(e2, "KeepAlive") ? Mc : isBuiltInType(e2, "BaseTransition") ? Fc : void 0; | |
} | |
const xl = /^\d|[^\$\w]/, isSimpleIdentifier = (e2) => !xl.test(e2), wl = /[A-Za-z_$\xA0-\uFFFF]/, Cl = /[\.\?\w$\xA0-\uFFFF]/, El = /\s+[.[]\s*|\s*[.[]\s+/g, isMemberExpressionNode = (e2, t2) => { | |
try { | |
let r2 = _c.parseExpression(e2, { plugins: t2.expressionPlugins }); | |
return "TSAsExpression" !== r2.type && "TSTypeAssertion" !== r2.type || (r2 = r2.expression), "MemberExpression" === r2.type || "OptionalMemberExpression" === r2.type || "Identifier" === r2.type; | |
} catch (e3) { | |
return false; | |
} | |
}, Sl = isMemberExpressionNode; | |
function getInnerRange(e2, t2, r2) { | |
const n2 = { source: e2.source.slice(t2, t2 + r2), start: advancePositionWithClone(e2.start, e2.source, t2), end: e2.end }; | |
return null != r2 && (n2.end = advancePositionWithClone(e2.start, e2.source, t2 + r2)), n2; | |
} | |
function advancePositionWithClone(e2, t2, r2 = t2.length) { | |
return advancePositionWithMutation(Tc.extend({}, e2), t2, r2); | |
} | |
function advancePositionWithMutation(e2, t2, r2 = t2.length) { | |
let n2 = 0, i2 = -1; | |
for (let e3 = 0; e3 < r2; e3++) | |
10 === t2.charCodeAt(e3) && (n2++, i2 = e3); | |
return e2.offset += r2, e2.line += n2, e2.column = -1 === i2 ? e2.column + r2 : r2 - i2, e2; | |
} | |
function findDir(e2, t2, r2 = false) { | |
for (let n2 = 0; n2 < e2.props.length; n2++) { | |
const i2 = e2.props[n2]; | |
if (7 === i2.type && (r2 || i2.exp) && (Tc.isString(t2) ? i2.name === t2 : t2.test(i2.name))) | |
return i2; | |
} | |
} | |
function findProp(e2, t2, r2 = false, n2 = false) { | |
for (let i2 = 0; i2 < e2.props.length; i2++) { | |
const a2 = e2.props[i2]; | |
if (6 === a2.type) { | |
if (r2) | |
continue; | |
if (a2.name === t2 && (a2.value || n2)) | |
return a2; | |
} else if ("bind" === a2.name && (a2.exp || n2) && isStaticArgOf(a2.arg, t2)) | |
return a2; | |
} | |
} | |
function isStaticArgOf(e2, t2) { | |
return !(!e2 || !isStaticExp(e2) || e2.content !== t2); | |
} | |
function isText$1(e2) { | |
return 5 === e2.type || 2 === e2.type; | |
} | |
function isVSlot(e2) { | |
return 7 === e2.type && "slot" === e2.name; | |
} | |
function isTemplateNode(e2) { | |
return 1 === e2.type && 3 === e2.tagType; | |
} | |
function isSlotOutlet(e2) { | |
return 1 === e2.type && 2 === e2.tagType; | |
} | |
const Al = /* @__PURE__ */ new Set([sl, il]); | |
function getUnnormalizedProps(e2, t2 = []) { | |
if (e2 && !Tc.isString(e2) && 14 === e2.type) { | |
const r2 = e2.callee; | |
if (!Tc.isString(r2) && Al.has(r2)) | |
return getUnnormalizedProps(e2.arguments[0], t2.concat(e2)); | |
} | |
return [e2, t2]; | |
} | |
function injectProp(e2, t2, r2) { | |
let n2, i2, a2 = 13 === e2.type ? e2.props : e2.arguments[2], c2 = []; | |
if (a2 && !Tc.isString(a2) && 14 === a2.type) { | |
const e3 = getUnnormalizedProps(a2); | |
a2 = e3[0], c2 = e3[1], i2 = c2[c2.length - 1]; | |
} | |
if (null == a2 || Tc.isString(a2)) | |
n2 = createObjectExpression([t2]); | |
else if (14 === a2.type) { | |
const e3 = a2.arguments[0]; | |
Tc.isString(e3) || 15 !== e3.type ? a2.callee === ol ? n2 = createCallExpression(r2.helper(tl), [createObjectExpression([t2]), a2]) : a2.arguments.unshift(createObjectExpression([t2])) : hasProp(t2, e3) || e3.properties.unshift(t2), !n2 && (n2 = a2); | |
} else | |
15 === a2.type ? (hasProp(t2, a2) || a2.properties.unshift(t2), n2 = a2) : (n2 = createCallExpression(r2.helper(tl), [createObjectExpression([t2]), a2]), i2 && i2.callee === il && (i2 = c2[c2.length - 2])); | |
13 === e2.type ? i2 ? i2.arguments[0] = n2 : e2.props = n2 : i2 ? i2.arguments[0] = n2 : e2.arguments[2] = n2; | |
} | |
function hasProp(e2, t2) { | |
let r2 = false; | |
if (4 === e2.key.type) { | |
const n2 = e2.key.content; | |
r2 = t2.properties.some((e3) => 4 === e3.key.type && e3.key.content === n2); | |
} | |
return r2; | |
} | |
function toValidAssetId(e2, t2) { | |
return `_${t2}_${e2.replace(/[^\w]/g, (t3, r2) => "-" === t3 ? "_" : e2.charCodeAt(r2).toString())}`; | |
} | |
function hasScopeRef(e2, t2) { | |
if (!e2 || 0 === Object.keys(t2).length) | |
return false; | |
switch (e2.type) { | |
case 1: | |
for (let r2 = 0; r2 < e2.props.length; r2++) { | |
const n2 = e2.props[r2]; | |
if (7 === n2.type && (hasScopeRef(n2.arg, t2) || hasScopeRef(n2.exp, t2))) | |
return true; | |
} | |
return e2.children.some((e3) => hasScopeRef(e3, t2)); | |
case 11: | |
return !!hasScopeRef(e2.source, t2) || e2.children.some((e3) => hasScopeRef(e3, t2)); | |
case 9: | |
return e2.branches.some((e3) => hasScopeRef(e3, t2)); | |
case 10: | |
return !!hasScopeRef(e2.condition, t2) || e2.children.some((e3) => hasScopeRef(e3, t2)); | |
case 4: | |
return !e2.isStatic && isSimpleIdentifier(e2.content) && !!t2[e2.content]; | |
case 8: | |
return e2.children.some((e3) => Tc.isObject(e3) && hasScopeRef(e3, t2)); | |
case 5: | |
case 12: | |
return hasScopeRef(e2.content, t2); | |
default: | |
return false; | |
} | |
} | |
function getMemoedVNodeCall(e2) { | |
return 14 === e2.type && e2.callee === gl ? e2.arguments[1].returns : e2; | |
} | |
const kl = { COMPILER_IS_ON_ELEMENT: { message: 'Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".', link: "https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html" }, COMPILER_V_BIND_SYNC: { message: (e2) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${e2}.sync\` should be changed to \`v-model:${e2}\`.`, link: "https://v3-migration.vuejs.org/breaking-changes/v-model.html" }, COMPILER_V_BIND_PROP: { message: ".prop modifier for v-bind has been removed and no longer necessary. Vue 3 will automatically set a binding as DOM property when appropriate." }, COMPILER_V_BIND_OBJECT_ORDER: { message: 'v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.', link: "https://v3-migration.vuejs.org/breaking-changes/v-bind.html" }, COMPILER_V_ON_NATIVE: { message: ".native modifier for v-on has been removed as is no longer necessary.", link: "https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html" }, COMPILER_V_IF_V_FOR_PRECEDENCE: { message: "v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.", link: "https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html" }, COMPILER_NATIVE_TEMPLATE: { message: "<template> with no special directives will render as a native template element instead of its inner content in Vue 3." }, COMPILER_INLINE_TEMPLATE: { message: '"inline-template" has been removed in Vue 3.', link: "https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html" }, COMPILER_FILTER: { message: 'filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.', link: "https://v3-migration.vuejs.org/breaking-changes/filters.html" } }; | |
function getCompatValue(e2, t2) { | |
const r2 = t2.options ? t2.options.compatConfig : t2.compatConfig, n2 = r2 && r2[e2]; | |
return "MODE" === e2 ? n2 || 3 : n2; | |
} | |
function isCompatEnabled(e2, t2) { | |
const r2 = getCompatValue("MODE", t2), n2 = getCompatValue(e2, t2); | |
return 3 === r2 ? true === n2 : false !== n2; | |
} | |
function checkCompatEnabled(e2, t2, r2, ...n2) { | |
return isCompatEnabled(e2, t2); | |
} | |
const Pl = /&(gt|lt|amp|apos|quot);/g, Tl = { gt: ">", lt: "<", amp: "&", apos: "'", quot: '"' }, _l = { delimiters: ["{{", "}}"], getNamespace: () => 0, getTextMode: () => 0, isVoidTag: Tc.NO, isPreTag: Tc.NO, isCustomElement: Tc.NO, decodeEntities: (e2) => e2.replace(Pl, (e3, t2) => Tl[t2]), onError: defaultOnError, onWarn: defaultOnWarn, comments: false }; | |
function baseParse(e2, t2 = {}) { | |
const r2 = function(e3, t3) { | |
const r3 = Tc.extend({}, _l); | |
let n3; | |
for (n3 in t3) | |
r3[n3] = void 0 === t3[n3] ? _l[n3] : t3[n3]; | |
return { options: r3, column: 1, line: 1, offset: 0, originalSource: e3, source: e3, inPre: false, inVPre: false, onWarn: r3.onWarn }; | |
}(e2, t2), n2 = getCursor(r2); | |
return createRoot(parseChildren(r2, 0, []), getSelection(r2, n2)); | |
} | |
function parseChildren(e2, t2, r2) { | |
const n2 = last(r2), i2 = n2 ? n2.ns : 0, a2 = []; | |
for (; !isEnd(e2, t2, r2); ) { | |
const c3 = e2.source; | |
let u2; | |
if (0 === t2 || 1 === t2) { | |
if (!e2.inVPre && startsWith(c3, e2.options.delimiters[0])) | |
u2 = parseInterpolation(e2, t2); | |
else if (0 === t2 && "<" === c3[0]) | |
if (1 === c3.length) | |
emitError(e2, 5, 1); | |
else if ("!" === c3[1]) | |
startsWith(c3, "<!--") ? u2 = parseComment(e2) : startsWith(c3, "<!DOCTYPE") ? u2 = parseBogusComment(e2) : startsWith(c3, "<![CDATA[") ? 0 !== i2 ? u2 = parseCDATA(e2, r2) : (emitError(e2, 1), u2 = parseBogusComment(e2)) : (emitError(e2, 11), u2 = parseBogusComment(e2)); | |
else if ("/" === c3[1]) | |
if (2 === c3.length) | |
emitError(e2, 5, 2); | |
else { | |
if (">" === c3[2]) { | |
emitError(e2, 14, 2), advanceBy(e2, 3); | |
continue; | |
} | |
if (/[a-z]/i.test(c3[2])) { | |
emitError(e2, 23), parseTag(e2, Il.End, n2); | |
continue; | |
} | |
emitError(e2, 12, 2), u2 = parseBogusComment(e2); | |
} | |
else | |
/[a-z]/i.test(c3[1]) ? (u2 = parseElement(e2, r2), isCompatEnabled("COMPILER_NATIVE_TEMPLATE", e2) && u2 && "template" === u2.tag && !u2.props.some((e3) => 7 === e3.type && Dl(e3.name)) && (u2 = u2.children)) : "?" === c3[1] ? (emitError(e2, 21, 1), u2 = parseBogusComment(e2)) : emitError(e2, 12, 1); | |
} | |
if (u2 || (u2 = parseText(e2, t2)), Tc.isArray(u2)) | |
for (let e3 = 0; e3 < u2.length; e3++) | |
pushNode(a2, u2[e3]); | |
else | |
pushNode(a2, u2); | |
} | |
let c2 = false; | |
if (2 !== t2 && 1 !== t2) { | |
const t3 = "preserve" !== e2.options.whitespace; | |
for (let r3 = 0; r3 < a2.length; r3++) { | |
const n3 = a2[r3]; | |
if (2 === n3.type) | |
if (e2.inPre) | |
n3.content = n3.content.replace(/\r\n/g, "\n"); | |
else if (/[^\t\r\n\f ]/.test(n3.content)) | |
t3 && (n3.content = n3.content.replace(/[\t\r\n\f ]+/g, " ")); | |
else { | |
const e3 = a2[r3 - 1], i3 = a2[r3 + 1]; | |
!e3 || !i3 || t3 && (3 === e3.type && 3 === i3.type || 3 === e3.type && 1 === i3.type || 1 === e3.type && 3 === i3.type || 1 === e3.type && 1 === i3.type && /[\r\n]/.test(n3.content)) ? (c2 = true, a2[r3] = null) : n3.content = " "; | |
} | |
else | |
3 !== n3.type || e2.options.comments || (c2 = true, a2[r3] = null); | |
} | |
if (e2.inPre && n2 && e2.options.isPreTag(n2.tag)) { | |
const e3 = a2[0]; | |
e3 && 2 === e3.type && (e3.content = e3.content.replace(/^\r?\n/, "")); | |
} | |
} | |
return c2 ? a2.filter(Boolean) : a2; | |
} | |
function pushNode(e2, t2) { | |
if (2 === t2.type) { | |
const r2 = last(e2); | |
if (r2 && 2 === r2.type && r2.loc.end.offset === t2.loc.start.offset) | |
return r2.content += t2.content, r2.loc.end = t2.loc.end, void (r2.loc.source += t2.loc.source); | |
} | |
e2.push(t2); | |
} | |
function parseCDATA(e2, t2) { | |
advanceBy(e2, 9); | |
const r2 = parseChildren(e2, 3, t2); | |
return 0 === e2.source.length ? emitError(e2, 6) : advanceBy(e2, 3), r2; | |
} | |
function parseComment(e2) { | |
const t2 = getCursor(e2); | |
let r2; | |
const n2 = /--(\!)?>/.exec(e2.source); | |
if (n2) { | |
n2.index <= 3 && emitError(e2, 0), n2[1] && emitError(e2, 10), r2 = e2.source.slice(4, n2.index); | |
const t3 = e2.source.slice(0, n2.index); | |
let i2 = 1, a2 = 0; | |
for (; -1 !== (a2 = t3.indexOf("<!--", i2)); ) | |
advanceBy(e2, a2 - i2 + 1), a2 + 4 < t3.length && emitError(e2, 16), i2 = a2 + 1; | |
advanceBy(e2, n2.index + n2[0].length - i2 + 1); | |
} else | |
r2 = e2.source.slice(4), advanceBy(e2, e2.source.length), emitError(e2, 7); | |
return { type: 3, content: r2, loc: getSelection(e2, t2) }; | |
} | |
function parseBogusComment(e2) { | |
const t2 = getCursor(e2), r2 = "?" === e2.source[1] ? 1 : 2; | |
let n2; | |
const i2 = e2.source.indexOf(">"); | |
return -1 === i2 ? (n2 = e2.source.slice(r2), advanceBy(e2, e2.source.length)) : (n2 = e2.source.slice(r2, i2), advanceBy(e2, i2 + 1)), { type: 3, content: n2, loc: getSelection(e2, t2) }; | |
} | |
function parseElement(e2, t2) { | |
const r2 = e2.inPre, n2 = e2.inVPre, i2 = last(t2), a2 = parseTag(e2, Il.Start, i2), c2 = e2.inPre && !r2, u2 = e2.inVPre && !n2; | |
if (a2.isSelfClosing || e2.options.isVoidTag(a2.tag)) | |
return c2 && (e2.inPre = false), u2 && (e2.inVPre = false), a2; | |
t2.push(a2); | |
const m2 = e2.options.getTextMode(a2, i2), g2 = parseChildren(e2, m2, t2); | |
t2.pop(); | |
{ | |
const t3 = a2.props.find((e3) => 6 === e3.type && "inline-template" === e3.name); | |
if (t3 && checkCompatEnabled("COMPILER_INLINE_TEMPLATE", e2, t3.loc)) { | |
const r3 = getSelection(e2, a2.loc.end); | |
t3.value = { type: 2, content: r3.source, loc: r3 }; | |
} | |
} | |
if (a2.children = g2, startsWithEndTagOpen(e2.source, a2.tag)) | |
parseTag(e2, Il.End, i2); | |
else if (emitError(e2, 24, 0, a2.loc.start), 0 === e2.source.length && "script" === a2.tag.toLowerCase()) { | |
const t3 = g2[0]; | |
t3 && startsWith(t3.loc.source, "<!--") && emitError(e2, 8); | |
} | |
return a2.loc = getSelection(e2, a2.loc.start), c2 && (e2.inPre = false), u2 && (e2.inVPre = false), a2; | |
} | |
var Il = ((e2) => (e2[e2.Start = 0] = "Start", e2[e2.End = 1] = "End", e2))(Il || {}); | |
const Dl = Tc.makeMap("if,else,else-if,for,slot"); | |
function parseTag(e2, t2, r2) { | |
const n2 = getCursor(e2), i2 = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(e2.source), a2 = i2[1], c2 = e2.options.getNamespace(a2, r2); | |
advanceBy(e2, i2[0].length), advanceSpaces(e2); | |
const u2 = getCursor(e2), m2 = e2.source; | |
e2.options.isPreTag(a2) && (e2.inPre = true); | |
let g2 = parseAttributes(e2, t2); | |
0 === t2 && !e2.inVPre && g2.some((e3) => 7 === e3.type && "pre" === e3.name) && (e2.inVPre = true, Tc.extend(e2, u2), e2.source = m2, g2 = parseAttributes(e2, t2).filter((e3) => "v-pre" !== e3.name)); | |
let b2 = false; | |
if (0 === e2.source.length ? emitError(e2, 9) : (b2 = startsWith(e2.source, "/>"), 1 === t2 && b2 && emitError(e2, 4), advanceBy(e2, b2 ? 2 : 1)), 1 === t2) | |
return; | |
let x2 = 0; | |
return e2.inVPre || ("slot" === a2 ? x2 = 2 : "template" === a2 ? g2.some((e3) => 7 === e3.type && Dl(e3.name)) && (x2 = 3) : function(e3, t3, r3) { | |
const n3 = r3.options; | |
if (n3.isCustomElement(e3)) | |
return false; | |
if ("component" === e3 || /^[A-Z]/.test(e3) || isCoreComponent(e3) || n3.isBuiltInComponent && n3.isBuiltInComponent(e3) || n3.isNativeTag && !n3.isNativeTag(e3)) | |
return true; | |
for (let e4 = 0; e4 < t3.length; e4++) { | |
const n4 = t3[e4]; | |
if (6 === n4.type) { | |
if ("is" === n4.name && n4.value) { | |
if (n4.value.content.startsWith("vue:")) | |
return true; | |
if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT", r3, n4.loc)) | |
return true; | |
} | |
} else { | |
if ("is" === n4.name) | |
return true; | |
if ("bind" === n4.name && isStaticArgOf(n4.arg, "is") && checkCompatEnabled("COMPILER_IS_ON_ELEMENT", r3, n4.loc)) | |
return true; | |
} | |
} | |
}(a2, g2, e2) && (x2 = 1)), { type: 1, ns: c2, tag: a2, tagType: x2, props: g2, isSelfClosing: b2, children: [], loc: getSelection(e2, n2), codegenNode: void 0 }; | |
} | |
function parseAttributes(e2, t2) { | |
const r2 = [], n2 = /* @__PURE__ */ new Set(); | |
for (; e2.source.length > 0 && !startsWith(e2.source, ">") && !startsWith(e2.source, "/>"); ) { | |
if (startsWith(e2.source, "/")) { | |
emitError(e2, 22), advanceBy(e2, 1), advanceSpaces(e2); | |
continue; | |
} | |
1 === t2 && emitError(e2, 3); | |
const i2 = parseAttribute(e2, n2); | |
6 === i2.type && i2.value && "class" === i2.name && (i2.value.content = i2.value.content.replace(/\s+/g, " ").trim()), 0 === t2 && r2.push(i2), /^[^\t\r\n\f />]/.test(e2.source) && emitError(e2, 15), advanceSpaces(e2); | |
} | |
return r2; | |
} | |
function parseAttribute(e2, t2) { | |
var r2; | |
const n2 = getCursor(e2), i2 = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(e2.source)[0]; | |
t2.has(i2) && emitError(e2, 2), t2.add(i2), "=" === i2[0] && emitError(e2, 19); | |
{ | |
const t3 = /["'<]/g; | |
let r3; | |
for (; r3 = t3.exec(i2); ) | |
emitError(e2, 17, r3.index); | |
} | |
let a2; | |
advanceBy(e2, i2.length), /^[\t\r\n\f ]*=/.test(e2.source) && (advanceSpaces(e2), advanceBy(e2, 1), advanceSpaces(e2), a2 = function(e3) { | |
const t3 = getCursor(e3); | |
let r3; | |
const n3 = e3.source[0], i3 = '"' === n3 || "'" === n3; | |
if (i3) { | |
advanceBy(e3, 1); | |
const t4 = e3.source.indexOf(n3); | |
-1 === t4 ? r3 = parseTextData(e3, e3.source.length, 4) : (r3 = parseTextData(e3, t4, 4), advanceBy(e3, 1)); | |
} else { | |
const t4 = /^[^\t\r\n\f >]+/.exec(e3.source); | |
if (!t4) | |
return; | |
const n4 = /["'<=`]/g; | |
let i4; | |
for (; i4 = n4.exec(t4[0]); ) | |
emitError(e3, 18, i4.index); | |
r3 = parseTextData(e3, t4[0].length, 4); | |
} | |
return { content: r3, isQuoted: i3, loc: getSelection(e3, t3) }; | |
}(e2), a2 || emitError(e2, 13)); | |
const c2 = getSelection(e2, n2); | |
if (!e2.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(i2)) { | |
const t3 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(i2); | |
let u2, m2 = startsWith(i2, "."), g2 = t3[1] || (m2 || startsWith(i2, ":") ? "bind" : startsWith(i2, "@") ? "on" : "slot"); | |
if (t3[2]) { | |
const a3 = "slot" === g2, c3 = i2.lastIndexOf(t3[2], i2.length - ((null == (r2 = t3[3]) ? void 0 : r2.length) || 0)), m3 = getSelection(e2, getNewPosition(e2, n2, c3), getNewPosition(e2, n2, c3 + t3[2].length + (a3 && t3[3] || "").length)); | |
let b3 = t3[2], x2 = true; | |
b3.startsWith("[") ? (x2 = false, b3.endsWith("]") ? b3 = b3.slice(1, b3.length - 1) : (emitError(e2, 27), b3 = b3.slice(1))) : a3 && (b3 += t3[3] || ""), u2 = { type: 4, content: b3, isStatic: x2, constType: x2 ? 3 : 0, loc: m3 }; | |
} | |
if (a2 && a2.isQuoted) { | |
const e3 = a2.loc; | |
e3.start.offset++, e3.start.column++, e3.end = advancePositionWithClone(e3.start, a2.content), e3.source = e3.source.slice(1, -1); | |
} | |
const b2 = t3[3] ? t3[3].slice(1).split(".") : []; | |
return m2 && b2.push("prop"), "bind" === g2 && u2 && b2.includes("sync") && checkCompatEnabled("COMPILER_V_BIND_SYNC", e2, 0, u2.loc.source) && (g2 = "model", b2.splice(b2.indexOf("sync"), 1)), { type: 7, name: g2, exp: a2 && { type: 4, content: a2.content, isStatic: false, constType: 0, loc: a2.loc }, arg: u2, modifiers: b2, loc: c2 }; | |
} | |
return !e2.inVPre && startsWith(i2, "v-") && emitError(e2, 26), { type: 6, name: i2, value: a2 && { type: 2, content: a2.content, loc: a2.loc }, loc: c2 }; | |
} | |
function parseInterpolation(e2, t2) { | |
const [r2, n2] = e2.options.delimiters, i2 = e2.source.indexOf(n2, r2.length); | |
if (-1 === i2) | |
return void emitError(e2, 25); | |
const a2 = getCursor(e2); | |
advanceBy(e2, r2.length); | |
const c2 = getCursor(e2), u2 = getCursor(e2), m2 = i2 - r2.length, g2 = e2.source.slice(0, m2), b2 = parseTextData(e2, m2, t2), x2 = b2.trim(), C2 = b2.indexOf(x2); | |
C2 > 0 && advancePositionWithMutation(c2, g2, C2); | |
return advancePositionWithMutation(u2, g2, m2 - (b2.length - x2.length - C2)), advanceBy(e2, n2.length), { type: 5, content: { type: 4, isStatic: false, constType: 0, content: x2, loc: getSelection(e2, c2, u2) }, loc: getSelection(e2, a2) }; | |
} | |
function parseText(e2, t2) { | |
const r2 = 3 === t2 ? ["]]>"] : ["<", e2.options.delimiters[0]]; | |
let n2 = e2.source.length; | |
for (let t3 = 0; t3 < r2.length; t3++) { | |
const i3 = e2.source.indexOf(r2[t3], 1); | |
-1 !== i3 && n2 > i3 && (n2 = i3); | |
} | |
const i2 = getCursor(e2); | |
return { type: 2, content: parseTextData(e2, n2, t2), loc: getSelection(e2, i2) }; | |
} | |
function parseTextData(e2, t2, r2) { | |
const n2 = e2.source.slice(0, t2); | |
return advanceBy(e2, t2), 2 !== r2 && 3 !== r2 && n2.includes("&") ? e2.options.decodeEntities(n2, 4 === r2) : n2; | |
} | |
function getCursor(e2) { | |
const { column: t2, line: r2, offset: n2 } = e2; | |
return { column: t2, line: r2, offset: n2 }; | |
} | |
function getSelection(e2, t2, r2) { | |
return { start: t2, end: r2 = r2 || getCursor(e2), source: e2.originalSource.slice(t2.offset, r2.offset) }; | |
} | |
function last(e2) { | |
return e2[e2.length - 1]; | |
} | |
function startsWith(e2, t2) { | |
return e2.startsWith(t2); | |
} | |
function advanceBy(e2, t2) { | |
const { source: r2 } = e2; | |
advancePositionWithMutation(e2, r2, t2), e2.source = r2.slice(t2); | |
} | |
function advanceSpaces(e2) { | |
const t2 = /^[\t\r\n\f ]+/.exec(e2.source); | |
t2 && advanceBy(e2, t2[0].length); | |
} | |
function getNewPosition(e2, t2, r2) { | |
return advancePositionWithClone(t2, e2.originalSource.slice(t2.offset, r2), r2); | |
} | |
function emitError(e2, t2, r2, n2 = getCursor(e2)) { | |
r2 && (n2.offset += r2, n2.column += r2), e2.options.onError(createCompilerError(t2, { start: n2, end: n2, source: "" })); | |
} | |
function isEnd(e2, t2, r2) { | |
const n2 = e2.source; | |
switch (t2) { | |
case 0: | |
if (startsWith(n2, "</")) { | |
for (let e3 = r2.length - 1; e3 >= 0; --e3) | |
if (startsWithEndTagOpen(n2, r2[e3].tag)) | |
return true; | |
} | |
break; | |
case 1: | |
case 2: { | |
const e3 = last(r2); | |
if (e3 && startsWithEndTagOpen(n2, e3.tag)) | |
return true; | |
break; | |
} | |
case 3: | |
if (startsWith(n2, "]]>")) | |
return true; | |
} | |
return !n2; | |
} | |
function startsWithEndTagOpen(e2, t2) { | |
return startsWith(e2, "</") && e2.slice(2, 2 + t2.length).toLowerCase() === t2.toLowerCase() && /[\t\r\n\f />]/.test(e2[2 + t2.length] || ">"); | |
} | |
function hoistStatic(e2, t2) { | |
walk(e2, t2, isSingleElementRoot(e2, e2.children[0])); | |
} | |
function isSingleElementRoot(e2, t2) { | |
const { children: r2 } = e2; | |
return 1 === r2.length && 1 === t2.type && !isSlotOutlet(t2); | |
} | |
function walk(e2, t2, r2 = false) { | |
const { children: n2 } = e2, i2 = n2.length; | |
let a2 = 0; | |
for (let e3 = 0; e3 < n2.length; e3++) { | |
const i3 = n2[e3]; | |
if (1 === i3.type && 0 === i3.tagType) { | |
const e4 = r2 ? 0 : getConstantType(i3, t2); | |
if (e4 > 0) { | |
if (e4 >= 2) { | |
i3.codegenNode.patchFlag = "-1", i3.codegenNode = t2.hoist(i3.codegenNode), a2++; | |
continue; | |
} | |
} else { | |
const e5 = i3.codegenNode; | |
if (13 === e5.type) { | |
const r3 = getPatchFlag(e5); | |
if ((!r3 || 512 === r3 || 1 === r3) && getGeneratedPropsConstantType(i3, t2) >= 2) { | |
const r4 = getNodeProps(i3); | |
r4 && (e5.props = t2.hoist(r4)); | |
} | |
e5.dynamicProps && (e5.dynamicProps = t2.hoist(e5.dynamicProps)); | |
} | |
} | |
} | |
if (1 === i3.type) { | |
const e4 = 1 === i3.tagType; | |
e4 && t2.scopes.vSlot++, walk(i3, t2), e4 && t2.scopes.vSlot--; | |
} else if (11 === i3.type) | |
walk(i3, t2, 1 === i3.children.length); | |
else if (9 === i3.type) | |
for (let e4 = 0; e4 < i3.branches.length; e4++) | |
walk(i3.branches[e4], t2, 1 === i3.branches[e4].children.length); | |
} | |
a2 && t2.transformHoist && t2.transformHoist(n2, t2, e2), a2 && a2 === i2 && 1 === e2.type && 0 === e2.tagType && e2.codegenNode && 13 === e2.codegenNode.type && Tc.isArray(e2.codegenNode.children) && (e2.codegenNode.children = t2.hoist(createArrayExpression(e2.codegenNode.children))); | |
} | |
function getConstantType(e2, t2) { | |
const { constantCache: r2 } = t2; | |
switch (e2.type) { | |
case 1: | |
if (0 !== e2.tagType) | |
return 0; | |
const n2 = r2.get(e2); | |
if (void 0 !== n2) | |
return n2; | |
const i2 = e2.codegenNode; | |
if (13 !== i2.type) | |
return 0; | |
if (i2.isBlock && "svg" !== e2.tag && "foreignObject" !== e2.tag) | |
return 0; | |
if (getPatchFlag(i2)) | |
return r2.set(e2, 0), 0; | |
{ | |
let n3 = 3; | |
const a3 = getGeneratedPropsConstantType(e2, t2); | |
if (0 === a3) | |
return r2.set(e2, 0), 0; | |
a3 < n3 && (n3 = a3); | |
for (let i3 = 0; i3 < e2.children.length; i3++) { | |
const a4 = getConstantType(e2.children[i3], t2); | |
if (0 === a4) | |
return r2.set(e2, 0), 0; | |
a4 < n3 && (n3 = a4); | |
} | |
if (n3 > 1) | |
for (let i3 = 0; i3 < e2.props.length; i3++) { | |
const a4 = e2.props[i3]; | |
if (7 === a4.type && "bind" === a4.name && a4.exp) { | |
const i4 = getConstantType(a4.exp, t2); | |
if (0 === i4) | |
return r2.set(e2, 0), 0; | |
i4 < n3 && (n3 = i4); | |
} | |
} | |
if (i2.isBlock) { | |
for (let t3 = 0; t3 < e2.props.length; t3++) { | |
if (7 === e2.props[t3].type) | |
return r2.set(e2, 0), 0; | |
} | |
t2.removeHelper(Bc), t2.removeHelper(getVNodeBlockHelper(t2.inSSR, i2.isComponent)), i2.isBlock = false, t2.helper(getVNodeHelper(t2.inSSR, i2.isComponent)); | |
} | |
return r2.set(e2, n3), n3; | |
} | |
case 2: | |
case 3: | |
return 3; | |
case 9: | |
case 11: | |
case 10: | |
default: | |
return 0; | |
case 5: | |
case 12: | |
return getConstantType(e2.content, t2); | |
case 4: | |
return e2.constType; | |
case 8: | |
let a2 = 3; | |
for (let r3 = 0; r3 < e2.children.length; r3++) { | |
const n3 = e2.children[r3]; | |
if (Tc.isString(n3) || Tc.isSymbol(n3)) | |
continue; | |
const i3 = getConstantType(n3, t2); | |
if (0 === i3) | |
return 0; | |
i3 < a2 && (a2 = i3); | |
} | |
return a2; | |
} | |
} | |
const Nl = /* @__PURE__ */ new Set([rl, nl, sl, il]); | |
function getConstantTypeOfHelperCall(e2, t2) { | |
if (14 === e2.type && !Tc.isString(e2.callee) && Nl.has(e2.callee)) { | |
const r2 = e2.arguments[0]; | |
if (4 === r2.type) | |
return getConstantType(r2, t2); | |
if (14 === r2.type) | |
return getConstantTypeOfHelperCall(r2, t2); | |
} | |
return 0; | |
} | |
function getGeneratedPropsConstantType(e2, t2) { | |
let r2 = 3; | |
const n2 = getNodeProps(e2); | |
if (n2 && 15 === n2.type) { | |
const { properties: e3 } = n2; | |
for (let n3 = 0; n3 < e3.length; n3++) { | |
const { key: i2, value: a2 } = e3[n3], c2 = getConstantType(i2, t2); | |
if (0 === c2) | |
return c2; | |
let u2; | |
if (c2 < r2 && (r2 = c2), u2 = 4 === a2.type ? getConstantType(a2, t2) : 14 === a2.type ? getConstantTypeOfHelperCall(a2, t2) : 0, 0 === u2) | |
return u2; | |
u2 < r2 && (r2 = u2); | |
} | |
} | |
return r2; | |
} | |
function getNodeProps(e2) { | |
const t2 = e2.codegenNode; | |
if (13 === t2.type) | |
return t2.props; | |
} | |
function getPatchFlag(e2) { | |
const t2 = e2.patchFlag; | |
return t2 ? parseInt(t2, 10) : void 0; | |
} | |
function createTransformContext(e2, { filename: t2 = "", prefixIdentifiers: r2 = false, hoistStatic: n2 = false, cacheHandlers: i2 = false, nodeTransforms: a2 = [], directiveTransforms: c2 = {}, transformHoist: u2 = null, isBuiltInComponent: m2 = Tc.NOOP, isCustomElement: g2 = Tc.NOOP, expressionPlugins: b2 = [], scopeId: x2 = null, slotted: C2 = true, ssr: A2 = false, inSSR: P2 = false, ssrCssVars: T2 = "", bindingMetadata: _2 = Tc.EMPTY_OBJ, inline: I2 = false, isTS: D2 = false, onError: N2 = defaultOnError, onWarn: O2 = defaultOnWarn, compatConfig: L2 }) { | |
const R2 = t2.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/), M2 = { selfName: R2 && Tc.capitalize(Tc.camelize(R2[1])), prefixIdentifiers: r2, hoistStatic: n2, cacheHandlers: i2, nodeTransforms: a2, directiveTransforms: c2, transformHoist: u2, isBuiltInComponent: m2, isCustomElement: g2, expressionPlugins: b2, scopeId: x2, slotted: C2, ssr: A2, inSSR: P2, ssrCssVars: T2, bindingMetadata: _2, inline: I2, isTS: D2, onError: N2, onWarn: O2, compatConfig: L2, root: e2, helpers: /* @__PURE__ */ new Map(), components: /* @__PURE__ */ new Set(), directives: /* @__PURE__ */ new Set(), hoists: [], imports: [], constantCache: /* @__PURE__ */ new Map(), temps: 0, cached: 0, identifiers: /* @__PURE__ */ Object.create(null), scopes: { vFor: 0, vSlot: 0, vPre: 0, vOnce: 0 }, parent: null, currentNode: e2, childIndex: 0, inVOnce: false, helper(e3) { | |
const t3 = M2.helpers.get(e3) || 0; | |
return M2.helpers.set(e3, t3 + 1), e3; | |
}, removeHelper(e3) { | |
const t3 = M2.helpers.get(e3); | |
if (t3) { | |
const r3 = t3 - 1; | |
r3 ? M2.helpers.set(e3, r3) : M2.helpers.delete(e3); | |
} | |
}, helperString: (e3) => `_${bl[M2.helper(e3)]}`, replaceNode(e3) { | |
M2.parent.children[M2.childIndex] = M2.currentNode = e3; | |
}, removeNode(e3) { | |
const t3 = M2.parent.children, r3 = e3 ? t3.indexOf(e3) : M2.currentNode ? M2.childIndex : -1; | |
e3 && e3 !== M2.currentNode ? M2.childIndex > r3 && (M2.childIndex--, M2.onNodeRemoved()) : (M2.currentNode = null, M2.onNodeRemoved()), M2.parent.children.splice(r3, 1); | |
}, onNodeRemoved: () => { | |
}, addIdentifiers(e3) { | |
Tc.isString(e3) ? addId(e3) : e3.identifiers ? e3.identifiers.forEach(addId) : 4 === e3.type && addId(e3.content); | |
}, removeIdentifiers(e3) { | |
Tc.isString(e3) ? removeId(e3) : e3.identifiers ? e3.identifiers.forEach(removeId) : 4 === e3.type && removeId(e3.content); | |
}, hoist(e3) { | |
Tc.isString(e3) && (e3 = createSimpleExpression(e3)), M2.hoists.push(e3); | |
const t3 = createSimpleExpression(`_hoisted_${M2.hoists.length}`, false, e3.loc, 2); | |
return t3.hoisted = e3, t3; | |
}, cache: (e3, t3 = false) => createCacheExpression(M2.cached++, e3, t3) }; | |
function addId(e3) { | |
const { identifiers: t3 } = M2; | |
void 0 === t3[e3] && (t3[e3] = 0), t3[e3]++; | |
} | |
function removeId(e3) { | |
M2.identifiers[e3]--; | |
} | |
return M2.filters = /* @__PURE__ */ new Set(), M2; | |
} | |
function transform$1(e2, t2) { | |
const r2 = createTransformContext(e2, t2); | |
traverseNode(e2, r2), t2.hoistStatic && hoistStatic(e2, r2), t2.ssr || function(e3, t3) { | |
const { helper: r3 } = t3, { children: n2 } = e3; | |
if (1 === n2.length) { | |
const r4 = n2[0]; | |
if (isSingleElementRoot(e3, r4) && r4.codegenNode) { | |
const n3 = r4.codegenNode; | |
13 === n3.type && convertToBlock(n3, t3), e3.codegenNode = n3; | |
} else | |
e3.codegenNode = r4; | |
} else if (n2.length > 1) { | |
let n3 = 64; | |
Tc.PatchFlagNames[64], e3.codegenNode = createVNodeCall(t3, r3(Oc), void 0, e3.children, n3 + "", void 0, void 0, true, void 0, false); | |
} | |
}(e2, r2), e2.helpers = /* @__PURE__ */ new Set([...r2.helpers.keys()]), e2.components = [...r2.components], e2.directives = [...r2.directives], e2.imports = r2.imports, e2.hoists = r2.hoists, e2.temps = r2.temps, e2.cached = r2.cached, e2.filters = [...r2.filters]; | |
} | |
function traverseNode(e2, t2) { | |
t2.currentNode = e2; | |
const { nodeTransforms: r2 } = t2, n2 = []; | |
for (let i3 = 0; i3 < r2.length; i3++) { | |
const a2 = r2[i3](e2, t2); | |
if (a2 && (Tc.isArray(a2) ? n2.push(...a2) : n2.push(a2)), !t2.currentNode) | |
return; | |
e2 = t2.currentNode; | |
} | |
switch (e2.type) { | |
case 3: | |
t2.ssr || t2.helper(Vc); | |
break; | |
case 5: | |
t2.ssr || t2.helper(el); | |
break; | |
case 9: | |
for (let r3 = 0; r3 < e2.branches.length; r3++) | |
traverseNode(e2.branches[r3], t2); | |
break; | |
case 10: | |
case 11: | |
case 1: | |
case 0: | |
!function(e3, t3) { | |
let r3 = 0; | |
const nodeRemoved = () => { | |
r3--; | |
}; | |
for (; r3 < e3.children.length; r3++) { | |
const n3 = e3.children[r3]; | |
Tc.isString(n3) || (t3.parent = e3, t3.childIndex = r3, t3.onNodeRemoved = nodeRemoved, traverseNode(n3, t3)); | |
} | |
}(e2, t2); | |
} | |
t2.currentNode = e2; | |
let i2 = n2.length; | |
for (; i2--; ) | |
n2[i2](); | |
} | |
function createStructuralDirectiveTransform(e2, t2) { | |
const r2 = Tc.isString(e2) ? (t3) => t3 === e2 : (t3) => e2.test(t3); | |
return (e3, n2) => { | |
if (1 === e3.type) { | |
const { props: i2 } = e3; | |
if (3 === e3.tagType && i2.some(isVSlot)) | |
return; | |
const a2 = []; | |
for (let c2 = 0; c2 < i2.length; c2++) { | |
const u2 = i2[c2]; | |
if (7 === u2.type && r2(u2.name)) { | |
i2.splice(c2, 1), c2--; | |
const r3 = t2(e3, u2, n2); | |
r3 && a2.push(r3); | |
} | |
} | |
return a2; | |
} | |
}; | |
} | |
const Ol = "/*#__PURE__*/", aliasHelper = (e2) => `${bl[e2]}: _${bl[e2]}`; | |
function createCodegenContext(e2, { mode: t2 = "function", prefixIdentifiers: r2 = "module" === t2, sourceMap: n2 = false, filename: i2 = "template.vue.html", scopeId: a2 = null, optimizeImports: c2 = false, runtimeGlobalName: u2 = "Vue", runtimeModuleName: m2 = "vue", ssrRuntimeModuleName: g2 = "vue/server-renderer", ssr: b2 = false, isTS: x2 = false, inSSR: C2 = false }) { | |
const A2 = { mode: t2, prefixIdentifiers: r2, sourceMap: n2, filename: i2, scopeId: a2, optimizeImports: c2, runtimeGlobalName: u2, runtimeModuleName: m2, ssrRuntimeModuleName: g2, ssr: b2, isTS: x2, inSSR: C2, source: e2.loc.source, code: "", column: 1, line: 1, offset: 0, indentLevel: 0, pure: false, map: void 0, helper: (e3) => `_${bl[e3]}`, push(e3, t3) { | |
if (A2.code += e3, A2.map) { | |
if (t3) { | |
let e4; | |
if (4 === t3.type && !t3.isStatic) { | |
const r3 = t3.content.replace(/^_ctx\./, ""); | |
r3 !== t3.content && isSimpleIdentifier(r3) && (e4 = r3); | |
} | |
addMapping(t3.loc.start, e4); | |
} | |
advancePositionWithMutation(A2, e3), t3 && t3.loc !== vl && addMapping(t3.loc.end); | |
} | |
}, indent() { | |
newline(++A2.indentLevel); | |
}, deindent(e3 = false) { | |
e3 ? --A2.indentLevel : newline(--A2.indentLevel); | |
}, newline() { | |
newline(A2.indentLevel); | |
} }; | |
function newline(e3) { | |
A2.push("\n" + " ".repeat(e3)); | |
} | |
function addMapping(e3, t3) { | |
A2.map.addMapping({ name: t3, source: A2.filename, original: { line: e3.line, column: e3.column - 1 }, generated: { line: A2.line, column: A2.column - 1 } }); | |
} | |
return n2 && (A2.map = new Ic.SourceMapGenerator(), A2.map.setSourceContent(i2, A2.source)), A2; | |
} | |
function generate(e2, t2 = {}) { | |
const r2 = createCodegenContext(e2, t2); | |
t2.onContextCreated && t2.onContextCreated(r2); | |
const { mode: n2, push: i2, prefixIdentifiers: a2, indent: c2, deindent: u2, newline: m2, scopeId: g2, ssr: b2 } = r2, x2 = Array.from(e2.helpers), C2 = x2.length > 0, A2 = !a2 && "module" !== n2, P2 = null != g2 && "module" === n2, T2 = !!t2.inline, _2 = T2 ? createCodegenContext(e2, t2) : r2; | |
"module" === n2 ? function(e3, t3, r3, n3) { | |
const { push: i3, newline: a3, optimizeImports: c3, runtimeModuleName: u3, ssrRuntimeModuleName: m3 } = t3; | |
r3 && e3.hoists.length && (e3.helpers.add(ul), e3.helpers.add(dl)); | |
if (e3.helpers.size) { | |
const t4 = Array.from(e3.helpers); | |
c3 ? (i3(`import { ${t4.map((e4) => bl[e4]).join(", ")} } from ${JSON.stringify(u3)} | |
`), i3(` | |
// Binding optimization for webpack code-split | |
const ${t4.map((e4) => `_${bl[e4]} = ${bl[e4]}`).join(", ")} | |
`)) : i3(`import { ${t4.map((e4) => `${bl[e4]} as _${bl[e4]}`).join(", ")} } from ${JSON.stringify(u3)} | |
`); | |
} | |
e3.ssrHelpers && e3.ssrHelpers.length && i3(`import { ${e3.ssrHelpers.map((e4) => `${bl[e4]} as _${bl[e4]}`).join(", ")} } from "${m3}" | |
`); | |
e3.imports.length && (!function(e4, t4) { | |
if (!e4.length) | |
return; | |
e4.forEach((e5) => { | |
t4.push("import "), genNode(e5.exp, t4), t4.push(` from '${e5.path}'`), t4.newline(); | |
}); | |
}(e3.imports, t3), a3()); | |
genHoists(e3.hoists, t3), a3(), n3 || i3("export "); | |
}(e2, _2, P2, T2) : function(e3, t3) { | |
const { ssr: r3, prefixIdentifiers: n3, push: i3, newline: a3, runtimeModuleName: c3, runtimeGlobalName: u3, ssrRuntimeModuleName: m3 } = t3, g3 = r3 ? `require(${JSON.stringify(c3)})` : u3, b3 = Array.from(e3.helpers); | |
if (b3.length > 0) { | |
if (n3) | |
i3(`const { ${b3.map(aliasHelper).join(", ")} } = ${g3} | |
`); | |
else if (i3(`const _Vue = ${g3} | |
`), e3.hoists.length) { | |
i3(`const { ${[Uc, Hc, Vc, zc, qc].filter((e4) => b3.includes(e4)).map(aliasHelper).join(", ")} } = _Vue | |
`); | |
} | |
} | |
e3.ssrHelpers && e3.ssrHelpers.length && i3(`const { ${e3.ssrHelpers.map(aliasHelper).join(", ")} } = require("${m3}") | |
`); | |
genHoists(e3.hoists, t3), a3(), i3("return "); | |
}(e2, _2); | |
const I2 = b2 ? "ssrRender" : "render", D2 = b2 ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"]; | |
t2.bindingMetadata && !t2.inline && D2.push("$props", "$setup", "$data", "$options"); | |
const N2 = t2.isTS ? D2.map((e3) => `${e3}: any`).join(",") : D2.join(", "); | |
if (i2(T2 ? `(${N2}) => {` : `function ${I2}(${N2}) {`), c2(), A2 && (i2("with (_ctx) {"), c2(), C2 && (i2(`const { ${x2.map(aliasHelper).join(", ")} } = _Vue`), i2("\n"), m2())), e2.components.length && (genAssets(e2.components, "component", r2), (e2.directives.length || e2.temps > 0) && m2()), e2.directives.length && (genAssets(e2.directives, "directive", r2), e2.temps > 0 && m2()), e2.filters && e2.filters.length && (m2(), genAssets(e2.filters, "filter", r2), m2()), e2.temps > 0) { | |
i2("let "); | |
for (let t3 = 0; t3 < e2.temps; t3++) | |
i2(`${t3 > 0 ? ", " : ""}_temp${t3}`); | |
} | |
return (e2.components.length || e2.directives.length || e2.temps) && (i2("\n"), m2()), b2 || i2("return "), e2.codegenNode ? genNode(e2.codegenNode, r2) : i2("null"), A2 && (u2(), i2("}")), u2(), i2("}"), { ast: e2, code: r2.code, preamble: T2 ? _2.code : "", map: r2.map ? r2.map.toJSON() : void 0 }; | |
} | |
function genAssets(e2, t2, { helper: r2, push: n2, newline: i2, isTS: a2 }) { | |
const c2 = r2("filter" === t2 ? Gc : "component" === t2 ? Wc : Jc); | |
for (let r3 = 0; r3 < e2.length; r3++) { | |
let u2 = e2[r3]; | |
const m2 = u2.endsWith("__self"); | |
m2 && (u2 = u2.slice(0, -6)), n2(`const ${toValidAssetId(u2, t2)} = ${c2}(${JSON.stringify(u2)}${m2 ? ", true" : ""})${a2 ? "!" : ""}`), r3 < e2.length - 1 && i2(); | |
} | |
} | |
function genHoists(e2, t2) { | |
if (!e2.length) | |
return; | |
t2.pure = true; | |
const { push: r2, newline: n2, helper: i2, scopeId: a2, mode: c2 } = t2, u2 = null != a2 && "function" !== c2; | |
n2(), u2 && (r2(`const _withScopeId = n => (${i2(ul)}("${a2}"),n=n(),${i2(dl)}(),n)`), n2()); | |
for (let i3 = 0; i3 < e2.length; i3++) { | |
const a3 = e2[i3]; | |
if (a3) { | |
const e3 = u2 && 13 === a3.type; | |
r2(`const _hoisted_${i3 + 1} = ${e3 ? `${Ol} _withScopeId(() => ` : ""}`), genNode(a3, t2), e3 && r2(")"), n2(); | |
} | |
} | |
t2.pure = false; | |
} | |
function genNodeListAsArray(e2, t2) { | |
const r2 = e2.length > 3 || e2.some((e3) => Tc.isArray(e3) || !function(e4) { | |
return Tc.isString(e4) || 4 === e4.type || 2 === e4.type || 5 === e4.type || 8 === e4.type; | |
}(e3)); | |
t2.push("["), r2 && t2.indent(), genNodeList(e2, t2, r2), r2 && t2.deindent(), t2.push("]"); | |
} | |
function genNodeList(e2, t2, r2 = false, n2 = true) { | |
const { push: i2, newline: a2 } = t2; | |
for (let c2 = 0; c2 < e2.length; c2++) { | |
const u2 = e2[c2]; | |
Tc.isString(u2) ? i2(u2) : Tc.isArray(u2) ? genNodeListAsArray(u2, t2) : genNode(u2, t2), c2 < e2.length - 1 && (r2 ? (n2 && i2(","), a2()) : n2 && i2(", ")); | |
} | |
} | |
function genNode(e2, t2) { | |
if (Tc.isString(e2)) | |
t2.push(e2); | |
else if (Tc.isSymbol(e2)) | |
t2.push(t2.helper(e2)); | |
else | |
switch (e2.type) { | |
case 1: | |
case 9: | |
case 11: | |
case 12: | |
genNode(e2.codegenNode, t2); | |
break; | |
case 2: | |
!function(e3, t3) { | |
t3.push(JSON.stringify(e3.content), e3); | |
}(e2, t2); | |
break; | |
case 4: | |
genExpression(e2, t2); | |
break; | |
case 5: | |
!function(e3, t3) { | |
const { push: r2, helper: n2, pure: i2 } = t3; | |
i2 && r2(Ol); | |
r2(`${n2(el)}(`), genNode(e3.content, t3), r2(")"); | |
}(e2, t2); | |
break; | |
case 8: | |
genCompoundExpression(e2, t2); | |
break; | |
case 3: | |
!function(e3, t3) { | |
const { push: r2, helper: n2, pure: i2 } = t3; | |
i2 && r2(Ol); | |
r2(`${n2(Vc)}(${JSON.stringify(e3.content)})`, e3); | |
}(e2, t2); | |
break; | |
case 13: | |
!function(e3, t3) { | |
const { push: r2, helper: n2, pure: i2 } = t3, { tag: a2, props: c2, children: u2, patchFlag: m2, dynamicProps: g2, directives: b2, isBlock: x2, disableTracking: C2, isComponent: A2 } = e3; | |
b2 && r2(n2(Zc) + "("); | |
x2 && r2(`(${n2(Bc)}(${C2 ? "true" : ""}), `); | |
i2 && r2(Ol); | |
const P2 = x2 ? getVNodeBlockHelper(t3.inSSR, A2) : getVNodeHelper(t3.inSSR, A2); | |
r2(n2(P2) + "(", e3), genNodeList(function(e4) { | |
let t4 = e4.length; | |
for (; t4-- && null == e4[t4]; ) | |
; | |
return e4.slice(0, t4 + 1).map((e5) => e5 || "null"); | |
}([a2, c2, u2, m2, g2]), t3), r2(")"), x2 && r2(")"); | |
b2 && (r2(", "), genNode(b2, t3), r2(")")); | |
}(e2, t2); | |
break; | |
case 14: | |
!function(e3, t3) { | |
const { push: r2, helper: n2, pure: i2 } = t3, a2 = Tc.isString(e3.callee) ? e3.callee : n2(e3.callee); | |
i2 && r2(Ol); | |
r2(a2 + "(", e3), genNodeList(e3.arguments, t3), r2(")"); | |
}(e2, t2); | |
break; | |
case 15: | |
!function(e3, t3) { | |
const { push: r2, indent: n2, deindent: i2, newline: a2 } = t3, { properties: c2 } = e3; | |
if (!c2.length) | |
return void r2("{}", e3); | |
const u2 = c2.length > 1 || c2.some((e4) => 4 !== e4.value.type); | |
r2(u2 ? "{" : "{ "), u2 && n2(); | |
for (let e4 = 0; e4 < c2.length; e4++) { | |
const { key: n3, value: i3 } = c2[e4]; | |
genExpressionAsPropertyKey(n3, t3), r2(": "), genNode(i3, t3), e4 < c2.length - 1 && (r2(","), a2()); | |
} | |
u2 && i2(), r2(u2 ? "}" : " }"); | |
}(e2, t2); | |
break; | |
case 17: | |
!function(e3, t3) { | |
genNodeListAsArray(e3.elements, t3); | |
}(e2, t2); | |
break; | |
case 18: | |
!function(e3, t3) { | |
const { push: r2, indent: n2, deindent: i2 } = t3, { params: a2, returns: c2, body: u2, newline: m2, isSlot: g2 } = e3; | |
g2 && r2(`_${bl[hl]}(`); | |
r2("(", e3), Tc.isArray(a2) ? genNodeList(a2, t3) : a2 && genNode(a2, t3); | |
r2(") => "), (m2 || u2) && (r2("{"), n2()); | |
c2 ? (m2 && r2("return "), Tc.isArray(c2) ? genNodeListAsArray(c2, t3) : genNode(c2, t3)) : u2 && genNode(u2, t3); | |
(m2 || u2) && (i2(), r2("}")); | |
g2 && (e3.isNonScopedSlot && r2(", undefined, true"), r2(")")); | |
}(e2, t2); | |
break; | |
case 19: | |
!function(e3, t3) { | |
const { test: r2, consequent: n2, alternate: i2, newline: a2 } = e3, { push: c2, indent: u2, deindent: m2, newline: g2 } = t3; | |
if (4 === r2.type) { | |
const e4 = !isSimpleIdentifier(r2.content); | |
e4 && c2("("), genExpression(r2, t3), e4 && c2(")"); | |
} else | |
c2("("), genNode(r2, t3), c2(")"); | |
a2 && u2(), t3.indentLevel++, a2 || c2(" "), c2("? "), genNode(n2, t3), t3.indentLevel--, a2 && g2(), a2 || c2(" "), c2(": "); | |
const b2 = 19 === i2.type; | |
b2 || t3.indentLevel++; | |
genNode(i2, t3), b2 || t3.indentLevel--; | |
a2 && m2(true); | |
}(e2, t2); | |
break; | |
case 20: | |
!function(e3, t3) { | |
const { push: r2, helper: n2, indent: i2, deindent: a2, newline: c2 } = t3; | |
r2(`_cache[${e3.index}] || (`), e3.isVNode && (i2(), r2(`${n2(pl)}(-1),`), c2()); | |
r2(`_cache[${e3.index}] = `), genNode(e3.value, t3), e3.isVNode && (r2(","), c2(), r2(`${n2(pl)}(1),`), c2(), r2(`_cache[${e3.index}]`), a2()); | |
r2(")"); | |
}(e2, t2); | |
break; | |
case 21: | |
genNodeList(e2.body, t2, true, false); | |
break; | |
case 22: | |
!function(e3, t3) { | |
const { push: r2, indent: n2, deindent: i2 } = t3; | |
r2("`"); | |
const a2 = e3.elements.length, c2 = a2 > 3; | |
for (let u2 = 0; u2 < a2; u2++) { | |
const a3 = e3.elements[u2]; | |
Tc.isString(a3) ? r2(a3.replace(/(`|\$|\\)/g, "\\$1")) : (r2("${"), c2 && n2(), genNode(a3, t3), c2 && i2(), r2("}")); | |
} | |
r2("`"); | |
}(e2, t2); | |
break; | |
case 23: | |
genIfStatement(e2, t2); | |
break; | |
case 24: | |
!function(e3, t3) { | |
genNode(e3.left, t3), t3.push(" = "), genNode(e3.right, t3); | |
}(e2, t2); | |
break; | |
case 25: | |
!function(e3, t3) { | |
t3.push("("), genNodeList(e3.expressions, t3), t3.push(")"); | |
}(e2, t2); | |
break; | |
case 26: | |
!function({ returns: e3 }, t3) { | |
t3.push("return "), Tc.isArray(e3) ? genNodeListAsArray(e3, t3) : genNode(e3, t3); | |
}(e2, t2); | |
} | |
} | |
function genExpression(e2, t2) { | |
const { content: r2, isStatic: n2 } = e2; | |
t2.push(n2 ? JSON.stringify(r2) : r2, e2); | |
} | |
function genCompoundExpression(e2, t2) { | |
for (let r2 = 0; r2 < e2.children.length; r2++) { | |
const n2 = e2.children[r2]; | |
Tc.isString(n2) ? t2.push(n2) : genNode(n2, t2); | |
} | |
} | |
function genExpressionAsPropertyKey(e2, t2) { | |
const { push: r2 } = t2; | |
if (8 === e2.type) | |
r2("["), genCompoundExpression(e2, t2), r2("]"); | |
else if (e2.isStatic) { | |
r2(isSimpleIdentifier(e2.content) ? e2.content : JSON.stringify(e2.content), e2); | |
} else | |
r2(`[${e2.content}]`, e2); | |
} | |
function genIfStatement(e2, t2) { | |
const { push: r2, indent: n2, deindent: i2 } = t2, { test: a2, consequent: c2, alternate: u2 } = e2; | |
r2("if ("), genNode(a2, t2), r2(") {"), n2(), genNode(c2, t2), i2(), r2("}"), u2 && (r2(" else "), 23 === u2.type ? genIfStatement(u2, t2) : (r2("{"), n2(), genNode(u2, t2), i2(), r2("}"))); | |
} | |
function walkIdentifiers(e2, t2, r2 = false, n2 = [], i2 = /* @__PURE__ */ Object.create(null)) { | |
const a2 = "Program" === e2.type && "ExpressionStatement" === e2.body[0].type && e2.body[0].expression; | |
Dc.walk(e2, { enter(e3, a3) { | |
if (a3 && n2.push(a3), a3 && a3.type.startsWith("TS") && !Ll.includes(a3.type)) | |
return this.skip(); | |
if ("Identifier" === e3.type) { | |
const c2 = !!i2[e3.name], u2 = isReferencedIdentifier(e3, a3, n2); | |
(r2 || u2 && !c2) && t2(e3, a3, n2, u2, c2); | |
} else | |
"ObjectProperty" === e3.type && "ObjectPattern" === a3.type ? e3.inPattern = true : isFunctionType(e3) ? walkFunctionParams(e3, (t3) => markScopeIdentifier(e3, t3, i2)) : "BlockStatement" === e3.type && walkBlockDeclarations(e3, (t3) => markScopeIdentifier(e3, t3, i2)); | |
}, leave(e3, t3) { | |
if (t3 && n2.po |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment